18
18
# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments
19
19
# for details about the block below.
20
20
#
21
- # TODO: Skip CI for now, we don't have any way to run this. Needs setup. See test_TC_CCTRL.py
21
+ # === BEGIN CI TEST ARGUMENTS ===
22
+ # test-runner-runs:
23
+ # run1:
24
+ # app: examples/fabric-admin/scripts/fabric-sync-app.py
25
+ # app-args: --app-admin=${FABRIC_ADMIN_APP} --app-bridge=${FABRIC_BRIDGE_APP} --stdin-pipe=dut-fsa-stdin --discriminator=1234
26
+ # app-ready-pattern: "Successfully opened pairing window on the device"
27
+ # script-args: >
28
+ # --PICS src/app/tests/suites/certification/ci-pics-values
29
+ # --storage-path admin_storage.json
30
+ # --commissioning-method on-network
31
+ # --discriminator 1234
32
+ # --passcode 20202021
33
+ # --endpoint 0
34
+ # --string-arg th_server_app_path:${ALL_CLUSTERS_APP}
35
+ # --trace-to json:${TRACE_TEST_JSON}.json
36
+ # --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
37
+ # factoryreset: true
38
+ # quiet: true
39
+ # === END CI TEST ARGUMENTS ===
22
40
23
41
# This test requires a TH_SERVER application. Please specify with --string-arg th_server_app_path:<path_to_app>
24
42
25
43
import logging
26
44
import os
27
45
import random
28
- import signal
29
- import subprocess
46
+ import tempfile
30
47
import time
31
- import uuid
32
48
33
49
import chip .clusters as Clusters
34
50
from chip import ChipDeviceCtrl
35
51
from chip .interaction_model import InteractionModelError , Status
36
52
from matter_testing_support import (MatterBaseTest , TestStep , async_test_body , default_matter_test_main , has_cluster ,
37
53
run_if_endpoint_matches )
38
54
from mobly import asserts
55
+ from TC_MCORE_FS_1_1 import AppServer
39
56
40
57
41
58
class TC_CCTRL_2_3 (MatterBaseTest ):
42
59
43
60
@async_test_body
44
61
async def setup_class (self ):
45
62
super ().setup_class ()
46
- self .app_process = None
47
- app = self .user_params .get ("th_server_app_path" , None )
48
- if not app :
49
- asserts .fail ('This test requires a TH_SERVER app. Specify app path with --string-arg th_server_app_path:<path_to_app>' )
50
-
51
- self .kvs = f'kvs_{ str (uuid .uuid4 ())} '
52
- self .port = 5543
53
- discriminator = random .randint (0 , 4095 )
54
- passcode = 20202021
55
- cmd = [app ]
56
- cmd .extend (['--secured-device-port' , str (5543 )])
57
- cmd .extend (['--discriminator' , str (discriminator )])
58
- cmd .extend (['--passcode' , str (passcode )])
59
- cmd .extend (['--KVS' , self .kvs ])
60
- # TODO: Determine if we want these logs cooked or pushed to somewhere else
61
- logging .info ("Starting TH_SERVER" )
62
- self .app_process = subprocess .Popen (cmd )
63
- logging .info ("TH_SERVER started" )
64
- time .sleep (3 )
63
+
64
+ self .th_server = None
65
+ self .storage = None
66
+
67
+ th_server_app = self .user_params .get ("th_server_app_path" , None )
68
+ if not th_server_app :
69
+ asserts .fail ("This test requires a TH_SERVER app. Specify app path with --string-arg th_server_app_path:<path_to_app>" )
70
+ if not os .path .exists (th_server_app ):
71
+ asserts .fail (f"The path { th_server_app } does not exist" )
72
+
73
+ # Create a temporary storage directory for keeping KVS files.
74
+ self .storage = tempfile .TemporaryDirectory (prefix = self .__class__ .__name__ )
75
+ logging .info ("Temporary storage directory: %s" , self .storage .name )
76
+
77
+ self .th_server_port = 5543
78
+ self .th_server_discriminator = random .randint (0 , 4095 )
79
+ self .th_server_passcode = 20202021
80
+
81
+ # Start the TH_SERVER app.
82
+ self .th_server = AppServer (
83
+ th_server_app ,
84
+ storage_dir = self .storage .name ,
85
+ port = self .th_server_port ,
86
+ discriminator = self .th_server_discriminator ,
87
+ passcode = self .th_server_passcode )
88
+ self .th_server .start ()
65
89
66
90
logging .info ("Commissioning from separate fabric" )
67
91
@@ -71,20 +95,18 @@ async def setup_class(self):
71
95
paa_path = str (self .matter_test_config .paa_trust_store_path )
72
96
self .TH_server_controller = new_fabric_admin .NewController (nodeId = 112233 , paaTrustStorePath = paa_path )
73
97
self .server_nodeid = 1111
74
- await self .TH_server_controller .CommissionOnNetwork (nodeId = self .server_nodeid , setupPinCode = passcode , filterType = ChipDeviceCtrl .DiscoveryFilterType .LONG_DISCRIMINATOR , filter = discriminator )
98
+ await self .TH_server_controller .CommissionOnNetwork (
99
+ nodeId = self .server_nodeid ,
100
+ setupPinCode = self .th_server_passcode ,
101
+ filterType = ChipDeviceCtrl .DiscoveryFilterType .LONG_DISCRIMINATOR ,
102
+ filter = self .th_server_discriminator )
75
103
logging .info ("Commissioning TH_SERVER complete" )
76
104
77
105
def teardown_class (self ):
78
- # In case the th_server_app_path does not exist, then we failed the test
79
- # and there is nothing to remove
80
- if self .app_process is not None :
81
- logging .warning ("Stopping app with SIGTERM" )
82
- self .app_process .send_signal (signal .SIGTERM .value )
83
- self .app_process .wait ()
84
-
85
- if os .path .exists (self .kvs ):
86
- os .remove (self .kvs )
87
-
106
+ if self .th_server is not None :
107
+ self .th_server .terminate ()
108
+ if self .storage is not None :
109
+ self .storage .cleanup ()
88
110
super ().teardown_class ()
89
111
90
112
def steps_TC_CCTRL_2_3 (self ) -> list [TestStep ]:
@@ -172,7 +194,7 @@ async def test_TC_CCTRL_2_3(self):
172
194
await self .send_single_cmd (cmd , dev_ctrl = self .TH_server_controller , node_id = self .server_nodeid , endpoint = 0 , timedRequestTimeoutMs = 5000 )
173
195
174
196
self .step (11 )
175
- time .sleep (30 )
197
+ time .sleep (5 if self . is_pics_sdk_ci_only else 30 )
176
198
177
199
self .step (12 )
178
200
th_server_fabrics_new = await self .read_single_attribute_check_success (cluster = Clusters .OperationalCredentials , attribute = Clusters .OperationalCredentials .Attributes .Fabrics , dev_ctrl = self .TH_server_controller , node_id = self .server_nodeid , endpoint = 0 , fabric_filtered = False )
0 commit comments