Skip to content

Commit

Permalink
fix(itest): wait for all containers to be ready (#771)
Browse files Browse the repository at this point in the history
* fix(itest): use port number properties

* extract containerName property

* wait for all containers to start

ensure correct container logs are captured by using property name

* fix(itest): update execution names

* get pod and container names from pom.xml

* do not invoke removed maven executions on teardown
  • Loading branch information
andrewazores authored Dec 3, 2021
1 parent 3bdd4f7 commit 6d6fafa
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 42 deletions.
60 changes: 25 additions & 35 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<cryostat.itest.webPort>8181</cryostat.itest.webPort>
<cryostat.itest.webHost>localhost</cryostat.itest.webHost>
<cryostat.itest.podName>cryostat-itests</cryostat.itest.podName>
<cryostat.itest.containerName>cryostat-itest</cryostat.itest.containerName>
<cryostat.itest.grafana.port>3000</cryostat.itest.grafana.port>
<cryostat.itest.grafana.imageStream>quay.io/cryostat/cryostat-grafana-dashboard</cryostat.itest.grafana.imageStream>
<cryostat.itest.grafana.version>1.0.0</cryostat.itest.grafana.version>
Expand Down Expand Up @@ -375,7 +376,7 @@
</configuration>
</execution>
<execution>
<id>start-container</id>
<id>start-cryostat</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
Expand All @@ -385,7 +386,7 @@
<arguments>
<argument>run</argument>
<argument>--pod=${cryostat.itest.podName}</argument>
<argument>--name=cryostat-itest</argument>
<argument>--name=${cryostat.itest.containerName}</argument>
<argument>--mount</argument>
<argument>type=tmpfs,target=/opt/cryostat.d/conf.d</argument>
<argument>--mount</argument>
Expand Down Expand Up @@ -419,9 +420,9 @@
<argument>--env</argument>
<argument>SSL_TRUSTSTORE_DIR=/opt/cryostat.d/truststore.d</argument>
<argument>--env</argument>
<argument>GRAFANA_DATASOURCE_URL=http://${cryostat.itest.webHost}:8080</argument>
<argument>GRAFANA_DATASOURCE_URL=http://${cryostat.itest.webHost}:${cryostat.itest.jfr-datasource.port}</argument>
<argument>--env</argument>
<argument>GRAFANA_DASHBOARD_URL=http://${cryostat.itest.webHost}:3000</argument>
<argument>GRAFANA_DASHBOARD_URL=http://${cryostat.itest.webHost}:${cryostat.itest.grafana.port}</argument>
<argument>--detach</argument>
<argument>--rm</argument>
<argument>${cryostat.imageStream}:${cryostat.imageVersion}</argument>
Expand All @@ -430,7 +431,7 @@
</configuration>
</execution>
<execution>
<id>wait-for-container</id>
<id>wait-for-cryostat</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
Expand All @@ -441,69 +442,58 @@
<argument>5m</argument>
<argument>sh</argument>
<argument>-c</argument>
<argument>until curl -sSk http://${cryostat.itest.webHost}:${cryostat.itest.webPort}/health; do sleep 10; done</argument>
<argument>until curl -sSk -o /dev/null http://${cryostat.itest.webHost}:${cryostat.itest.webPort}/health; do sleep 10; done</argument>
</arguments>
<skip>${skipITs}</skip>
</configuration>
</execution>
<execution>
<id>capture-oci-logs</id>
<phase>post-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${imageBuilder}</executable>
<arguments>
<argument>logs</argument>
<argument>cryostat-itest</argument>
</arguments>
<outputFile>${project.build.directory}/cryostat-itest-${maven.build.timestamp}.log</outputFile>
<skip>${skipITs}</skip>
</configuration>
</execution>
<execution>
<id>stop-jfr-datasource</id>
<phase>post-integration-test</phase>
<id>wait-for-jfr-datasource</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${imageBuilder}</executable>
<executable>timeout</executable>
<arguments>
<argument>kill</argument>
<argument>jfr-datasource-itest</argument>
<argument>5m</argument>
<argument>sh</argument>
<argument>-c</argument>
<argument>until curl -sSk -o /dev/null http://${cryostat.itest.webHost}:${cryostat.itest.jfr-datasource.port}; do sleep 10; done</argument>
</arguments>
<skip>${skipITs}</skip>
</configuration>
</execution>
<execution>
<id>stop-grafana</id>
<phase>post-integration-test</phase>
<id>wait-for-grafana</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${imageBuilder}</executable>
<executable>timeout</executable>
<arguments>
<argument>kill</argument>
<argument>grafana-itest</argument>
<argument>5m</argument>
<argument>sh</argument>
<argument>-c</argument>
<argument>until curl -sSk -o /dev/null http://${cryostat.itest.webHost}:${cryostat.itest.grafana.port}; do sleep 10; done</argument>
</arguments>
<skip>${skipITs}</skip>
</configuration>
</execution>
<execution>
<id>stop-container</id>
<id>capture-oci-logs</id>
<phase>post-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${imageBuilder}</executable>
<arguments>
<argument>kill</argument>
<argument>cryostat-itest</argument>
<argument>logs</argument>
<argument>${cryostat.itest.containerName}</argument>
</arguments>
<outputFile>${project.build.directory}/${cryostat.itest.containerName}-${maven.build.timestamp}.log</outputFile>
<skip>${skipITs}</skip>
</configuration>
</execution>
Expand Down
14 changes: 7 additions & 7 deletions repeated-integration-tests.bash
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ else
runs=1
fi

POD_NAME=cryostat-itests
POD_NAME="$(xpath -q -e 'project/properties/cryostat.itest.podName/text()' pom.xml)"
CONTAINER_NAME="$(xpath -q -e 'project/properties/cryostat.itest.containerName/text()' pom.xml)"

function cleanup() {
if podman pod exists "${POD_NAME}"; then
Expand All @@ -24,16 +25,15 @@ STARTFLAGS=(
"exec:exec@create-pod"
"exec:exec@start-jfr-datasource"
"exec:exec@start-grafana"
"exec:exec@start-container"
"exec:exec@wait-for-container"
"exec:exec@start-cryostat"
"exec:exec@wait-for-cryostat"
"exec:exec@wait-for-jfr-datasource"
"exec:exec@wait-for-grafana"
"failsafe:integration-test"
"failsafe:verify"
)

STOPFLAGS=(
"exec:exec@stop-jfr-datasource"
"exec:exec@stop-grafana"
"exec:exec@stop-container"
"exec:exec@destroy-pod"
)

Expand All @@ -57,7 +57,7 @@ while [ "${runcount}" -lt "${runs}" ]; do
failures=$((failures+1))
fi
runcount=$((runcount+1))
podman pod logs -c cryostat-itest "${POD_NAME}" &>> "${server_logfile}"
podman pod logs -c "${CONTAINER_NAME}" "${POD_NAME}" &>> "${server_logfile}"
mvn "${STOPFLAGS[@]}" |& tee -a >($PIPECLEANER >> "${client_logfile}")
done

Expand Down

0 comments on commit 6d6fafa

Please sign in to comment.