Skip to content

Commit

Permalink
RDK-54098: Fix events upload time hazard in Analytics L2 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianM27 committed Jan 9, 2025
1 parent 4e9d360 commit d4f18e3
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions Tests/L2Tests/L2TestsPlugin/tests/Analytics_L2Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ TEST_F(AnalyticsTest, SendAndReceiveMultipleEventsTimeOk)
uint32_t status = InvokeServiceMethod("org.rdk.System", "setTimeZoneDST", paramsJson, resultJson);
EXPECT_EQ(status, Core::ERROR_NONE);

sleep(3);
sleep(5);

paramsJson.Clear();
paramsJson["eventName"] = "L2TestEvent";
Expand All @@ -626,16 +626,19 @@ TEST_F(AnalyticsTest, SendAndReceiveMultipleEventsTimeOk)
eventPayload["data"] = "random data";
paramsJson["eventPayload"] = eventPayload;

SiftServerMock siftServer;
EXPECT_TRUE(siftServer.Start());

const int eventsSentNbr = 6;

for (int i = 0; i < eventsSentNbr; ++i) {
status = InvokeServiceMethod("org.rdk.Analytics", "sendEvent", paramsJson, resultJson);
EXPECT_EQ(status, Core::ERROR_NONE);
}

// wait for all events to be stored in the analytics store
sleep(3);

SiftServerMock siftServer;
EXPECT_TRUE(siftServer.Start());

string eventMsg = siftServer.AwaitData(SIFT_SERVER_TIMEOUT_SEC);
EXPECT_NE(eventMsg, "");

Expand Down Expand Up @@ -1019,17 +1022,19 @@ TEST_F(AnalyticsTest, EventsMapping)
status = InvokeServiceMethod("org.rdk.Analytics", "sendEvent", paramsJson, resultJson);
EXPECT_EQ(status, Core::ERROR_NONE);


SiftServerMock siftServer;
EXPECT_TRUE(siftServer.Start());

// Set TimeZone to FINAL what allows event to be decorated and sent to Sift server
paramsJson.Clear();
paramsJson["timeZone"] = "America/New_York";
paramsJson["accuracy"] = "FINAL";
status = InvokeServiceMethod("org.rdk.System", "setTimeZoneDST", paramsJson, resultJson);
EXPECT_EQ(status, Core::ERROR_NONE);

// wait for all events to be stored in the analytics store
sleep(5);

SiftServerMock siftServer;
EXPECT_TRUE(siftServer.Start());

string eventsMsg = siftServer.AwaitData(SIFT_SERVER_TIMEOUT_SEC);
EXPECT_NE(eventsMsg, "");

Expand Down

0 comments on commit d4f18e3

Please sign in to comment.