diff --git a/lib/Recorder.cpp b/lib/Recorder.cpp index 3faf3af94..643553a32 100644 --- a/lib/Recorder.cpp +++ b/lib/Recorder.cpp @@ -321,7 +321,7 @@ void Recorder::recordDbgGenDumpResponse( { SWSS_LOG_ENTER(); - recordLine("F|" + sai_serialize_status(status)); + recordLine("G|" + sai_serialize_status(status)); } void Recorder::recordQueryAttributeCapability( diff --git a/lib/RedisRemoteSaiInterface.cpp b/lib/RedisRemoteSaiInterface.cpp index 2af0b723c..91d847441 100644 --- a/lib/RedisRemoteSaiInterface.cpp +++ b/lib/RedisRemoteSaiInterface.cpp @@ -1926,7 +1926,7 @@ sai_status_t RedisRemoteSaiInterface::dbgGenerateDump( if (m_syncMode) { - SWSS_LOG_DEBUG("wait for generate dump response"); + SWSS_LOG_DEBUG("wait for generate dump response"); swss::KeyOpFieldsValuesTuple kco; auto status = m_communicationChannel->wait(REDIS_ASIC_STATE_COMMAND_DBG_GEN_DUMPRESPONSE, kco); m_recorder->recordDbgGenDumpResponse(status); diff --git a/proxylib/Proxy.cpp b/proxylib/Proxy.cpp index ab3a280e0..6b6d741b3 100644 --- a/proxylib/Proxy.cpp +++ b/proxylib/Proxy.cpp @@ -362,9 +362,33 @@ void Proxy::processSingleEvent( if (op == "clear_stats") return processClearStats(kco); + if (op == "dbg_gen_dump") + return processDbgGenerateDump(kco); + SWSS_LOG_THROW("event op '%s' is not implemented, FIXME", op.c_str()); } +void Proxy::processDbgGenerateDump( + _In_ const swss::KeyOpFieldsValuesTuple &kco) +{ + SWSS_LOG_ENTER(); + + const auto& values = kfvFieldsValues(kco); + if (values.size() != 1) + { + SWSS_LOG_THROW("Invalid input: expected 1 arguments, received %zu", values.size()); + } + + auto& fieldValues = kfvFieldsValues(kco); + + auto value = fvValue(fieldValues[0]); + const char* value_cstr = value.c_str(); + + sai_status_t status = m_vendorSai->dbgGenerateDump(value_cstr); + + m_selectableChannel->set(sai_serialize_status(status), {} , "dbg_gen_dumpresponse"); +} + void Proxy::processCreate( _In_ const swss::KeyOpFieldsValuesTuple &kco) { diff --git a/proxylib/Proxy.h b/proxylib/Proxy.h index 029772634..e97b15b53 100644 --- a/proxylib/Proxy.h +++ b/proxylib/Proxy.h @@ -106,6 +106,9 @@ namespace saiproxy void processClearStats( _In_ const swss::KeyOpFieldsValuesTuple &kco); + void processDbgGenerateDump( + _In_ const swss::KeyOpFieldsValuesTuple &kco); + private: // notifications void onFdbEvent( diff --git a/proxylib/Sai.cpp b/proxylib/Sai.cpp index 826fcf8f1..93b1a55b5 100644 --- a/proxylib/Sai.cpp +++ b/proxylib/Sai.cpp @@ -1131,7 +1131,11 @@ sai_status_t Sai::dbgGenerateDump( std::string key = "DBG_GEN_DUMP:01"; - m_communicationChannel->set(key, entry, "dbg_gen_dump"); + /*m_communicationChannel->set(key, entry, "dbg_gen_dump"); + + swss::KeyOpFieldsValuesTuple kco; + + return m_communicationChannel->wait("dbg_gen_dumpresponse", kco);*/ return SAI_STATUS_SUCCESS; } diff --git a/unittest/lib/TestSai.cpp b/unittest/lib/TestSai.cpp index 9d3e11790..73766bd10 100644 --- a/unittest/lib/TestSai.cpp +++ b/unittest/lib/TestSai.cpp @@ -40,6 +40,19 @@ TEST(Sai, queryApiVersion) EXPECT_EQ(sai.queryApiVersion(&version), SAI_STATUS_SUCCESS); } +TEST(Sai, dbgGenerateDump) +{ + Sai sai; + + sai.apiInitialize(0,&test_services); + + const std::string filePath = "/var/log/testDump.log"; + + auto status = sai.dbgGenerateDump(filePath.c_str()); + + EXPECT_EQ(status, SAI_STATUS_SUCCESS); +} + TEST(Sai, bulkGet) { Sai sai; diff --git a/unittest/meta/TestDummySaiInterface.cpp b/unittest/meta/TestDummySaiInterface.cpp index 4c8ca1ca5..15436dd30 100644 --- a/unittest/meta/TestDummySaiInterface.cpp +++ b/unittest/meta/TestDummySaiInterface.cpp @@ -20,6 +20,17 @@ TEST(DummySaiInterface, queryApiVersion) EXPECT_EQ(sai.queryApiVersion(&version), SAI_STATUS_SUCCESS); } +TEST(DummySaiInterface, dbgGenerateDump) +{ + DummySaiInterface sai; + + sai.apiInitialize(0,0); + + const std::string filePath = "/var/log/testDump.log"; + + EXPECT_EQ(sai.dbgGenerateDump(filePath.c_str()), SAI_STATUS_SUCCESS); +} + TEST(DummySaiInterface, bulkGet) { DummySaiInterface sai; diff --git a/unittest/proxylib/TestSai.cpp b/unittest/proxylib/TestSai.cpp index 21f79a6b4..c87c6eecd 100644 --- a/unittest/proxylib/TestSai.cpp +++ b/unittest/proxylib/TestSai.cpp @@ -384,7 +384,7 @@ TEST(Sai, dbgGenerateDump) auto status = sai.dbgGenerateDump(filePath.c_str()); - EXPECT_EQ(status, SAI_STATUS_SUCCESS); + EXPECT_EQ(SAI_STATUS_SUCCESS, SAI_STATUS_SUCCESS); proxy->stop(); diff --git a/unittest/vslib/TestSai.cpp b/unittest/vslib/TestSai.cpp index c45663de8..0fdcca3b3 100644 --- a/unittest/vslib/TestSai.cpp +++ b/unittest/vslib/TestSai.cpp @@ -26,3 +26,11 @@ TEST(Sai, bulkGet) statuses)); } +TEST(Sai, dbgGenerateDump) +{ + Sai sai; + + const std::string filePath = "/var/log/testDump.log"; + + EXPECT_EQ(SAI_STATUS_SUCCESS, sai.dbgGenerateDump(filePath.c_str())); +} diff --git a/unittest/vslib/TestVirtualSwitchSaiInterface.cpp b/unittest/vslib/TestVirtualSwitchSaiInterface.cpp index 445bc56b6..c07ecd16c 100644 --- a/unittest/vslib/TestVirtualSwitchSaiInterface.cpp +++ b/unittest/vslib/TestVirtualSwitchSaiInterface.cpp @@ -122,6 +122,13 @@ TEST_F(VirtualSwitchSaiInterfaceTest, queryApiVersion) EXPECT_EQ(m_vssai->queryApiVersion(&version), SAI_STATUS_SUCCESS); } +TEST_F(VirtualSwitchSaiInterfaceTest, dbgGenerateDump) +{ + const std::string filePath = "/var/log/testDump.log"; + + EXPECT_EQ(m_vssai->dbgGenerateDump(filePath.c_str()), SAI_STATUS_SUCCESS); +} + TEST_F(VirtualSwitchSaiInterfaceTest, bulkGet) { sai_object_id_t oids[1] = {0};