Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Test] Creating TC_CADMIN_1_22 and TC_CADMIN_1_24 python test modules #35632

Merged
merged 21 commits into from
Nov 25, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions src/python_testing/TC_CADMIN_1_22_24.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
# --PICS src/app/tests/suites/certification/ci-pics-values
# factory-reset: true
# quiet: true
# quiet: false
# === END CI TEST ARGUMENTS ===

import asyncio
import logging
import random
from time import sleep
Expand All @@ -51,7 +52,7 @@ async def OpenCommissioningWindow(self) -> CommissioningParameters:

except Exception as e:
logging.exception('Error running OpenCommissioningWindow %s', e)
asserts.assert_true(False, 'Failed to open commissioning window')
asserts.fail('Failed to open commissioning window')

async def get_window_status(self) -> int:
AC_cluster = Clusters.AdministratorCommissioning
Expand Down Expand Up @@ -94,7 +95,8 @@ async def test_TC_CADMIN_1_22(self):
self.step(4)
window_status = await self.get_window_status()
if window_status != Clusters.AdministratorCommissioning.Enums.CommissioningWindowStatusEnum.kWindowNotOpen:
asserts.fail("Commissioning window is expected to be closed, but was found to be open")
asserts.assert_equal(window_status, Clusters.AdministratorCommissioning.Enums.CommissioningWindowStatusEnum.kWindowNotOpen,
"Commissioning window is expected to be closed, but was found to be open")

self.step(5)
try:
Expand All @@ -104,13 +106,14 @@ async def test_TC_CADMIN_1_22(self):
except ChipStackError as e:
# Since we provided 901 seconds as the timeout duration,
# we should not be able to open comm window as duration is too long.
# we are expected receive Failed to open commissioning window: IM Error 0x00000585: General error: 0x85 (INVALID_COMMAND)
asserts.assert_equal(e.err, 0x00000585,
"Expected to error as we provided failure value for opening commissioning window")

self.step(6)
window_status2 = await self.get_window_status()
if window_status2 != Clusters.AdministratorCommissioning.Enums.CommissioningWindowStatusEnum.kWindowNotOpen:
asserts.fail("Commissioning window is expected to be closed, but was found to be open")
asserts.assert_equal(await window_status, Clusters.AdministratorCommissioning.Enums.CommissioningWindowStatusEnum.kWindowNotOpen, "Commissioning window is expected to be closed, but was found to be open")

def pics_TC_CADMIN_1_24(self) -> list[str]:
return ["CADMIN.S"]
Expand All @@ -120,7 +123,7 @@ def steps_TC_CADMIN_1_24(self) -> list[TestStep]:
TestStep(1, "Commissioning, already done", is_commissioning=True),
TestStep(2, "TH_CR1 opens a commissioning window on DUT_CE using ECM with a value of 180 seconds",
"DUT_CE opens its Commissioning window to allow a second commissioning"),
TestStep(3, "TH_CR1 sends an RevokeCommissioning command to the DUT"),
TestStep(3, "Wait for the commissioning window in step 2 to timeout"),
TestStep(4, "TH_CR1 reads the window status to verify the DUT_CE window is closed",
"DUT_CE windows status shows the window is closed"),
TestStep(5, "TH_CR1 opens a commissioning window on DUT_CE using ECM with a value of 179 seconds",
Expand All @@ -140,31 +143,36 @@ async def test_TC_CADMIN_1_24(self):
nodeid=self.dut_node_id, timeout=180, iteration=10000, discriminator=self.discriminator, option=1)

self.step(3)
revokeCmd = Clusters.AdministratorCommissioning.Commands.RevokeCommissioning()
await self.th1.SendCommand(nodeid=self.dut_node_id, endpoint=0, payload=revokeCmd, timedRequestTimeoutMs=6000)
# The failsafe cleanup is scheduled after the command completes, so give it a bit of time to do that
sleep(1)
sleep(180)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yaml used to wait for 181 seconds instead of 180 for some reason.

Also this is absolutely terrible for CI. Could we make CI sleep less? Or maybe have an interface to skip slow in PR CI the same like we have for YAML: https://github.com/project-chip/connectedhomeip/blob/master/scripts/tests/chiptest/__init__.py#L98

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I apologize for this test having caused some issues in the CI currently due to the sleep time.
I will file a PR here soon to remove this test from running in the CI moving forward, sounds like this test is not needed to be run in the CI.

Copy link
Contributor Author

@j-ororke j-ororke Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @andy31415,
I noticed that there is some new code in src/python_testing/test_metadata.yaml in the master branch.
In the slow_tests section of that yaml file there appears to be CADMIN_1_9, CADMIN_1_19, and CADMIN_1_22_24 tests with duration of test runs added currently.
Does this resolve the issue with the CI and the test from this above PR? Can this comment be resolved?


self.step(4)
window_status = await self.get_window_status()
# TODO: Issue noticed when initially attempting to check window status after waiting for timeout to occur, issue is detailed here: https://github.com/project-chip/connectedhomeip/issues/35983
# Workaround in place below until above issue resolved
try:
window_status = await self.get_window_status()
except asyncio.CancelledError:
window_status = await self.get_window_status()

if window_status != Clusters.AdministratorCommissioning.Enums.CommissioningWindowStatusEnum.kWindowNotOpen:
asserts.fail("Commissioning window is expected to be closed, but was found to be open")
asserts.assert_equal(window_status, Clusters.AdministratorCommissioning.Enums.CommissioningWindowStatusEnum.kWindowNotOpen,
"Commissioning window is expected to be closed, but was found to be open")

self.step(5)
try:
await self.th1.OpenCommissioningWindow(
nodeid=self.dut_node_id, timeout=179, iteration=10000, discriminator=self.discriminator, option=1)

except ChipStackError as e:
# Since we provided 901 seconds as the timeout duration,
# Since we provided 179 seconds as the timeout duration,
# we should not be able to open comm window as duration is too long.
# we are expected receive Failed to open commissioning window: IM Error 0x00000585: General error: 0x85 (INVALID_COMMAND)
asserts.assert_equal(e.err, 0x00000585,
"Expected to error as we provided failure value for opening commissioning window")

self.step(6)
window_status2 = await self.get_window_status()
if window_status2 != Clusters.AdministratorCommissioning.Enums.CommissioningWindowStatusEnum.kWindowNotOpen:
asserts.fail("Commissioning window is expected to be closed, but was found to be open")
asserts.assert_equal(await window_status, Clusters.AdministratorCommissioning.Enums.CommissioningWindowStatusEnum.kWindowNotOpen, "Commissioning window is expected to be closed, but was found to be open")


if __name__ == "__main__":
Expand Down
Loading