-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add test shell scripts, run inside docker network
- Loading branch information
Showing
6 changed files
with
127 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,27 @@ | ||
# Performance Tests | ||
|
||
This package contains a script that will determine the performance of Rafiki by repeatedly making a series of requests to a Rafiki instance to create several kinds of resources (receivers, quotes, outgoing payments). | ||
|
||
## Prerequisites | ||
|
||
* [Grafana k6](https://grafana.com/docs/k6/latest/set-up/install-k6/) | ||
* [Grafana k6](https://grafana.com/docs/k6/latest/) is used to run performance test scripts against Rafiki. | ||
|
||
* [Running local playground for Rafiki](../../localenv/README.md) | ||
|
||
If the local environment isn't running it may be started | ||
|
||
## Run tests | ||
To run the performance tests (of which there is currently only one): | ||
|
||
``` | ||
pnpm --filter performance run-tests | ||
``` | ||
|
||
The test makes a few checks to verify the local playground is running, then runs the k6 binary on the [create-outgoing-payments.js](./scripts/create-outgoing-payments.js) script. | ||
|
||
The test can also be run inside of a Docker container on the same Docker network as the Local Playground: | ||
|
||
``` | ||
pnpm --filter performance run-docker-tests | ||
``` |
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
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
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,33 @@ | ||
#!/bin/bash | ||
|
||
c9_gql_url="http://localhost:3001/graphql" | ||
c9_wallet_address="http://localhost:3000/accounts/gfranklin" | ||
hlb_wallet_address="http://localhost:4000/accounts/pfry" | ||
|
||
# Verify that the localenv backend is live | ||
if curl -s --head --request GET "$c9_gql_url" | grep "HTTP/1.[01]" > /dev/null; then | ||
echo "Localenv is up: $c9_gql_url" | ||
else | ||
echo "Localenv is down: $c9_gql_url" | ||
exit 1 | ||
fi | ||
|
||
# Verify that cloud nine wallet address is live | ||
if curl -s --head --request GET "$c9_wallet_address" | grep "HTTP/1.[01]" > /dev/null; then | ||
echo "Cloud Nine Wallet Address is up: $c9_wallet_address" | ||
else | ||
echo "Cloud Nine Wallet Address is down: $c9_wallet_address" | ||
exit 1 | ||
fi | ||
|
||
# Verify that happy life bank wallet address is live | ||
if curl -s --head --request GET "$hlb_wallet_address" | grep "HTTP/1.[01]" > /dev/null; then | ||
echo "Happy Life Bank Address is up: $hlb_wallet_address" | ||
else | ||
echo "Happy Life Bank Address is down: $hlb_wallet_address" | ||
exit 1 | ||
fi | ||
|
||
# run tests | ||
docker run --rm --network=rafiki_rafiki -v ./scripts:/scripts -i grafana/k6 run /scripts/create-outgoing-payments.js | ||
exit $? |
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,53 @@ | ||
#!/bin/bash | ||
|
||
c9_gql_url="http://localhost:3001/graphql" | ||
c9_wallet_address="http://localhost:3000/accounts/gfranklin" | ||
hlb_wallet_address="http://localhost:4000/accounts/pfry" | ||
|
||
# Verify that the localenv backend is live | ||
if curl -s --head --request GET "$c9_gql_url" | grep "HTTP/1.[01]" > /dev/null; then | ||
echo "Localenv is up: $c9_gql_url" | ||
else | ||
echo "Localenv is down: $c9_gql_url" | ||
exit 1 | ||
fi | ||
|
||
# Verify that cloud nine wallet address is live | ||
if curl -s --head --request GET "$c9_wallet_address" | grep "HTTP/1.[01]" > /dev/null; then | ||
echo "Cloud Nine Wallet Address is up: $c9_wallet_address" | ||
else | ||
echo "Cloud Nine Wallet Address is down: $c9_wallet_address" | ||
exit 1 | ||
fi | ||
|
||
# Verify that happy life bank wallet address is live | ||
if curl -s --head --request GET "$hlb_wallet_address" | grep "HTTP/1.[01]" > /dev/null; then | ||
echo "Happy Life Bank Address is up: $hlb_wallet_address" | ||
else | ||
echo "Happy Life Bank Address is down: $hlb_wallet_address" | ||
exit 1 | ||
fi | ||
|
||
# setup hosts | ||
addHost() { | ||
local hostname="$1" | ||
|
||
# check first to avoid sudo prompt if host is already set | ||
if pnpm --filter performance hostile list | grep -q "127.0.0.1 $hostname"; then | ||
echo "$hostname already set" | ||
else | ||
sudo pnpm --filter performance hostile set 127.0.0.1 "$hostname" | ||
if [ $? -ne 0 ]; then | ||
echo "Error: Failed to write hosts to hostfile." | ||
exit 1 | ||
fi | ||
fi | ||
} | ||
addHost "cloud-nine-wallet-backend" | ||
addHost "cloud-nine-wallet-auth" | ||
addHost "happy-life-bank-backend" | ||
addHost "happy-life-bank-auth" | ||
|
||
# run tests | ||
pnpm --filter performance test | ||
exit $? |