Skip to content

Commit

Permalink
migrate remove mirror tests from hw test to agent mirroring tests
Browse files Browse the repository at this point in the history
Summary: as titled

Reviewed By: jasmeetbagga

Differential Revision: D62768987

fbshipit-source-id: 709b0936036cbedbb58f696385590e7b7b789bcd
  • Loading branch information
Parvez Shaikh authored and facebook-github-bot committed Sep 19, 2024
1 parent 61014fb commit bccb69b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 129 deletions.
129 changes: 0 additions & 129 deletions fboss/agent/hw/test/HwMirrorTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,34 +192,6 @@ class HwMirrorTest : public HwTest {

TYPED_TEST_SUITE(HwMirrorTest, TestTypes);

TYPED_TEST(HwMirrorTest, MirrorRemoved) {
auto setup = [=, this]() {
auto cfg = this->initialConfig();
cfg.mirrors()->push_back(this->getSpanMirror());
cfg.mirrors()->push_back(this->getErspanMirror());
this->applyNewConfig(cfg);
auto newState = this->getProgrammedState()->clone();
auto mnpuMirrors =
this->getProgrammedState()->getMirrors()->modify(&newState);
auto mirror = mnpuMirrors->getNodeIf(kSpan);
mnpuMirrors->removeNode(mirror);
this->applyNewState(newState);
};
auto verify = [=, this]() {
auto local = this->getProgrammedState()->getMirrors()->getNodeIf(kSpan);
EXPECT_EQ(local, nullptr);
auto erspan = this->getProgrammedState()->getMirrors()->getNodeIf(kErspan);
utility::verifyUnResolvedMirror(this->getHwSwitch(), erspan);
};
if (this->skipMirrorTest()) {
#if defined(GTEST_SKIP)
GTEST_SKIP();
#endif
return;
}
this->verifyAcrossWarmBoots(setup, verify);
}

TYPED_TEST(HwMirrorTest, UnresolvedToUnresolvedUpdate) {
auto setup = [=, this]() {
auto params = this->testParams();
Expand Down Expand Up @@ -428,59 +400,6 @@ TYPED_TEST(HwMirrorTest, PortMirrorUpdateIfMirrorUpdate) {
this->verifyAcrossWarmBoots(setup, verify);
}

TYPED_TEST(HwMirrorTest, RemovePortMirror) {
auto setup = [=, this]() {
auto params = this->testParams();
auto cfg = this->initialConfig();
cfg.mirrors()->push_back(this->getErspanMirror());
auto portCfg = utility::findCfgPort(cfg, this->masterLogicalPortIds()[0]);
portCfg->ingressMirror() = kErspan;
portCfg->egressMirror() = kErspan;
this->applyNewConfig(cfg);

auto mirror = this->getProgrammedState()->getMirrors()->getNodeIf(kErspan);
auto newMirror = std::make_shared<Mirror>(
mirror->getID(),
mirror->getEgressPortDesc(),
mirror->getDestinationIp());
newMirror->setEgressPortDesc(
PortDescriptor(this->masterLogicalPortIds()[1]));
newMirror->setMirrorTunnel(MirrorTunnel(
params.ipAddrs[2],
params.ipAddrs[3],
params.macAddrs[2],
params.macAddrs[3]));
this->updateMirror(newMirror);

portCfg->ingressMirror().reset();
portCfg->egressMirror().reset();
this->applyNewConfig(cfg);
};
auto verify = [=, this]() {
auto mirror = this->getProgrammedState()->getMirrors()->getNodeIf(kErspan);
utility::verifyResolvedMirror(this->getHwSwitch(), mirror);
std::vector<uint64_t> destinations;
utility::getAllMirrorDestinations(this->getHwSwitch(), destinations);
ASSERT_EQ(destinations.size(), 1);

utility::verifyPortNoMirrorDestination(
this->getHwSwitch(),
PortID(this->masterLogicalPortIds()[0]),
utility::getMirrorPortIngressFlags());
utility::verifyPortNoMirrorDestination(
this->getHwSwitch(),
PortID(this->masterLogicalPortIds()[0]),
utility::getMirrorPortEgressFlags());
};
if (this->skipMirrorTest()) {
#if defined(GTEST_SKIP)
GTEST_SKIP();
#endif
return;
}
this->verifyAcrossWarmBoots(setup, verify);
}

TYPED_TEST(HwMirrorTest, HwMirrorStat) {
auto setup = [=, this]() {
auto cfg = this->initialConfig();
Expand Down Expand Up @@ -647,54 +566,6 @@ TYPED_TEST(HwMirrorTest, HwUnresolvedMirrorStat) {
this->verifyAcrossWarmBoots(setup, verify);
}

TYPED_TEST(HwMirrorTest, RemoveAclMirror) {
auto setup = [=, this]() {
auto params = this->testParams();
auto cfg = this->initialConfig();
cfg.mirrors()->push_back(this->getErspanMirror());
cfg::AclEntry acl;
acl.name() = "acl0";
acl.dstIp() = "192.168.0.0/16";
this->addAclMirror(kErspan, acl, cfg);
this->applyNewConfig(cfg);

auto mirrors = this->getProgrammedState()->getMirrors();
auto mirror = mirrors->getNodeIf(kErspan);
auto newMirror = std::make_shared<Mirror>(
mirror->getID(),
mirror->getEgressPortDesc(),
mirror->getDestinationIp());
newMirror->setEgressPortDesc(
PortDescriptor(this->masterLogicalPortIds()[1]));
newMirror->setMirrorTunnel(MirrorTunnel(
params.ipAddrs[2],
params.ipAddrs[3],
params.macAddrs[2],
params.macAddrs[3]));
this->updateMirror(newMirror);

for (auto& match2Action : *cfg.dataPlaneTrafficPolicy()->matchToAction()) {
if (*match2Action.matcher() == "acl0") {
match2Action.action()->ingressMirror().reset();
match2Action.action()->egressMirror().reset();
}
}
this->applyNewConfig(cfg);
};
auto verify = [=, this]() {
auto mirror = this->getProgrammedState()->getMirrors()->getNodeIf(kErspan);
utility::verifyResolvedMirror(this->getHwSwitch(), mirror);
utility::verifyNoAclMirrorDestination(this->getHwSwitch(), kErspan);
};
if (this->skipMirrorTest()) {
#if defined(GTEST_SKIP)
GTEST_SKIP();
#endif
return;
}
this->verifyAcrossWarmBoots(setup, verify);
}

TYPED_TEST(HwMirrorTest, HwMirrorLimitExceeded) {
if (this->skipMirrorTest()) {
#if defined(GTEST_SKIP)
Expand Down
38 changes: 38 additions & 0 deletions fboss/agent/test/agent_hw_tests/AgentMirroringTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,36 @@ class AgentMirroringTest : public AgentHwTest {
this->verifyAcrossWarmBoots(setup, verify);
}

void testRemoveMirror(const std::string& mirrorName) {
auto setup = [=, this]() {
const auto& ensemble = *getAgentEnsemble();
this->resolveMirror(mirrorName);

auto config = utility::onePortPerInterfaceConfig(
ensemble.getSw(),
ensemble.masterLogicalPortIds(),
true /*interfaceHasSubnet*/);

this->applyNewConfig(config);
};
auto verify = [=, this]() {
auto mirror = getProgrammedState()->getMirrors()->getNodeIf(mirrorName);
EXPECT_EQ(mirror, nullptr);
auto scopeResolver = getAgentEnsemble()->getSw()->getScopeResolver();
auto scope = scopeResolver->scope(mirror);
for (auto switchID : scope.switchIds()) {
auto client = getAgentEnsemble()->getHwAgentTestClient(switchID);
WITH_RETRIES({
EXPECT_EVENTUALLY_FALSE(client->sync_isPortMirrored(
getTrafficPort(*getAgentEnsemble()), mirrorName, isIngress()));
EXPECT_TRUE(client->sync_isAclEntryMirrored(
kMirrorAcl, mirrorName, isIngress()));
});
}
};
this->verifyAcrossWarmBoots(setup, verify);
}

void testPortMirrorWithLargePacket(const std::string& mirrorName) {
auto setup = [=, this]() { this->resolveMirror(mirrorName); };
auto verify = [=, this]() {
Expand Down Expand Up @@ -617,10 +647,18 @@ TYPED_TEST(AgentIngressPortSpanMirroringTest, UpdateSpanPortMirror) {
this->testUpdatePortMirror(kIngressSpan);
}

TYPED_TEST(AgentIngressAclSpanMirroringTest, RemoveSpanMirror) {
this->testRemoveMirror(utility::kIngressSpan);
}

TYPED_TEST(AgentIngressPortErspanMirroringTest, ErspanPortMirror) {
this->testPortMirror(utility::kIngressErspan);
}

TYPED_TEST(AgentIngressAclSpanMirroringTest, RemoveErspanMirror) {
this->testRemoveMirror(utility::kIngressErspan);
}

TYPED_TEST(AgentIngressPortErspanMirroringTest, UpdateErspanPortMirror) {
this->testUpdatePortMirror(kIngressErspan);
}
Expand Down

0 comments on commit bccb69b

Please sign in to comment.