Skip to content

Commit 6976435

Browse files
committed
Updated docker compose/Dockerfile, fixed Integration Test to wait for response from user service
1 parent 095f63c commit 6976435

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM anapsix/alpine-java:8
22
MAINTAINER Justin Phillips "[email protected]"
33
VOLUME /tmp
4-
ADD build/libs/microservices--backing-service--edge-service-0.0.1.jar app.jar
4+
ADD build/libs/edge-service-0.0.1.jar app.jar
55
RUN bash -c 'touch /app.jar'
66
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]

docker-compose.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ services:
3131
# ports:
3232
# - 8888:8888
3333

34-
mysql-server:
34+
mysqlserver:
3535
image: mysql:5.7
36-
container_name: mysql-server
36+
container_name: mysqlserver
3737
volumes:
3838
- mysql-data:/var/lib/mysql:rw
3939
restart: always
@@ -50,10 +50,10 @@ services:
5050
image: aista/user-service
5151
depends_on:
5252
- discovery-service
53-
- mysql-server
53+
- mysqlserver
5454
container_name: userservice
5555
ports:
56-
- '8091:8091'
56+
- '8080'
5757

5858
mongo:
5959
image: 'mongo:3.4.1'

src/test/java/aist/edge/edgeservice/EdgeServiceIntegrationTests.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class EdgeServiceIntegrationTests {
3333
private static String tripQueryURL;
3434
private static String gmapsAdapterURL;
3535
private static String calculationServiceURL;
36+
private static String userServiceURL;
3637

3738
//Wait for all services to have ports open
3839
@ClassRule
@@ -44,8 +45,6 @@ public class EdgeServiceIntegrationTests {
4445
.waitingForService("gmapsadapter", HealthChecks.toHaveAllPortsOpen())
4546
.waitingForService("calculationservice", HealthChecks.toHaveAllPortsOpen())
4647
.waitingForService("discovery-service", HealthChecks.toHaveAllPortsOpen())
47-
.waitingForService("userservice", HealthChecks.toRespondOverHttp(8091,
48-
(port) -> port.inFormat("http://localhost:8091")))
4948
.waitingForService("discovery-service", HealthChecks.toRespondOverHttp(8761,
5049
(port) -> port.inFormat("http://localhost:8761")))
5150
.build();
@@ -77,6 +76,16 @@ public static void initialize() {
7776
calculationServiceURL = String.format("http://%s:%s", calculationService.getIp(),
7877
calculationService.getExternalPort());
7978
LOG.info("Calculation Service endpoint found: " + calculationServiceURL);
79+
80+
DockerPort userService = docker.containers().container("userservice")
81+
.port(8080);
82+
userServiceURL = String.format("http://%s:%s", userService.getIp(),
83+
userService.getExternalPort());
84+
while (!docker.containers().container("userservice").portIsListeningOnHttp(8080,
85+
(port) -> port.inFormat(userServiceURL)).succeeded()) {
86+
LOG.info("Waiting for user service to respond over HTTP");
87+
}
88+
LOG.info("User Service endpoint found: " + userServiceURL);
8089
}
8190

8291
private TestRestTemplate restTemplate = new TestRestTemplate();
@@ -85,6 +94,8 @@ public static void initialize() {
8594

8695
@Before
8796
public void setUp() throws JSONException {
97+
98+
8899
String plainCreds = "eagleeye:thisissecret";
89100
byte[] plainCredsBytes = plainCreds.getBytes();
90101
byte[] base64CredsBytes = Base64.getEncoder().encode(plainCredsBytes);
@@ -101,7 +112,7 @@ public void setUp() throws JSONException {
101112
HttpEntity<String> request = new HttpEntity<>(body, headers);
102113

103114
//when:
104-
ResponseEntity<String> response = restTemplate.postForEntity("http://localhost:8091/auth/oauth/token",
115+
ResponseEntity<String> response = restTemplate.postForEntity(userServiceURL + "/auth/oauth/token",
105116
request, String.class, parameters);
106117

107118
//then:

src/test/resources/docker-compose.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ services:
2323
# ports:
2424
# - 8888:8888
2525

26-
mysql-server:
26+
mysqlserver:
2727
image: mysql:5.7
28+
container_name: mysqlserver
2829
volumes:
2930
- mysql-data:/var/lib/mysql:rw
3031
restart: always
@@ -39,11 +40,12 @@ services:
3940

4041
userservice:
4142
image: aista/user-service
43+
container_name: userservice
4244
depends_on:
4345
- discovery-service
44-
- mysql-server
46+
- mysqlserver
4547
ports:
46-
- '8091:8091'
48+
- '8080'
4749

4850
mongo:
4951
image: 'mongo:3.4.1'

0 commit comments

Comments
 (0)