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

Python framework - write_to_app_pipe updates. #37637

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

jtrejoespinoza-grid
Copy link

@jtrejoespinoza-grid jtrejoespinoza-grid commented Feb 18, 2025

Fixes #32139

Description

Improve the base function write_to_app_pipe from matter_testig.py.
Update the implementations for write_to_app_pipe in the test cases.
Ensure the test cases are working as expected on CI.

Ack is not implemented in this task. As it should be implemented by the app.

Found files using write_to_app_pipe:

grep  'self.write_to_app_pipe' src/python_testing/*.py | cut -d ':' -f 1 | sort  | uniq`

Found the following

src/python_testing/TC_OCC_3_1.py
src/python_testing/TC_OCC_3_2.py
src/python_testing/TC_OpstateCommon.py
src/python_testing/TC_RVCCLEANM_2_1.py
src/python_testing/TC_RVCCLEANM_2_2.py
src/python_testing/TC_RVCOPSTATE_2_1.py
src/python_testing/TC_RVCOPSTATE_2_3.py
src/python_testing/TC_RVCOPSTATE_2_4.py
src/python_testing/TC_RVCRUNM_2_1.py
src/python_testing/TC_RVCRUNM_2_2.py
src/python_testing/TC_SEAR_1_2.py
src/python_testing/TC_SEAR_1_3.py
src/python_testing/TC_SEAR_1_5.py
src/python_testing/TC_SEAR_1_6.py

Excluded: src/python_testing/TC_OpstateCommon.py

Updated test cases:

src/python_testing/TC_OCC_3_1.py
src/python_testing/TC_OCC_3_2.py
src/python_testing/TC_RVCCLEANM_2_1.py
src/python_testing/TC_RVCCLEANM_2_2.py
src/python_testing/TC_RVCOPSTATE_2_1.py
src/python_testing/TC_RVCOPSTATE_2_3.py
src/python_testing/TC_RVCOPSTATE_2_4.py
src/python_testing/TC_RVCRUNM_2_1.py
src/python_testing/TC_RVCRUNM_2_2.py
src/python_testing/TC_SEAR_1_2.py
src/python_testing/TC_SEAR_1_3.py
src/python_testing/TC_SEAR_1_5.py
src/python_testing/TC_SEAR_1_6.py
TC_OVENOPSTATE_2_5 -> Updated base file which implements the write_to_app_pipe

Testing

Commands executed to test the updated files:

OCC

python3 src/python_testing/TC_OCC_2_1.py --commissioning-method on-network --qr-code MT:-24J0AFN00KA0648G00  --PICS src/app/tests/suites/certification/ci-pics-values --app-pid $(ps waux | grep chip-all-clusters | grep -v grep | awk '{print $2}' )  --bool-arg simulate_occupancy:true --endpoint 1 --app-pipe /tmp/chip_all_clusters_fifo_ 

python3 src/python_testing/TC_OCC_3_2.py --commissioning-method on-network --qr-code MT:-24J0AFN00KA0648G00  --PICS src/app/tests/suites/certification/ci-pics-values --app-pid $(ps waux | grep chip-all-clusters | grep -v grep | awk '{print $2}' )  --bool-arg simulate_occupancy:true --endpoint 1 --app-pipe /tmp/chip_all_clusters_fifo_

RVCCLEANM

python3 src/python_testing/TC_RVCCLEANM_2_1.py --commissioning-method on-network --qr-code MT:-24J0AFN00KA0648G00  --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --app-pid $(ps waux | grep chip-rvc-app | grep -v grep | awk '{print $2}' ) --endpoint 1  --int-arg PIXIT.RVCCLEANM.MODE_CHANGE_OK:2  --int-arg PIXIT.RVCCLEANM.MODE_CHANGE_FAIL:1 --app-pipe /tmp/chip_rvc_fifo_

python3 src/python_testing/TC_RVCCLEANM_2_2.py --commissioning-method on-network --qr-code MT:-24J0AFN00KA0648G00  --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --app-pid $(ps waux | grep chip-rvc-app | grep -v grep | awk '{print $2}' ) --endpoint 1 --app-pipe /tmp/chip_rvc_fifo_

RVCOPSTATE

 python3 src/python_testing/TC_RVCOPSTATE_2_1.py --commissioning-method on-network --qr-code MT:-24J0AFN00KA0648G00  --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --app-pid $(ps waux | grep chip-rvc-app | grep -v grep | awk '{print $2}' ) --endpoint 1 --app-pipe /tmp/chip_rvc_fifo_

python3 src/python_testing/TC_RVCOPSTATE_2_2.py --commissioning-method on-network --qr-code MT:-24J0AFN00KA0648G00  --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --app-pid $(ps waux | grep chip-rvc-app | grep -v grep | awk '{print $2}' ) --endpoint 1 --app-pipe /tmp/chip_rvc_fifo_


python3 src/python_testing/TC_RVCOPSTATE_2_3.py --commissioning-method on-network --qr-code MT:-24J0AFN00KA0648G00  --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --app-pid $(ps waux | grep chip-rvc-app | grep -v grep | awk '{print $2}' ) --endpoint 1 --app-pipe /tmp/chip_rvc_fifo_

 python3 src/python_testing/TC_RVCOPSTATE_2_4.py --commissioning-method on-network --qr-code MT:-24J0AFN00KA0648G00  --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --app-pid $(ps waux | grep chip-rvc-app | grep -v grep | awk '{print $2}' ) --endpoint 1 --app-pipe /tmp/chip_rvc_fifo_


RVCRUNM

python3 src/python_testing/TC_RVCRUNM_2_2.py --commissioning-method on-network --qr-code MT:-24J0AFN00KA0648G00  --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --app-pid $(ps waux | grep chip-rvc-app | grep -v grep | awk '{print $2}' ) --endpoint 1  --int-arg PIXIT.RVCRUNM.MODE_A:1  --int-arg PIXIT.RVCRUNM.MODE_B:2 --app-pipe /tmp/chip_rvc_fifo_

python3 src/python_testing/TC_RVCRUNM_2_1.py --commissioning-method on-network --qr-code MT:-24J0AFN00KA0648G00  --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --app-pid $(ps waux | grep chip-rvc-app | grep -v grep | awk '{print $2}' ) --endpoint 1  --int-arg PIXIT.RVCRUNM.MODE_CHANGE_OK:0  --int-arg PIXIT.RVCRUNM.MODE_CHANGE_FAIL:2 --app-pipe /tmp/chip_rvc_fifo_


TC_SEAR

python3 src/python_testing/TC_SEAR_1_6.py --commissioning-method on-network --qr-code MT:-24J0AFN00KA0648G00  --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --app-pid $(ps waux | grep chip-rvc-app | grep -v grep | awk '{print $2}' ) --endpoint 1 --app-pipe /tmp/chip_rvc_fifo_

python3 src/python_testing/TC_SEAR_1_3.py --commissioning-method on-network --qr-code MT:-24J0AFN00KA0648G00  --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --app-pid $(ps waux | grep chip-rvc-app | grep -v grep | awk '{print $2}' ) --endpoint 1 --app-pipe /tmp/chip_rvc_fifo_

python3 src/python_testing/TC_SEAR_1_2.py --commissioning-method on-network --qr-code MT:-24J0AFN00KA0648G00  --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --app-pid $(ps waux | grep chip-rvc-app | grep -v grep | awk '{print $2}' ) --endpoint 1 --app-pipe /tmp/chip_rvc_fifo_

python3 src/python_testing/TC_SEAR_1_5.py --commissioning-method on-network --qr-code MT:-24J0AFN00KA0648G00  --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --app-pid $(ps waux | grep chip-rvc-app | grep -v grep | awk '{print $2}' ) --endpoint 1 --app-pipe /tmp/chip_rvc_fifo_

TC_OVEN

python3 src/python_testing/TC_OVENOPSTATE_2_5.py --commissioning-method on-network --qr-code MT:-24J0AFN00KA0648G00  --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --int-arg PIXIT.WAITTIME.REBOOT:5 --endpoint 1

Copy link

semanticdiff-com bot commented Feb 18, 2025

Copy link

github-actions bot commented Feb 18, 2025

PR #37637: Size comparison from 08535fd to 6b17a4d

Full report (7 builds for cc32xx, qpg, stm32, tizen)
platform target config section 08535fd 6b17a4de change % change
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 538730 538730 0 0.0
RAM 205112 205112 0 0.0
lock CC3235SF_LAUNCHXL FLASH 572886 572886 0 0.0
RAM 205360 205360 0 0.0
qpg lighting-app qpg6105+debug FLASH 662132 662132 0 0.0
RAM 105116 105116 0 0.0
lock-app qpg6105+debug FLASH 620240 620240 0 0.0
RAM 99664 99664 0 0.0
stm32 light STM32WB5MM-DK FLASH 459776 459776 0 0.0
RAM 141472 141472 0 0.0
tizen all-clusters-app arm unknown 5076 5076 0 0.0
FLASH 1750404 1750404 0 0.0
RAM 93260 93260 0 0.0
chip-tool-ubsan arm unknown 11476 11476 0 0.0
FLASH 18960222 18960222 0 0.0
RAM 8296776 8296776 0 0.0

@@ -968,6 +968,8 @@ def __init__(self, *args):
self.is_commissioning = False
# The named pipe name must be set in the derived classes
self.app_pipe = None
# The app_pipe_pid pid must be set in the derived class
self.app_pipe_pid = None
Copy link
Contributor

Choose a reason for hiding this comment

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

This comes from the command line, so you an use self.matter_test_config.app_pid as the default directly, without having the tests override this individually.

Choose a reason for hiding this comment

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

Removed those as they wont be needed.

@async_test_body
async def test_TC_OCC_3_2(self):
endpoint_id = self.get_endpoint()
node_id = self.dut_node_id
dev_ctrl = self.default_controller
self.app_pipe = "/tmp/chip_all_clusters_fifo_"
Copy link
Contributor

Choose a reason for hiding this comment

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

This is also something that should come in on the command line rather than being hard coded. This makes it so that you can only run this test against the one app specified in the CI config.

Choose a reason for hiding this comment

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

If this is going to be sent over an argument , should it be sent using --string-arg or should it use a dedicated argument like is the case for --app-pid? . Also this implementation raises a different question that if is possible to have more than one app to pipe commands to?

Choose a reason for hiding this comment

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

Udpated to use to arguments -app-pid and --app-pipe from the args.
No need to use hardcoded values in the code.

jtrejoespinoza-grid and others added 4 commits February 19, 2025 16:55
…he command line to build the app file to send the out of band command. Implemetation the same for CI and SSH
…name to use the values from arguments while on CI
@jtrejoespinoza-grid jtrejoespinoza-grid marked this pull request as ready for review February 20, 2025 20:02
Copy link
Contributor

@juandediosg juandediosg left a comment

Choose a reason for hiding this comment

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

Looks good to me

@asirko-soft asirko-soft self-requested a review February 21, 2025 11:59
logging.error("Named pipe %r does NOT exist" % app_pipe_name)
raise FileNotFoundError("CANNOT FIND %r" % app_pipe_name)
with open(app_pipe_name, "w") as app_pipe:
logger.info(f"Sending out-of-band command: {command} to file: {app_pipe_name}")
app_pipe.write(command + "\n")
Copy link
Contributor

@asirko-soft asirko-soft Feb 21, 2025

Choose a reason for hiding this comment

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

adding app_pipe.flush() should ensure immediate write and we can remove the sleep then

Choose a reason for hiding this comment

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

The sleep is used to emulate the linux app Acknowledgement , but this needs to be implemented in the app and then implement the ack check on this side.

Copy link
Contributor

@asirko-soft asirko-soft left a comment

Choose a reason for hiding this comment

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

Generally it looks ok to me, but I have one concern, we have parallel activity to extract commonly used functions/classes to separate modules project-chip/matter-test-scripts#443 . My understanding is that after split complete we would have only Base class in matter_testing.py that should handle only test-related stuff like steps, init, teardown, test config, stack management and so on and this function looks like really utility one that should be places in some separate module.

FYI @cecille

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move the write_to_app_pipe that exists in python_tests in a common location
5 participants