Skip to content

Commit 9fdc801

Browse files
author
Vasile Baluta
committed
some polish
1 parent 31f2e54 commit 9fdc801

File tree

8 files changed

+25
-50
lines changed

8 files changed

+25
-50
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ script:
1717
# since we run parallel tests using embedded mongodb in fresh environment all tests run first in parallel
1818
# will try to download the embedded mongo to this travis instance but the late ones will fail to write.
1919
# We will therefore run one test using mongodb first that will download the mongo instance and
20-
# then the rest of the test that will no longer need to download the embedded mongo since it will exist
20+
# then the rest of the test that will no longer need to download the embedded mongo since it will exist.
21+
#
22+
# It is also importan that the first test to be run is a Spring Boot Test since spring boot also downloads
23+
# another version of embedded mongo db so all Spring Boot tests will end up in a race condition also
2124
- mvn -DsomeModule.test.includes="**/QueryServiceTest.java" test
2225
- mvn -DsomeModule.test.excludes="**/QueryServiceTest.java" test
2326

pom.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,11 @@
262262
<version>2.20</version>
263263
<configuration>
264264
<forkCount>2C</forkCount>
265-
<reuseForks>false</reuseForks>
265+
<reuseForks>true</reuseForks>
266+
<parallel>classes</parallel>
267+
<useUnlimitedThreads>true</useUnlimitedThreads>
268+
<threadCount>80</threadCount>
269+
<perCoreThreadCount>true</perCoreThreadCount>
266270
<excludes>
267271
<exclude>${someModule.test.excludes}</exclude>
268272
</excludes>

src/main/java/com/ericsson/ei/waitlist/WaitListStorageHandler.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ public void addEventToWaitList(String event, RulesObject rulesObject) throws Exc
6767
if (result == false) {
6868
throw new Exception("failed to insert the document into database");
6969
}
70-
updateTestEventCount(true);
7170
}
7271

7372
private String addProprtiesToEvent(String event, RulesObject rulesObject) {
@@ -103,26 +102,6 @@ public ArrayList<String> getWaitList() {
103102

104103
public boolean dropDocumentFromWaitList(String document) {
105104
boolean result = mongoDbHandler.dropDocument(databaseName, collectionName, document);
106-
107-
if (result) {
108-
updateTestEventCount(false);
109-
}
110-
111105
return result;
112106
}
113-
114-
private void updateTestEventCount(boolean increase) {
115-
// if (System.getProperty("flow.test") == "true") {
116-
// String countStr =
117-
// System.getProperty("eiffel.intelligence.waitListEventsCount");
118-
// int count = Integer.parseInt(countStr);
119-
// if (increase) {
120-
// count++;
121-
// } else {
122-
// count--;
123-
// }
124-
// System.setProperty("eiffel.intelligence.waitListEventsCount", "" +
125-
// count);
126-
// }
127-
}
128107
}

src/test/java/com/ericsson/ei/flowtests/FlowTestBase.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ public abstract class FlowTestBase extends AbstractTestExecutionListener {
7979
@Override
8080
public void beforeTestClass(TestContext testContext) throws Exception {
8181
System.setProperty("flow.test", "true");
82-
// System.setProperty("eiffel.intelligence.processedEventsCount", "0");
83-
// System.setProperty("eiffel.intelligence.waitListEventsCount", "0");
8482
createFlowTestConfigs();
8583
getFlowTestConfigs().init();
8684
}
@@ -103,17 +101,16 @@ private void createFlowTestConfigs() {
103101
}
104102

105103
private String getClasName() {
106-
// Class c = MethodHandles.lookup().lookupClass();
107-
// return c.getName();
108104
return this.getClass().getName();
109105
}
110106

111107
private void cleanFlowTestConfigs() {
112108
configsMap.remove(getClasName());
113109
}
114-
110+
115111
// setFirstEventWaitTime: variable to set the wait time after publishing the
116-
// first event. So any thread looking for the events don't do it before actually
112+
// first event. So any thread looking for the events don't do it before
113+
// actually
117114
// populating events in the database
118115
private int firstEventWaitTime = 0;
119116

src/test/java/com/ericsson/ei/flowtests/SingleEventAggregationTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ String getEventsFilePath() {
8383
public void before() {
8484
MockitoAnnotations.initMocks(this);
8585
upStreamEventsHandler.setEventRepositoryQueryService(erQueryService);
86-
// MockitoAnnotations.initMocks(this);
8786
when(erQueryService.getEventStreamDataById(anyString(), any(SearchOption.class), anyInt(), anyInt(),
8887
anyBoolean())).thenReturn(null);
8988
super.setFirstEventWaitTime(5000);

src/test/java/com/ericsson/ei/handlers/test/ObjectHandlerTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ public class ObjectHandlerTest {
6464
private String dataBaseName = "EventStorageDBbbb";
6565
private String collectionName = "SampleEvents";
6666
private String input = "{\"TemplateName\":\"ARTIFACT_1\",\"id\":\"eventId\",\"type\":\"eventType11\",\"test_cases\":[{\"event_id\":\"testcaseid1\",\"test_data\":\"testcase1data\"},{\"event_id\":\"testcaseid2\",\"test_data\":\"testcase2data\"}]}";
67-
private String updateInput = "{\"TemplateName\":\"ARTIFACT_1\",\"id\":\"eventId\",\"type\":\"eventType11\",\"test_cases\" : [{\"event_id\" : \"testcaseid1\", \"test_data\" : \"testcase2data\"},{\"event_id\" : \"testcaseid3\", \"test_data\" : \"testcase3data\"}]}";
6867
private String condition = "{\"_id\" : \"eventId\"}";
6968
private String event = "{\"meta\":{\"id\":\"eventId\"}}";
7069

src/test/java/com/ericsson/ei/queryservice/test/QueryServiceTest.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,14 @@ public static void setUpEmbeddedMongo() throws Exception {
9393
mongoClient = testsFactory.newMongo();
9494
String port = "" + mongoClient.getAddress().getPort();
9595
System.setProperty("mongodb.port", port);
96-
} catch (Exception e) {
97-
log.error(e.getMessage(), e);
98-
e.printStackTrace();
99-
}
10096

101-
try {
10297
aggregatedObject = FileUtils.readFileToString(new File(aggregatedPath));
103-
System.out.println("The aggregatedObject is : " + aggregatedObject);
98+
log.debug("The aggregatedObject is : " + aggregatedObject);
10499
missedNotification = FileUtils.readFileToString(new File(missedNotificationPath));
105-
System.out.println("The missedNotification is : " + missedNotification);
100+
log.debug("The missedNotification is : " + missedNotification);
106101
} catch (Exception e) {
107102
log.error(e.getMessage(), e);
103+
e.printStackTrace();
108104
}
109105
}
110106

@@ -116,22 +112,22 @@ public static void init() throws Exception {
116112
@PostConstruct
117113
public void initMocks() {
118114
mongoDBHandler.setMongoClient(mongoClient);
119-
System.out.println("Database connected");
115+
log.debug("Database connected");
120116
// deleting all documents before inserting
121117
mongoClient.getDatabase(aggregationDataBaseName).getCollection(aggregationCollectionName)
122118
.deleteMany(new BsonDocument());
123119
Document missedDocument = Document.parse(missedNotification);
124120
Document aggDocument = Document.parse(aggregatedObject);
125121
mongoClient.getDatabase(missedNotificationDataBaseName).getCollection(missedNotificationCollectionName)
126122
.insertOne(missedDocument);
127-
System.out.println("Document Inserted in missed Notification Database");
123+
log.debug("Document Inserted in missed Notification Database");
128124

129125
JsonNode preparedAggDocument = objectHandler.prepareDocumentForInsertion(aggDocument.getString("id"),
130126
aggregatedObject);
131127
aggDocument = Document.parse(preparedAggDocument.toString());
132128
mongoClient.getDatabase(aggregationDataBaseName).getCollection(aggregationCollectionName)
133129
.insertOne(aggDocument);
134-
System.out.println("Document Inserted in Aggregated Object Database");
130+
log.debug("Document Inserted in Aggregated Object Database");
135131
}
136132

137133
@Test
@@ -140,11 +136,12 @@ public void processMissedNotificationTest() {
140136
.getCollection(missedNotificationCollectionName).find();
141137
Iterator itr = responseDB.iterator();
142138
String response = itr.next().toString();
143-
log.info("The inserted doc is : " + response);
139+
log.debug("The inserted doc is : " + response);
144140
List<String> result = processMissedNotification.processQueryMissedNotification("Subscription_1");
145-
log.info("The retrieved data is : " + result.toString());
141+
log.debug("The retrieved data is : " + result.toString());
146142
ObjectNode record = null;
147143
JsonNode actual = null;
144+
148145
try {
149146
JsonNode tempRecord = new ObjectMapper().readTree(result.get(0));
150147
record = (ObjectNode) tempRecord;
@@ -154,7 +151,7 @@ record = (ObjectNode) tempRecord;
154151
} catch (Exception e) {
155152
log.error(e.getMessage(), e);
156153
}
157-
log.info("The result is : " + record.toString());
154+
log.debug("The result is : " + record.toString());
158155
assertEquals(record.toString(), actual.toString());
159156
}
160157

@@ -164,11 +161,12 @@ public void processAggregatedObjectTest() {
164161
.getCollection(aggregationCollectionName).find();
165162
Iterator itr = responseDB.iterator();
166163
String response = itr.next().toString();
167-
log.info("The inserted doc is : " + response);
164+
log.debug("The inserted doc is : " + response);
168165
ArrayList<String> result = processAggregatedObject
169166
.processQueryAggregatedObject("6acc3c87-75e0-4b6d-88f5-b1a5d4e62b43");
170167
ObjectNode record = null;
171168
JsonNode actual = null;
169+
172170
try {
173171
JsonNode tempRecord = new ObjectMapper().readTree(result.get(0));
174172
record = (ObjectNode) tempRecord;
@@ -178,7 +176,7 @@ record = (ObjectNode) tempRecord;
178176
} catch (Exception e) {
179177
log.error(e.getMessage(), e);
180178
}
181-
log.info("The result is : " + record.toString());
179+
log.debug("The result is : " + record.toString());
182180
assertEquals(record.get("aggregatedObject").toString(), actual.toString());
183181
}
184182

@@ -189,5 +187,4 @@ public static void tearDown() throws Exception {
189187
if (testsFactory != null)
190188
testsFactory.shutdown();
191189
}
192-
193190
}

src/test/java/com/ericsson/ei/waitlist/TestWaitListWorker.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ public void init() throws Exception {
9494
setupMB();
9595
list.add(FileUtils.readFileToString(new File(input1), "UTF-8"));
9696
list.add(FileUtils.readFileToString(new File(input2), "UTF-8"));
97-
// Mockito.when(mongoDBHandler.dropDocument(Mockito.anyString(),
98-
// Mockito.anyString(), Mockito.anyString()))
99-
// .thenReturn(true);
10097
Mockito.when(waitListStorageHandler.getWaitList()).thenReturn(list);
10198
Mockito.when(rulesHandler.getRulesForEvent(Mockito.anyString())).thenReturn(rulesObject);
10299
Mockito.when(jmesPathInterface.runRuleOnEvent(Mockito.anyString(), Mockito.anyString())).thenReturn(jsonNode);

0 commit comments

Comments
 (0)