diff --git a/fboss/agent/hw/test/HwMirrorTests.cpp b/fboss/agent/hw/test/HwMirrorTests.cpp index 087e2bffd87c5..85784e24a44ef 100644 --- a/fboss/agent/hw/test/HwMirrorTests.cpp +++ b/fboss/agent/hw/test/HwMirrorTests.cpp @@ -428,74 +428,6 @@ TYPED_TEST(HwMirrorTest, PortMirrorUpdateIfMirrorUpdate) { this->verifyAcrossWarmBoots(setup, verify); } -TYPED_TEST(HwMirrorTest, UpdatePortMirror) { - 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->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); - - cfg.mirrors()[0] = this->getSpanMirror(); - portCfg->ingressMirror().reset(); - portCfg->egressMirror().reset(); - portCfg = utility::findCfgPort(cfg, this->masterLogicalPortIds()[1]); - portCfg->ingressMirror() = kSpan; - portCfg->egressMirror() = kSpan; - this->applyNewConfig(cfg); - }; - auto verify = [=, this]() { - auto mirror = this->getProgrammedState()->getMirrors()->getNodeIf(kSpan); - utility::verifyResolvedMirror(this->getHwSwitch(), mirror); - std::vector 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()); - - utility::verifyPortMirrorDestination( - this->getHwSwitch(), - PortID(this->masterLogicalPortIds()[1]), - utility::getMirrorPortIngressFlags(), - destinations[0]); - utility::verifyPortMirrorDestination( - this->getHwSwitch(), - PortID(this->masterLogicalPortIds()[1]), - utility::getMirrorPortEgressFlags(), - destinations[0]); - }; - if (this->skipMirrorTest()) { -#if defined(GTEST_SKIP) - GTEST_SKIP(); -#endif - return; - } - this->verifyAcrossWarmBoots(setup, verify); -} - TYPED_TEST(HwMirrorTest, RemovePortMirror) { auto setup = [=, this]() { auto params = this->testParams(); @@ -715,60 +647,6 @@ TYPED_TEST(HwMirrorTest, HwUnresolvedMirrorStat) { this->verifyAcrossWarmBoots(setup, verify); } -TYPED_TEST(HwMirrorTest, UpdateAclMirror) { - auto setup = [=, this]() { - auto params = this->testParams(); - auto cfg = this->initialConfig(); - cfg.mirrors()->push_back(this->getSpanMirror()); - 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->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); - - cfg.mirrors()->clear(); - cfg.mirrors()->push_back(this->getSpanMirror()); - for (auto& match2Action : *cfg.dataPlaneTrafficPolicy()->matchToAction()) { - if (*match2Action.matcher() == "acl0") { - match2Action.action()->ingressMirror() = kSpan; - match2Action.action()->egressMirror() = kSpan; - } - } - this->applyNewConfig(cfg); - }; - auto verify = [=, this]() { - auto erspan = this->getProgrammedState()->getMirrors()->getNodeIf(kErspan); - EXPECT_EQ(erspan, nullptr); - - auto span = this->getProgrammedState()->getMirrors()->getNodeIf(kSpan); - utility::verifyResolvedMirror(this->getHwSwitch(), span); - utility::verifyAclMirrorDestination(this->getHwSwitch(), kSpan); - }; - if (this->skipMirrorTest()) { -#if defined(GTEST_SKIP) - GTEST_SKIP(); -#endif - return; - } - this->verifyAcrossWarmBoots(setup, verify); -} - TYPED_TEST(HwMirrorTest, RemoveAclMirror) { auto setup = [=, this]() { auto params = this->testParams(); diff --git a/fboss/agent/test/agent_hw_tests/AgentMirroringTests.cpp b/fboss/agent/test/agent_hw_tests/AgentMirroringTests.cpp index f66d85f90daa1..b925b427cb7a5 100644 --- a/fboss/agent/test/agent_hw_tests/AgentMirroringTests.cpp +++ b/fboss/agent/test/agent_hw_tests/AgentMirroringTests.cpp @@ -241,8 +241,10 @@ class AgentMirroringTest : public AgentHwTest { for (auto switchID : scope.switchIds()) { auto client = getAgentEnsemble()->getHwAgentTestClient(switchID); verifyMirrorProgrammed(client.get(), fields); - EXPECT_TRUE( - client->sync_isAclEntryMirrored(kMirrorAcl, mirrorName, isIngress())); + WITH_RETRIES({ + EXPECT_EVENTUALLY_TRUE(client->sync_isAclEntryMirrored( + kMirrorAcl, mirrorName, isIngress())); + }); } } @@ -288,6 +290,26 @@ class AgentMirroringTest : public AgentHwTest { this->verifyAcrossWarmBoots(setup, verify); } + void testUpdatePortMirror(const std::string& mirrorName) { + auto setup = [=, this]() { + this->resolveMirror(mirrorName); + auto cfg = initialConfig(*getAgentEnsemble()); + cfg.mirrors()->clear(); + utility::addMirrorConfig( + &cfg, + *getAgentEnsemble(), + mirrorName, + false /* truncate */, + 48 /* dscp */); + this->applyNewConfig(cfg); + }; + auto verify = [=, this]() { + this->verify(mirrorName); + this->verifyPortMirrorProgrammed(mirrorName); + }; + this->verifyAcrossWarmBoots(setup, verify); + } + void testAclMirror(const std::string& mirrorName) { auto setup = [=, this]() { this->resolveMirror(mirrorName); }; auto verify = [=, this]() { @@ -297,6 +319,26 @@ class AgentMirroringTest : public AgentHwTest { this->verifyAcrossWarmBoots(setup, verify); } + void testUpdateAclMirror(const std::string& mirrorName) { + auto setup = [=, this]() { + this->resolveMirror(mirrorName); + auto cfg = initialConfig(*getAgentEnsemble()); + cfg.mirrors()->clear(); + utility::addMirrorConfig( + &cfg, + *getAgentEnsemble(), + mirrorName, + false /* truncate */, + 48 /* dscp */); + this->applyNewConfig(cfg); + }; + auto verify = [=, this]() { + this->verify(mirrorName); + this->verifyAclMirrorProgrammed(mirrorName); + }; + this->verifyAcrossWarmBoots(setup, verify); + } + void testPortMirrorWithLargePacket(const std::string& mirrorName) { auto setup = [=, this]() { this->resolveMirror(mirrorName); }; auto verify = [=, this]() { @@ -571,18 +613,34 @@ TYPED_TEST(AgentIngressPortSpanMirroringTest, SpanPortMirror) { this->testPortMirror(utility::kIngressSpan); } +TYPED_TEST(AgentIngressPortSpanMirroringTest, UpdateSpanPortMirror) { + this->testUpdatePortMirror(kIngressSpan); +} + TYPED_TEST(AgentIngressPortErspanMirroringTest, ErspanPortMirror) { this->testPortMirror(utility::kIngressErspan); } +TYPED_TEST(AgentIngressPortErspanMirroringTest, UpdateErspanPortMirror) { + this->testUpdatePortMirror(kIngressErspan); +} + TYPED_TEST(AgentIngressAclSpanMirroringTest, SpanAclMirror) { this->testAclMirror(utility::kIngressSpan); } +TYPED_TEST(AgentIngressAclSpanMirroringTest, UpdateSpanAclMirror) { + this->testUpdateAclMirror(kIngressSpan); +} + TYPED_TEST(AgentIngressAclErspanMirroringTest, ErspanAclMirror) { this->testAclMirror(utility::kIngressErspan); } +TYPED_TEST(AgentIngressAclErspanMirroringTest, UpdateErspanAclMirror) { + this->testUpdateAclMirror(kIngressErspan); +} + TYPED_TEST( AgentIngressPortErspanMirroringTruncateTest, TrucatePortErspanMirror) {