From 028a651e34f36f33196cae8795fcdc59d8cffc6c Mon Sep 17 00:00:00 2001 From: Santhosh Nagaraj Date: Wed, 18 Dec 2024 00:39:02 -0800 Subject: [PATCH] Port HwParityErrorTest to agent hw parity error test Summary: Porting HW parity error test to agent hw parity error test Differential Revision: D67288660 fbshipit-source-id: 383b7bd76a4e370b20caa32dde78dec921aee9ef --- cmake/AgentTestAgentHwTests.cmake | 1 + .../AgentHwParityErrorTests.cpp | 57 +++++++++++++++++++ fboss/agent/test/agent_hw_tests/BUCK | 1 + 3 files changed, 59 insertions(+) create mode 100644 fboss/agent/test/agent_hw_tests/AgentHwParityErrorTests.cpp diff --git a/cmake/AgentTestAgentHwTests.cmake b/cmake/AgentTestAgentHwTests.cmake index 6ee5aab959bd2..6aad7feb84ee6 100644 --- a/cmake/AgentTestAgentHwTests.cmake +++ b/cmake/AgentTestAgentHwTests.cmake @@ -59,6 +59,7 @@ add_library(agent_hw_test_src fboss/agent/test/agent_hw_tests/AgentHwAclQualifierTest.cpp fboss/agent/test/agent_hw_tests/AgentHwAclStatTests.cpp fboss/agent/test/agent_hw_tests/AgentHwResourceStatsTests.cpp + fboss/agent/test/agent_hw_tests/AgentHwParityErrorTests.cpp ) target_link_libraries(agent_hw_test_src diff --git a/fboss/agent/test/agent_hw_tests/AgentHwParityErrorTests.cpp b/fboss/agent/test/agent_hw_tests/AgentHwParityErrorTests.cpp new file mode 100644 index 0000000000000..d28717584acfc --- /dev/null +++ b/fboss/agent/test/agent_hw_tests/AgentHwParityErrorTests.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2004-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional + * grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +#include "fboss/agent/test/AgentHwTest.h" +#include "fboss/agent/test/utils/AsicUtils.h" +#include "fboss/agent/test/utils/ConfigUtils.h" +#include "fboss/lib/CommonUtils.h" + +namespace facebook::fboss { +class AgentHwParityErrorTest : public AgentHwTest { + protected: + cfg::SwitchConfig initialConfig( + const AgentEnsemble& ensemble) const override { + return utility::onePortPerInterfaceConfig( + ensemble.getSw(), + ensemble.masterLogicalPortIds(), + true /*interfaceHasSubnet*/); + } + std::vector + getProductionFeaturesVerified() const override { + return {production_features::ProductionFeature::HW_SWITCH}; + } +}; + +TEST_F(AgentHwParityErrorTest, verifyParityError) { + auto setup = [=, this]() { + applyNewConfig(initialConfig(*getAgentEnsemble())); + }; + auto verify = [=, this]() { + const auto kPort = masterLogicalInterfacePortIds()[0]; + auto switchId = scopeResolver().scope(kPort).switchId(); + auto switchIndex = + getSw()->getSwitchInfoTable().getSwitchIndexFromSwitchId(switchId); + auto client = getAgentEnsemble()->getHwAgentTestClient(switchId); + WITH_RETRIES({ + auto switchStats = getSw()->getHwSwitchStatsExpensive()[switchIndex]; + auto asicErrors = switchStats.hwAsicErrors().value(); + EXPECT_EVENTUALLY_EQ(*asicErrors.correctedParityErrors(), 0); + }); + client->sync_triggerParityError(); + WITH_RETRIES({ + auto switchStats = getSw()->getHwSwitchStatsExpensive()[switchIndex]; + auto asicErrors = switchStats.hwAsicErrors().value(); + EXPECT_EVENTUALLY_GT(*asicErrors.correctedParityErrors(), 0); + }); + }; + this->verifyAcrossWarmBoots(setup, verify); +} +} // namespace facebook::fboss diff --git a/fboss/agent/test/agent_hw_tests/BUCK b/fboss/agent/test/agent_hw_tests/BUCK index 9867ce4dab411..3bb0f6197cabe 100644 --- a/fboss/agent/test/agent_hw_tests/BUCK +++ b/fboss/agent/test/agent_hw_tests/BUCK @@ -29,6 +29,7 @@ cpp_library( "AgentHwAclMatchActionsTest.cpp", "AgentHwAclQualifierTest.cpp", "AgentHwAclStatTests.cpp", + "AgentHwParityErrorTests.cpp", "AgentHwResourceStatsTests.cpp", "AgentInNullRouteDiscardsTest.cpp", "AgentInTrapDiscardsTest.cpp",