Skip to content

Commit 9d5b473

Browse files
Extend wait times
prolong waiting time in tests
1 parent 9af3590 commit 9d5b473

File tree

8 files changed

+57
-50
lines changed

8 files changed

+57
-50
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,4 @@ script:
2222
# It is also importan that the first test to be run is a Spring Boot Test since spring boot also downloads
2323
# another version of embedded mongo db so all Spring Boot tests will end up in a race condition also
2424
- mvn -DsomeModule.test.includes="**/QueryServiceTest.java" test
25-
- mvn -DsomeModule.test.excludes="**/QueryServiceTest.java" test
26-
25+
- mvn -DsomeModule.test.excludes="**/QueryServiceTest.java" test

docs/index.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11

22
# _Introduction_
33

4-
Eiffel Intelligence is a service that aggregates informations from different events of a flow with the purpose of notifying subscribers when content of interest has been collected from desired events. The aggregation is stored in a JSON bject. By flow we mean a chain of Eiffel events that are linked together directly or indirectly.
4+
Eiffel Intelligence is a service that aggregates information from different events of a flow with the purpose of notifying subscribers when content of interest has been collected from desired flow events. The aggregation is stored in a JSON bject. By flow we mean a chain of Eiffel events that are linked together directly or indirectly.
55

6-
Eiffel Intelligence uses a set of rules to define what information will be extracted from an Eiffel event in the flow and at what location to store this information in the aggregated object. Today only one rule set can be run in each instance and the reason is that in an Eiffel domain with million of events flowing we will have multiple extractions and checks for each rule set and multiple rule sets will require large machines and scalability problems.
6+
Eiffel Intelligence uses a set of rules to define what information will be extracted from an Eiffel event in the flow and at what location to store this information in the aggregated object. Today only one rule set can be run in each instance and the reason is that in an Eiffel domain with millions of events flowing we will have multiple extractions and checks for each rule set and multiple rule sets in same service will require large machines and more difficult optimization.
77

88
Eiffel intelligence uses subscriptions to notify interested parties when several evens have occurred with desired content in each event aggregated in an aggregated object. Every time an aggregated object is updated we check whether any subscription is fulfilled by the curent state of the aggregated object.
99

10+
[Under the hood](under_hood.md)
11+
1012
[Rules](rules.md)
1113

12-
[Subscriptions](subscription.md)
14+
[Subscriptions](subscriptions.md)
15+
16+
[Starting Eiffel Intelligence](starting.md)

docs/starting.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# _Starting Eiffel Intelligence service_
2+
3+
## _Prerequisites_
4+

docs/under_hood.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# _Under the hood_
2+
3+
A more detailed description of what it happens with an event is described on this page.
4+
5+
When the service is [started](starting.md) it will connect to configured Mongo DB instance and message bus. The message bus instance must be the same you use to publish the events to. If several message buses are used then it is needed to federate these into one more extra message bus and configure Eiffel Intelligence to use the federated message bus.
6+
7+
When an event is received

src/main/java/com/ericsson/ei/controller/RuleCheckController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
package com.ericsson.ei.controller;
33

4+
import com.ericsson.ei.controller.model.RuleCheckBody;
5+
import com.ericsson.ei.controller.model.RulesCheckBody;
46
import org.springframework.http.ResponseEntity;
57
import org.springframework.web.bind.annotation.RequestMapping;
68
import org.springframework.web.bind.annotation.RequestMethod;

src/main/java/com/ericsson/ei/handlers/ObjectHandler.java

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@
1616
*/
1717
package com.ericsson.ei.handlers;
1818

19+
import com.ericsson.ei.jmespath.JmesPathInterface;
20+
import com.ericsson.ei.mongodbhandler.MongoDBHandler;
21+
import com.ericsson.ei.rules.RulesObject;
22+
import com.ericsson.ei.subscriptionhandler.SubscriptionHandler;
23+
import com.fasterxml.jackson.databind.JsonNode;
24+
import com.fasterxml.jackson.databind.ObjectMapper;
25+
import com.fasterxml.jackson.databind.node.ObjectNode;
26+
import com.mongodb.util.JSON;
27+
1928
import java.util.ArrayList;
2029
import java.util.List;
2130

@@ -26,15 +35,6 @@
2635
import org.springframework.beans.factory.annotation.Value;
2736
import org.springframework.stereotype.Component;
2837

29-
import com.ericsson.ei.jmespath.JmesPathInterface;
30-
import com.ericsson.ei.mongodbhandler.MongoDBHandler;
31-
import com.ericsson.ei.rules.RulesObject;
32-
import com.ericsson.ei.subscriptionhandler.SubscriptionHandler;
33-
import com.fasterxml.jackson.databind.JsonNode;
34-
import com.fasterxml.jackson.databind.ObjectMapper;
35-
import com.fasterxml.jackson.databind.node.ObjectNode;
36-
import com.mongodb.util.JSON;
37-
3838
import lombok.Getter;
3939
import lombok.Setter;
4040

@@ -87,10 +87,7 @@ public boolean insertObject(String aggregatedObject, RulesObject rulesObject, St
8787
}
8888

8989
boolean result = mongoDbHandler.insertDocument(databaseName, collectionName, document.toString());
90-
if (result)
91-
eventToObjectMap.updateEventToObjectMapInMemoryDB(rulesObject, event, id);
92-
93-
subscriptionHandler.checkSubscriptionForObject(aggregatedObject, id);
90+
postInsertActions(aggregatedObject, rulesObject, event, id, result);
9491
return result;
9592
}
9693

@@ -99,9 +96,9 @@ public boolean insertObject(JsonNode aggregatedObject, RulesObject rulesObject,
9996
}
10097

10198
/**
102-
* This method uses previously locked in database aggregatedObject (lock was set
103-
* in lockDocument method) and modifies this document with the new values and
104-
* removes the lock in one query
99+
* This method uses previously locked in database aggregatedObject (lock was
100+
* set in lockDocument method) and modifies this document with the new
101+
* values and removes the lock in one query
105102
*
106103
* @param aggregatedObject
107104
* String to insert in database
@@ -124,11 +121,16 @@ public boolean updateObject(String aggregatedObject, RulesObject rulesObject, St
124121
String condition = "{\"_id\" : \"" + id + "\"}";
125122
String documentStr = document.toString();
126123
boolean result = mongoDbHandler.updateDocument(databaseName, collectionName, condition, documentStr);
127-
if (result) {
124+
postInsertActions(aggregatedObject, rulesObject, event, id, result);
125+
return result;
126+
}
127+
128+
private void postInsertActions(String aggregatedObject, RulesObject rulesObject, String event, String id,
129+
boolean performActions) {
130+
if (performActions) {
128131
eventToObjectMap.updateEventToObjectMapInMemoryDB(rulesObject, event, id);
129132
subscriptionHandler.checkSubscriptionForObject(aggregatedObject, id);
130133
}
131-
return result;
132134
}
133135

134136
public boolean updateObject(JsonNode aggregatedObject, RulesObject rulesObject, String event, String id) {
@@ -188,7 +190,8 @@ public String extractObjectId(JsonNode aggregatedDbObject) {
188190

189191
/**
190192
* Locks the document in database to achieve pessimistic locking. Method
191-
* findAndModify is used to optimize the quantity of requests towards database.
193+
* findAndModify is used to optimize the quantity of requests towards
194+
* database.
192195
*
193196
* @param id
194197
* String to search

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,14 @@ private long countProcessedEvents(String database, String collection) {
209209
return table.count();
210210
}
211211

212-
private void waitForEventsToBeProcessed(int eventsCount) {
212+
protected void waitForEventsToBeProcessed(int eventsCount) {
213213
// wait for all events to be processed
214214
long processedEvents = 0;
215215
while (processedEvents < eventsCount) {
216216
processedEvents = countProcessedEvents(database, event_map);
217217
LOGGER.info("Have gotten: " + processedEvents + " out of: " + eventsCount);
218218
try {
219-
TimeUnit.MILLISECONDS.sleep(3000);
219+
TimeUnit.MILLISECONDS.sleep(10000);
220220
} catch (InterruptedException e) {
221221
LOGGER.error(e.getMessage(), e);
222222
}

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

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@
2323
import static org.mockito.ArgumentMatchers.anyString;
2424
import static org.mockito.Mockito.when;
2525

26+
import com.ericsson.ei.erqueryservice.ERQueryService;
27+
import com.ericsson.ei.erqueryservice.SearchOption;
28+
import com.ericsson.ei.handlers.ObjectHandler;
29+
import com.ericsson.ei.handlers.UpStreamEventsHandler;
30+
import com.ericsson.ei.rmqhandler.RmqHandler;
31+
import com.ericsson.ei.rules.RulesHandler;
32+
import com.fasterxml.jackson.databind.JsonNode;
33+
import com.fasterxml.jackson.databind.ObjectMapper;
34+
import com.fasterxml.jackson.databind.node.ObjectNode;
35+
import com.rabbitmq.client.Channel;
36+
2637
import java.io.File;
2738
import java.io.IOException;
2839
import java.util.ArrayList;
@@ -47,18 +58,6 @@
4758
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
4859
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
4960

50-
import com.ericsson.ei.erqueryservice.ERQueryService;
51-
import com.ericsson.ei.erqueryservice.SearchOption;
52-
import com.ericsson.ei.handlers.ObjectHandler;
53-
import com.ericsson.ei.handlers.UpStreamEventsHandler;
54-
import com.ericsson.ei.rmqhandler.RmqHandler;
55-
import com.ericsson.ei.rules.RulesHandler;
56-
import com.fasterxml.jackson.databind.JsonNode;
57-
import com.fasterxml.jackson.databind.ObjectMapper;
58-
import com.fasterxml.jackson.databind.node.ObjectNode;
59-
import com.mongodb.client.MongoCollection;
60-
import com.rabbitmq.client.Channel;
61-
6261
@RunWith(SpringJUnit4ClassRunner.class)
6362
@TestExecutionListeners(listeners = { DependencyInjectionTestExecutionListener.class, TrafficGeneratedTest.class })
6463
@SpringBootTest
@@ -92,7 +91,7 @@ public class TrafficGeneratedTest extends FlowTestBase {
9291
private String database;
9392
@Value("${event_object_map.collection.name}")
9493
private String event_map;
95-
94+
9695
@Before
9796
public void before() throws IOException {
9897
MockitoAnnotations.initMocks(this);
@@ -196,17 +195,6 @@ List<String> getEventNamesToSend() {
196195
return eventNames;
197196
}
198197

199-
private void waitForEventsToBeProcessed(int eventsCount) throws InterruptedException {
200-
// wait for all events to be processed
201-
long processedEvents = 0;
202-
MongoCollection eventMap = getFlowTestConfigs().getMongoClient().getDatabase(database).getCollection(event_map);
203-
while (processedEvents < eventsCount) {
204-
processedEvents = eventMap.count();
205-
}
206-
LOGGER.debug("Have gotten: " + processedEvents + " out of: " + eventsCount);
207-
TimeUnit.MILLISECONDS.sleep(2000);
208-
}
209-
210198
private void checkResult() throws IOException, JSONException {
211199
String expectedDocument = FileUtils.readFileToString(new File(AGGREGATED_OBJECT_FILE_PATH), "UTF-8");
212200
ObjectMapper objectmapper = new ObjectMapper();

0 commit comments

Comments
 (0)