Skip to content

Commit 1cbdc69

Browse files
make more strict matching between events and aggregated objects
make more strict matching between events and aggregated objects
1 parent 4300afc commit 1cbdc69

23 files changed

+327
-222
lines changed

pom.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@
404404
<excludes>
405405
<exclude>**/*IT.java</exclude>
406406
<exclude>${someModule.test.excludes}</exclude>
407+
<exclude>**/integrationtests/*</exclude>
407408
</excludes>
408409
<includes>
409410
<include>${someModule.test.includes}</include>
@@ -434,9 +435,6 @@
434435
<exclude>**/test/*</exclude>
435436
<exclude>**/functionaltests/*</exclude>
436437
</excludes>
437-
<includes>
438-
<include>**/FlowTest.class</include>
439-
</includes>
440438
<additionalClasspathElements>
441439
<additionalClasspathElement>${basedir}/target/classes</additionalClasspathElement>
442440
</additionalClasspathElements>

src/functionaltests/java/com/ericsson/ei/subscriptions/repeatHandler/SubscriptionRepeatHandlerSteps.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
public class SubscriptionRepeatHandlerSteps extends FunctionalTestBase {
4242

4343
private static final String AGGREGATED_OBJECT_FILE_PATH = "src/functionaltests/resources/aggregatedObject.json";
44+
private static final String AGGREGATED_OBJECT_FINAL_FILE_PATH = "src/functionaltests/resources/aggregatedObjectFinal.json";
4445
private static final String EVENTS_FILE_PATH = "src/test/resources/TestExecutionTestEvents.json";
4546
private static final String RULES_FILE_PATH = "src/test/resources/TestExecutionObjectRules.json";
4647
private static final String REPEAT_FLAG_SUBSCRIPTION_COLLECTIONS_WITH_ONE_MATCH = "src/functionaltests/resources/subscriptionRepeatHandlerOneMatch.json";
@@ -83,10 +84,10 @@ public class SubscriptionRepeatHandlerSteps extends FunctionalTestBase {
8384
public void beforeScenario() throws IOException, JSONException {
8485
assertTrue(mongoDBHandler.insertDocument(dataBaseName, collectionName,
8586
eventManager.getJSONFromFile(AGGREGATED_OBJECT_FILE_PATH).toString()));
86-
subscriptionStrWithOneMatch = FileUtils
87-
.readFileToString(new File(REPEAT_FLAG_SUBSCRIPTION_COLLECTIONS_WITH_ONE_MATCH), "UTF-8");
88-
subscriptionStrWithTwoMatch = FileUtils
89-
.readFileToString(new File(REPEAT_FLAG_SUBSCRIPTION_COLLECTIONS_WITH_TWO_MATCH), "UTF-8");
87+
subscriptionStrWithOneMatch = FileUtils.readFileToString(
88+
new File(REPEAT_FLAG_SUBSCRIPTION_COLLECTIONS_WITH_ONE_MATCH), "UTF-8");
89+
subscriptionStrWithTwoMatch = FileUtils.readFileToString(
90+
new File(REPEAT_FLAG_SUBSCRIPTION_COLLECTIONS_WITH_TWO_MATCH), "UTF-8");
9091
aggregatedObject = FileUtils.readFileToString(new File(AGGREGATED_OBJECT_FILE_PATH), "UTF-8");
9192
subscriptionWithOneMatch = new JSONObject(subscriptionStrWithOneMatch);
9293
subscriptionWithTwoMatch = new JSONObject(subscriptionStrWithTwoMatch);
@@ -115,25 +116,26 @@ public void in_MongoDb_RepeatFlagHandler_and_subscription_collections_the_subscr
115116
}
116117

117118
@Then("^I make a DELETE request with subscription name \"([^\"]*)\" to the subscription REST API \"([^\"]*)\"$")
118-
public void i_make_a_DELETE_request_with_subscription_name_to_the_subscription_REST_API(String name, String subscriptionEndPoint) throws Exception {
119+
public void i_make_a_DELETE_request_with_subscription_name_to_the_subscription_REST_API(String name,
120+
String subscriptionEndPoint) throws Exception {
119121
HttpRequest deleteRequest = new HttpRequest(HttpRequest.HttpMethod.DELETE);
120122
ResponseEntity response = deleteRequest.setHost(getHostName())
121-
.setPort(applicationPort)
122-
.addHeader("content-type", "application/json")
123-
.addHeader("Accept", "application/json")
124-
.setEndpoint(subscriptionEndPoint + name)
125-
.performRequest();
123+
.setPort(applicationPort)
124+
.addHeader("content-type", "application/json")
125+
.addHeader("Accept", "application/json")
126+
.setEndpoint(subscriptionEndPoint + name)
127+
.performRequest();
126128
assertEquals(HttpStatus.OK.value(), response.getStatusCodeValue());
127129
}
128130

129131
@Then("^Check in MongoDB RepeatFlagHandler collection that the subscription has been removed$")
130132
public void check_in_MongoDB_RepeatFlagHandler_collections_that_the_subscription_has_been_removed()
131-
throws IOException {
133+
throws IOException, InterruptedException {
132134
List<String> resultRepeatFlagHandler = mongoDBHandler.find(dataBaseName, repeatFlagHandlerCollection,
133135
subscriptionIdMatchedAggrIdObjQuery);
134136
assertEquals("[]", resultRepeatFlagHandler.toString());
135137
assertTrue(mongoDBHandler.dropDocument(dataBaseName, collectionName,
136-
eventManager.getJSONFromFile(AGGREGATED_OBJECT_FILE_PATH).toString()));
138+
eventManager.getJSONFromFile(AGGREGATED_OBJECT_FINAL_FILE_PATH).toString()));
137139
}
138140

139141
@When("^In MongoDb RepeatFlagHandler collection the subscription has matched the AggrObjectId at least two times$")

src/functionaltests/java/com/ericsson/ei/subscriptions/trigger/SubscriptionTriggerSteps.java

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import java.io.File;
1010
import java.io.IOException;
11+
import java.net.BindException;
1112
import java.util.ArrayList;
1213
import java.util.Arrays;
1314
import java.util.List;
@@ -94,11 +95,11 @@ public void afterScenario() throws IOException {
9495
public void the_REST_API_is_up_and_running(String endPoint) throws Exception {
9596
HttpRequest getRequest = new HttpRequest(HttpRequest.HttpMethod.GET);
9697
response = getRequest.setHost(getHostName())
97-
.setPort(applicationPort)
98-
.addHeader("content-type", "application/json")
99-
.addHeader("Accept", "application/json")
100-
.setEndpoint(endPoint)
101-
.performRequest();
98+
.setPort(applicationPort)
99+
.addHeader("content-type", "application/json")
100+
.addHeader("Accept", "application/json")
101+
.setEndpoint(endPoint)
102+
.performRequest();
102103
assertEquals(HttpStatus.OK.value(), response.getStatusCodeValue());
103104
}
104105

@@ -116,7 +117,8 @@ public void send_eiffel_events() throws Throwable {
116117
LOGGER.debug("About to send Eiffel events.");
117118
List<String> eventNamesToSend = getEventNamesToSend();
118119
eventManager.sendEiffelEvents(EIFFEL_EVENTS_JSON_PATH, eventNamesToSend);
119-
List<String> missingEventIds = dbManager.verifyEventsInDB(eventManager.getEventsIdList(EIFFEL_EVENTS_JSON_PATH, eventNamesToSend));
120+
List<String> missingEventIds = dbManager.verifyEventsInDB(
121+
eventManager.getEventsIdList(EIFFEL_EVENTS_JSON_PATH, eventNamesToSend));
120122
assertEquals("The following events are missing in mongoDB: " + missingEventIds.toString(), 0,
121123
missingEventIds.size());
122124
LOGGER.debug("Eiffel events sent.");
@@ -126,7 +128,8 @@ public void send_eiffel_events() throws Throwable {
126128
public void wait_for_ei_to_aggregate_objects_and_trigger_subscriptions() throws Throwable {
127129
List<String> eventNamesToSend = getEventNamesToSend();
128130
LOGGER.debug("Checking Aggregated Objects.");
129-
List<String> arguments = new ArrayList<>(eventManager.getEventsIdList(EIFFEL_EVENTS_JSON_PATH, eventNamesToSend));
131+
List<String> arguments = new ArrayList<>(
132+
eventManager.getEventsIdList(EIFFEL_EVENTS_JSON_PATH, eventNamesToSend));
130133
arguments.add("id=TC5");
131134
arguments.add("conclusion=SUCCESSFUL");
132135
List<String> missingArguments = dbManager.verifyAggregatedObjectInDB(arguments);
@@ -151,8 +154,8 @@ public void check_mail_subscriptions_were_triggered() {
151154
@Then("^Rest subscriptions were triggered$")
152155
public void check_rest_subscriptions_were_triggered() throws Throwable {
153156
LOGGER.debug("Verifying REST requests.");
154-
List<String> endpointsToCheck = new ArrayList<>(
155-
Arrays.asList(REST_ENDPOINT, REST_ENDPOINT_AUTH, REST_ENDPOINT_PARAMS, REST_ENDPOINT_AUTH_PARAMS, REST_ENDPOINT_ROW_BODY));
157+
List<String> endpointsToCheck = new ArrayList<>(Arrays.asList(REST_ENDPOINT, REST_ENDPOINT_AUTH,
158+
REST_ENDPOINT_PARAMS, REST_ENDPOINT_AUTH_PARAMS, REST_ENDPOINT_ROW_BODY));
156159

157160
assert (allEndpointsGotAtLeastXCalls(endpointsToCheck, 1));
158161
for (String endpoint : endpointsToCheck) {
@@ -183,12 +186,12 @@ private void readSubscriptionNames(String jsonDataAsString) throws Throwable {
183186
private void postSubscriptions(String jsonDataAsString, String endPoint) throws Exception {
184187
HttpRequest postRequest = new HttpRequest(HttpRequest.HttpMethod.POST);
185188
response = postRequest.setHost(getHostName())
186-
.setPort(applicationPort)
187-
.addHeader("content-type", "application/json")
188-
.addHeader("Accept", "application/json")
189-
.setEndpoint(endPoint)
190-
.setBody(jsonDataAsString)
191-
.performRequest();
189+
.setPort(applicationPort)
190+
.addHeader("content-type", "application/json")
191+
.addHeader("Accept", "application/json")
192+
.setEndpoint(endPoint)
193+
.setBody(jsonDataAsString)
194+
.performRequest();
192195
assertEquals(HttpStatus.OK.value(), response.getStatusCodeValue());
193196
}
194197

@@ -201,11 +204,11 @@ private void postSubscriptions(String jsonDataAsString, String endPoint) throws
201204
private void validateSubscriptionsSuccessfullyAdded(String endPoint) throws Exception {
202205
HttpRequest getRequest = new HttpRequest(HttpRequest.HttpMethod.GET);
203206
response = getRequest.setHost(getHostName())
204-
.setPort(applicationPort)
205-
.addHeader("content-type", "application/json")
206-
.addHeader("Accept", "application/json")
207-
.setEndpoint(endPoint)
208-
.performRequest();
207+
.setPort(applicationPort)
208+
.addHeader("content-type", "application/json")
209+
.addHeader("Accept", "application/json")
210+
.setEndpoint(endPoint)
211+
.performRequest();
209212
assertEquals(HttpStatus.OK.value(), response.getStatusCodeValue());
210213
LOGGER.debug("Checking that response contains all subscriptions");
211214
for (String subscriptionName : subscriptionNames) {
@@ -277,15 +280,16 @@ private void setupRestEndpoints() {
277280
LOGGER.debug("Setting up endpoints on host '" + getHostName() + "' and port '" + port + "'.");
278281
mockClient = new MockServerClient(getHostName(), port);
279282
mockClient.when(request().withMethod("POST").withPath(REST_ENDPOINT)).respond(response().withStatusCode(201));
280-
mockClient.when(request().withMethod("POST").withPath(REST_ENDPOINT_AUTH)
281-
.withHeader("Authorization", "Basic bXlVc2VyTmFtZTpteVBhc3N3b3Jk"))
282-
.respond(response().withStatusCode(201));
283+
mockClient.when(request().withMethod("POST")
284+
.withPath(REST_ENDPOINT_AUTH)
285+
.withHeader("Authorization", "Basic bXlVc2VyTmFtZTpteVBhc3N3b3Jk"))
286+
.respond(response().withStatusCode(201));
283287
mockClient.when(request().withMethod("POST").withPath(REST_ENDPOINT_PARAMS))
284-
.respond(response().withStatusCode(201));
288+
.respond(response().withStatusCode(201));
285289
mockClient.when(request().withMethod("POST").withPath(REST_ENDPOINT_AUTH_PARAMS))
286-
.respond(response().withStatusCode(201));
290+
.respond(response().withStatusCode(201));
287291
mockClient.when(request().withMethod("POST").withPath(REST_ENDPOINT_ROW_BODY))
288-
.respond(response().withStatusCode(201));
292+
.respond(response().withStatusCode(201));
289293
}
290294

291295
/**
@@ -294,10 +298,20 @@ private void setupRestEndpoints() {
294298
* @throws IOException
295299
*/
296300
private void setupSMTPServer() throws IOException {
297-
int port = SocketUtils.findAvailableTcpPort();
298-
LOGGER.debug("Setting SMTP port to " + port);
299-
mailSender.setPort(port);
300-
smtpServer = SimpleSmtpServer.start(port);
301+
boolean connected = false;
302+
while (!connected) {
303+
try {
304+
int port = SocketUtils.findAvailableTcpPort();
305+
LOGGER.debug("Setting SMTP port to " + port);
306+
mailSender.setPort(port);
307+
smtpServer = SimpleSmtpServer.start(port);
308+
// connected, go on
309+
connected = true;
310+
} catch (BindException e) {
311+
String msg = "Failed to start SMTP server. address already in use. Try again!";
312+
LOGGER.debug(msg, e);
313+
}
314+
}
301315
}
302316

303317
/**
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
{
2+
"_id": "b46ef12d-25gb-4d7y-b9fd-8763re66de47",
3+
"aggregatedObject": {
4+
"ongoing": "false",
5+
"test_suite": [
6+
{
7+
"test_suite_started_event_id": "v46ef19d-20gb-4d7y-h9fd-8763re6kde47",
8+
"test_case": [
9+
{
10+
"conclusion": "SUCCESSFUL",
11+
"ongoing": "false",
12+
"test_data": {
13+
"tracker": "My Test Management System",
14+
"id": "TC-1234",
15+
"version": "42",
16+
"uri": "http://tm.company.com/browse/TC-1234/42"
17+
},
18+
"test_case_started_event_id": "v46ef19d-20ab-4e2y-e9se-8762ae6kde47",
19+
"verdict": "PASSED",
20+
"description": "Accidentally started a fire in the lab during execution.",
21+
"test_case_finished_event_id": "v46ef19d-20fb-4e2k-h9fa-8763ae6ese47",
22+
"metrics": [
23+
{
24+
"name": "myMetric",
25+
"value": 5
26+
},
27+
{
28+
"name": "throughput",
29+
"value": 8.325
30+
},
31+
{
32+
"name": "somethingElse",
33+
"value": "hello"
34+
}
35+
],
36+
"test_case_triggered_event_id": "v46ef19a-20ga-4d2y-h9fa-8763ae6kde47"
37+
},
38+
{
39+
"conclusion": "SUCCESSFUL",
40+
"ongoing": "false",
41+
"test_data": {
42+
"tracker": "My Test Management System",
43+
"id": "TC-1234",
44+
"version": "42",
45+
"uri": "http://tm.company.com/browse/TC-1234/42"
46+
},
47+
"test_case_started_event_id": "v46ef19d-20ab-4d2y-h9fe-87haha6kde47",
48+
"verdict": "PASSED",
49+
"description": "Accidentally started a fire in the lab during execution.",
50+
"test_case_finished_event_id": "v46ef19d-20gb-4c2a-h9fa-8763heheae47",
51+
"metrics": [
52+
{
53+
"name": "myMetric",
54+
"value": 5
55+
},
56+
{
57+
"name": "throughput",
58+
"value": 8.325
59+
},
60+
{
61+
"name": "somethingElse",
62+
"value": "hello"
63+
}
64+
],
65+
"test_case_triggered_event_id": "v46ef19d-20gb-4d2y-h9fa-87dada6kde47"
66+
}
67+
],
68+
"test_suite_name": "Pre-release installation and security verification"
69+
}
70+
],
71+
"activity_triggered_event_id": "b46ef12d-25gb-4d7y-b9fd-8763re66de47",
72+
"test_batches": [
73+
{
74+
"recipes": [
75+
{
76+
"id": "aaaaaaaa-bbbb-5ccc-addd-eeeeeeeeeee0",
77+
"constraints": {
78+
"environment": {
79+
"os": "ubuntu-15.04",
80+
"MY_PATH": "/home/lt-worf"
81+
},
82+
"load": 10000
83+
},
84+
"testCase": {
85+
"tracker": "My Test Management System",
86+
"id": "TC-1234",
87+
"uri": "http://tm.company.com/browse/TC-1234"
88+
}
89+
},
90+
{
91+
"id": "aaaaaaaa-bbbb-5ccc-addd-eeeeeeeeeee1",
92+
"constraints": {
93+
"environment": {
94+
"os": "ubuntu-16.04.1",
95+
"MY_PATH": "/home/cpt-picard"
96+
},
97+
"load": 500
98+
},
99+
"testCase": {
100+
"tracker": "My Test Management System",
101+
"id": "TC-1234",
102+
"uri": "http://tm.company.com/browse/TC-1234"
103+
}
104+
}
105+
],
106+
"name": "First batch",
107+
"priority": 1,
108+
"dependencies": [
109+
{
110+
"dependency": "aaaaaaaa-bbbb-5ccc-addd-eeeeeeeeeee1",
111+
"dependent": "aaaaaaaa-bbbb-5ccc-addd-eeeeeeeeeee0"
112+
}
113+
]
114+
}
115+
],
116+
"TemplateName": "TEST_EXECUTION_1",
117+
"time": 1234567890,
118+
"activity_started_event_id": "b46e01ud-25gb-4d7y-b9f6-836fre6yde47",
119+
"type": "EiffelActivityTriggeredEvent",
120+
"version": "1.0.0",
121+
"activity_finished_event_id": "b46t01uh-29gs-4d7y-b9v6-83kfqe6y4e47",
122+
"outcome": {
123+
"conclusion": "TIMED_OUT",
124+
"description": "Compilation timed out."
125+
}
126+
}
127+
}

src/functionaltests/resources/eiffel_events_for_test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@
638638
"event_EiffelTestCaseFinishedEvent_3": {
639639
"links": [
640640
{
641-
"target": "cb9d64b0-a6e9-4419-8b5d-a650c27c59ca",
641+
"target": "6d3df0e0-404d-46ee-ab4f-3118457148f4",
642642
"type": "TEST_CASE_EXECUTION"
643643
}
644644
],

src/integrationtests/java/com/ericsson/ei/artifactintegrationtests/ArtifactFlowRunnerIT.java renamed to src/integrationtests/java/com/ericsson/ei/artifactintegration/ArtifactFlowRunnerIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.ericsson.ei.artifactintegrationtests;
1+
package com.ericsson.ei.artifactintegration;
22

33
import org.junit.runner.RunWith;
44

src/integrationtests/java/com/ericsson/ei/artifactintegrationtests/ArtifactFlowStepsIT.java renamed to src/integrationtests/java/com/ericsson/ei/artifactintegration/ArtifactFlowStepsIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.ericsson.ei.artifactintegrationtests;
1+
package com.ericsson.ei.artifactintegration;
22

33
import static org.junit.Assert.assertEquals;
44

0 commit comments

Comments
 (0)