Skip to content

Commit 9a895d2

Browse files
authored
Merge pull request #10 from AITestingOrg/gmaps-adapter-integration-test
Gmaps adapter integration test
2 parents f3eaddf + c65ec33 commit 9a895d2

File tree

5 files changed

+182
-20
lines changed

5 files changed

+182
-20
lines changed

docker-compose-local.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
version: '3'
2+
3+
services:
4+
5+
edgeservice:
6+
build: ./
7+
ports:
8+
- "80:8080"
9+
depends_on:
10+
- discovery-service
11+
12+
discovery-service:
13+
image: springcloud/eureka
14+
ports:
15+
- "8761:8761"
16+
17+
# hystrix-dashboard:
18+
# image: kbastani/hystrix-dashboard
19+
# container_name: hystrix-dashboard
20+
# environment:
21+
# - SPRING_PROFILES_ACTIVE=docker
22+
# ports:
23+
# - 6161:6161
24+
25+
# config-service:
26+
# build: config-service
27+
# container_name: config-service
28+
# environment:
29+
# - SPRING_PROFILES_ACTIVE=docker
30+
# ports:
31+
# - 8888:8888
32+
33+
mysqlserver:
34+
image: mysql:5.7
35+
volumes:
36+
- mysql-data:/var/lib/mysql:rw
37+
restart: always
38+
ports:
39+
- '3306:3306'
40+
environment:
41+
MYSQL_USER:
42+
MYSQL_PASSWORD:
43+
MYSQL_ROOT_PASSWORD: 'root'
44+
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
45+
MYSQL_DATABASE: 'user_service'
46+
47+
userservice:
48+
image: aista/user-service
49+
depends_on:
50+
- discovery-service
51+
- mysqlserver
52+
ports:
53+
- '8091:8091'
54+
55+
mongo:
56+
image: 'mongo:3.4.1'
57+
container_name: 'mongo'
58+
ports:
59+
- '27017:27017'
60+
volumes:
61+
- 'mongo:/data/db'
62+
63+
rabbitmq:
64+
image: rabbitmq:management
65+
container_name: 'rabbitmq'
66+
ports:
67+
- "5672:5672"
68+
- "15672:15672"
69+
70+
tripmanagementcmd:
71+
image: aista/trip-management-cmd:local
72+
environment:
73+
- RABBIT_HOST=rabbitmq
74+
- MONGO_HOST=mongo
75+
ports:
76+
- '8080'
77+
depends_on:
78+
- discovery-service
79+
- rabbitmq
80+
- mongo
81+
82+
tripmanagementquery:
83+
image: aista/trip-management-query:local
84+
environment:
85+
- RABBIT_HOST=rabbitmq
86+
- MONGO_HOST=mongo
87+
ports:
88+
- '8080'
89+
depends_on:
90+
- rabbitmq
91+
- mongo
92+
- discovery-service
93+
94+
gmapsadapter:
95+
image: aista/gmaps-adapter:local
96+
environment:
97+
- EUREKA_SERVER=discovery-service
98+
ports:
99+
- '8080'
100+
depends_on:
101+
- discovery-service
102+
103+
calculationservice:
104+
image: aista/calculation-service:local
105+
environment:
106+
- EUREKA_SERVER=discovery-service
107+
ports:
108+
- '8080'
109+
depends_on:
110+
- discovery-service
111+
112+
volumes:
113+
mongo:
114+
mysql-data:

docker-compose.yml

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@ version: '3'
22

33
services:
44

5-
edge-service:
5+
edgeservice:
66
build: ./
77
ports:
8-
- "8080:8080"
8+
- "80:8080"
99
depends_on:
1010
- discovery-service
1111

1212
discovery-service:
1313
image: springcloud/eureka
1414
ports:
1515
- "8761:8761"
16-
container_name: eureka-server
1716

1817
# hystrix-dashboard:
1918
# image: kbastani/hystrix-dashboard
@@ -33,7 +32,6 @@ services:
3332

3433
mysqlserver:
3534
image: mysql:5.7
36-
container_name: mysqlserver
3735
volumes:
3836
- mysql-data:/var/lib/mysql:rw
3937
restart: always
@@ -51,7 +49,6 @@ services:
5149
depends_on:
5250
- discovery-service
5351
- mysqlserver
54-
container_name: userservice
5552
ports:
5653
- '8080'
5754

@@ -70,9 +67,8 @@ services:
7067
- "5672:5672"
7168
- "15672:15672"
7269

73-
trip-management-cmd:
70+
tripmanagementcmd:
7471
image: aista/trip-management-cmd
75-
container_name: trip-management-cmd
7672
environment:
7773
- RABBIT_HOST=rabbitmq
7874
- MONGO_HOST=mongo
@@ -83,9 +79,8 @@ services:
8379
- rabbitmq
8480
- mongo
8581

86-
trip-management-query:
82+
tripmanagementquery:
8783
image: aista/trip-management-query
88-
container_name: trip-management-query
8984
environment:
9085
- RABBIT_HOST=rabbitmq
9186
- MONGO_HOST=mongo
@@ -94,7 +89,25 @@ services:
9489
depends_on:
9590
- rabbitmq
9691
- mongo
97-
- discovery-service
92+
- discovery-service
93+
94+
gmapsadapter:
95+
image: aista/gmaps-adapter
96+
environment:
97+
- EUREKA_SERVER=discovery-service
98+
ports:
99+
- '8080'
100+
depends_on:
101+
- discovery-service
102+
103+
calculationservice:
104+
image: aista/calculation-service
105+
environment:
106+
- EUREKA_SERVER=discovery-service
107+
ports:
108+
- '8080'
109+
depends_on:
110+
- discovery-service
98111

99112
volumes:
100113
mongo:

readme.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Edge Service
22
The edge service is one of the backing services that serves as the front door for the API. The services utilizes Zuul.
33

4-
#Performance Metrics API
5-
Once edge service is UP, you can access the metrics at http://localhost:8080/actuator
4+
# Running the service:
5+
After making sure the project assembled properly run: ```docker-compose up --build```
6+
7+
## Running with locally build images.
8+
Build the images locally but tag them with version ```:local``` instead of default, for example instead of just building gmaps-adapter as aista/gmaps-adapter tag it aista/gmaps-adapter:local
9+
Run ```docker-compose -f docker-compose-local.yml up```
10+
remove the :local from the docker-compose-local.yml file for images that wont be changed locally.
11+
12+
# Performance Metrics API
13+
Once edge service is UP, you can access the metrics at http://localhost:8080/actuator

src/main/resources/application.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ spring:
55
spring:
66
profiles: development
77
application:
8-
name: edge-service
8+
name: edgeservice
99
zuul:
10-
ignored-services: '*'
11-
ignoredPatterns: /**/api/**
10+
prefix: /api
1211
routes:
13-
example-service: /example/**
12+
trip-cmd:
13+
path: /trip/cmd/**
14+
url: http://tripmanagementcmd:8080/api
15+
trip-query:
16+
path: /trip/query/**
17+
url: http://tripmanagementquery:8080/api
1418
security:
1519
oauth2:
1620
resource:
@@ -32,12 +36,16 @@ management:
3236
spring:
3337
profiles: docker
3438
application:
35-
name: edge-service
39+
name: edgeservice
3640
zuul:
37-
ignored-services: '*'
38-
ignoredPatterns: /**/api/**
41+
prefix: /api
3942
routes:
40-
example-service: /example/**
43+
trip-cmd:
44+
path: /trip/cmd/**
45+
url: http://tripmanagementcmd:8080/api
46+
trip-query:
47+
path: /trip/query/**
48+
url: http://tripmanagementquery:8080/api
4149
security:
4250
oauth2:
4351
resource:

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,23 @@ public void calculationServiceRequestSuccess() {
203203
assertThat(response.getStatusCodeValue()).isEqualTo(200);
204204

205205
}
206+
207+
@Test
208+
public void gmapsAdapterRequestSuccess() {
209+
//given:
210+
HttpHeaders headers = new HttpHeaders();
211+
headers.add("Authorization", "Bearer " + token);
212+
headers.add("Content-Type", "application/json");
213+
214+
String body = "{ \"origin\": \"Weston, FL\", \"destination\": \"Miami, FL\", \"departureTime\": \"15220998650000000\" }";
215+
HttpEntity<String> request = new HttpEntity<>(body, headers);
216+
217+
//when:
218+
ResponseEntity<String> response = restTemplate.postForEntity(gmapsAdapterURL + "/api/v1/directions", request,
219+
String.class);
220+
221+
//then:
222+
assertThat(response.getStatusCodeValue()).isEqualTo(200);
223+
224+
}
206225
}

0 commit comments

Comments
 (0)