Skip to content

Commit

Permalink
Update pewpew examples and test (#243)
Browse files Browse the repository at this point in the history
* Added script to test the examples and script with example variables

* Updated example files to send to stdout so test_examples can view actual errors

* Fixed the loggers for several broken examples
  • Loading branch information
tkmcmaster committed Aug 2, 2024
1 parent 376feed commit b58e703
Show file tree
Hide file tree
Showing 30 changed files with 80 additions and 36 deletions.
1 change: 1 addition & 0 deletions examples/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/stats-*.json
/search-results*.json
/log-results*
/*.yaml.out
2 changes: 1 addition & 1 deletion examples/body_file.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ load_pattern:

loggers:
test:
to: stderr
to: stdout

endpoints:
- method: POST
Expand Down
6 changes: 3 additions & 3 deletions examples/body_formdata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ load_pattern:

loggers:
test:
to: stderr
to: stdout

endpoints:
- method: POST
url: http://localhost:${port}
headers:
Accept-Language: en-us
Content-Type: application/x-www-form-urlencoded
body: username=${username}&password=${password}&grant_type=password&client_id=${dev_key}
body: username=${username}&password=${password}&grant_type=password&client_id=${dev_key}&token=abcd-1234-efgh
peak_load: 1hps
logs:
test:
select:
ts: epoch("ms")
response: request.body
token: response.body.token
token: match(response.body, "token=(?P<token>[a-zA-Z0-9-]+)").token
on_demand: true

2 changes: 1 addition & 1 deletion examples/body_json.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ load_pattern:

loggers:
test:
to: stderr
to: stdout

endpoints:
- method: POST
Expand Down
2 changes: 1 addition & 1 deletion examples/body_multipart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ load_pattern:

loggers:
test:
to: stderr
to: stdout

endpoints:
- method: POST
Expand Down
2 changes: 1 addition & 1 deletion examples/delete_search.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ providers:

loggers:
test:
to: stderr
to: stdout
test_404s:
limit: 1
to: stdout
Expand Down
2 changes: 1 addition & 1 deletion examples/delete_sequential_404s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ providers:

loggers:
test:
to: stderr
to: stdout
test_404s:
limit: 1
to: stdout
Expand Down
2 changes: 1 addition & 1 deletion examples/log_all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ loggers:
pretty: false

test:
to: stderr
to: stdout

endpoints:
- method: POST
Expand Down
2 changes: 1 addition & 1 deletion examples/log_csv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ loggers:
pretty: false

test:
to: stderr
to: stdout

endpoints:
- method: POST
Expand Down
2 changes: 1 addition & 1 deletion examples/log_errors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ loggers:
pretty: false

test:
to: stderr
to: stdout

endpoints:
- method: GET
Expand Down
10 changes: 7 additions & 3 deletions examples/login_for_apis_block.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ providers:

loggers:
test:
to: stderr
to: stdout

endpoints:
- method: POST
Expand Down Expand Up @@ -67,7 +67,9 @@ endpoints:
logs:
test:
select:
a: response.body.a
a: a
b: response.body.b
session: session

- method: POST
url: http://localhost:${port}?c
Expand All @@ -78,4 +80,6 @@ endpoints:
logs:
test:
select:
a: response.body.a
a: a
c: response.body.c
session: session
10 changes: 7 additions & 3 deletions examples/login_for_apis_force_new.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ providers:

loggers:
test:
to: stderr
to: stdout

endpoints:
- method: POST
Expand Down Expand Up @@ -67,7 +67,9 @@ endpoints:
logs:
test:
select:
a: response.body.a
a: a
b: response.body.b
session: session

- method: POST
url: http://localhost:${port}?c
Expand All @@ -78,4 +80,6 @@ endpoints:
logs:
test:
select:
a: response.body.a
a: a
c: response.body.c
session: session
10 changes: 7 additions & 3 deletions examples/login_for_apis_on_demand.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ providers:

loggers:
test:
to: stderr
to: stdout

endpoints:
- method: POST
Expand Down Expand Up @@ -65,7 +65,9 @@ endpoints:
logs:
test:
select:
a: response.body.a
a: a
b: response.body.b
session: session

- method: POST
url: http://localhost:${port}?c
Expand All @@ -76,4 +78,6 @@ endpoints:
logs:
test:
select:
a: response.body.a
a: a
c: response.body.c
session: session
2 changes: 1 addition & 1 deletion examples/provider_chain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ providers:

loggers:
test:
to: stderr
to: stdout

endpoints:
- method: POST
Expand Down
2 changes: 1 addition & 1 deletion examples/provider_collect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ providers:

loggers:
test:
to: stderr
to: stdout

endpoints:
- method: POST
Expand Down
2 changes: 1 addition & 1 deletion examples/provider_create_and_delete.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ providers:

loggers:
test:
to: stderr
to: stdout

endpoints:
- method: POST
Expand Down
2 changes: 1 addition & 1 deletion examples/provider_grid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ providers:

loggers:
test:
to: stderr
to: stdout

endpoints:
- method: POST
Expand Down
2 changes: 1 addition & 1 deletion examples/provider_loop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ providers:

loggers:
test:
to: stderr
to: stdout

endpoints:
- method: POST
Expand Down
2 changes: 1 addition & 1 deletion examples/provider_loop_with_counter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ providers:

loggers:
test:
to: stderr
to: stdout

endpoints:
- method: POST
Expand Down
2 changes: 1 addition & 1 deletion examples/provider_redirect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ providers:

loggers:
test:
to: stderr
to: stdout

endpoints:
- method: GET
Expand Down
2 changes: 1 addition & 1 deletion examples/provider_spread.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ providers:

loggers:
test:
to: stderr
to: stdout

endpoints:
- method: POST
Expand Down
2 changes: 1 addition & 1 deletion examples/ramp_and_load.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ load_pattern:

loggers:
test:
to: stderr
to: stdout

endpoints:
- method: GET
Expand Down
2 changes: 1 addition & 1 deletion examples/ramp_api_different.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ load_pattern:

loggers:
test:
to: stderr
to: stdout

endpoints:
- method: GET
Expand Down
2 changes: 1 addition & 1 deletion examples/ramp_basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ load_pattern:

loggers:
test:
to: stderr
to: stdout

endpoints:
- method: GET
Expand Down
2 changes: 1 addition & 1 deletion examples/ramp_over_time.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ load_pattern:

loggers:
test:
to: stderr
to: stdout

endpoints:
- method: GET
Expand Down
2 changes: 1 addition & 1 deletion examples/ramp_to_scale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ load_pattern:

loggers:
test:
to: stderr
to: stdout

endpoints:
- method: GET
Expand Down
2 changes: 1 addition & 1 deletion examples/ramp_up_and_down.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ load_pattern:

loggers:
test:
to: stderr
to: stdout

endpoints:
- method: GET
Expand Down
4 changes: 2 additions & 2 deletions examples/random_search.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ providers:

loggers:
test:
to: stderr
to: stdout
http_errors:
select:
timestamp: epoch("ms")
Expand All @@ -120,7 +120,7 @@ loggers:
responseBody: response.body
where: response.status >= 400
limit: 1000
to: stderr
to: stdout
pretty: false
search_logger:
to: 'search-results-${epoch("ms")}.json' # log to a file with a timestamp. timestamp set at test start
Expand Down
26 changes: 26 additions & 0 deletions examples/test_examples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
set -e
set +x
source ./variables.sh

if [ -z ${PORT+x} ]; then
echo "PORT is unset. Please start the test-server and specify the PORT variable when running this";
exit 1
else
echo "Testing examples on PORT '$PORT'";
fi
PEWPEW_PATH=("pewpew")
if [[ ! -z "$1" ]] ; then
PEWPEW_PATH=("$1")
fi
PEWPEW_VERSION=$($PEWPEW_PATH --version)
echo "Testing examples against version $PEWPEW_VERSION"


for file in *.yaml; do
[ -f "$file" ] || break
echo "Running: $PEWPEW_PATH run -f json $file"
"$PEWPEW_PATH" run -f json "$file" > "$file.out"
echo "Result: $?"
done
echo "All examples passed!"
5 changes: 5 additions & 0 deletions examples/variables.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
export PASSWORD=bogus
export RAMP_TIME=5s
export LOAD_TIME=10s
export SCALE_PERCENTAGE=100

0 comments on commit b58e703

Please sign in to comment.