-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement dockerized benchmarks
- Loading branch information
Showing
4 changed files
with
141 additions
and
39 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
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 |
---|---|---|
@@ -1,46 +1,76 @@ | ||
#!/usr/bin/env bash | ||
|
||
# hurl is required | ||
if ! command -v hurl &>/dev/null; then | ||
echo "> hurl is required but it's not installed. Aborting." >&2 | ||
exit 1 | ||
fi | ||
|
||
if [ "$1" == "benchmark" ]; then | ||
benchmark_mode=0 # 0 (true) for benchmarks | ||
echo "> benchmark mode" | ||
else | ||
benchmark_mode=1 # 1 (false) for tests | ||
echo "> test mode" | ||
fi | ||
|
||
# docker parameters | ||
tag=typed-pid-maker-test | ||
container=typid-test | ||
|
||
# meta information for this script | ||
this=${BASH_SOURCE[0]} | ||
echo "this script is at $this" | ||
echo "> this script is at $this" | ||
docker_dir=$(dirname "$this") | ||
|
||
echo "build docker image" | ||
echo "> trigger local build" | ||
"$docker_dir"/../gradlew build -x test || exit 1 | ||
|
||
echo "> build docker image, reusing local build" | ||
sleep .2 | ||
# use "standalone" or "release" to build in the docker container | ||
if [ "$1" ] | ||
then | ||
echo " > compiling in container: " | ||
docker build --file $docker_dir/Dockerfile-build-in-image --tag $tag $docker_dir/.. || exit 1 | ||
else | ||
echo " > reusing local build: " | ||
docker build --file $docker_dir/Dockerfile-reuse-local-build --tag $tag $docker_dir/.. || exit 1 | ||
fi | ||
docker build --file "$docker_dir/Dockerfile-reuse-local-build" \ | ||
--tag "$tag" "$docker_dir/.." || exit 1 | ||
|
||
echo -n "run container: " | ||
docker run -p 8090:8090 --detach --name $container $tag | ||
echo -n "> run container: " | ||
docker run \ | ||
--env pit.typeregistry.cache.maxEntries=0 \ | ||
-p 8090:8090 \ | ||
--detach \ | ||
--name $container $tag | ||
|
||
echo "> Making sure the service is ready to accept requests" | ||
hurl --retry=20 --retry-interval=5000 \ | ||
--test "$docker_dir"/tests/create_resolve_exists.hurl || | ||
exit 1 | ||
echo "> Service is ready. Starting with actual tests." | ||
|
||
##################################### | ||
### tests ########################### | ||
### run tests / benchmarks ################ | ||
##################################### | ||
hurl --retry=10 --retry-interval=10000 \ | ||
--test "$docker_dir"/tests/*.hurl | ||
failure=$? | ||
echo "> benchmark mode: $benchmark_mode" | ||
if [ "$benchmark_mode" -eq 0 ]; then | ||
echo "> running benchmark" | ||
hurl --retry=20 --retry-interval=5000 \ | ||
--test --jobs 1 --repeat 1000 \ | ||
"$docker_dir"/tests/benchmark-create_dryrun.hurl | ||
failure=$? | ||
else | ||
echo "> running tests" | ||
hurl --retry=20 --retry-interval=5000 \ | ||
--test "$docker_dir"/tests/*.hurl | ||
failure=$? | ||
fi | ||
##################################### | ||
|
||
echo -n "stopping container ... " | ||
echo -n "> stopping container ... " | ||
docker container stop $container | ||
echo -n "removing container ... " | ||
echo -n "> removing container ... " | ||
docker container rm $container | ||
|
||
if [ $failure -eq 0 ] | ||
then | ||
echo "ALL TESTS SUCCESSFUL." | ||
exit 0 | ||
if [ $failure -eq 0 ]; then | ||
echo "> ALL TESTS SUCCESSFUL." | ||
exit 0 | ||
else | ||
echo "TESTS FAILED (see output for details)" | ||
exit 1 | ||
echo "> TESTS FAILED (see output for details)" | ||
exit 1 | ||
fi |
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,65 @@ | ||
# create/register a pid record | ||
POST http://localhost:8090/api/v1/pit/pid/ | ||
Content-Type: application/vnd.datamanager.pid.simple+json | ||
Accept: application/vnd.datamanager.pid.simple+json | ||
[QueryStringParams] | ||
dryrun: true | ||
{ | ||
"record": [ | ||
{ | ||
"key": "21.T11148/076759916209e5d62bd5", | ||
"value": "21.T11148/b9b76f887845e32d29f7" | ||
}, | ||
{ | ||
"key": "21.T11148/1c699a5d1b4ad3ba4956", | ||
"value": "21.T11148/ca9fd0b2414177b79ac2" | ||
}, | ||
{ | ||
"key": "21.T11148/a753134738da82809fc1", | ||
"value": "21.T11148/a753134738da82809fc1" | ||
}, | ||
{ | ||
"key": "21.T11148/b8457812905b83046284", | ||
"value": "https://hdl.handle.net/21.T11148/b8457812905b83046284" | ||
}, | ||
{ | ||
"key": "21.T11148/1a73af9e7ae00182733b", | ||
"value": "https://orcid.org/0000-0001-6575-1022" | ||
}, | ||
{ | ||
"key": "21.T11148/aafd5fb4c7222e2d950a", | ||
"value": "2020-10-21T00:00:00+02:00" | ||
}, | ||
{ | ||
"key": "21.T11969/a00985b98dac27bd32f8", | ||
"value": "Book" | ||
}, | ||
{ | ||
"key": "21.T11148/2f314c8fe5fb6a0063a8", | ||
"value": "{\"licenseURL\": \"https://www.gnu.org/licenses/agpl-3.0.en.html\"}" | ||
}, | ||
{ | ||
"key": "21.T11148/82e2503c49209e987740", | ||
"value": "{\"md5sum\": \"2289159614f3e3b06fc436423c0dc398\"}" | ||
}, | ||
{ | ||
"key": "21.T11148/7fdada5846281ef5d461", | ||
"value": "{\"locationPreview/Sample\": \"https://example.com/my/path/to/image.svg\"}" | ||
}, | ||
{ | ||
"key": "21.T11148/6ae999552a0d2dca14d6", | ||
"value": "this-is-a-string" | ||
}, | ||
{ | ||
"key": "21.T11148/f3f0cbaa39fa9966b279", | ||
"value": "{\"identifier\": \"this-is-a-string\"}" | ||
}, | ||
{ | ||
"key": "21.T11148/4fe7cde52629b61e3b82", | ||
"value": "sandboxed/some-random-pid" | ||
} | ||
] | ||
} | ||
|
||
# on success, we get a 200 (no 201, because we're in dry-run mode) | ||
HTTP 200 |