Skip to content

Commit

Permalink
docker is starting
Browse files Browse the repository at this point in the history
  • Loading branch information
QubitPi committed Apr 17, 2024
1 parent 3493635 commit ede2678
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 7 deletions.
23 changes: 23 additions & 0 deletions athena-examples/athena-example-acceptance-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright Jiaqi Liu
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM jetty:jdk17

LABEL maintainer="Jiaqi (Jack) Liu"
LABEL maintainer-email="[email protected]"

ARG ATHENA_VERSION=1.0-SNAPSHOT

ENV JETTY_WEBAPPS_DIR /var/lib/jetty/webapps

COPY ./target/athena-example-books-$ATHENA_VERSION.war $JETTY_WEBAPPS_DIR/ROOT.war
34 changes: 34 additions & 0 deletions athena-examples/athena-example-acceptance-tests/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright Jiaqi Liu
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
version: "3.9"
services:
web:
build: .
ports:
- "80:8080"
depends_on:
db:
condition: service_healthy
db:
image: "mysql:5.7"
ports:
- "3305:3306"
volumes:
- "./mysql-init.sql:/docker-entrypoint-initdb.d/mysql-init.sql"
environment:
MYSQL_ROOT_PASSWORD: root
healthcheck:
test: mysqladmin ping -h localhost -u root -proot
timeout: 3s
retries: 3
24 changes: 18 additions & 6 deletions athena-examples/athena-example-acceptance-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-bom</artifactId>
<version>1.19.7</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand All @@ -72,12 +79,6 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
Expand All @@ -93,6 +94,17 @@
<artifactId>jackson-databind</artifactId>
<version>2.13.1</version>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mysql</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@
*/
package io.github.qubitpi.athena.test.acceptance;

import org.testcontainers.containers.DockerComposeContainer;
import org.testcontainers.containers.wait.strategy.Wait;

import io.cucumber.java.BeforeAll;
import io.restassured.RestAssured;

import java.io.File;

/**
* BDD initialization step definition before all other steps are executed.
* <p>
Expand All @@ -26,11 +31,16 @@
@SuppressWarnings("unused")
public class InitStepDefinitions {

private static final int WS_PORT = 8080;

/**
* BDD initialization definition.
*/
@BeforeAll
public static void beforeAll() {
new DockerComposeContainer(new File("docker-compose.yml"))
.withExposedService("web", WS_PORT, Wait.forHttp("/v1/data/book").forStatusCode(200))
.start();
initRestAssured();
}

Expand All @@ -39,7 +49,7 @@ public static void beforeAll() {
*/
private static void initRestAssured() {
RestAssured.baseURI = "http://localhost";
RestAssured.port = 8080;
RestAssured.port = WS_PORT;
RestAssured.basePath = "/v1";
}
}

0 comments on commit ede2678

Please sign in to comment.