You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by "jkevan (via GitHub)" <gi...@apache.org> on 2023/05/15 09:26:29 UTC

[GitHub] [unomi] jkevan opened a new pull request, #626: UNOMI-782: fix flaky test SegmentIT

jkevan opened a new pull request, #626:
URL: https://github.com/apache/unomi/pull/626

   (no comment)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@unomi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [unomi] sergehuber commented on pull request #626: UNOMI-782: fix flaky test SegmentIT

Posted by "sergehuber (via GitHub)" <gi...@apache.org>.
sergehuber commented on PR #626:
URL: https://github.com/apache/unomi/pull/626#issuecomment-1547826831

   The typos were corrected by Kevan separately in both master and this branch. Thanks !


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@unomi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [unomi] jkevan merged pull request #626: UNOMI-782: fix flaky test SegmentIT

Posted by "jkevan (via GitHub)" <gi...@apache.org>.
jkevan merged PR #626:
URL: https://github.com/apache/unomi/pull/626


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@unomi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [unomi] sergehuber commented on a diff in pull request #626: UNOMI-782: fix flaky test SegmentIT

Posted by "sergehuber (via GitHub)" <gi...@apache.org>.
sergehuber commented on code in PR #626:
URL: https://github.com/apache/unomi/pull/626#discussion_r1193788932


##########
itests/src/test/java/org/apache/unomi/itests/SegmentIT.java:
##########
@@ -547,41 +544,47 @@ public void testScoringRecalculation() throws Exception {
         scoringElements.add(scoringElement);
         scoring.setElements(scoringElements);
         segmentService.setScoringDefinition(scoring);
-        refreshPersistence(Scoring.class, Profile.class);
+        refreshPersistence(Segment.class);
 
         // Send 2 events that match the scoring plan.
         profile = profileService.load("test_profile_id");
         Event testEvent = new Event("test-event-type", null, profile, null, null, profile, timestampEventInRange);
         testEvent.setPersistent(true);
         eventService.send(testEvent);
-        persistenceService.refreshIndex(Event.class, timestampEventInRange);
+        refreshPersistence(Event.class);
         // 2nd event
         testEvent = new Event("test-event-type", null, testEvent.getProfile(), null, null, testEvent.getProfile(), timestampEventInRange);
         eventService.send(testEvent);
-        persistenceService.refreshIndex(Event.class, timestampEventInRange);
+        refreshPersistence(Event.class, Profile.class);
 
         // insure the profile is engaged;
-        Assert.assertTrue("Profile should have 2 events in the scoring",  (Long) ((Map) testEvent.getProfile().getSystemProperties().get("pastEvents")).get(pastEventCondition.getParameterValues().get("generatedPropertyKey")) == 2);
-        Assert.assertTrue("Profile is engaged",  testEvent.getProfile().getScores().containsKey("past-event-scoring-test") && testEvent.getProfile().getScores().get("past-event-scoring-test") == 50);
+        try {
+            Assert.assertTrue("Profile should have 2 events in the scoring",
+                    (Long) ((Map) testEvent.getProfile().getSystemProperties().get("pastEvents"))
+                            .get(pastEventCondition.getParameterValues().get("generatedPropertyKey")) == 2);
+            Assert.assertTrue("Profile is engaged", testEvent.getProfile().getScores().containsKey("past-event-scoring-test")
+                    && testEvent.getProfile().getScores().get("past-event-scoring-test") == 50);
+        } catch (Exception e) {
+            Assert.fail("Unable to read past event because " + e.getMessage());
+        }
         profileService.save(testEvent.getProfile());
         refreshPersistence(Profile.class);
         // recalculate event conditions
         segmentService.recalculatePastEventConditions();
         // insure the profile is still engaged after recalculate;
-        keepTrying("Profile should have 2 events in the scoring",
-                () -> profileService.load("test_profile_id"),
-                updatedProfile -> {
-                    try {
-                        boolean eventCounted = (Integer) ((Map) updatedProfile.getSystemProperties().get("pastEvents")).get(pastEventCondition.getParameterValues().get("generatedPropertyKey")) == 2;
-                        boolean profileEngaged = updatedProfile.getScores().containsKey("past-event-scoring-test") && updatedProfile.getScores().get("past-event-scoring-test") == 50;
-                        return eventCounted && profileEngaged;
-                    } catch (Exception e) {
-                        // Do nothing, unable to read value
-                    };
-                    return false;
-                },
-                1000, 20);
-
+        keepTrying("Profile should have 2 events in the scoring", () -> profileService.load("test_profile_id"), updatedProfile -> {
+            try {
+                boolean eventCounted = (Integer) ((Map) updatedProfile.getSystemProperties().get("pastEvents"))
+                        .get(pastEventCondition.getParameterValues().get("generatedPropertyKey")) == 2;
+                boolean profileEngaged = updatedProfile.getScores().containsKey("past-event-scoring-test")
+                        && updatedProfile.getScores().get("past-event-scoring-test") == 50;
+                return eventCounted && profileEngaged;
+            } catch (Exception e) {
+                // Do nothing, unable to read value
+            }
+            ;

Review Comment:
   Don't think we need this one do we ?



##########
itests/src/test/java/org/apache/unomi/itests/SegmentIT.java:
##########
@@ -531,8 +527,9 @@ public void testScoringRecalculation() throws Exception {
         pastEventCondition.setParameter("minimumEventCount", 1);
         pastEventCondition.setParameter("maximumEventCount", 2);
 
-        pastEventCondition.setParameter("fromDate","2000-07-15T07:00:00Z");
-        pastEventCondition.setParameter("toDate","2001-01-15T07:00:00Z");;
+        pastEventCondition.setParameter("fromDate", "2000-07-15T07:00:00Z");
+        pastEventCondition.setParameter("toDate", "2001-01-15T07:00:00Z");
+        ;

Review Comment:
   Small typo



##########
itests/src/test/java/org/apache/unomi/itests/SegmentIT.java:
##########
@@ -531,8 +527,9 @@ public void testScoringRecalculation() throws Exception {
         pastEventCondition.setParameter("minimumEventCount", 1);
         pastEventCondition.setParameter("maximumEventCount", 2);
 
-        pastEventCondition.setParameter("fromDate","2000-07-15T07:00:00Z");
-        pastEventCondition.setParameter("toDate","2001-01-15T07:00:00Z");;
+        pastEventCondition.setParameter("fromDate", "2000-07-15T07:00:00Z");
+        pastEventCondition.setParameter("toDate", "2001-01-15T07:00:00Z");
+        ;

Review Comment:
   We should just remove the ;



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@unomi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org