Skip to content

Commit 2c27b13

Browse files
committed
Added dependency and review commit
1 parent 16dba83 commit 2c27b13

1 file changed

Lines changed: 32 additions & 24 deletions

File tree

tests/platform_tests/api/test_watchdog.py

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,45 +55,48 @@ def conf(self, request, duthost):
5555

5656
self.expect('valid_timeout' in config, "valid_timeout is not defined in config")
5757
# make sure watchdog won't reboot the system when test sleeps for @TEST_WAIT_TIME_SECONDS
58-
self.expect(config['valid_timeout'] > TEST_WAIT_TIME_SECONDS * 2, "valid_timeout {} is too short".format(config['valid_timeout']))
58+
self.expect(config['valid_timeout'] > TEST_WAIT_TIME_SECONDS * 2, "valid_timeout {} seconds is too short".format(config['valid_timeout']))
5959
self.assert_expectations()
6060
return config
6161

62+
@pytest.mark.dependency()
6263
def test_arm_disarm_states(self, duthost, localhost, platform_api_conn, conf):
6364
''' arm watchdog with a valid timeout value, verify it is in armed state,
6465
disarm watchdog and verify it is in disarmed state
6566
'''
6667
watchdog_timeout = conf['valid_timeout']
6768
actual_timeout = watchdog.arm(platform_api_conn, watchdog_timeout)
6869

69-
if self.expect(actual_timeout is not None, "Failed to arm the watchdog"):
70-
self.expect(actual_timeout >= watchdog_timeout, "Actual watchdog setting with {} apears wrong from the original setting {}".format(actual_timeout, watchdog_timeout))
70+
if self.expect(actual_timeout is not None, "Watchdog.arm is not supported"):
71+
if self.expect(actual_timeout != -1, "Failed to arm the watchdog"):
72+
self.expect(actual_timeout >= watchdog_timeout, "Actual watchdog {} seconds apears wrong, should be less than {} seconds".format(actual_timeout, watchdog_timeout))
7173

7274
watchdog_status = watchdog.is_armed(platform_api_conn)
73-
if self.expect(watchdog_status is not None, "Failed to check the watchdog status"):
74-
self.expect(watchdog_status is True, "Watchdog armed is expected but not armed.")
75+
if self.expect(watchdog_status is not None, "Failed to retrieve watchdog status"):
76+
self.expect(watchdog_status is True, "Watchdog is not armed.")
7577

7678
remaining_time = watchdog.get_remaining_time(platform_api_conn)
7779
if self.expect(remaining_time is not None, "Failed to get the remaining time of watchdog"):
78-
self.expect(remaining_time <= watchdog_timeout, "watchdog remaining_time is not expected value {}".format(remaining_time))
80+
self.expect(remaining_time <= watchdog_timeout, "Watchdog remaining_time {} seconds is wrong compared to watchdog timeout {} seocnds".format(remaining_time))
7981

8082
watchdog_status = watchdog.disarm(platform_api_conn)
81-
if self.expect(watchdog_status is not None, "Failed to disarm the watchdog"):
82-
self.expect(watchdog_status is True, "Watchdog disarm returns False")
83+
if self.expect(watchdog_status is not None, "Watchdog.disarm is not supported"):
84+
self.expect(watchdog_status is True, "Failed to disarm the watchdog")
8385

8486
watchdog_status = watchdog.is_armed(platform_api_conn)
8587
if self.expect(watchdog_status is not None, "Failed to check the watchdog status"):
86-
self.expect(watchdog_status is False, "Watchdog disarmed is expected but armed")
88+
self.expect(watchdog_status is False, "Watchdog is not disarmed")
8789

8890
remaining_time = watchdog.get_remaining_time(platform_api_conn)
8991
if self.expect(remaining_time is not None, "Failed to get the remaining time of watchdog"):
90-
self.expect(remaining_time is -1, "watchdog remaining_time is not expected value {}".format(remaining_time))
92+
self.expect(remaining_time is -1, "Watchdog remaining_time {} seconds is wrong for disarmed state".format(remaining_time))
9193

9294
res = localhost.wait_for(host=duthost.hostname, port=22, state="stopped", delay=5, timeout=watchdog_timeout + TIMEOUT_DEVIATION, module_ignore_errors=True)
9395

9496
self.expect('exception' in res, "unexpected disconnection from dut")
9597
self.assert_expectations()
9698

99+
@pytest.mark.dependency(depends=["test_arm_disarm_states"])
97100
def test_remaining_time(self, duthost, platform_api_conn, conf):
98101
''' arm watchdog with a valid timeout and verify that remaining time API works correctly '''
99102

@@ -107,15 +110,16 @@ def test_remaining_time(self, duthost, platform_api_conn, conf):
107110
remaining_time = watchdog.get_remaining_time(platform_api_conn)
108111

109112
if self.expect(actual_timeout >= watchdog_timeout, "watchdog arm with {} seconds failed".format(watchdog_timeout)):
110-
if self.expect(remaining_time > 0, "watchdog remaining_time {} is not valid".format(remaining_time)):
111-
self.expect(remaining_time <= actual_timeout, "remaining_time {} should be less than watchdog armed timeout {}".format(remaining_timeout, actual_timeout))
113+
if self.expect(remaining_time > 0, "Remaining_time {} seconds is not valid".format(remaining_time)):
114+
self.expect(remaining_time <= actual_timeout, "Remaining_time {} seconds should be less than watchdog armed timeout {} seconds".format(remaining_timeout, actual_timeout))
112115

113116
remaining_time = watchdog.get_remaining_time(platform_api_conn)
114117
time.sleep(TEST_WAIT_TIME_SECONDS)
115118
remaining_time_new = watchdog.get_remaining_time(platform_api_conn)
116-
self.expect(remaining_time_new < remaining_time, "remaining_time {} should be decreased from previous remaining_time {}".format(remaining_time_new, remaining_time))
119+
self.expect(remaining_time_new < remaining_time, "Remaining_time {} seconds should be decreased from previous remaining_time {} seconds".format(remaining_time_new, remaining_time))
117120
self.assert_expectations()
118121

122+
@pytest.mark.dependency(depends=["test_arm_disarm_states"])
119123
def test_periodic_arm(self, duthost, platform_api_conn, conf):
120124
''' arm watchdog several times as watchdog deamon would and verify API behaves correctly '''
121125

@@ -126,10 +130,11 @@ def test_periodic_arm(self, duthost, platform_api_conn, conf):
126130
actual_timeout_new = watchdog.arm(platform_api_conn, watchdog_timeout)
127131
remaining_time_new = watchdog.get_remaining_time(platform_api_conn)
128132

129-
self.expect(actual_timeout == actual_timeout_new, "{}: new watchdog timeout {} setting should be same as the previous actual watchdog timeout {}".format(test_periodic_arm.__name__, actual_timeout_new, actual_timeout))
130-
self.expect(remaining_time_new > remaining_time, "{}: new remaining timeout {} should be bigger than the previous remaining timeout {} by {}".format(test_periodic_arm.__name__, remaining_time_new, remaining_time, TEST_WAIT_TIME_SECONDS))
133+
self.expect(actual_timeout == actual_timeout_new, "{}: new watchdog timeout {} seconds setting should be same as the previous actual watchdog timeout {} seconds".format(test_periodic_arm.__name__, actual_timeout_new, actual_timeout))
134+
self.expect(remaining_time_new > remaining_time, "{}: new remaining timeout {} seconds should be bigger than the previous remaining timeout {} seconds by {} seconds".format(test_periodic_arm.__name__, remaining_time_new, remaining_time, TEST_WAIT_TIME_SECONDS))
131135
self.assert_expectations()
132136

137+
@pytest.mark.dependency(depends=["test_arm_disarm_states"])
133138
def test_arm_different_timeout_greater(self, duthost, platform_api_conn, conf):
134139
''' arm the watchdog with greater timeout value and verify new timeout was accepted;
135140
If platform accepts only single valid timeout value, @greater_timeout should be None.
@@ -139,14 +144,15 @@ def test_arm_different_timeout_greater(self, duthost, platform_api_conn, conf):
139144
watchdog_timeout_greater = conf['greater_timeout']
140145
if watchdog_timeout_greater is None:
141146
pytest.skip('"greater_timeout" parameter is required for this test case')
142-
actual_timeout_second = watchdog.arm(platform_api_conn, watchdog_timeout)
147+
actual_timeout = watchdog.arm(platform_api_conn, watchdog_timeout)
143148
remaining_time = watchdog.get_remaining_time(platform_api_conn)
144-
actual_timeout_second_second = watchdog.arm(platform_api_conn, watchdog_timeout_greater)
145-
self.expect(actual_timeout_second < actual_timeout_second_second, "{}: 1st timeout {} should be smaller than 2nd timeout {}".format(test_arm_different_timeout_greater.__name__, actual_timeout_second, actual_timeout_second_second))
146-
remaining_time_second = watchdog.get_remaining_time(platform_api_conn)
147-
self.expect(remaining_time_second > remaining_time, "{}: 2nd remaining_timeout {} should be bigger than 1st remaining timeout {}".format(test_arm_different_timeout_greater.__name__, remaining_time_second, remaining_time))
149+
actual_timeout_greater = watchdog.arm(platform_api_conn, watchdog_timeout_greater)
150+
self.expect(actual_timeout < actual_timeout_greater, "{}: 1st timeout {} seconds should be smaller than 2nd timeout {} seconds".format(test_arm_different_timeout_greater.__name__, actual_timeout, actual_timeout_greater))
151+
remaining_time_greater = watchdog.get_remaining_time(platform_api_conn)
152+
self.expect(remaining_time_greater > remaining_time, "{}: 2nd remaining_timeout {} seconds should be bigger than 1st remaining timeout {} seconds".format(test_arm_different_timeout_greater.__name__, remaining_time_greater, remaining_time))
148153
self.assert_expectations()
149154

155+
@pytest.mark.dependency(depends=["test_arm_disarm_states"])
150156
def test_arm_different_timeout_smaller(self, duthost, platform_api_conn, conf):
151157
''' arm the watchdog with smaller timeout value and verify new timeout was accepted;
152158
If platform accepts only single valid timeout value, @greater_timeout should be None.
@@ -160,11 +166,12 @@ def test_arm_different_timeout_smaller(self, duthost, platform_api_conn, conf):
160166
remaining_time = watchdog.get_remaining_time(platform_api_conn)
161167
actual_timeout_smaller = watchdog.arm(platform_api_conn, watchdog_timeout_smaller)
162168

163-
self.expect(actual_timeout > actual_timeout_smaller, "{}: 1st timeout {} should be bigger than 2nd timeout {}".format(test_arm_different_timeout_smaller.__name__, actual_timeout, actual_timeout_smaller))
169+
self.expect(actual_timeout > actual_timeout_smaller, "{}: 1st timeout {} seconds should be bigger than 2nd timeout {} seconds".format(test_arm_different_timeout_smaller.__name__, actual_timeout, actual_timeout_smaller))
164170
remaining_time_smaller = watchdog.get_remaining_time(platform_api_conn)
165-
self.expect(remaining_time_smaller < remaining_time, "{}: 2nd remaining_timeout {} should be smaller than 1st remaining timeout {}".format(test_arm_different_timeout_smaller.__name__, remaining_time_smaller, remaining_time))
171+
self.expect(remaining_time_smaller < remaining_time, "{}: 2nd remaining_timeout {} seconds should be smaller than 1st remaining timeout {} seconds".format(test_arm_different_timeout_smaller.__name__, remaining_time_smaller, remaining_time))
166172
self.assert_expectations()
167173

174+
@pytest.mark.dependency(depends=["test_arm_disarm_states"])
168175
def test_arm_too_big_timeout(self, duthost, platform_api_conn, conf):
169176
''' try to arm the watchdog with timeout that is too big for hardware watchdog;
170177
If no such limitation exist, @too_big_timeout should be None for such platform.
@@ -174,13 +181,14 @@ def test_arm_too_big_timeout(self, duthost, platform_api_conn, conf):
174181
if watchdog_timeout is None:
175182
pytest.skip('"too_big_timeout" parameter is required for this test case')
176183
actual_timeout = watchdog.arm(platform_api_conn, watchdog_timeout)
177-
self.expect(actual_timeout == -1, "{}: watchdog time {} shouldn't be set".format(test_arm_too_big_timeout.__name__, watchdog_timeout))
184+
self.expect(actual_timeout == -1, "{}: watchdog time {} seconds shouldn't be set for big {} seconds".format(test_arm_too_big_timeout.__name__, actual_timeout, watchdog_timeout))
178185
self.assert_expectations()
179186

187+
@pytest.mark.dependency(depends=["test_arm_disarm_states"])
180188
def test_arm_negative_timeout(self, duthost, platform_api_conn):
181189
''' try to arm the watchdog with negative value '''
182190

183191
watchdog_timeout = -1
184192
actual_timeout = watchdog.arm(platform_api_conn, watchdog_timeout)
185-
self.expect(actual_timeout == -1, "{}: watchdog time {} shouldn't be set".format(test_arm_negative_timeout.__name__, watchdog_timeout))
193+
self.expect(actual_timeout == -1, "{}: watchdog time {} seconds shouldn't be set for negative {} seconds".format(test_arm_negative_timeout.__name__, actual_timeout, watchdog_timeout))
186194
self.assert_expectations()

0 commit comments

Comments
 (0)