-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Pre Agent Executor for NetOS Native
Summary: Updating Pre Agent Executor To run correctly in the NetOS Environment. 1. Created a separate runNetOS for startup - Removed all systemd references since the systemd units defined in the netOS container environment handles this. - Temporarily Removed FBOSS Update Build Info since there is no plans on it. Task: T198905811 2. Added Command Line Args for ``--netos`` and ``--switch_index <int32>``` respectively - both these need to be passed to run the new runNetOs flow. - Only hw_agent_0 would ever run this and the hw_agent_1 would be no-op in this case and be skipped Assumptions: in NetOS: cpp_agent_wrapper and multi_switch are always enabled Reviewed By: peygar Differential Revision: D60749563 fbshipit-source-id: 31c7b09ea35a1bdd60126ca7a9a5a02821c359c7
- Loading branch information
1 parent
009fd92
commit d12f0e4
Showing
3 changed files
with
144 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,32 +21,49 @@ using ::testing::_; | |
namespace facebook::fboss { | ||
|
||
namespace { | ||
template <bool multiSwitch, bool cppRefactor, bool sai, bool brcm> | ||
template <bool multiSwitch, bool cppRefactor, bool sai, bool brcm, bool netOS> | ||
struct TestAttr { | ||
static constexpr bool kMultiSwitch = multiSwitch; | ||
static constexpr bool kCppRefactor = cppRefactor; | ||
static constexpr bool kSai = sai; | ||
static constexpr bool kBrcm = brcm; | ||
static constexpr bool kNetOS = netOS; | ||
}; | ||
|
||
#define TEST_ATTR(NAME, a, b, c, d) \ | ||
struct TestAttr##NAME : public TestAttr<a, b, c, d> {}; | ||
|
||
TEST_ATTR(NoMultiSwitchNoCppRefactorNoSaiBrcm, false, false, false, true); | ||
TEST_ATTR(NoMultiSwitchNoCppRefactorSaiBrcm, false, false, true, true); | ||
TEST_ATTR(NoMultiSwitchNoCppRefactorSaiNoBrcm, false, false, true, false); | ||
|
||
TEST_ATTR(NoMultiSwitchCppRefactorNoSaiBrcm, false, true, false, true); | ||
TEST_ATTR(NoMultiSwitchCppRefactorSaiBrcm, false, true, true, true); | ||
TEST_ATTR(NoMultiSwitchCppRefactorSaiNoBrcm, false, true, true, false); | ||
|
||
TEST_ATTR(MultiSwitchNoCppRefactorNoSaiBrcm, true, false, false, true); | ||
TEST_ATTR(MultiSwitchNoCppRefactorSaiBrcm, true, false, true, true); | ||
TEST_ATTR(MultiSwitchNoCppRefactorSaiNoBrcm, true, false, true, false); | ||
|
||
TEST_ATTR(MultiSwitchCppRefactorNoSaiBrcm, true, true, false, true); | ||
TEST_ATTR(MultiSwitchCppRefactorSaiBrcm, true, true, true, true); | ||
TEST_ATTR(MultiSwitchCppRefactorSaiNoBrcm, true, true, true, false); | ||
#define TEST_ATTR(NAME, a, b, c, d, e) \ | ||
struct TestAttr##NAME : public TestAttr<a, b, c, d, e> {}; | ||
|
||
TEST_ATTR( | ||
NoMultiSwitchNoCppRefactorNoSaiBrcm, | ||
false, | ||
false, | ||
false, | ||
true, | ||
false); | ||
TEST_ATTR(NoMultiSwitchNoCppRefactorSaiBrcm, false, false, true, true, false); | ||
TEST_ATTR( | ||
NoMultiSwitchNoCppRefactorSaiNoBrcm, | ||
false, | ||
false, | ||
true, | ||
false, | ||
false); | ||
|
||
TEST_ATTR(NoMultiSwitchCppRefactorNoSaiBrcm, false, true, false, true, false); | ||
TEST_ATTR(NoMultiSwitchCppRefactorSaiBrcm, false, true, true, true, false); | ||
TEST_ATTR(NoMultiSwitchCppRefactorSaiNoBrcm, false, true, true, false, false); | ||
|
||
TEST_ATTR(MultiSwitchNoCppRefactorNoSaiBrcm, true, false, false, true, false); | ||
TEST_ATTR(MultiSwitchNoCppRefactorSaiBrcm, true, false, true, true, false); | ||
TEST_ATTR(MultiSwitchNoCppRefactorSaiNoBrcm, true, false, true, false, false); | ||
|
||
TEST_ATTR(MultiSwitchCppRefactorNoSaiBrcm, true, true, false, true, false); | ||
TEST_ATTR(MultiSwitchCppRefactorSaiBrcm, true, true, true, true, false); | ||
TEST_ATTR(MultiSwitchCppRefactorSaiNoBrcm, true, true, true, false, false); | ||
|
||
TEST_ATTR(MultiSwitchCppRefactorNetOsNoSaiBrcm, true, true, false, true, true); | ||
TEST_ATTR(MultiSwitchCppRefactorNetOsSaiBrcm, true, true, true, true, true); | ||
TEST_ATTR(MultiSwitchCppRefactorNetOsSaiNoBrcm, true, true, true, false, true); | ||
} // namespace | ||
|
||
template <typename TestAttr> | ||
|
@@ -150,80 +167,92 @@ class AgentPreStartExecTests : public ::testing::Test { | |
std::vector<std::string> installKmod{ | ||
kmodsInstaller, "install", "--sdk-upgrade", kmodVersion}; | ||
EXPECT_CALL(executor, runCommand(installKmod, true)).Times(1); | ||
EXPECT_CALL(*netwhoami, isBcmSaiPlatform()) | ||
.WillOnce(Return(TestAttr::kSai && TestAttr::kBrcm)); | ||
if (!TestAttr::kNetOS) { | ||
// wedge agent binaries not included in netOS | ||
EXPECT_CALL(*netwhoami, isBcmSaiPlatform()) | ||
.WillOnce(Return(TestAttr::kSai && TestAttr::kBrcm)); | ||
} | ||
if (TestAttr::kMultiSwitch) { | ||
// once again for hw agent | ||
EXPECT_CALL(*netwhoami, isBcmSaiPlatform()) | ||
.WillOnce(Return(TestAttr::kSai && TestAttr::kBrcm)); | ||
} | ||
EXPECT_CALL(*netwhoami, isBcmVoqPlatform()).WillOnce(Return(voq)); | ||
if (TestAttr::kMultiSwitch) { | ||
EXPECT_CALL( | ||
executor, | ||
runCommand( | ||
std::vector<std::string>{ | ||
"/usr/bin/systemctl", | ||
"enable", | ||
util_->getSwAgentServicePath()}, | ||
true)); | ||
EXPECT_CALL( | ||
executor, | ||
runCommand( | ||
std::vector<std::string>{ | ||
"/usr/bin/systemctl", | ||
"enable", | ||
util_->getHwAgentServiceInstance(0)}, | ||
true)); | ||
|
||
EXPECT_CALL( | ||
executor, | ||
runCommand( | ||
std::vector<std::string>{ | ||
"/usr/bin/systemctl", | ||
"enable", | ||
util_->getHwAgentServiceInstance(1)}, | ||
true)); | ||
} else { | ||
EXPECT_CALL( | ||
executor, | ||
runCommand( | ||
std::vector<std::string>{ | ||
"/usr/bin/systemctl", "disable", "fboss_sw_agent"}, | ||
false)); | ||
if (voq) { | ||
EXPECT_CALL(*netwhoami, isBcmSaiPlatform()) | ||
.WillOnce(Return(TestAttr::kSai && TestAttr::kBrcm)); | ||
} | ||
if (!TestAttr::kNetOS) { | ||
if (TestAttr::kMultiSwitch) { | ||
EXPECT_CALL( | ||
executor, | ||
runCommand( | ||
std::vector<std::string>{ | ||
"/usr/bin/systemctl", | ||
"enable", | ||
util_->getSwAgentServicePath()}, | ||
true)); | ||
EXPECT_CALL( | ||
executor, | ||
runCommand( | ||
std::vector<std::string>{ | ||
"/usr/bin/systemctl", | ||
"enable", | ||
util_->getHwAgentServiceInstance(0)}, | ||
true)); | ||
|
||
EXPECT_CALL( | ||
executor, | ||
runCommand( | ||
std::vector<std::string>{ | ||
"/usr/bin/systemctl", | ||
"disable", | ||
"[email protected]"}, | ||
false)); | ||
EXPECT_CALL( | ||
executor, | ||
runCommand( | ||
std::vector<std::string>{ | ||
"/usr/bin/systemctl", | ||
"enable", | ||
util_->getHwAgentServiceInstance(1)}, | ||
true)); | ||
} else { | ||
EXPECT_CALL( | ||
executor, | ||
runCommand( | ||
std::vector<std::string>{ | ||
"/usr/bin/systemctl", "disable", "fboss_sw_agent"}, | ||
false)); | ||
|
||
if (TestAttr::kMultiSwitch) { | ||
EXPECT_CALL( | ||
executor, | ||
runCommand( | ||
std::vector<std::string>{ | ||
"/usr/bin/systemctl", | ||
"disable", | ||
"fboss_hw_agent@1.service"}, | ||
"fboss_hw_agent@0.service"}, | ||
false)); | ||
|
||
if (TestAttr::kMultiSwitch) { | ||
EXPECT_CALL( | ||
executor, | ||
runCommand( | ||
std::vector<std::string>{ | ||
"/usr/bin/systemctl", | ||
"disable", | ||
"[email protected]"}, | ||
false)); | ||
} | ||
} | ||
|
||
// update-buildinfo | ||
EXPECT_CALL( | ||
executor, runShellCommand("/usr/local/bin/fboss-build-info", false)) | ||
.Times(1); | ||
} | ||
// update-buildinfo | ||
EXPECT_CALL( | ||
executor, runShellCommand("/usr/local/bin/fboss-build-info", false)) | ||
.Times(1); | ||
} | ||
|
||
exec.run( | ||
&executor, | ||
std::move(netwhoami), | ||
*util_, | ||
std::make_unique<AgentConfig>(getConfig()), | ||
TestAttr::kCppRefactor); | ||
TestAttr::kCppRefactor, | ||
TestAttr::kNetOS, | ||
0); | ||
|
||
if (TestAttr::kCppRefactor) { | ||
auto verifySymLink = [&](const std::string& name, | ||
|
@@ -234,14 +263,24 @@ class AgentPreStartExecTests : public ::testing::Test { | |
util_->getPackageDirectory() + "/" + sdk + "/" + name; | ||
EXPECT_EQ(actualTarget.string(), expectedTarget); | ||
}; | ||
verifySymLink( | ||
"wedge_agent", | ||
// sai + brcm has directories with sai sdk version | ||
// non-sai + brcm and non-brcm has directories with asic sdk version | ||
TestAttr::kSai && TestAttr::kBrcm | ||
? getSaiSdkVersion(getSdkVersion()) | ||
: getAsicSdkVersion(getSdkVersion())); | ||
|
||
if (!TestAttr::kNetOS) { | ||
verifySymLink( | ||
"wedge_agent", | ||
// sai + brcm has directories with sai sdk version | ||
// non-sai + brcm and non-brcm has directories with asic sdk version | ||
TestAttr::kSai && TestAttr::kBrcm | ||
? getSaiSdkVersion(getSdkVersion()) | ||
: getAsicSdkVersion(getSdkVersion())); | ||
} | ||
if (TestAttr::kMultiSwitch) { | ||
verifySymLink( | ||
"fboss_hw_agent", | ||
// sai + brcm has directories with sai sdk version | ||
// non-sai + brcm and non-brcm has directories with asic sdk version | ||
TestAttr::kSai && TestAttr::kBrcm | ||
? getSaiSdkVersion(getSdkVersion()) | ||
: getAsicSdkVersion(getSdkVersion())); | ||
} | ||
if (coldBoot) { | ||
EXPECT_TRUE(checkFileExists(util_->getSwColdBootOnceFile())); | ||
auto cfg = getConfig(); | ||
|
@@ -289,15 +328,19 @@ class AgentPreStartExecTests : public ::testing::Test { | |
std::move(netwhoami), | ||
*util_, | ||
std::make_unique<AgentConfig>(getConfig()), | ||
TestAttr::kCppRefactor), | ||
TestAttr::kCppRefactor, | ||
TestAttr::kNetOS, | ||
0), | ||
FbossError); | ||
} else { | ||
exec.run( | ||
&executor, | ||
std::move(netwhoami), | ||
*util_, | ||
std::make_unique<AgentConfig>(getConfig()), | ||
TestAttr::kCppRefactor); | ||
TestAttr::kCppRefactor, | ||
TestAttr::kNetOS, | ||
0); | ||
} | ||
} | ||
|
||
|
@@ -443,6 +486,10 @@ TestFixtureName(MultiSwitchCppRefactorNoSaiBrcm); | |
TestFixtureName(MultiSwitchCppRefactorSaiBrcm); | ||
TestFixtureName(MultiSwitchCppRefactorSaiNoBrcm); | ||
|
||
TestFixtureName(MultiSwitchCppRefactorNetOsNoSaiBrcm); | ||
TestFixtureName(MultiSwitchCppRefactorNetOsSaiBrcm); | ||
TestFixtureName(MultiSwitchCppRefactorNetOsSaiNoBrcm); | ||
|
||
TestFixtureNameFdsw(NoMultiSwitchCppRefactorSaiBrcm); | ||
TestFixtureNameFdsw(NoMultiSwitchCppRefactorNoSaiBrcm); | ||
TestFixtureNameFdsw(NoMultiSwitchCppRefactorSaiNoBrcm); | ||
|