Skip to content

Commit

Permalink
Add test which loads firmware during warmboot
Browse files Browse the repository at this point in the history
Summary:
In prod, we plan to enable/update FW across a warm boot
via config change. Add a test to test loading the FW across a warm boot

Reviewed By: shri-khare

Differential Revision: D68816000

fbshipit-source-id: ecccc4310d759ca5e4d92fead13d9f360f4b5f3a
  • Loading branch information
Jasmeet Bagga authored and facebook-github-bot committed Jan 30, 2025
1 parent debb3c8 commit a249fd3
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fboss/agent/test/AgentHwTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class AgentHwTest : public ::testing::Test {
~AgentHwTest() override = default;
void SetUp() override;
void TearDown() override;
void tearDownAgentEnsemble(bool doWarmboot = false);
virtual void tearDownAgentEnsemble(bool doWarmboot = false);
using StateUpdateFn = SwSwitch::StateUpdateFn;

protected:
Expand Down
44 changes: 44 additions & 0 deletions fboss/agent/test/agent_hw_tests/AgentVoqSwitchFirmwareTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,36 @@ class AgentVoqSwitchIsolationFirmwareTest : public AgentVoqSwitchTest {
}
};

class AgentVoqSwitchIsolationFirmwareUpdateTest
: public AgentVoqSwitchIsolationFirmwareTest {
public:
cfg::SwitchConfig initialConfig(
const AgentEnsemble& ensemble) const override {
auto config = utility::onePortPerInterfaceConfig(
ensemble.getSw(),
ensemble.masterLogicalPortIds(),
true, /*interfaceHasSubnet*/
true, /*setInterfaceMac*/
utility::kBaseVlanId,
true /*enable fabric ports*/);
utility::populatePortExpectedNeighborsToSelf(
ensemble.masterLogicalPortIds(), config);
return config;
}
void tearDownAgentEnsemble(bool warmboot = false) override {
// We check for agentEnsemble not being NULL since the tests
// are also invoked for just listing their prod features.
// Then in such case, agentEnsemble is never setup
if (getAgentEnsemble() && getSw()->getBootType() == BootType::COLD_BOOT) {
auto agentConfig = getSw()->getAgentConfig();
const auto& configFileName = getAgentEnsemble()->configFileName();
agentConfig.sw() = addFwConfig(*agentConfig.sw());
AgentEnsemble::writeConfig(agentConfig, configFileName);
}
AgentHwTest::tearDownAgentEnsemble(warmboot);
}
};

TEST_F(AgentVoqSwitchIsolationFirmwareTest, forceIsolate) {
auto setup = [this]() {
assertPortAndDrainState(false /* not drained*/);
Expand Down Expand Up @@ -212,4 +242,18 @@ TEST_F(AgentVoqSwitchIsolationFirmwareTest, forceCrashDuringWarmBoot) {
auto verifyPostWarmboot = [this]() { forceIsolatePostCrashAndVerify(); };
verifyAcrossWarmBoots(setup, []() {}, []() {}, verifyPostWarmboot);
}

TEST_F(AgentVoqSwitchIsolationFirmwareUpdateTest, loadOnWarmboot) {
auto setup = [this]() {
assertPortAndDrainState(false /* not drained*/);
setMinLinksConfig();
};

auto verifyPostWarmboot = [this]() {
forceIsolate();
assertSwitchDrainState(true /* drained */);
};
verifyAcrossWarmBoots(setup, []() {}, []() {}, verifyPostWarmboot);
}

} // namespace facebook::fboss

0 comments on commit a249fd3

Please sign in to comment.