Skip to content

Commit

Permalink
2nd attempt to fix random EEM and EPM CI failures (#34476)
Browse files Browse the repository at this point in the history
* Revert "Attempt to reduce CI failures by increasing timeout in checking fake readings have changed."

This reverts commit 42d36e9.

* Added fixed random seed to try to avoid CI failures when looking for different values between two readings. There is a high probability that 2 energy readings could be the same, so using a fixed seed should mean that tests are at least reproducible.

* Restyled by whitespace

* Improved comment

* Moved the change previously made in EVSManufacturerImpl to FakeReadings.cpp after updating to master.

* Restyled by whitespace

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Oct 25, 2024
1 parent d2206c5 commit 1000968
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ void FakeReadings::StartFakeReadings(EndpointId aEndpointId, int64_t aPower_mW,

if (bReset)
{
// Use a fixed random seed to try to avoid random CI test failures
// which are caused when the test is checking for 2 different numbers.
// This is statistically more likely when the test runs for a long time
// or if the seed is not set
srand(1);

mTotalEnergyImported = 0;
mTotalEnergyExported = 0;
}
Expand Down
4 changes: 2 additions & 2 deletions src/python_testing/TC_EEM_2_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def steps_TC_EEM_2_2(self) -> list[TestStep]:
TestStep("4", "Wait 3 seconds"),
TestStep("4a", "TH reads from the DUT the CumulativeEnergyImported attribute",
"Verify the read is successful and note the value read."),
TestStep("5", "Wait 5 seconds"),
TestStep("5", "Wait 3 seconds"),
TestStep("5a", "TH reads from the DUT the CumulativeEnergyImported attribute",
"Verify the read is successful and that the value is greater than the value measured in step 4a."),
TestStep("6", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.EEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.EEM.TEST_EVENT_TRIGGER for Stop Fake Readings Test Event."),
Expand All @@ -80,7 +80,7 @@ async def test_TC_EEM_2_2(self):
cumulative_energy_imported = await self.read_eem_attribute_expect_success("CumulativeEnergyImported")

self.step("5")
time.sleep(5)
time.sleep(3)

self.step("5a")
cumulative_energy_imported_2 = await self.read_eem_attribute_expect_success("CumulativeEnergyImported")
Expand Down
4 changes: 2 additions & 2 deletions src/python_testing/TC_EEM_2_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def steps_TC_EEM_2_3(self) -> list[TestStep]:
TestStep("4", "Wait 6 seconds"),
TestStep("4a", "TH reads from the DUT the CumulativeEnergyExported attribute",
"Verify the read is successful and note the value read."),
TestStep("5", "Wait 11 seconds"),
TestStep("5", "Wait 6 seconds"),
TestStep("5a", "TH reads from the DUT the CumulativeEnergyExported attribute",
"Verify the read is successful and that the value is greater than the value measured in step 4a."),
TestStep("6", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.EEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.EEM.TEST_EVENT_TRIGGER for Stop Fake Readings Test Event."),
Expand All @@ -80,7 +80,7 @@ async def test_TC_EEM_2_3(self):
cumulative_energy_exported = await self.read_eem_attribute_expect_success("CumulativeEnergyExported")

self.step("5")
time.sleep(11)
time.sleep(6)

self.step("5a")
cumulative_energy_exported_2 = await self.read_eem_attribute_expect_success("CumulativeEnergyExported")
Expand Down
4 changes: 2 additions & 2 deletions src/python_testing/TC_EEM_2_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def steps_TC_EEM_2_4(self) -> list[TestStep]:
TestStep("4", "Wait 3 seconds"),
TestStep("4a", "TH reads from the DUT the PeriodicEnergyImported attribute",
"Verify the read is successful and note the value read."),
TestStep("5", "Wait 5 seconds"),
TestStep("5", "Wait 3 seconds"),
TestStep("5a", "TH reads from the DUT the PeriodicEnergyImported attribute",
"Verify the read is successful and that the value read has to be different from value measure in step 4a."),
TestStep("6", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.EEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.EEM.TEST_EVENT_TRIGGER for Stop Fake Readings Test Event."),
Expand All @@ -80,7 +80,7 @@ async def test_TC_EEM_2_4(self):
periodic_energy_imported = await self.read_eem_attribute_expect_success("PeriodicEnergyImported")

self.step("5")
time.sleep(5)
time.sleep(3)

self.step("5a")
periodic_energy_imported_2 = await self.read_eem_attribute_expect_success("PeriodicEnergyImported")
Expand Down
4 changes: 2 additions & 2 deletions src/python_testing/TC_EEM_2_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def steps_TC_EEM_2_5(self) -> list[TestStep]:
TestStep("4", "Wait 6 seconds"),
TestStep("4a", "TH reads from the DUT the PeriodicEnergyExported attribute",
"Verify the read is successful and note the value read."),
TestStep("5", "Wait 11 seconds"),
TestStep("5", "Wait 6 seconds"),
TestStep("5a", "TH reads from the DUT the PeriodicEnergyExported attribute",
"Verify the read is successful and that the value read has to be different from value measure in step 4a."),
TestStep("6", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.EEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.EEM.TEST_EVENT_TRIGGER for Stop Fake Readings Test Event."),
Expand All @@ -80,7 +80,7 @@ async def test_TC_EEM_2_5(self):
periodic_energy_exported = await self.read_eem_attribute_expect_success("PeriodicEnergyExported")

self.step("5")
time.sleep(11)
time.sleep(6)

self.step("5a")
periodic_energy_exported_2 = await self.read_eem_attribute_expect_success("PeriodicEnergyExported")
Expand Down
6 changes: 3 additions & 3 deletions src/python_testing/TC_EPM_2_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def steps_TC_EPM_2_2(self) -> list[TestStep]:
"Verify the read is successful and that the value is between 3'848 and 4'848 mA. Note the value read."),
TestStep("4c", "TH reads from the DUT the Voltage attribute",
"Verify the read is successful and that the value is between 229'000 and 231'000 mV. Note the value read."),
TestStep("5", "Wait 5 seconds"),
TestStep("5", "Wait 3 seconds"),
TestStep("5a", "TH reads from the DUT the ActivePower attribute",
"Verify the read is successful, that the value is between '980'000 and 1'020'000 mW, and the value is different from the value read in step 4a."),
TestStep("5b", "TH reads from the DUT the ActiveCurrent attribute",
Expand Down Expand Up @@ -105,8 +105,8 @@ async def test_TC_EPM_2_2(self):
voltage = await self.check_epm_attribute_in_range("Voltage", 229000, 231000)

self.step("5")
# After 5 seconds...
time.sleep(5)
# After 3 seconds...
time.sleep(3)

self.step("5a")
# Active power is Mandatory
Expand Down

0 comments on commit 1000968

Please sign in to comment.