Skip to content

Commit 160a1ba

Browse files
author
David Noble
committed
tests/test_searchcommands_app improvements + examples/searchcommands_app documentation update
1 parent 11b4817 commit 160a1ba

File tree

6 files changed

+55
-84
lines changed

6 files changed

+55
-84
lines changed

examples/searchcommands_app/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ The app is tested on Splunk 5 and 6. Here is its manifest:
2626
│   └── default.xml ..
2727
├── app.conf ................. Used by Splunk to maintain app state [1]
2828
├── commands.conf ............ Search command configuration [2]
29-
├── logging.conf ............. Python logging[3] configuration in ConfigParser[4] format
30-
└── logging.debug.conf ....... Logs to app root directory as well as the Splunk log file
29+
└── logging.conf ............. Python logging[3] configuration in ConfigParser[4] format
3130
```
3231
**References**
3332
[1] [app.conf](http://docs.splunk.com/Documentation/Splunk/6.0.1/Admin/Appconf app.conf)

examples/searchcommands_app/bin/simulate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class SimulateCommand(GeneratingCommand):
3131
##Syntax
3232
3333
simulate csv=<path> rate=<expected-event-count> interval=<sampling-period>
34-
duration=<execution-period> [seed=<
34+
duration=<execution-period> [seed=<string>]
3535
3636
##Description
3737
@@ -44,8 +44,8 @@ class SimulateCommand(GeneratingCommand):
4444
##Example
4545
4646
```
47-
| simulate csv="tweets.csv" rate=200 interval=00:00:01 duration=00:00:30 |
48-
countmatches fieldname=word_count pattern=\w+ text |
47+
| simulate csv=population.csv rate=200 interval=00:00:01 duration=00:00:30 |
48+
countmatches fieldname=word_count pattern="\\w+" text |
4949
stats mean(word_count) stdev(word_count)
5050
```
5151

examples/searchcommands_app/bin/sum.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,23 @@
2424
class SumCommand(ReportingCommand):
2525
""" Computes the sum of a set of fields
2626
27-
**Syntax:** sum total=*<fieldname>* [*<fieldname>*]...
28-
**Description:** The total produced is sum(sum(fieldname, 1, n), 1, N) where
29-
n = number of fields, N = number of records.
27+
##Syntax
28+
29+
sum total=*<fieldname>* [*<fieldname>*]...
30+
31+
##Description:
32+
33+
The total produced is sum(sum(fieldname, 1, n), 1, N) where n = number of
34+
fields, N = number of records.
35+
36+
##Example
37+
38+
```
39+
index = _internal | head 200 | sum total=lines linecount
40+
```
41+
42+
This example computes the total linecount in the first 200 records in the
43+
_internal index.
3044
3145
"""
3246
total = Option(

examples/searchcommands_app/default/logging.debug.conf

Lines changed: 0 additions & 42 deletions
This file was deleted.

examples/searchcommands_scaffolding/default/logging.debug.conf

Lines changed: 0 additions & 32 deletions
This file was deleted.

tests/test_searchcommands_app.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,38 @@ def test_command_parser(self):
120120
command_line)
121121
return
122122

123+
def test_option_logging_configuration(self):
124+
self._run(
125+
'simulate', [
126+
'csv=%s' % TestSearchCommandsApp._data_file(
127+
"input/population.csv"),
128+
'duration=00:00:10',
129+
'interval=00:00:01',
130+
'rate=200',
131+
'seed=%s' % TestSearchCommandsApp._seed,
132+
'logging_configuration=logging.conf'],
133+
__GETINFO__=(
134+
'input/population.csv',
135+
'output/test_option_logging_configuration.csv',
136+
'log/test_option_logging_configuration.log'))
137+
return
138+
139+
def test_option_logging_level(self):
140+
self._run(
141+
'simulate', [
142+
'csv=%s' % TestSearchCommandsApp._data_file(
143+
"input/population.csv"),
144+
'duration=00:00:10',
145+
'interval=00:00:01',
146+
'rate=200',
147+
'seed=%s' % TestSearchCommandsApp._seed,
148+
'logging_level=ERROR'],
149+
__GETINFO__=(
150+
'input/population.csv',
151+
'output/test_option_logging_level.csv',
152+
'log/test_option_logging_level.log'))
153+
return
154+
123155
def test_option_show_configuration(self):
124156
self._run(
125157
'simulate', [
@@ -132,8 +164,8 @@ def test_option_show_configuration(self):
132164
'show_configuration=true'],
133165
__GETINFO__=(
134166
'input/population.csv',
135-
'output/samples.csv',
136-
'log/test_show_configuration.log'))
167+
'output/test_option_show_configuration.csv',
168+
'log/test_option_show_configuration.log'))
137169
return
138170

139171
def test_generating_command_in_isolation(self):

0 commit comments

Comments
 (0)