Skip to content

Commit 3d54e5a

Browse files
Jasmeet Baggafacebook-github-bot
Jasmeet Bagga
authored andcommitted
Ensure that we wait long enough during teardown for the delayed event to happen
Summary: Used for force{Crash,Isolate}DuringWarmboot test. - Delay the event by 20 seconds - Exit for WB (this should happen much sooner than 20 secs). Most importantly the unregister of callbacks should happen before 20secs - Wait 2X20 secs post the time switch has already been destroyed for WB - This ensures that the delayed event has happened while callbacks are unregistered. Post WB take actions to ensure that the desired action happened Reviewed By: shri-khare Differential Revision: D68879202 fbshipit-source-id: 36a97a1c386642a3ae0e5ba108d930765c082902
1 parent 317aa96 commit 3d54e5a

File tree

1 file changed

+38
-19
lines changed

1 file changed

+38
-19
lines changed

fboss/agent/test/agent_hw_tests/AgentVoqSwitchFirmwareTests.cpp

+38-19
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,23 @@ class AgentVoqSwitchIsolationFirmwareTest : public AgentVoqSwitchTest {
146146
}
147147
};
148148

149+
class AgentVoqSwitchIsolationFirmwareWBEventsTest
150+
: public AgentVoqSwitchIsolationFirmwareTest {
151+
public:
152+
static constexpr auto kEventDelay = 20;
153+
void tearDownAgentEnsemble(bool warmboot = false) override {
154+
// We check for agentEnsemble not being NULL since the tests
155+
// are also invoked for just listing their prod features.
156+
// Then in such case, agentEnsemble is never setup
157+
bool isColdBoot =
158+
getAgentEnsemble() && getSw()->getBootType() == BootType::COLD_BOOT;
159+
AgentHwTest::tearDownAgentEnsemble(warmboot);
160+
if (isColdBoot) {
161+
sleep(kEventDelay * 2);
162+
}
163+
}
164+
};
165+
149166
class AgentVoqSwitchIsolationFirmwareUpdateTest
150167
: public AgentVoqSwitchIsolationFirmwareTest {
151168
public:
@@ -193,23 +210,6 @@ TEST_F(AgentVoqSwitchIsolationFirmwareTest, forceIsolate) {
193210
verifyAcrossWarmBoots(setup, verify);
194211
}
195212

196-
TEST_F(AgentVoqSwitchIsolationFirmwareTest, forceIsolateDuringWarmBoot) {
197-
auto setup = [this]() {
198-
assertPortAndDrainState(false /* not drained*/);
199-
setMinLinksConfig();
200-
forceIsolate(20);
201-
};
202-
203-
auto verifyPostWarmboot = [this]() {
204-
assertSwitchDrainState(true /* drained */);
205-
utility::checkFabricPortsActiveState(
206-
getAgentEnsemble(),
207-
masterLogicalFabricPortIds(),
208-
true /* expect active*/);
209-
};
210-
verifyAcrossWarmBoots(setup, []() {}, []() {}, verifyPostWarmboot);
211-
}
212-
213213
TEST_F(AgentVoqSwitchIsolationFirmwareTest, forceCrash) {
214214
auto setup = [this]() {
215215
assertPortAndDrainState(false /* not drained*/);
@@ -230,13 +230,32 @@ TEST_F(AgentVoqSwitchIsolationFirmwareTest, forceCrash) {
230230
verifyAcrossWarmBoots(setup, verify);
231231
}
232232

233-
TEST_F(AgentVoqSwitchIsolationFirmwareTest, forceCrashDuringWarmBoot) {
233+
TEST_F(
234+
AgentVoqSwitchIsolationFirmwareWBEventsTest,
235+
forceIsolateDuringWarmBoot) {
236+
auto setup = [this]() {
237+
assertPortAndDrainState(false /* not drained*/);
238+
setMinLinksConfig();
239+
forceIsolate(kEventDelay);
240+
};
241+
242+
auto verifyPostWarmboot = [this]() {
243+
assertSwitchDrainState(true /* drained */);
244+
utility::checkFabricPortsActiveState(
245+
getAgentEnsemble(),
246+
masterLogicalFabricPortIds(),
247+
true /* expect active*/);
248+
};
249+
verifyAcrossWarmBoots(setup, []() {}, []() {}, verifyPostWarmboot);
250+
}
251+
252+
TEST_F(AgentVoqSwitchIsolationFirmwareWBEventsTest, forceCrashDuringWarmBoot) {
234253
auto setup = [this]() {
235254
assertPortAndDrainState(false /* not drained*/);
236255
setMinLinksConfig();
237256
// Force delayed crash - which most likely
238257
// will now happen while switch is warm booting
239-
forceCrash(20);
258+
forceCrash(kEventDelay);
240259
};
241260

242261
auto verifyPostWarmboot = [this]() { forceIsolatePostCrashAndVerify(); };

0 commit comments

Comments
 (0)