From f56a39ea5471faa89be7dd75000bd2bc3e9fc4a5 Mon Sep 17 00:00:00 2001 From: Kamil Cudnik Date: Fri, 30 Jul 2021 20:50:48 +0200 Subject: [PATCH] [sairedis] Record create, remove and set response in sync mode (#869) Start recording CRS operations response to sairedis.rec but only when response is not success. --- lib/inc/Recorder.h | 8 +++++++ lib/src/Recorder.cpp | 36 +++++++++++++++++++++++++++++ lib/src/RedisRemoteSaiInterface.cpp | 4 ++++ 3 files changed, 48 insertions(+) diff --git a/lib/inc/Recorder.h b/lib/inc/Recorder.h index d11a0e65ee..85fcd8c01d 100644 --- a/lib/inc/Recorder.h +++ b/lib/inc/Recorder.h @@ -157,6 +157,9 @@ namespace sairedis _In_ sai_status_t status, _In_ const std::vector& arguments); + void recordGenericResponse( + _In_ sai_status_t status); + public: // create ENTRY SAI_REDIS_RECORDER_DECLARE_RECORD_CREATE(fdb_entry); @@ -263,6 +266,11 @@ namespace sairedis _In_ uint32_t objectCount, _In_ const sai_status_t *objectStatuses); + void recordBulkGenericResponse( + _In_ sai_status_t status, + _In_ uint32_t objectCount, + _In_ const sai_status_t *objectStatuses); + public: // SAI query interface API void recordFlushFdbEntries( diff --git a/lib/src/Recorder.cpp b/lib/src/Recorder.cpp index 001130c7d9..5ecfe59b68 100644 --- a/lib/src/Recorder.cpp +++ b/lib/src/Recorder.cpp @@ -1117,3 +1117,39 @@ void Recorder::recordStats( m_recordStats = enable; } + + +void Recorder::recordGenericResponse( + _In_ sai_status_t status) +{ + SWSS_LOG_ENTER(); + + if (status != SAI_STATUS_SUCCESS) + { + // record only when response is not success + + recordLine("E|" + sai_serialize_status(status)); + } +} + +void Recorder::recordBulkGenericResponse( + _In_ sai_status_t status, + _In_ uint32_t objectCount, + _In_ const sai_status_t *objectStatuses) +{ + SWSS_LOG_ENTER(); + + if (status != SAI_STATUS_SUCCESS) + { + // record only when response is not success + + std::string statuses = ""; + + for (uint32_t i = 0; i < objectCount; i++) + { + statuses += "|" + sai_serialize_status(objectStatuses[i]); + } + + recordLine("E|" + sai_serialize_status(status) + "|" + statuses); + } +} diff --git a/lib/src/RedisRemoteSaiInterface.cpp b/lib/src/RedisRemoteSaiInterface.cpp index 91640f547a..919f80d255 100644 --- a/lib/src/RedisRemoteSaiInterface.cpp +++ b/lib/src/RedisRemoteSaiInterface.cpp @@ -742,6 +742,8 @@ sai_status_t RedisRemoteSaiInterface::waitForResponse( auto status = m_communicationChannel->wait(REDIS_ASIC_STATE_COMMAND_GETRESPONSE, kco); + m_recorder->recordGenericResponse(status); + return status; } @@ -1347,6 +1349,8 @@ sai_status_t RedisRemoteSaiInterface::waitForBulkResponse( sai_deserialize_status(fvField(values[idx]), object_statuses[idx]); } + m_recorder->recordBulkGenericResponse(status, object_count, object_statuses); + return status; }