forked from FamilySearch/pewpew
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create a folder of example files * Added some initial examples with chaining/looping providers * Added a script to simulate logging in and scrubbing password from the log * Updated the README and yaml files with additional info on running * Added 3 different versions of login, force, block, and on_demand * Added 3 different versions of login, force, block, and on_demand * Added an example that does a random search on multiple criteria * Added an example that deletes sequentially * Renamed file * Added fixed delete sequential * Added comments * Added a test that searches for ids to delete * Fixed the counter to start at zero * Added a test that is used to create/update data * Added some examples using various ramps * Added comments on options * Added an example of an API that returns a redirect and fixed the tags on the redirect url * Added several logging examples including errors and csv * Added a test that creates, updates, then deletes data * Removed unneeded var * Added a delayed burst example * Updated the README with some descriptions * Added example generating a grid of calls from a request call
- Loading branch information
1 parent
acde4c8
commit 8f30ab3
Showing
26 changed files
with
1,654 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/stats-*.json | ||
/search-results*.json | ||
/log-results* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Pewpew Examples | ||
These are some examples based on tests written for different services tests. See the [guide](https://familysearch.github.io/pewpew) for documentation on functions. | ||
|
||
Most of these examples will work with the [test-server](https://familysearch.github.io/pewpew/bug-report.html#using-the-pewpew-test-server). Then specifying the same `PORT` when running the test. | ||
|
||
Example: | ||
```bash | ||
|
||
PORT=8080 test-server & | ||
PORT=8080 PASSWORD=bogus pewpew try login_for_apis.yaml -l | ||
``` | ||
|
||
### delete_*.yaml | ||
|
||
These examples are different ways to clean-up or DELETE after a test has one. `delete_search.yaml` simulates a search for data based on some created data and deletes until the search returns no results. `delete_sequential_404s.yaml` and `delete_sequential_count.yaml` both assume you used some counter similar to in `provider_spread.yaml` and either delete until X number of 404s, or until X number of deletes happen. | ||
|
||
### log_*.yaml | ||
|
||
These have some various logging examples. Note: `random_search.yaml` also includes some interesting logging | ||
|
||
### login_for_apis*.yaml | ||
|
||
These examples assume a basic password type login and have different ways of rotating in new sessions either by `force`, `block`, or `on_demand`. | ||
|
||
### provider_*.yaml | ||
|
||
These examples show various ways that providers can be changed, looped, or used to have APIs call from one to another and pass data. | ||
|
||
### ramp_*.yaml | ||
|
||
These examples show various ramping systems you can use. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# Run this file with the test-server, then specify the PORT as a parameter to this try or run script. | ||
|
||
# This file will delete sequentially until we get 50 (maxDelete404) 404s in a row. If we ever don't get a 404, it resets. | ||
# Once we hit 50 in a row, it logs to `test_404s` logger which causes the test to exit with `kill: true` | ||
|
||
vars: | ||
port: "${PORT}" | ||
createdName: 'test:loadtest-' # Only used so we can prepopulate the results for the test server | ||
maxDelete404: 50 | ||
maxSearchDelete404: 500 | ||
maxEmptySearch: 20 | ||
peakLoadDelete: 400hpm | ||
peakLoadSearch: 20hpm | ||
|
||
load_pattern: | ||
- linear: | ||
from: 100% | ||
to: 100% | ||
over: 15s | ||
|
||
config: | ||
client: | ||
headers: | ||
TestTime: '${epoch("ms")}' | ||
Accept: application/json | ||
|
||
providers: | ||
createdId: # Only used so we can prepopulate the results for the test server | ||
range: | ||
start: 1 | ||
nextPageTokenGroup: | ||
list: | ||
values: | ||
- token: 0 | ||
emptyCount: 0 | ||
testId: | ||
response: | ||
buffer: 1 | ||
|
||
|
||
loggers: | ||
test: | ||
to: stderr | ||
test_404s: | ||
limit: 1 | ||
to: stdout | ||
pretty: false | ||
kill: true | ||
|
||
endpoints: | ||
- method: PUT | ||
url: 'http://localhost:${port}' | ||
headers: | ||
Content-Type: application/json | ||
declare: | ||
resultsIds: collect('${createdName}${start_pad(createdId, 6, "0")}', 0, 20) | ||
body: '{ | ||
"pageSize": 20, | ||
"name": "TEST-GROUP", | ||
"nextPageToken": "${nextPageTokenGroup.token + 1}", | ||
"userIds": ${resultsIds}, | ||
"numberReturned":${resultsIds.length} | ||
}' | ||
peak_load: ${peakLoadSearch} | ||
provides: | ||
testId: | ||
select: for_each[0] | ||
for_each: | ||
- response.body.userIds | ||
where: response.status == 200 && response.body.numberReturned > 0 | ||
send: block | ||
nextPageTokenGroup: | ||
select: | ||
token: if(response.status == 200 && response.body.numberReturned > 0 && response.body.nextPageToken != null, response.body.nextPageToken + 1, 0) | ||
emptyCount: if(response.status == 200 && response.body.numberReturned > 0, 0, nextPageTokenGroup.emptyCount + 1) | ||
where: nextPageTokenGroup.emptyCount < maxEmptySearch | ||
logs: | ||
test: | ||
select: | ||
ids: response.body.numberReturned | ||
test_404s: | ||
select: | ||
timestamp: epoch("ms") | ||
request: request["start-line"] | ||
response: response["start-line"] | ||
responseBody: response.body | ||
status: response.status | ||
token: nextPageTokenGroup.token | ||
emptyCount: nextPageTokenGroup.emptyCount | ||
maxEmptySearch: maxEmptySearch | ||
where: response.status == 200 && response.body != "" && response.body.numberReturned == 0 | ||
|
||
|
||
- method: DELETE | ||
url: 'http://localhost:${port}?id=${testId}?include-children=true' | ||
tags: | ||
status: ${response.status} | ||
peak_load: 1hps | ||
logs: | ||
test: | ||
select: | ||
id: testId | ||
test_404s: | ||
select: | ||
timestamp: epoch("ms") | ||
id: testId | ||
request: request["start-line"] | ||
response: response["start-line"] | ||
status: response.status | ||
maxDelete404: maxDelete404 | ||
where: response.status == 404 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Run this file with the test-server, then specify the PORT as a parameter to this try or run script. | ||
|
||
# This file will delete sequentially until we get 50 (maxDelete404) 404s in a row. If we ever don't get a 404, it resets. | ||
# Once we hit 50 in a row, it logs to `test_404s` logger which causes the test to exit with `kill: true` | ||
|
||
vars: | ||
port: "${PORT}" | ||
ingestName: 'test:loadtest-' | ||
maxDelete404: 50 | ||
maxSearchDelete404: 500 | ||
maxEmptySearch: 20 | ||
|
||
load_pattern: | ||
- linear: | ||
from: 100% | ||
to: 100% | ||
over: 15s | ||
|
||
config: | ||
client: | ||
headers: | ||
TestTime: '${epoch("ms")}' | ||
Accept: application/json | ||
|
||
providers: | ||
createdId: | ||
range: | ||
start: 1 | ||
delete404s: | ||
list: | ||
values: | ||
- 0 # Initial value to pre-populate a counter | ||
repeat: false | ||
|
||
|
||
loggers: | ||
test: | ||
to: stderr | ||
test_404s: | ||
limit: 1 | ||
to: stdout | ||
pretty: false | ||
kill: true | ||
|
||
endpoints: | ||
- method: DELETE | ||
url: 'http://localhost:${port}?id=${ingestName}${start_pad(createdId, 6, "0")}?include-children=true' | ||
tags: | ||
status: ${response.status} | ||
headers: | ||
Delete404s: ${delete404s} | ||
peak_load: 1hps | ||
provides: | ||
delete404s: | ||
select: if(response.status == 404, delete404s + 1, 0) | ||
send: force | ||
logs: | ||
test: | ||
select: | ||
id: '`${ingestName}${start_pad(createdId, 6, "0")}`' | ||
delete404s: delete404s | ||
test_404s: | ||
select: | ||
timestamp: epoch("ms") | ||
id: '`${ingestName}${start_pad(createdId, 6, "0")}`' | ||
request: request["start-line"] | ||
response: response["start-line"] | ||
status: response.status | ||
delete404s: delete404s | ||
maxDelete404: maxDelete404 | ||
where: response.status == 404 && delete404s >= maxDelete404 | ||
# where: response.status == 404 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Run this file with the test-server, then specify the PORT as a parameter to this try or run script. | ||
|
||
# This file will delete sequentially until we get 50 (createdId.end) calls | ||
|
||
vars: | ||
port: "${PORT}" | ||
ingestName: 'test:loadtest-' | ||
maxEmptySearch: 20 | ||
|
||
load_pattern: | ||
- linear: | ||
from: 100% | ||
to: 100% | ||
over: 60m # Doesn't really matter since once createdId runs out it will exit. | ||
|
||
config: | ||
client: | ||
headers: | ||
TestTime: '${epoch("ms")}' | ||
Accept: application/json | ||
|
||
providers: | ||
createdId: | ||
range: | ||
start: 1 | ||
end: 50 # How many to delete. total time should be this / peak_load | ||
|
||
|
||
loggers: | ||
test: | ||
to: stdout | ||
|
||
endpoints: | ||
- method: DELETE | ||
url: 'http://localhost:${port}?id=${ingestName}${start_pad(createdId, 6, "0")}?include-children=true' | ||
tags: | ||
status: ${response.status} | ||
peak_load: 10hps | ||
logs: | ||
test: | ||
select: | ||
ts: epoch("ms") | ||
id: '`${ingestName}${start_pad(createdId, 6, "0")}`' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Run this file with the test-server, then specify the PORT as a parameter to this try or run script. | ||
|
||
vars: | ||
port: "${PORT}" | ||
|
||
load_pattern: | ||
- linear: | ||
from: 10% | ||
to: 100% | ||
over: 15s | ||
|
||
loggers: | ||
http_errors: | ||
select: | ||
timestamp: epoch("ms") | ||
request: request["start-line"] | ||
requestHeaders: request.headers # headers_all includes duplicate headers, headers only has the first of each named header | ||
requestBody: request.body | ||
response: response["start-line"] | ||
responseHeaders: response.headers | ||
responseBody: response.body | ||
stats: stats | ||
to: 'log-results-${epoch("ms")}.json' # log to a file with a timestamp. timestamp set at test start | ||
pretty: false | ||
|
||
test: | ||
to: stderr | ||
|
||
endpoints: | ||
- method: POST | ||
url: http://localhost:${port} | ||
headers: | ||
Accept-Language: en-us | ||
Content-Type: application/json | ||
Authorization: Bearer test-token | ||
body: '{"test":true}' | ||
peak_load: 1hps | ||
logs: | ||
test: | ||
select: response.status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Run this file with the test-server, then specify the PORT as a parameter to this try or run script. | ||
|
||
vars: | ||
port: "${PORT}" | ||
|
||
load_pattern: | ||
- linear: | ||
from: 10% | ||
to: 100% | ||
over: 15s | ||
|
||
providers: | ||
a: # Counter for creating groups | ||
range: {} | ||
|
||
loggers: | ||
csv_data: | ||
to: 'log-results-${epoch("ms")}.csv' # log to a file with a timestamp. timestamp set at test start | ||
pretty: false | ||
|
||
test: | ||
to: stderr | ||
|
||
endpoints: | ||
- method: POST | ||
url: http://localhost:${port} | ||
headers: | ||
Accept-Language: en-us | ||
Content-Type: application/json | ||
Authorization: Bearer test-token | ||
body: '{ | ||
"a":${a}, | ||
"data":"test data ${a}", | ||
"test":true | ||
}' | ||
peak_load: 1hps | ||
logs: | ||
csv_data: | ||
select: '`${response.body.a},"${response.body.data}",${response.body.test},${response.status},${stats.rtt}`' | ||
where: response.status == 200 | ||
test: | ||
select: response.status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Run this file with the test-server, then specify the PORT as a parameter to this try or run script. | ||
|
||
vars: | ||
port: "${PORT}" | ||
|
||
load_pattern: | ||
- linear: | ||
from: 10% | ||
to: 100% | ||
over: 15s | ||
|
||
loggers: | ||
http_errors: | ||
select: | ||
timestamp: epoch("ms") | ||
request: request["start-line"] | ||
method: request.method | ||
url: request.url.href | ||
requestHeaders: request.headers_all # headers_all includes duplicate headers | ||
response: response["start-line"] | ||
status: response.status | ||
responseHeaders: response.headers_all | ||
responseBody: response.body | ||
stats: stats | ||
where: response.status >= 400 && response.status != 503 | ||
limit: 1000 | ||
to: stdout | ||
pretty: false | ||
|
||
test: | ||
to: stderr | ||
|
||
endpoints: | ||
- method: GET | ||
url: http://localhost:${port} | ||
headers: | ||
Accept-Language: en-us | ||
Content-Type: application/json | ||
Authorization: Bearer test-token | ||
body: '{"test":true}' | ||
peak_load: 1hps | ||
logs: | ||
test: | ||
select: response.status |
Oops, something went wrong.