From b58e703b3e83026a4f54f45e4c0b4ce960609a72 Mon Sep 17 00:00:00 2001 From: Trevor McMaster Date: Fri, 2 Aug 2024 10:52:16 -0700 Subject: [PATCH] Update pewpew examples and test (#243) * 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 --- examples/.gitignore | 1 + examples/body_file.yaml | 2 +- examples/body_formdata.yaml | 6 +++--- examples/body_json.yaml | 2 +- examples/body_multipart.yaml | 2 +- examples/delete_search.yaml | 2 +- examples/delete_sequential_404s.yaml | 2 +- examples/log_all.yaml | 2 +- examples/log_csv.yaml | 2 +- examples/log_errors.yaml | 2 +- examples/login_for_apis_block.yaml | 10 ++++++--- examples/login_for_apis_force_new.yaml | 10 ++++++--- examples/login_for_apis_on_demand.yaml | 10 ++++++--- examples/provider_chain.yaml | 2 +- examples/provider_collect.yaml | 2 +- examples/provider_create_and_delete.yaml | 2 +- examples/provider_grid.yaml | 2 +- examples/provider_loop.yaml | 2 +- examples/provider_loop_with_counter.yaml | 2 +- examples/provider_redirect.yaml | 2 +- examples/provider_spread.yaml | 2 +- examples/ramp_and_load.yaml | 2 +- examples/ramp_api_different.yaml | 2 +- examples/ramp_basic.yaml | 2 +- examples/ramp_over_time.yaml | 2 +- examples/ramp_to_scale.yaml | 2 +- examples/ramp_up_and_down.yaml | 2 +- examples/random_search.yaml | 4 ++-- examples/test_examples.sh | 26 ++++++++++++++++++++++++ examples/variables.sh | 5 +++++ 30 files changed, 80 insertions(+), 36 deletions(-) create mode 100755 examples/test_examples.sh create mode 100755 examples/variables.sh diff --git a/examples/.gitignore b/examples/.gitignore index aaaa699d..22a3b63c 100644 --- a/examples/.gitignore +++ b/examples/.gitignore @@ -1,3 +1,4 @@ /stats-*.json /search-results*.json /log-results* +/*.yaml.out diff --git a/examples/body_file.yaml b/examples/body_file.yaml index 045c299d..03ee2ba9 100644 --- a/examples/body_file.yaml +++ b/examples/body_file.yaml @@ -11,7 +11,7 @@ load_pattern: loggers: test: - to: stderr + to: stdout endpoints: - method: POST diff --git a/examples/body_formdata.yaml b/examples/body_formdata.yaml index 7fe95d4b..99458434 100644 --- a/examples/body_formdata.yaml +++ b/examples/body_formdata.yaml @@ -17,7 +17,7 @@ load_pattern: loggers: test: - to: stderr + to: stdout endpoints: - method: POST @@ -25,13 +25,13 @@ endpoints: 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[a-zA-Z0-9-]+)").token on_demand: true diff --git a/examples/body_json.yaml b/examples/body_json.yaml index e14b6e1e..ef056d19 100644 --- a/examples/body_json.yaml +++ b/examples/body_json.yaml @@ -11,7 +11,7 @@ load_pattern: loggers: test: - to: stderr + to: stdout endpoints: - method: POST diff --git a/examples/body_multipart.yaml b/examples/body_multipart.yaml index f80899f6..9164499e 100644 --- a/examples/body_multipart.yaml +++ b/examples/body_multipart.yaml @@ -11,7 +11,7 @@ load_pattern: loggers: test: - to: stderr + to: stdout endpoints: - method: POST diff --git a/examples/delete_search.yaml b/examples/delete_search.yaml index 1c443165..3c624901 100644 --- a/examples/delete_search.yaml +++ b/examples/delete_search.yaml @@ -40,7 +40,7 @@ providers: loggers: test: - to: stderr + to: stdout test_404s: limit: 1 to: stdout diff --git a/examples/delete_sequential_404s.yaml b/examples/delete_sequential_404s.yaml index c3e44f90..57450e8e 100644 --- a/examples/delete_sequential_404s.yaml +++ b/examples/delete_sequential_404s.yaml @@ -35,7 +35,7 @@ providers: loggers: test: - to: stderr + to: stdout test_404s: limit: 1 to: stdout diff --git a/examples/log_all.yaml b/examples/log_all.yaml index b9bc888d..04b4bb64 100644 --- a/examples/log_all.yaml +++ b/examples/log_all.yaml @@ -24,7 +24,7 @@ loggers: pretty: false test: - to: stderr + to: stdout endpoints: - method: POST diff --git a/examples/log_csv.yaml b/examples/log_csv.yaml index 69a24f1e..b07e9622 100644 --- a/examples/log_csv.yaml +++ b/examples/log_csv.yaml @@ -19,7 +19,7 @@ loggers: pretty: false test: - to: stderr + to: stdout endpoints: - method: POST diff --git a/examples/log_errors.yaml b/examples/log_errors.yaml index ad9796a5..4f14c5aa 100644 --- a/examples/log_errors.yaml +++ b/examples/log_errors.yaml @@ -28,7 +28,7 @@ loggers: pretty: false test: - to: stderr + to: stdout endpoints: - method: GET diff --git a/examples/login_for_apis_block.yaml b/examples/login_for_apis_block.yaml index e9b468ab..5c3383ca 100644 --- a/examples/login_for_apis_block.yaml +++ b/examples/login_for_apis_block.yaml @@ -33,7 +33,7 @@ providers: loggers: test: - to: stderr + to: stdout endpoints: - method: POST @@ -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 @@ -78,4 +80,6 @@ endpoints: logs: test: select: - a: response.body.a \ No newline at end of file + a: a + c: response.body.c + session: session diff --git a/examples/login_for_apis_force_new.yaml b/examples/login_for_apis_force_new.yaml index 2d39fdf6..13d2d344 100644 --- a/examples/login_for_apis_force_new.yaml +++ b/examples/login_for_apis_force_new.yaml @@ -33,7 +33,7 @@ providers: loggers: test: - to: stderr + to: stdout endpoints: - method: POST @@ -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 @@ -78,4 +80,6 @@ endpoints: logs: test: select: - a: response.body.a \ No newline at end of file + a: a + c: response.body.c + session: session diff --git a/examples/login_for_apis_on_demand.yaml b/examples/login_for_apis_on_demand.yaml index 7c892250..8e825cac 100644 --- a/examples/login_for_apis_on_demand.yaml +++ b/examples/login_for_apis_on_demand.yaml @@ -32,7 +32,7 @@ providers: loggers: test: - to: stderr + to: stdout endpoints: - method: POST @@ -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 @@ -76,4 +78,6 @@ endpoints: logs: test: select: - a: response.body.a \ No newline at end of file + a: a + c: response.body.c + session: session diff --git a/examples/provider_chain.yaml b/examples/provider_chain.yaml index aec44431..f04380d4 100644 --- a/examples/provider_chain.yaml +++ b/examples/provider_chain.yaml @@ -25,7 +25,7 @@ providers: loggers: test: - to: stderr + to: stdout endpoints: - method: POST diff --git a/examples/provider_collect.yaml b/examples/provider_collect.yaml index 3e5a0463..21c9667d 100644 --- a/examples/provider_collect.yaml +++ b/examples/provider_collect.yaml @@ -25,7 +25,7 @@ providers: loggers: test: - to: stderr + to: stdout endpoints: - method: POST diff --git a/examples/provider_create_and_delete.yaml b/examples/provider_create_and_delete.yaml index e553c4a4..fa881608 100644 --- a/examples/provider_create_and_delete.yaml +++ b/examples/provider_create_and_delete.yaml @@ -20,7 +20,7 @@ providers: loggers: test: - to: stderr + to: stdout endpoints: - method: POST diff --git a/examples/provider_grid.yaml b/examples/provider_grid.yaml index ffecc7f7..87f5eca6 100644 --- a/examples/provider_grid.yaml +++ b/examples/provider_grid.yaml @@ -20,7 +20,7 @@ providers: loggers: test: - to: stderr + to: stdout endpoints: - method: POST diff --git a/examples/provider_loop.yaml b/examples/provider_loop.yaml index 4f5657c7..df5da727 100644 --- a/examples/provider_loop.yaml +++ b/examples/provider_loop.yaml @@ -21,7 +21,7 @@ providers: loggers: test: - to: stderr + to: stdout endpoints: - method: POST diff --git a/examples/provider_loop_with_counter.yaml b/examples/provider_loop_with_counter.yaml index b1a854dd..fe0c346a 100644 --- a/examples/provider_loop_with_counter.yaml +++ b/examples/provider_loop_with_counter.yaml @@ -20,7 +20,7 @@ providers: loggers: test: - to: stderr + to: stdout endpoints: - method: POST diff --git a/examples/provider_redirect.yaml b/examples/provider_redirect.yaml index 5be718e2..e5378d7e 100644 --- a/examples/provider_redirect.yaml +++ b/examples/provider_redirect.yaml @@ -17,7 +17,7 @@ providers: loggers: test: - to: stderr + to: stdout endpoints: - method: GET diff --git a/examples/provider_spread.yaml b/examples/provider_spread.yaml index 4d48d63c..72cc690b 100644 --- a/examples/provider_spread.yaml +++ b/examples/provider_spread.yaml @@ -29,7 +29,7 @@ providers: loggers: test: - to: stderr + to: stdout endpoints: - method: POST diff --git a/examples/ramp_and_load.yaml b/examples/ramp_and_load.yaml index 12682446..fffaaf3c 100644 --- a/examples/ramp_and_load.yaml +++ b/examples/ramp_and_load.yaml @@ -15,7 +15,7 @@ load_pattern: loggers: test: - to: stderr + to: stdout endpoints: - method: GET diff --git a/examples/ramp_api_different.yaml b/examples/ramp_api_different.yaml index a8a6683b..b8933b8e 100644 --- a/examples/ramp_api_different.yaml +++ b/examples/ramp_api_different.yaml @@ -11,7 +11,7 @@ load_pattern: loggers: test: - to: stderr + to: stdout endpoints: - method: GET diff --git a/examples/ramp_basic.yaml b/examples/ramp_basic.yaml index d3c081c9..8ff5e4a2 100644 --- a/examples/ramp_basic.yaml +++ b/examples/ramp_basic.yaml @@ -11,7 +11,7 @@ load_pattern: loggers: test: - to: stderr + to: stdout endpoints: - method: GET diff --git a/examples/ramp_over_time.yaml b/examples/ramp_over_time.yaml index 1655cfe3..3e94e729 100644 --- a/examples/ramp_over_time.yaml +++ b/examples/ramp_over_time.yaml @@ -20,7 +20,7 @@ load_pattern: loggers: test: - to: stderr + to: stdout endpoints: - method: GET diff --git a/examples/ramp_to_scale.yaml b/examples/ramp_to_scale.yaml index 421aa398..c130bc13 100644 --- a/examples/ramp_to_scale.yaml +++ b/examples/ramp_to_scale.yaml @@ -16,7 +16,7 @@ load_pattern: loggers: test: - to: stderr + to: stdout endpoints: - method: GET diff --git a/examples/ramp_up_and_down.yaml b/examples/ramp_up_and_down.yaml index 81ce6e5c..a3791211 100644 --- a/examples/ramp_up_and_down.yaml +++ b/examples/ramp_up_and_down.yaml @@ -31,7 +31,7 @@ load_pattern: loggers: test: - to: stderr + to: stdout endpoints: - method: GET diff --git a/examples/random_search.yaml b/examples/random_search.yaml index c7f429d0..495ca0bd 100644 --- a/examples/random_search.yaml +++ b/examples/random_search.yaml @@ -105,7 +105,7 @@ providers: loggers: test: - to: stderr + to: stdout http_errors: select: timestamp: epoch("ms") @@ -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 diff --git a/examples/test_examples.sh b/examples/test_examples.sh new file mode 100755 index 00000000..f9471af8 --- /dev/null +++ b/examples/test_examples.sh @@ -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!" diff --git a/examples/variables.sh b/examples/variables.sh new file mode 100755 index 00000000..ed98af1d --- /dev/null +++ b/examples/variables.sh @@ -0,0 +1,5 @@ +#!/bin/bash +export PASSWORD=bogus +export RAMP_TIME=5s +export LOAD_TIME=10s +export SCALE_PERCENTAGE=100 \ No newline at end of file