Skip to content

Commit

Permalink
create load balancers with config apply and override seed in hw tests
Browse files Browse the repository at this point in the history
Summary: as titled, this is to make transition to migrate load balancer tests to agent hw tests

Reviewed By: jasmeetbagga

Differential Revision: D56039338

fbshipit-source-id: e6eeb6846a3d17dc76a297441b849b9321daf612
  • Loading branch information
Parvez Shaikh authored and facebook-github-bot committed Apr 18, 2024
1 parent 9e5b74e commit 59a29b9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 25 deletions.
4 changes: 4 additions & 0 deletions fboss/agent/hw/test/HwSwitchEnsemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,11 @@ void HwSwitchEnsemble::applyInitialConfig(const cfg::SwitchConfig& initCfg) {
CHECK(haveFeature(HwSwitchEnsemble::LINKSCAN))
<< "Link scan feature must be enabled for exercising "
<< "applyInitialConfig";

linkToggler_->applyInitialConfig(initCfg);
/* link togglers apply config with ports down and bring ports up differently
*/
currentConfig_ = initCfg;
}

void HwSwitchEnsemble::linkStateChanged(
Expand Down
16 changes: 14 additions & 2 deletions fboss/agent/hw/test/dataplane_tests/HwLoadBalancerTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,18 @@ class HwLoadBalancerTest
bool loopThroughFrontPanel = false,
bool loadBalanceExpected = true,
uint8_t deviation = 25) {
/* TODO: remove this hack.
* apply thrift config relies on sdk version in switch config to determine
* how to compute load balancer seeds. however sdk version is unavailable in
* hw tests unlike agent tests. remove this hack when hw tests can inject
* sdk version in thrift config.
*/
auto lbConfig = loadBalancer;
auto seed = getHwSwitch()->generateDeterministicSeed(*lbConfig.id());
lbConfig.seed() = seed;
Runner::runLoadBalanceTest(
ecmpWidth,
loadBalancer,
lbConfig,
weights,
loopThroughFrontPanel,
loadBalanceExpected,
Expand All @@ -63,9 +72,12 @@ class HwLoadBalancerTest
bool loopThroughFrontPanel = false,
bool loadBalanceExpected = true,
uint8_t deviation = 25) {
auto lbConfig = loadBalancer;
auto seed = getHwSwitch()->generateDeterministicSeed(*lbConfig.id());
lbConfig.seed() = seed;
Runner::runDynamicLoadBalanceTest(
ecmpWidth,
loadBalancer,
lbConfig,
weights,
loopThroughFrontPanel,
loadBalanceExpected,
Expand Down
34 changes: 16 additions & 18 deletions fboss/agent/test/utils/EcmpDataPlaneTestUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,27 +101,25 @@ bool HwEcmpDataPlaneTestUtil<EcmpSetupHelperT>::isLoadBalanced(
template <typename AddrT>
void HwEcmpDataPlaneTestUtil<AddrT>::programLoadBalancer(
const cfg::LoadBalancer& lb) {
if (ensemble_->getHwAsicTable()
->getSwitchIDs(HwAsic::Feature::HASH_FIELDS_CUSTOMIZATION)
.empty()) {
return;
}
auto config = ensemble_->getCurrentConfig();
config.loadBalancers()->clear();
config.loadBalancers()->push_back(lb);
if (ensemble_->isSai()) {
// always program half lag hash for sai switches, see CS00012317640
ensemble_->applyNewState(
[this, lb](const std::shared_ptr<SwitchState>& state) {
return utility::addLoadBalancers(
ensemble_,
state,
{lb,
utility::getTrunkHalfHashConfig(
*ensemble_->getHwAsicTable()->getHwAsic(SwitchID(0)))},
ensemble_->scopeResolver());
},
"program lb");
} else {
ensemble_->applyNewState(
[this, lb](const std::shared_ptr<SwitchState>& state) {
return utility::setLoadBalancer(
ensemble_, state, lb, ensemble_->scopeResolver());
},
"program lb");
auto switchIds = ensemble_->getHwAsicTable()->getSwitchIDs(
HwAsic::Feature::SAI_LAG_HASH);
if (!switchIds.empty()) {
config.loadBalancers()->push_back(utility::getTrunkHalfHashConfig(
*ensemble_->getHwAsicTable()->getHwAsic(*switchIds.begin())));
}
}
XLOG(INFO) << "Programming load balancer: " << *lb.id();
ensemble_->applyNewConfig(config);
}

template <typename AddrT>
Expand Down
6 changes: 1 addition & 5 deletions fboss/agent/test/utils/LoadBalancerTestRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,7 @@ class HwLoadBalancerTestRunner {
// verfiy the Dlb fail packets is zero
EXPECT_EQ(l3EcmpDlbFailPackets, 0);

auto cfg = utility::onePortPerInterfaceConfig(
getEnsemble(), getMasterLogicalPortIds());
cfg.udfConfig() = utility::addUdfFlowletAclConfig();
// Add flowlet config to convert flowlet QUALITY to PER_PACKET_QUALITY
// run the load balance test and verify again
auto cfg = getEnsemble()->getCurrentConfig();
utility::addFlowletConfigs(
cfg,
getMasterLogicalPortIds(),
Expand Down

0 comments on commit 59a29b9

Please sign in to comment.