Skip to content

Commit 792bec8

Browse files
author
Ivetted
committed
fixed merge conflict
2 parents 0e7c264 + f3eaddf commit 792bec8

File tree

4 files changed

+39
-9
lines changed

4 files changed

+39
-9
lines changed

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ dependencies {
4848
compile('org.springframework.cloud:spring-cloud-starter-oauth2')
4949
compile('org.springframework.cloud:spring-cloud-starter-zuul')
5050
compile('org.springframework.boot:spring-boot-starter-web')
51+
compile('org.springframework.boot:spring-boot-starter-actuator')
52+
compile('org.springframework.boot:spring-boot-starter-security')
53+
compile('org.springframework.data:spring-data-rest-hal-browser')
5154
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
5255
testCompile ('org.springframework.cloud:spring-cloud-starter-eureka-server')
5356
testCompile('com.jayway.restassured:rest-assured:2.5.0')

readme.md

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

44
# Running the service:
5-
65
After making sure the project assembled properly run: ```docker-compose up --build```
76

87
## Running with locally build images.
9-
10-
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
11-
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
129
Run ```docker-compose -f docker-compose-local.yml up```
13-
1410
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: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ zuul:
1818
security:
1919
oauth2:
2020
resource:
21-
userInfoUri: http://localhost:8181/uaa/user
21+
userInfoUri: http://localhost:8080/uaa/user
2222
ignored: /catalog/**
2323
eureka:
2424
instance:
@@ -28,7 +28,10 @@ eureka:
2828
fetchRegistry: true
2929
serviceUrl:
3030
defaultZone: http://discovery-service:8761/eureka/
31-
31+
management:
32+
security:
33+
enabled: false
34+
context-path: /actuator
3235
---
3336
spring:
3437
profiles: docker

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

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ public static void initialize() {
7777
.port(8080);
7878
calculationServiceURL = String.format("http://%s:%s", calculationService.getIp(),
7979
calculationService.getExternalPort());
80+
while (!docker.containers().container("calculationservice").portIsListeningOnHttp(8080,
81+
(port) -> port.inFormat(calculationServiceURL)).succeeded()) {
82+
LOG.info("Waiting for calculation service to respond over HTTP");
83+
}
8084
LOG.info("Calculation Service url found: " + calculationServiceURL);
8185

8286
DockerPort userService = docker.containers().container("userservice")
@@ -152,14 +156,16 @@ public void tripQueryGETSpecificTripRequestSuccess() throws JSONException {
152156
String body = "{ \"originAddress\": \"Weston, FL\", \"destinationAddress\": "
153157
+ "\"Miami, FL\", \"userId\": \"123e4567-e89b-12d3-a456-426655440000\" }";
154158
HttpEntity<String> request = new HttpEntity<>(body, headers);
155-
ResponseEntity<String> postResponse = restTemplate.postForEntity(tripCommandURL + "/api/v1/trip", request, String.class);
159+
ResponseEntity<String> postResponse = restTemplate.postForEntity(tripCommandURL + "/api/v1/trip", request,
160+
String.class);
156161
assertThat(postResponse.getStatusCodeValue()).isEqualTo(201);
157162

158163
JSONObject json = new JSONObject(postResponse.getBody());
159164
tripId = json.getString("id");
160165

161166
//when:
162-
ResponseEntity<String> response = restTemplate.getForEntity(tripQueryURL + "/api/v1/trip/" + tripId, String.class);
167+
ResponseEntity<String> response = restTemplate.getForEntity(tripQueryURL + "/api/v1/trip/" + tripId,
168+
String.class);
163169

164170
//then:
165171
assertThat(response.getStatusCodeValue()).isEqualTo(200);
@@ -178,4 +184,23 @@ public void tripQueryGETAllTripsRequestSuccess() {
178184
//then:
179185
assertThat(response.getStatusCodeValue()).isEqualTo(200);
180186
}
187+
188+
@Test
189+
public void calculationServiceRequestSuccess() {
190+
//given:
191+
HttpHeaders headers = new HttpHeaders();
192+
headers.add("Authorization", "Bearer " + token);
193+
headers.add("Content-Type", "application/json");
194+
195+
String body = "{ \"origin\": \"Weston, FL\", \"destination\": \"Miami, FL\" }";
196+
HttpEntity<String> request = new HttpEntity<>(body, headers);
197+
198+
//when:
199+
ResponseEntity<String> response = restTemplate.postForEntity(calculationServiceURL + "/api/v1/cost", request,
200+
String.class);
201+
202+
//then:
203+
assertThat(response.getStatusCodeValue()).isEqualTo(200);
204+
205+
}
181206
}

0 commit comments

Comments
 (0)