-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate server tests to JUnit5 #593
Conversation
55fcbf1
to
f750944
Compare
@@ -471,13 +453,13 @@ static void writeYaml(File file, Map<String, Object> map) throws IOException | |||
{ | |||
Yaml yaml = new Yaml(); | |||
String text = yaml.dump(map); | |||
FileUtils.writeStringToFile(file, text); | |||
FileUtils.writeStringToFile(file, text, Charset.defaultCharset(), false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix deprecation warning.
ports: | ||
- "9000:9000" | ||
- "9001:9001" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use 9001 port for authentication testing to avoid port collision during parallel test run.
# redefine helathcheck because of another port | ||
# see the same configuration in common-services.yml | ||
healthcheck: | ||
test: wget --no-verbose --tries=1 --spider http://localhost:9001/actuator/health |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redefine healthcheck because port was changed.
@@ -15,6 +14,9 @@ if [ "$APPLICATION" == "" ]; then | |||
APPLICATION="extender-test" | |||
fi | |||
|
|||
if [ "$PORT" == "" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read port from external variable
@@ -48,12 +50,23 @@ check_containers_health() { | |||
all_healthy=true | |||
|
|||
for container in $(docker ps -q); do | |||
health_field=$(docker inspect --format='{{.State.Health}}' "$container") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If during test some other containers are running - check if health status is not defined - skip container information.
name=$(docker inspect --format='{{.Name}}' "$container" | sed 's/\///') | ||
app_name=$(docker inspect "$container" | jq -r '.[0].Config.Labels["com.docker.compose.project"]') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract application name from Labels
for further container filtering.
health_status=$(docker inspect --format='{{.State.Health.Status}}' "$container") | ||
|
||
if [ "$app_name" != "$APPLICATION" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When two tests suites run simultaneously (auth and integration tests) - filter containers by application name to avoid check of unrelated containers.
@@ -0,0 +1,2 @@ | |||
junit.jupiter.execution.parallel.enabled = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Configuration to enable parallel test execution.
private static final int EXTENDER_PORT = 9000; | ||
|
||
private TestConfiguration configuration; | ||
private long startTime; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need calculate execution time because JUnit measures time itself.
public static void afterClass() throws IOException, InterruptedException { | ||
ProcessExecutor processExecutor = new ProcessExecutor(); | ||
processExecutor.putEnv("APPLICATION", "extender-test"); | ||
processExecutor.execute("scripts/stop-test-server.sh"); | ||
System.out.println(processExecutor.getOutput()); | ||
} | ||
|
||
@Before | ||
public void beforeTest() throws IOException { | ||
File cachedBuild = new File(String.format("build/%s/build.zip", configuration.platform)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create temporary directory for extender's cache when doBuild
is called.
…ve stuff to fix concurrent tests execution.
f750944
to
216baa6
Compare
AuthentificationTest
andIntegrationTest
. Now two sets of docker containers can be run in parallel.For local execution
on my Mac (Apple M3 Pro, 36 GB)
took
Fixes #565