-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Expand and modularize the integration test suite
Drop the Docker containers - we need the gradle and maven caches to get reasonable build times. If we need to do a build matrix of Java VM versions, we can use Travis to do that. Refactor the single large bats file into separate test suites with their own fixtures.
- Loading branch information
Showing
27 changed files
with
217 additions
and
215 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,6 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# run smoke tests | ||
set -e | ||
|
||
# see https://blog.travis-ci.com/docker-rate-limits | ||
if [ ! -z "$DOCKERHUB_PASSWORD" ] && [ ! -z "$DOCKERHUB_USERNAME" ]; then | ||
echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin | ||
fi | ||
|
||
JAVA_VERSION=$(java -version 2>&1 | head -1 | cut -d'"' -f2 | sed 's/^1\.//'| cut -d'.' -f1) | ||
|
||
if [ $JAVA_VERSION -lt "9" ]; then | ||
CONFIG=test/docker/java8/Dockerfile | ||
else | ||
CONFIG=test/docker/java11/Dockerfile | ||
fi | ||
|
||
docker build \ | ||
-t "petclinic:latest" \ | ||
-f test/docker/petclinic/Dockerfile \ | ||
. | ||
|
||
IMAGE_NAME=appmap-test | ||
IMAGE_TAG=latest | ||
|
||
docker build \ | ||
-t "${IMAGE_NAME}:${IMAGE_TAG}" \ | ||
-f $CONFIG \ | ||
. | ||
|
||
set -e | ||
|
||
printf '\n=== begin tests ===\n' | ||
exec docker run -i $(tty -s && echo '-t') \ | ||
-v $PWD/test/smoke.bats:/test/smoke.bats \ | ||
--rm \ | ||
"${IMAGE_NAME}:${IMAGE_TAG}" \ | ||
"${@:-/sbin/entrypoint}" | ||
./bin/test_install | ||
./bin/test_run |
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,22 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
mkdir -p build/fixtures | ||
cd build/fixtures | ||
fixture_dir=$(pwd) | ||
|
||
git clone --depth 1 https://github.com/spring-projects/spring-petclinic.git \ | ||
&& cd spring-petclinic \ | ||
&& ./mvnw package -Dmaven.test.skip=true | ||
|
||
cd ../../.. | ||
mkdir -p build/bats | ||
cd build/bats | ||
bats_dir=$(pwd) | ||
|
||
git clone --depth 1 https://github.com/bats-core/bats-core.git \ | ||
&& git clone --depth 1 https://github.com/bats-core/bats-support.git \ | ||
&& git clone --depth 1 https://github.com/bats-core/bats-assert.git \ | ||
&& cd bats-core \ | ||
&& ./install.sh "$bats_dir" |
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,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
export PATH="bats_dir"/bin:$PATH | ||
|
||
./test/petclinic/test | ||
./test/http_client/test | ||
./test/agent_cli/test |
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 @@ | ||
spring-petclinic |
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,39 @@ | ||
#!/usr/bin/env bats | ||
|
||
load '../../build/bats/bats-support/load' | ||
load '../../build/bats/bats-assert/load' | ||
load '../helper' | ||
|
||
appmap_jar=build/libs/$(ls build/libs | grep 'appmap-[[:digit:]]') | ||
|
||
# bats captures stdout and stderr to the same variable ($output). We | ||
# need to hide the informational message from the agent commands so | ||
# json assertions don't get confused. | ||
@test "appmap agent init packages" { | ||
run bash -c "java -jar $appmap_jar -d test/agent_cli/sampleproj init 2>/dev/null" | ||
assert_success | ||
|
||
assert_json_contains '.configuration.contents' 'path: pkg1' | ||
assert_json_contains '.configuration.contents' 'path: pkg2' | ||
} | ||
|
||
@test "appmap agent init empty project" { | ||
run bash -c "java -jar $appmap_jar -d test/agent_cli/emptyproj init 2>/dev/null" | ||
assert_success | ||
|
||
assert_json_contains '.configuration.contents' 'path: com.mycorp.pkg' | ||
} | ||
|
||
@test "appmap agent status petclinic" { | ||
run bash -c "java -jar $appmap_jar -d test/agent_cli/spring-petclinic status 2>/dev/null" | ||
assert_success | ||
|
||
assert_json_eq '.properties.config.app' 'spring-petclinic' | ||
assert_json_eq '.properties.config.present' 'true' | ||
assert_json_eq '.properties.config.valid' 'true' | ||
assert_json_eq '.properties.frameworks[0].name' 'gradle' | ||
assert_json_eq '.properties.frameworks[1].name' 'maven' | ||
|
||
# TODO: Configure the agent in the spring-petclinic pom.xml and verify that it's | ||
# reported present and valid by the agent status command. | ||
} |
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 @@ | ||
// intentionally blank |
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 @@ | ||
// intentionally blank |
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 @@ | ||
// intentionally blank |
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,14 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
cp -r build/fixtures/spring-petclinic test/agent_cli | ||
cp test/petclinic/appmap.yml test/agent_cli/spring-petclinic | ||
|
||
run_bats() { | ||
bats --tap test/agent_cli/agent_cli.bats > build/log/bats-agent_cli.log 2>&1 | ||
} | ||
${@:-run_bats} | ||
bats_ret=$? | ||
|
||
cat build/log/bats-agent_cli.log | ||
exit $bats_ret |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
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,2 @@ | ||
appmap | ||
classes |
6 changes: 1 addition & 5 deletions
6
test/HttpClientTest.java → test/http_client/HttpClientTest.java
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,3 @@ | ||
name: HTTP client test | ||
packages: | ||
- path: http_client.HttpClientTest |
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,32 @@ | ||
#!/usr/bin/env bats | ||
|
||
load '../../build/bats/bats-support/load' | ||
load '../../build/bats/bats-assert/load' | ||
load '../helper' | ||
|
||
WS_URL=${WS_URL:-http://localhost:8080} | ||
appmap_jar=build/libs/$(ls build/libs | grep 'appmap-[[:digit:]]') | ||
mkdir -p appmap | ||
|
||
@test "expected number of http client events captured" { | ||
skip | ||
|
||
# Exception in thread "main" java.lang.NoClassDefFoundError: java/sql/Time | ||
# at com.appland.shade.com.alibaba.fastjson.util.TypeUtils.addBaseClassMappings(TypeUtils.java:1456) | ||
# at com.appland.shade.com.alibaba.fastjson.util.TypeUtils.<clinit>(TypeUtils.java:119) | ||
# at com.appland.shade.com.alibaba.fastjson.serializer.SerializeConfig.getObjectWriter(SerializeConfig.java:544) | ||
# at com.appland.shade.com.alibaba.fastjson.serializer.SerializeConfig.getObjectWriter(SerializeConfig.java:436) | ||
# at com.appland.shade.com.alibaba.fastjson.serializer.SerializeConfig.getObjectWriter(SerializeConfig.java:527) | ||
# at com.appland.shade.com.alibaba.fastjson.serializer.SerializeConfig.getObjectWriter(SerializeConfig.java:436) | ||
# at com.appland.shade.com.alibaba.fastjson.serializer.JSONSerializer.getObjectWriter(JSONSerializer.java:410) | ||
# at com.appland.shade.com.alibaba.fastjson.serializer.JSONSerializer.write(JSONSerializer.java:282) | ||
# at com.appland.shade.com.alibaba.fastjson.JSONWriter.writeObject(JSONWriter.java:61) | ||
# at com.appland.shade.com.alibaba.fastjson.JSONWriter.writeValue(JSONWriter.java:48) | ||
# at com.appland.appmap.record.AppMapSerializer.writeClassMap(AppMapSerializer.java:211) | ||
|
||
java -Xbootclasspath/a:$appmap_jar -javaagent:$appmap_jar -Dappmap.debug -Dappmap.config.file=test/http_client/appmap.yml \ | ||
-Dappmap.output.directory=test/http_client/appmap -Dappmap.record=http_client.HttpClientTest.main -cp test/http_client/classes http_client.HttpClientTest ${WS_URL} | ||
output=$(<appmap/*.appmap.json) | ||
assert_json_eq '[.events[] | select(.http_client_request)] | length' 3 | ||
assert_json_eq '[.events[] | select(.http_client_response)] | length' 3 | ||
} |
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 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -x | ||
|
||
basedir=test/http_client | ||
cd test/http_client | ||
|
||
javac -d classes -g HttpClientTest.java | ||
|
||
cd - | ||
|
||
export WS_URL="http://localhost:8080" | ||
|
||
PETCLINIC_LOG=build/log/http_client_petclinic.log | ||
java -ea -jar build/fixtures/spring-petclinic/target/$(ls build/fixtures/spring-petclinic/target | grep 'spring-petclinic-[[:digit:]].*\.jar$') &> $PETCLINIC_LOG & | ||
JVM_PID=$! | ||
|
||
printf 'Starting spring-petclinic' | ||
while [ -z "$(curl -I "${WS_URL}" | grep 'HTTP/1.1 200')" ]; do | ||
if ! kill -0 "${JVM_PID}" 2> /dev/null; then | ||
printf '. failed!\n\nprocess exited unexpectedly:\n' | ||
cat $PETCLINIC_LOG | ||
exit 1 | ||
fi | ||
|
||
printf '.' | ||
sleep 1 | ||
done | ||
printf ' ok\n\n' | ||
|
||
mkdir -p build/log | ||
run_bats() { | ||
bats --tap test/http_client/http_client.bats > build/log/bats-http_client.log 2>&1 | ||
} | ||
${@:-run_bats} | ||
bats_ret=$? | ||
|
||
kill ${JVM_PID} | ||
wait ${JVM_PID} | ||
cat $PETCLINIC_LOG | ||
cat build/log/bats-http_client.log | ||
exit $bats_ret |
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 @@ | ||
classes |
Oops, something went wrong.