Skip to content

Commit 824b589

Browse files
committed
Add test steps logging for TCP Tests (project-chip#37397)
* Add test steps logging for TCP Tests * Fix naming of Test steps.
1 parent 093d14d commit 824b589

File tree

1 file changed

+132
-8
lines changed

1 file changed

+132
-8
lines changed

src/python_testing/TCP_Tests.py

+132-8
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import chip.clusters as Clusters
3434
from chip import ChipDeviceCtrl
3535
from chip.interaction_model import InteractionModelError
36-
from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main
36+
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
3737
from mobly import asserts
3838

3939

@@ -48,141 +48,265 @@ async def teardown_test(self):
4848
await self.send_single_cmd(cmd=cmd, endpoint=0,
4949
payloadCapability=ChipDeviceCtrl.TransportPayloadCapability.LARGE_PAYLOAD)
5050

51-
def pics_SC_8_1(self):
51+
def pics_TC_SC_8_1(self):
5252
return ['MCORE.SC.TCP']
5353

54+
def steps_TC_SC_8_1(self) -> list[TestStep]:
55+
steps = [
56+
TestStep(1, "Commissioning, already done", is_commissioning=True),
57+
TestStep(2, "TH initiates a CASE session establishment with DUT, requesting a session supporting large payloads."),
58+
TestStep(3, "Verifying that a session is set up with an underlying TCP connection established with DUT."),
59+
]
60+
return steps
61+
5462
# TCP Connection Establishment
5563
@async_test_body
5664
async def test_TC_SC_8_1(self):
5765

66+
self.step(1)
5867
try:
68+
self.step(2)
5969
device = await self.default_controller.GetConnectedDevice(nodeid=self.dut_node_id, allowPASE=False, timeoutMs=1000,
6070
payloadCapability=ChipDeviceCtrl.TransportPayloadCapability.LARGE_PAYLOAD)
6171
except TimeoutError:
6272
asserts.fail("Unable to establish a CASE session over TCP to the device")
73+
74+
self.step(3)
6375
asserts.assert_equal(device.isSessionOverTCPConnection, True, "Session does not have associated TCP connection")
6476
asserts.assert_equal(device.isActiveSession, True, "Large Payload Session should be active over TCP connection")
6577

66-
def pics_SC_8_2(self):
78+
def pics_TC_SC_8_2(self):
6779
return ['MCORE.SC.TCP']
6880

81+
def steps_TC_SC_8_2(self) -> list[TestStep]:
82+
steps = [
83+
TestStep(1, "Commissioning, already done", is_commissioning=True),
84+
TestStep(2, "TH initiates a CASE session establishment with DUT, requesting a session supporting large payloads."),
85+
TestStep(3, "Verifying that the session established with DUT allows large payloads."),
86+
]
87+
return steps
88+
6989
# Large Payload Session Establishment
7090
@async_test_body
7191
async def test_TC_SC_8_2(self):
7292

93+
self.step(1)
7394
try:
95+
self.step(2)
7496
device = await self.default_controller.GetConnectedDevice(nodeid=self.dut_node_id, allowPASE=False, timeoutMs=1000,
7597
payloadCapability=ChipDeviceCtrl.TransportPayloadCapability.LARGE_PAYLOAD)
7698
except TimeoutError:
7799
asserts.fail("Unable to establish a CASE session over TCP to the device")
100+
101+
self.step(3)
78102
asserts.assert_equal(device.sessionAllowsLargePayload, True, "Session does not have associated TCP connection")
79103

80-
def pics_SC_8_3(self):
104+
def pics_TC_SC_8_3(self):
81105
return ['MCORE.SC.TCP']
82106

107+
def steps_TC_SC_8_3(self) -> list[TestStep]:
108+
steps = [
109+
TestStep(1, "Commissioning, already done", is_commissioning=True),
110+
TestStep(2, "TH initiates a CASE session establishment with DUT, requesting a session supporting large payloads."),
111+
TestStep(3, "Verifying that a session is set up with an underlying TCP connection established with DUT."),
112+
TestStep(4, "TH closes the TCP connection with DUT"),
113+
TestStep(5, "Verifying that the secure session with DUT is inactive."),
114+
]
115+
return steps
116+
83117
# Session Inactive After TCP Disconnect
84118
@async_test_body
85119
async def test_TC_SC_8_3(self):
86120

121+
self.step(1)
87122
try:
123+
self.step(2)
88124
device = await self.default_controller.GetConnectedDevice(nodeid=self.dut_node_id, allowPASE=False, timeoutMs=1000,
89125
payloadCapability=ChipDeviceCtrl.TransportPayloadCapability.LARGE_PAYLOAD)
90126
except TimeoutError:
91127
asserts.fail("Unable to establish a CASE session over TCP to the device")
128+
129+
self.step(3)
92130
asserts.assert_equal(device.isSessionOverTCPConnection, True, "Session does not have associated TCP connection")
93131

132+
self.step(4)
94133
device.closeTCPConnectionWithPeer()
134+
135+
self.step(5)
95136
asserts.assert_equal(device.isActiveSession, False,
96137
"Large Payload Session should not be active after TCP connection closure")
97138

98-
def pics_SC_8_4(self):
139+
def pics_TC_SC_8_4(self):
99140
return ['MCORE.SC.TCP']
100141

142+
def steps_TC_SC_8_4(self) -> list[TestStep]:
143+
steps = [
144+
TestStep(1, "Commissioning, already done", is_commissioning=True),
145+
TestStep(2, "TH initiates a CASE session establishment with DUT, requesting a session supporting large payloads."),
146+
TestStep(3, "Verifying that a session is set up with an underlying TCP connection established with DUT."),
147+
TestStep(4, "TH closes the TCP connection with DUT"),
148+
TestStep(5, "Verifyng that the secure session with DUT is inactive."),
149+
TestStep(6, "TH re-initiates CASE session establishment over TCP with DUT"),
150+
TestStep(7, "Verifying that a session is set up with an underlying TCP connection established with DUT."),
151+
TestStep(8, "Verifying that the large-payload secure session with DUT is active."),
152+
]
153+
return steps
154+
101155
# TCP Connect, Disconnect, Then Connect Again
102156
@async_test_body
103157
async def test_TC_SC_8_4(self):
104158

159+
self.step(1)
105160
try:
161+
self.step(2)
106162
device = await self.default_controller.GetConnectedDevice(nodeid=self.dut_node_id, allowPASE=False, timeoutMs=1000,
107163
payloadCapability=ChipDeviceCtrl.TransportPayloadCapability.LARGE_PAYLOAD)
108164
except TimeoutError:
109165
asserts.fail("Unable to establish a CASE session over TCP to the device")
166+
167+
self.step(3)
110168
asserts.assert_equal(device.isSessionOverTCPConnection, True, "Session does not have associated TCP connection")
111169

170+
self.step(4)
112171
device.closeTCPConnectionWithPeer()
172+
173+
self.step(5)
113174
asserts.assert_equal(device.isActiveSession, False,
114175
"Large Payload Session should not be active after TCP connection closure")
115176

116177
# Connect again
117178
try:
179+
self.step(6)
118180
device = await self.default_controller.GetConnectedDevice(nodeid=self.dut_node_id, allowPASE=False, timeoutMs=1000,
119181
payloadCapability=ChipDeviceCtrl.TransportPayloadCapability.LARGE_PAYLOAD)
120182
except TimeoutError:
121183
asserts.fail("Unable to establish a CASE session over TCP to the device")
184+
185+
self.step(7)
122186
asserts.assert_equal(device.isSessionOverTCPConnection, True, "Session does not have associated TCP connection")
187+
188+
self.step(8)
123189
asserts.assert_equal(device.isActiveSession, True, "Large Payload Session should be active over TCP connection")
124190

125-
def pics_SC_8_5(self):
191+
def pics_TC_SC_8_5(self):
126192
return ['MCORE.SC.TCP']
127193

194+
def steps_TC_SC_8_5(self) -> list[TestStep]:
195+
steps = [
196+
TestStep(1, "Commissioning, already done", is_commissioning=True),
197+
TestStep(2, "TH initiates a CASE session establishment with DUT, requesting a session supporting large payloads."),
198+
TestStep(3, "Verifying that a session is set up with an underlying TCP connection established with DUT."),
199+
TestStep(4, "Verifying that the large-payload secure session with DUT is active."),
200+
TestStep(5, "TH initiates an InvokeCommandRequest with DUT over the established session."),
201+
TestStep(6, "Verifying successful invocation with DUT over the established session without any error."),
202+
]
203+
return steps
204+
128205
@async_test_body
129206
async def test_TC_SC_8_5(self):
130207

208+
self.step(1)
131209
try:
210+
self.step(2)
132211
device = await self.default_controller.GetConnectedDevice(nodeid=self.dut_node_id, allowPASE=False, timeoutMs=1000,
133212
payloadCapability=ChipDeviceCtrl.TransportPayloadCapability.LARGE_PAYLOAD)
134213
except TimeoutError:
135214
asserts.fail("Unable to establish a CASE session over TCP to the device")
215+
216+
self.step(3)
136217
asserts.assert_equal(device.isSessionOverTCPConnection, True, "Session does not have associated TCP connection")
218+
219+
self.step(4)
137220
asserts.assert_equal(device.isActiveSession, True, "Large Payload Session should be active over TCP connection")
138221
asserts.assert_equal(device.sessionAllowsLargePayload, True, "Session does not have associated TCP connection")
139222

140223
try:
224+
self.step(5)
141225
await self.send_arm_cmd(ChipDeviceCtrl.TransportPayloadCapability.LARGE_PAYLOAD)
142226
except InteractionModelError:
143227
asserts.fail("Unexpected error returned by DUT")
228+
self.step(6)
144229

145-
def pics_SC_8_6(self):
230+
def pics_TC_SC_8_6(self):
146231
return ['MCORE.SC.TCP']
147232

233+
def steps_TC_SC_8_6(self) -> list[TestStep]:
234+
steps = [
235+
TestStep(1, "Commissioning, already done", is_commissioning=True),
236+
TestStep(2, "TH initiates a CASE session establishment with DUT, requesting a session supporting large payloads."),
237+
TestStep(3, "Verifying that a session is set up with an underlying TCP connection established with DUT."),
238+
TestStep(4, "Verifying that the large-payload secure session with DUT is active."),
239+
TestStep(5, "TH initiates a Read of all attributes of all clusters of DUT."),
240+
TestStep(6, "Verifying wildcard read was successful with DUT over the established session without any error."),
241+
]
242+
return steps
243+
148244
# WildCard Read Over TCP Session
149245
@async_test_body
150246
async def test_TC_SC_8_6(self):
151247

248+
self.step(1)
152249
try:
250+
self.step(2)
153251
device = await self.default_controller.GetConnectedDevice(nodeid=self.dut_node_id, allowPASE=False, timeoutMs=1000,
154252
payloadCapability=ChipDeviceCtrl.TransportPayloadCapability.LARGE_PAYLOAD)
155253
except TimeoutError:
156254
asserts.fail("Unable to establish a CASE session over TCP to the device")
255+
256+
self.step(3)
157257
asserts.assert_equal(device.isSessionOverTCPConnection, True, "Session does not have associated TCP connection")
258+
259+
self.step(4)
158260
asserts.assert_equal(device.isActiveSession, True, "Large Payload Session should be active over TCP connection")
159261
asserts.assert_equal(device.sessionAllowsLargePayload, True, "Session does not have associated TCP connection")
160262

161263
try:
264+
self.step(5)
162265
await self.default_controller.Read(self.dut_node_id, [()], payloadCapability=ChipDeviceCtrl.TransportPayloadCapability.LARGE_PAYLOAD)
163266
except InteractionModelError:
164267
asserts.fail("Unexpected error returned by DUT")
268+
self.step(6)
165269

166-
def pics_SC_8_7(self):
270+
def pics_TC_SC_8_7(self):
167271
return ['MCORE.SC.TCP']
168272

273+
def steps_TC_SC_8_7(self) -> list[TestStep]:
274+
steps = [
275+
TestStep(1, "Commissioning, already done", is_commissioning=True),
276+
TestStep(2, "TH initiates a CASE session establishment with DUT, requesting a session supporting large payloads."),
277+
TestStep(3, "Verifying that a session is set up with an underlying TCP connection established with DUT."),
278+
TestStep(4, "Verifying that the large-payload secure session with DUT is active."),
279+
TestStep(5, "TH initiates a regularly-sized InvokeCommandRequest with DUT, specifying that either a MRP or TCP-based session is usable."),
280+
TestStep(6, "Verifying successful invocation with DUT over the established TCP-based session without any error."),
281+
]
282+
return steps
283+
169284
# Use TCP Session If Available For MRP Interaction
170285
@async_test_body
171286
async def test_TC_SC_8_7(self):
172287

288+
self.step(1)
289+
173290
try:
291+
self.step(2)
174292
device = await self.default_controller.GetConnectedDevice(nodeid=self.dut_node_id, allowPASE=False, timeoutMs=1000,
175293
payloadCapability=ChipDeviceCtrl.TransportPayloadCapability.LARGE_PAYLOAD)
176294
except TimeoutError:
177295
asserts.fail("Unable to establish a CASE session over TCP to the device")
296+
297+
self.step(3)
178298
asserts.assert_equal(device.isSessionOverTCPConnection, True, "Session does not have associated TCP connection")
299+
300+
self.step(4)
179301
asserts.assert_equal(device.isActiveSession, True, "Large Payload Session should be active over TCP connection")
180302
asserts.assert_equal(device.sessionAllowsLargePayload, True, "Session does not have associated TCP connection")
181303

182304
try:
305+
self.step(5)
183306
self.send_arm_cmd(ChipDeviceCtrl.TransportPayloadCapability.MRP_OR_TCP_PAYLOAD)
184307
except InteractionModelError:
185308
asserts.fail("Unexpected error returned by DUT")
309+
self.step(6)
186310

187311

188312
if __name__ == "__main__":

0 commit comments

Comments
 (0)