diff --git a/cfgmgr/Makefile.am b/cfgmgr/Makefile.am index a8cbddb4e7..45afff7e9b 100644 --- a/cfgmgr/Makefile.am +++ b/cfgmgr/Makefile.am @@ -3,7 +3,7 @@ CFLAGS_SAI = -I /usr/include/sai LIBNL_CFLAGS = -I/usr/include/libnl3 LIBNL_LIBS = -lnl-genl-3 -lnl-route-3 -lnl-3 SAIMETA_LIBS = -lsaimeta -lsaimetadata -lzmq -COMMON_LIBS = -lswsscommon +COMMON_LIBS = -lswsscommon -lpthread bin_PROGRAMS = vlanmgrd teammgrd portmgrd intfmgrd buffermgrd vrfmgrd nbrmgrd vxlanmgrd sflowmgrd natmgrd coppmgrd tunnelmgrd macsecmgrd fabricmgrd diff --git a/orchagent/orch.h b/orchagent/orch.h index 6e4702ce3d..bdbecf5f5f 100644 --- a/orchagent/orch.h +++ b/orchagent/orch.h @@ -271,7 +271,7 @@ class Orch void addExecutor(Executor* executor); Executor *getExecutor(std::string executorName); - ResponsePublisher m_publisher; + ResponsePublisher m_publisher{"APPL_STATE_DB"}; private: void addConsumer(swss::DBConnector *db, std::string tableName, int pri = default_orch_pri); }; diff --git a/orchagent/p4orch/p4orch.cpp b/orchagent/p4orch/p4orch.cpp index f1e6bd4702..00e5ef6c4d 100644 --- a/orchagent/p4orch/p4orch.cpp +++ b/orchagent/p4orch/p4orch.cpp @@ -154,6 +154,8 @@ void P4Orch::doTask(Consumer &consumer) { manager->drain(); } + + m_publisher.flush(); } void P4Orch::doTask(swss::SelectableTimer &timer) diff --git a/orchagent/p4orch/p4orch.h b/orchagent/p4orch/p4orch.h index cc02052830..549aac17b2 100644 --- a/orchagent/p4orch/p4orch.h +++ b/orchagent/p4orch/p4orch.h @@ -83,5 +83,8 @@ class P4Orch : public Orch // Notification consumer for port state change swss::NotificationConsumer *m_portStatusNotificationConsumer; + // Sepcial publisher that writes to APPL DB instead of APPL STATE DB. + ResponsePublisher m_publisher{"APPL_DB", /*bool buffered=*/true, /*db_write_thread=*/true}; + friend class p4orch::test::WcmpManagerTest; }; diff --git a/orchagent/p4orch/tests/return_code_test.cpp b/orchagent/p4orch/tests/return_code_test.cpp index 7ab21121aa..6ee73b74f9 100644 --- a/orchagent/p4orch/tests/return_code_test.cpp +++ b/orchagent/p4orch/tests/return_code_test.cpp @@ -119,6 +119,7 @@ TEST(ReturnCodeTest, SaiCodeToReturnCodeMapping) {SAI_STATUS_TABLE_FULL, StatusCode::SWSS_RC_FULL}, {SAI_STATUS_NOT_IMPLEMENTED, StatusCode::SWSS_RC_UNIMPLEMENTED}, {SAI_STATUS_OBJECT_IN_USE, StatusCode::SWSS_RC_IN_USE}, + {SAI_STATUS_NOT_EXECUTED, StatusCode::SWSS_RC_NOT_EXECUTED}, {SAI_STATUS_FAILURE, StatusCode::SWSS_RC_UNKNOWN}, {SAI_STATUS_INVALID_ATTRIBUTE_0, StatusCode::SWSS_RC_INVALID_PARAM}, {SAI_STATUS_INVALID_ATTRIBUTE_10, StatusCode::SWSS_RC_INVALID_PARAM}, diff --git a/orchagent/response_publisher.cpp b/orchagent/response_publisher.cpp index d5b94a586d..f630ddf589 100644 --- a/orchagent/response_publisher.cpp +++ b/orchagent/response_publisher.cpp @@ -64,26 +64,45 @@ void RecordResponse(const std::string &response_channel, const std::string &key, } // namespace -ResponsePublisher::ResponsePublisher(bool buffered) - : m_db(std::make_unique("APPL_STATE_DB", 0)), - m_pipe(std::make_unique(m_db.get())), m_buffered(buffered) +ResponsePublisher::ResponsePublisher(const std::string &dbName, bool buffered, bool db_write_thread) + : m_db(std::make_unique(dbName, 0)), m_buffered(buffered) { + if (m_buffered) + { + m_ntf_pipe = std::make_unique(m_db.get()); + m_db_pipe = std::make_unique(m_db.get()); + } + else + { + m_ntf_pipe = std::make_unique(m_db.get(), 1); + m_db_pipe = std::make_unique(m_db.get(), 1); + } + if (db_write_thread) + { + m_update_thread = std::unique_ptr(new std::thread(&ResponsePublisher::dbUpdateThread, this)); + } } -void ResponsePublisher::publish(const std::string &table, const std::string &key, - const std::vector &intent_attrs, const ReturnCode &status, - const std::vector &state_attrs, bool replace) +ResponsePublisher::~ResponsePublisher() { - // Write to the DB only if: - // 1) A write operation is being performed and state attributes are specified. - // 2) A successful delete operation. - if ((intent_attrs.size() && state_attrs.size()) || (status.ok() && !intent_attrs.size())) + if (m_update_thread != nullptr) { - writeToDB(table, key, state_attrs, intent_attrs.size() ? SET_COMMAND : DEL_COMMAND, replace); + { + std::lock_guard lock(m_lock); + m_queue.emplace(/*table=*/"", /*key=*/"", /*values =*/std::vector{}, /*op=*/"", + /*replace=*/false, /*flush=*/false, /*shutdown=*/true); + } + m_signal.notify_one(); + m_update_thread->join(); } +} +void ResponsePublisher::publish(const std::string &table, const std::string &key, + const std::vector &intent_attrs, const ReturnCode &status, + const std::vector &state_attrs, bool replace) +{ std::string response_channel = "APPL_DB_" + table + "_RESPONSE_CHANNEL"; - swss::NotificationProducer notificationProducer{m_pipe.get(), response_channel, m_buffered}; + swss::NotificationProducer notificationProducer{m_ntf_pipe.get(), response_channel, m_buffered}; auto intent_attrs_copy = intent_attrs; // Add error message as the first field-value-pair. @@ -92,6 +111,14 @@ void ResponsePublisher::publish(const std::string &table, const std::string &key // Sends the response to the notification channel. notificationProducer.send(status.codeStr(), key, intent_attrs_copy); RecordResponse(response_channel, key, intent_attrs_copy, status.codeStr()); + + // Write to the DB only if: + // 1) A write operation is being performed and state attributes are specified. + // 2) A successful delete operation. + if ((intent_attrs.size() && state_attrs.size()) || (status.ok() && !intent_attrs.size())) + { + writeToDB(table, key, state_attrs, intent_attrs.size() ? SET_COMMAND : DEL_COMMAND, replace); + } } void ResponsePublisher::publish(const std::string &table, const std::string &key, @@ -113,7 +140,26 @@ void ResponsePublisher::publish(const std::string &table, const std::string &key void ResponsePublisher::writeToDB(const std::string &table, const std::string &key, const std::vector &values, const std::string &op, bool replace) { - swss::Table applStateTable{m_pipe.get(), table, m_buffered}; + if (m_update_thread != nullptr) + { + { + std::lock_guard lock(m_lock); + m_queue.emplace(table, key, values, op, replace, /*flush=*/false, /*shutdown=*/false); + } + m_signal.notify_one(); + } + else + { + writeToDBInternal(table, key, values, op, replace); + } + RecordDBWrite(table, key, values, op); +} + +void ResponsePublisher::writeToDBInternal(const std::string &table, const std::string &key, + const std::vector &values, const std::string &op, + bool replace) +{ + swss::Table applStateTable{m_db_pipe.get(), table, m_buffered}; auto attrs = values; if (op == SET_COMMAND) @@ -133,7 +179,6 @@ void ResponsePublisher::writeToDB(const std::string &table, const std::string &k if (!applStateTable.get(key, fv)) { applStateTable.set(key, attrs); - RecordDBWrite(table, key, attrs, op); return; } for (auto it = attrs.cbegin(); it != attrs.cend();) @@ -150,22 +195,63 @@ void ResponsePublisher::writeToDB(const std::string &table, const std::string &k if (attrs.size()) { applStateTable.set(key, attrs); - RecordDBWrite(table, key, attrs, op); } } else if (op == DEL_COMMAND) { applStateTable.del(key); - RecordDBWrite(table, key, {}, op); } } void ResponsePublisher::flush() { - m_pipe->flush(); + m_ntf_pipe->flush(); + if (m_update_thread != nullptr) + { + { + std::lock_guard lock(m_lock); + m_queue.emplace(/*table=*/"", /*key=*/"", /*values =*/std::vector{}, /*op=*/"", + /*replace=*/false, /*flush=*/true, /*shutdown=*/false); + } + m_signal.notify_one(); + } + else + { + m_db_pipe->flush(); + } } void ResponsePublisher::setBuffered(bool buffered) { m_buffered = buffered; } + +void ResponsePublisher::dbUpdateThread() +{ + while (true) + { + entry e; + { + std::unique_lock lock(m_lock); + while (m_queue.empty()) + { + m_signal.wait(lock); + } + + e = m_queue.front(); + m_queue.pop(); + } + if (e.shutdown) + { + break; + } + if (e.flush) + { + m_db_pipe->flush(); + } + else + { + writeToDBInternal(e.table, e.key, e.values, e.op, e.replace); + } + } +} diff --git a/orchagent/response_publisher.h b/orchagent/response_publisher.h index 985532e827..e859852e3f 100644 --- a/orchagent/response_publisher.h +++ b/orchagent/response_publisher.h @@ -1,7 +1,11 @@ #pragma once +#include #include +#include +#include #include +#include #include #include @@ -17,9 +21,9 @@ class ResponsePublisher : public ResponsePublisherInterface { public: - explicit ResponsePublisher(bool buffered = false); + explicit ResponsePublisher(const std::string &dbName, bool buffered = false, bool db_write_thread = false); - virtual ~ResponsePublisher() = default; + virtual ~ResponsePublisher(); // Intent attributes are the attributes sent in the notification into the // redis channel. @@ -57,8 +61,39 @@ class ResponsePublisher : public ResponsePublisherInterface void setBuffered(bool buffered); private: + struct entry + { + std::string table; + std::string key; + std::vector values; + std::string op; + bool replace; + bool flush; + bool shutdown; + + entry() + { + } + + entry(const std::string &table, const std::string &key, const std::vector &values, + const std::string &op, bool replace, bool flush, bool shutdown) + : table(table), key(key), values(values), op(op), replace(replace), flush(flush), shutdown(shutdown) + { + } + }; + + void dbUpdateThread(); + void writeToDBInternal(const std::string &table, const std::string &key, + const std::vector &values, const std::string &op, bool replace); + std::unique_ptr m_db; - std::unique_ptr m_pipe; + std::unique_ptr m_ntf_pipe; + std::unique_ptr m_db_pipe; bool m_buffered{false}; + // Thread to write to DB. + std::unique_ptr m_update_thread; + std::queue m_queue; + mutable std::mutex m_lock; + std::condition_variable m_signal; }; diff --git a/orchagent/return_code.h b/orchagent/return_code.h index ed154784b7..c9b404f5d7 100644 --- a/orchagent/return_code.h +++ b/orchagent/return_code.h @@ -177,7 +177,24 @@ class ReturnCode ReturnCode(const sai_status_t &status, const std::string &message = "") : stream_(std::ios_base::out | std::ios_base::ate), is_sai_(true) { - if (m_saiStatusCodeLookup.find(status) == m_saiStatusCodeLookup.end()) + // Non-ranged SAI codes that are not included in this lookup map will map to + // SWSS_RC_UNKNOWN. This includes the general SAI failure: + // SAI_STATUS_FAILURE. + static const auto *const saiStatusCodeLookup = new std::unordered_map({ + {SAI_STATUS_SUCCESS, StatusCode::SWSS_RC_SUCCESS}, + {SAI_STATUS_NOT_SUPPORTED, StatusCode::SWSS_RC_UNIMPLEMENTED}, + {SAI_STATUS_NO_MEMORY, StatusCode::SWSS_RC_NO_MEMORY}, + {SAI_STATUS_INSUFFICIENT_RESOURCES, StatusCode::SWSS_RC_FULL}, + {SAI_STATUS_INVALID_PARAMETER, StatusCode::SWSS_RC_INVALID_PARAM}, + {SAI_STATUS_ITEM_ALREADY_EXISTS, StatusCode::SWSS_RC_EXISTS}, + {SAI_STATUS_ITEM_NOT_FOUND, StatusCode::SWSS_RC_NOT_FOUND}, + {SAI_STATUS_TABLE_FULL, StatusCode::SWSS_RC_FULL}, + {SAI_STATUS_NOT_IMPLEMENTED, StatusCode::SWSS_RC_UNIMPLEMENTED}, + {SAI_STATUS_OBJECT_IN_USE, StatusCode::SWSS_RC_IN_USE}, + {SAI_STATUS_NOT_EXECUTED, StatusCode::SWSS_RC_NOT_EXECUTED}, + }); + + if (saiStatusCodeLookup->find(status) == saiStatusCodeLookup->end()) { // Check for ranged SAI codes. if (SAI_RANGED_STATUS_IS_INVALID_ATTRIBUTE(status)) @@ -207,7 +224,7 @@ class ReturnCode } else { - status_ = m_saiStatusCodeLookup[status]; + status_ = saiStatusCodeLookup->at(status); } stream_ << message; } @@ -298,21 +315,6 @@ class ReturnCode } private: - // Non-ranged SAI codes that are not included in this lookup map will map to - // SWSS_RC_UNKNOWN. This includes the general SAI failure: SAI_STATUS_FAILURE. - std::unordered_map m_saiStatusCodeLookup = { - {SAI_STATUS_SUCCESS, StatusCode::SWSS_RC_SUCCESS}, - {SAI_STATUS_NOT_SUPPORTED, StatusCode::SWSS_RC_UNIMPLEMENTED}, - {SAI_STATUS_NO_MEMORY, StatusCode::SWSS_RC_NO_MEMORY}, - {SAI_STATUS_INSUFFICIENT_RESOURCES, StatusCode::SWSS_RC_FULL}, - {SAI_STATUS_INVALID_PARAMETER, StatusCode::SWSS_RC_INVALID_PARAM}, - {SAI_STATUS_ITEM_ALREADY_EXISTS, StatusCode::SWSS_RC_EXISTS}, - {SAI_STATUS_ITEM_NOT_FOUND, StatusCode::SWSS_RC_NOT_FOUND}, - {SAI_STATUS_TABLE_FULL, StatusCode::SWSS_RC_FULL}, - {SAI_STATUS_NOT_IMPLEMENTED, StatusCode::SWSS_RC_UNIMPLEMENTED}, - {SAI_STATUS_OBJECT_IN_USE, StatusCode::SWSS_RC_IN_USE}, - }; - StatusCode status_; std::stringstream stream_; // Whether the ReturnCode is generated from a SAI status code or not. diff --git a/tests/mock_tests/fake_response_publisher.cpp b/tests/mock_tests/fake_response_publisher.cpp index 29a28d2360..5e6aa0f2a0 100644 --- a/tests/mock_tests/fake_response_publisher.cpp +++ b/tests/mock_tests/fake_response_publisher.cpp @@ -8,7 +8,10 @@ * when needed to test code that uses response publisher. */ std::unique_ptr gMockResponsePublisher; -ResponsePublisher::ResponsePublisher(bool buffered) : m_db(std::make_unique("APPL_STATE_DB", 0)), m_buffered(buffered) {} +ResponsePublisher::ResponsePublisher(const std::string& dbName, bool buffered, bool db_write_thread) : + m_db(std::make_unique(dbName, 0)), m_buffered(buffered) {} + +ResponsePublisher::~ResponsePublisher() {} void ResponsePublisher::publish( const std::string& table, const std::string& key, diff --git a/tests/mock_tests/response_publisher/response_publisher_ut.cpp b/tests/mock_tests/response_publisher/response_publisher_ut.cpp index 9e836bad04..ca4956fdcf 100644 --- a/tests/mock_tests/response_publisher/response_publisher_ut.cpp +++ b/tests/mock_tests/response_publisher/response_publisher_ut.cpp @@ -9,7 +9,7 @@ TEST(ResponsePublisher, TestPublish) DBConnector conn{"APPL_STATE_DB", 0}; Table stateTable{&conn, "SOME_TABLE"}; std::string value; - ResponsePublisher publisher{}; + ResponsePublisher publisher{"APPL_STATE_DB"}; publisher.publish("SOME_TABLE", "SOME_KEY", {{"field", "value"}}, ReturnCode(SAI_STATUS_SUCCESS)); ASSERT_TRUE(stateTable.hget("SOME_KEY", "field", value)); @@ -21,7 +21,7 @@ TEST(ResponsePublisher, TestPublishBuffered) DBConnector conn{"APPL_STATE_DB", 0}; Table stateTable{&conn, "SOME_TABLE"}; std::string value; - ResponsePublisher publisher{}; + ResponsePublisher publisher{"APPL_STATE_DB"}; publisher.setBuffered(true); diff --git a/tests/p4rt/test_l3.py b/tests/p4rt/test_l3.py index a16c8d3f03..0536e88b4f 100644 --- a/tests/p4rt/test_l3.py +++ b/tests/p4rt/test_l3.py @@ -59,11 +59,6 @@ def test_IPv4RouteWithNexthopAddUpdateDeletePass(self, dvs, testlog): "%s:%s" % (self._p4rt_route_obj.APP_DB_TBL_NAME, self._p4rt_route_obj.TBL_NAME), ), - ( - self._p4rt_route_obj.appl_state_db, - "%s:%s" - % (self._p4rt_route_obj.APP_DB_TBL_NAME, self._p4rt_route_obj.TBL_NAME), - ), (self._p4rt_route_obj.asic_db, self._p4rt_route_obj.ASIC_DB_TBL_NAME), ) self._p4rt_route_obj.get_original_redis_entries(db_list) @@ -145,24 +140,6 @@ def test_IPv4RouteWithNexthopAddUpdateDeletePass(self, dvs, testlog): assert status == True util.verify_attr(fvs, attr_list) - # Query application state database for route entries. - state_route_entries = util.get_keys( - self._p4rt_route_obj.appl_state_db, - self._p4rt_route_obj.APP_DB_TBL_NAME + ":" + self._p4rt_route_obj.TBL_NAME, - ) - assert len(state_route_entries) == ( - self._p4rt_route_obj.get_original_appl_state_db_entries_count() + 1 - ) - - # Query application state database for newly created route key. - (status, fvs) = util.get_key( - self._p4rt_route_obj.appl_state_db, - self._p4rt_route_obj.APP_DB_TBL_NAME, - route_key, - ) - assert status == True - util.verify_attr(fvs, attr_list) - # Query ASIC database for route entries. route_entries = util.get_keys( self._p4rt_route_obj.asic_db, self._p4rt_route_obj.ASIC_DB_TBL_NAME @@ -227,24 +204,6 @@ def test_IPv4RouteWithNexthopAddUpdateDeletePass(self, dvs, testlog): ] util.verify_attr(fvs, attr_list_appl_db) - # Query application state database for route entries. - state_route_entries = util.get_keys( - self._p4rt_route_obj.appl_state_db, - self._p4rt_route_obj.APP_DB_TBL_NAME + ":" + self._p4rt_route_obj.TBL_NAME, - ) - assert len(state_route_entries) == ( - self._p4rt_route_obj.get_original_appl_state_db_entries_count() + 1 - ) - - # Query application state database for the updated route key. - (status, fvs) = util.get_key( - self._p4rt_route_obj.appl_state_db, - self._p4rt_route_obj.APP_DB_TBL_NAME, - route_key, - ) - assert status == True - util.verify_attr(fvs, attr_list) - # Query ASIC database for route entries. route_entries = util.get_keys( self._p4rt_route_obj.asic_db, self._p4rt_route_obj.ASIC_DB_TBL_NAME @@ -295,37 +254,6 @@ def test_IPv4RouteWithNexthopAddUpdateDeletePass(self, dvs, testlog): route_key, ) assert status == True - attr_list_appl_db = [ - (self._p4rt_route_obj.ACTION_FIELD, "drop"), - ( - util.prepend_param_field( - self._p4rt_route_obj.NEXTHOP_ID_FIELD), - nexthop_id, - ), - ( - util.prepend_param_field( - self._p4rt_route_obj.ROUTE_METADATA_FIELD), - "2", - ), - ] - util.verify_attr(fvs, attr_list_appl_db) - - # Query application state database for route entries. - state_route_entries = util.get_keys( - self._p4rt_route_obj.appl_state_db, - self._p4rt_route_obj.APP_DB_TBL_NAME + ":" + self._p4rt_route_obj.TBL_NAME, - ) - assert len(state_route_entries) == ( - self._p4rt_route_obj.get_original_appl_state_db_entries_count() + 1 - ) - - # Query application state database for the updated route key. - (status, fvs) = util.get_key( - self._p4rt_route_obj.appl_state_db, - self._p4rt_route_obj.APP_DB_TBL_NAME, - route_key, - ) - assert status == True util.verify_attr(fvs, attr_list) # Query ASIC database for route entries. @@ -417,24 +345,6 @@ def test_IPv4RouteWithNexthopAddUpdateDeletePass(self, dvs, testlog): ) assert status == False - # Query application state database for route entries. - state_route_entries = util.get_keys( - self._p4rt_route_obj.appl_state_db, - self._p4rt_route_obj.APP_DB_TBL_NAME + ":" + self._p4rt_route_obj.TBL_NAME, - ) - assert len(state_route_entries) == ( - self._p4rt_route_obj.get_original_appl_state_db_entries_count() - ) - - # Verify that the route_key no longer exists in application state - # database. - (status, fsv) = util.get_key( - self._p4rt_route_obj.appl_state_db, - self._p4rt_route_obj.APP_DB_TBL_NAME, - route_key, - ) - assert status == False - # Query ASIC database for route entries. route_entries = util.get_keys( self._p4rt_route_obj.asic_db, self._p4rt_route_obj.ASIC_DB_TBL_NAME @@ -468,11 +378,6 @@ def test_IPv6WithWcmpRouteAddUpdateDeletePass(self, dvs, testlog): "%s:%s" % (self._p4rt_route_obj.APP_DB_TBL_NAME, self._p4rt_route_obj.TBL_NAME), ), - ( - self._p4rt_route_obj.appl_state_db, - "%s:%s" - % (self._p4rt_route_obj.APP_DB_TBL_NAME, self._p4rt_route_obj.TBL_NAME), - ), (self._p4rt_route_obj.asic_db, self._p4rt_route_obj.ASIC_DB_TBL_NAME), ) self._p4rt_route_obj.get_original_redis_entries(db_list) @@ -490,14 +395,6 @@ def test_IPv6WithWcmpRouteAddUpdateDeletePass(self, dvs, testlog): self._p4rt_wcmp_group_obj.TBL_NAME, ), ), - ( - self._p4rt_wcmp_group_obj.appl_state_db, - "%s:%s" - % ( - self._p4rt_wcmp_group_obj.APP_DB_TBL_NAME, - self._p4rt_wcmp_group_obj.TBL_NAME, - ), - ), ( self._p4rt_wcmp_group_obj.asic_db, self._p4rt_wcmp_group_obj.ASIC_DB_GROUP_TBL_NAME, @@ -597,26 +494,6 @@ def test_IPv6WithWcmpRouteAddUpdateDeletePass(self, dvs, testlog): assert status == True util.verify_attr(fvs, attr_list) - # Query application state database for wcmp group entries. - state_wcmp_group_entries = util.get_keys( - self._p4rt_wcmp_group_obj.appl_state_db, - self._p4rt_wcmp_group_obj.APP_DB_TBL_NAME - + ":" - + self._p4rt_wcmp_group_obj.TBL_NAME, - ) - assert len(state_wcmp_group_entries) == ( - self._p4rt_wcmp_group_obj.get_original_appl_state_db_entries_count() + 1 - ) - - # Query application state database for newly created wcmp group key. - (status, fvs) = util.get_key( - self._p4rt_wcmp_group_obj.appl_state_db, - self._p4rt_wcmp_group_obj.APP_DB_TBL_NAME, - wcmp_group_key, - ) - assert status == True - util.verify_attr(fvs, attr_list) - # Query ASIC database for wcmp group entries. wcmp_group_entries = util.get_keys( self._p4rt_wcmp_group_obj.asic_db, @@ -708,24 +585,6 @@ def test_IPv6WithWcmpRouteAddUpdateDeletePass(self, dvs, testlog): assert status == True util.verify_attr(fvs, attr_list) - # Query application state database for route entries. - state_route_entries = util.get_keys( - self._p4rt_route_obj.appl_state_db, - self._p4rt_route_obj.APP_DB_TBL_NAME + ":" + self._p4rt_route_obj.TBL_NAME, - ) - assert len(state_route_entries) == ( - self._p4rt_route_obj.get_original_appl_state_db_entries_count() + 1 - ) - - # Query application state database for newly created route key. - (status, fvs) = util.get_key( - self._p4rt_route_obj.appl_state_db, - self._p4rt_route_obj.APP_DB_TBL_NAME, - route_key, - ) - assert status == True - util.verify_attr(fvs, attr_list) - # Query ASIC database for route entries. route_entries = util.get_keys( self._p4rt_route_obj.asic_db, self._p4rt_route_obj.ASIC_DB_TBL_NAME @@ -776,32 +635,6 @@ def test_IPv6WithWcmpRouteAddUpdateDeletePass(self, dvs, testlog): route_key, ) assert status == True - attr_list_appl_db = [ - (self._p4rt_route_obj.ACTION_FIELD, "drop"), - ( - util.prepend_param_field( - self._p4rt_route_obj.WCMP_GROUP_ID_FIELD), - wcmp_group_id, - ), - ] - util.verify_attr(fvs, attr_list_appl_db) - - # Query application state database for route entries. - state_route_entries = util.get_keys( - self._p4rt_route_obj.appl_state_db, - self._p4rt_route_obj.APP_DB_TBL_NAME + ":" + self._p4rt_route_obj.TBL_NAME, - ) - assert len(state_route_entries) == ( - self._p4rt_route_obj.get_original_appl_state_db_entries_count() + 1 - ) - - # Query application state database for the updated route key. - (status, fvs) = util.get_key( - self._p4rt_route_obj.appl_state_db, - self._p4rt_route_obj.APP_DB_TBL_NAME, - route_key, - ) - assert status == True util.verify_attr(fvs, attr_list) # Query ASIC database for route entries. @@ -859,32 +692,6 @@ def test_IPv6WithWcmpRouteAddUpdateDeletePass(self, dvs, testlog): route_key, ) assert status == True - attr_list_appl_db = [ - (self._p4rt_route_obj.ACTION_FIELD, "trap"), - ( - util.prepend_param_field( - self._p4rt_route_obj.WCMP_GROUP_ID_FIELD), - wcmp_group_id, - ), - ] - util.verify_attr(fvs, attr_list_appl_db) - - # Query application state database for route entries. - state_route_entries = util.get_keys( - self._p4rt_route_obj.appl_state_db, - self._p4rt_route_obj.APP_DB_TBL_NAME + ":" + self._p4rt_route_obj.TBL_NAME, - ) - assert len(state_route_entries) == ( - self._p4rt_route_obj.get_original_appl_state_db_entries_count() + 1 - ) - - # Query application state database for the updated route key. - (status, fvs) = util.get_key( - self._p4rt_route_obj.appl_state_db, - self._p4rt_route_obj.APP_DB_TBL_NAME, - route_key, - ) - assert status == True util.verify_attr(fvs, attr_list) # Query ASIC database for route entries. @@ -988,24 +795,6 @@ def test_IPv6WithWcmpRouteAddUpdateDeletePass(self, dvs, testlog): ) assert status == False - # Query application state database for route entries. - state_route_entries = util.get_keys( - self._p4rt_route_obj.appl_state_db, - self._p4rt_route_obj.APP_DB_TBL_NAME + ":" + self._p4rt_route_obj.TBL_NAME, - ) - assert len(state_route_entries) == ( - self._p4rt_route_obj.get_original_appl_state_db_entries_count() - ) - - # Verify that the route_key no longer exists in application state - # database. - (status, fsv) = util.get_key( - self._p4rt_route_obj.appl_state_db, - self._p4rt_route_obj.APP_DB_TBL_NAME, - route_key, - ) - assert status == False - # Query ASIC database for route entries. route_entries = util.get_keys( self._p4rt_route_obj.asic_db, self._p4rt_route_obj.ASIC_DB_TBL_NAME @@ -1041,26 +830,6 @@ def test_IPv6WithWcmpRouteAddUpdateDeletePass(self, dvs, testlog): ) assert status == False - # Query application state database for wcmp group entries. - state_wcmp_group_entries = util.get_keys( - self._p4rt_wcmp_group_obj.appl_state_db, - self._p4rt_wcmp_group_obj.APP_DB_TBL_NAME - + ":" - + self._p4rt_wcmp_group_obj.TBL_NAME, - ) - assert len(state_wcmp_group_entries) == ( - self._p4rt_wcmp_group_obj.get_original_appl_state_db_entries_count() - ) - - # Verify that the wcmp_group_key no longer exists in application state - # database. - (status, fsv) = util.get_key( - self._p4rt_wcmp_group_obj.appl_state_db, - self._p4rt_wcmp_group_obj.APP_DB_TBL_NAME, - wcmp_group_key, - ) - assert status == False - # Query ASIC database for wcmp group entries. wcmp_group_entries = util.get_keys( self._p4rt_wcmp_group_obj.asic_db, @@ -1114,14 +883,6 @@ def test_NexthopWithGreTunnelAddDeletePass(self, dvs, testlog): self._p4rt_nexthop_obj.TBL_NAME, ), ), - ( - self._p4rt_nexthop_obj.appl_state_db, - "%s:%s" - % ( - self._p4rt_nexthop_obj.APP_DB_TBL_NAME, - self._p4rt_nexthop_obj.TBL_NAME, - ), - ), (self._p4rt_nexthop_obj.asic_db, self._p4rt_nexthop_obj.ASIC_DB_TBL_NAME), ) @@ -1135,14 +896,6 @@ def test_NexthopWithGreTunnelAddDeletePass(self, dvs, testlog): self._p4rt_gre_tunnel_obj.TBL_NAME, ), ), - ( - self._p4rt_gre_tunnel_obj.appl_state_db, - "%s:%s" - % ( - self._p4rt_gre_tunnel_obj.APP_DB_TBL_NAME, - self._p4rt_gre_tunnel_obj.TBL_NAME, - ), - ), (self._p4rt_gre_tunnel_obj.asic_db, self._p4rt_gre_tunnel_obj.ASIC_DB_TBL_NAME), ) @@ -1215,25 +968,6 @@ def test_NexthopWithGreTunnelAddDeletePass(self, dvs, testlog): assert status == True util.verify_attr(fvs, attr_list) - # Query application state database for tunnel entries. - state_tunnel_entries = util.get_keys( - self._p4rt_gre_tunnel_obj.appl_state_db, - self._p4rt_gre_tunnel_obj.APP_DB_TBL_NAME + - ":" + self._p4rt_gre_tunnel_obj.TBL_NAME, - ) - assert len(state_tunnel_entries) == ( - self._p4rt_gre_tunnel_obj.get_original_appl_state_db_entries_count() + 1 - ) - - # Query application state database for newly created tunnel key. - (status, fvs) = util.get_key( - self._p4rt_gre_tunnel_obj.appl_state_db, - self._p4rt_gre_tunnel_obj.APP_DB_TBL_NAME, - tunnel_key, - ) - assert status == True - util.verify_attr(fvs, attr_list) - # Query ASIC database for tunnel entries. tunnel_entries = util.get_keys( self._p4rt_gre_tunnel_obj.asic_db, self._p4rt_gre_tunnel_obj.ASIC_DB_TBL_NAME @@ -1311,24 +1045,6 @@ def test_NexthopWithGreTunnelAddDeletePass(self, dvs, testlog): assert status == True util.verify_attr(fvs, attr_list) - # Query application state database for nexthop entries. - state_nexthop_entries = util.get_keys( - self._p4rt_nexthop_obj.appl_state_db, - self._p4rt_nexthop_obj.APP_DB_TBL_NAME + ":" + self._p4rt_nexthop_obj.TBL_NAME, - ) - assert len(state_nexthop_entries) == ( - self._p4rt_nexthop_obj.get_original_appl_state_db_entries_count() + 1 - ) - - # Query application state database for newly created nexthop key. - (status, fvs) = util.get_key( - self._p4rt_nexthop_obj.appl_state_db, - self._p4rt_nexthop_obj.APP_DB_TBL_NAME, - nexthop_key, - ) - assert status == True - util.verify_attr(fvs, attr_list) - # Query ASIC database for nexthop entries. nexthop_entries = util.get_keys( self._p4rt_nexthop_obj.asic_db, self._p4rt_nexthop_obj.ASIC_DB_TBL_NAME @@ -1418,24 +1134,6 @@ def test_NexthopWithGreTunnelAddDeletePass(self, dvs, testlog): ) assert status == False - # Query application state database for nexthop entries. - state_nexthop_entries = util.get_keys( - self._p4rt_nexthop_obj.appl_state_db, - self._p4rt_nexthop_obj.APP_DB_TBL_NAME + ":" + self._p4rt_nexthop_obj.TBL_NAME, - ) - assert len(state_nexthop_entries) == ( - self._p4rt_nexthop_obj.get_original_appl_state_db_entries_count() - ) - - # Verify that the nexthop_key no longer exists in application state - # database. - (status, fsv) = util.get_key( - self._p4rt_nexthop_obj.appl_state_db, - self._p4rt_nexthop_obj.APP_DB_TBL_NAME, - nexthop_key, - ) - assert status == False - # Query ASIC database for nexthop entries. nexthop_entries = util.get_keys( self._p4rt_nexthop_obj.asic_db, self._p4rt_nexthop_obj.ASIC_DB_TBL_NAME @@ -1470,25 +1168,6 @@ def test_NexthopWithGreTunnelAddDeletePass(self, dvs, testlog): ) assert status == False - # Query application state database for tunnel entries. - state_tunnel_entries = util.get_keys( - self._p4rt_gre_tunnel_obj.appl_state_db, - self._p4rt_gre_tunnel_obj.APP_DB_TBL_NAME + - ":" + self._p4rt_gre_tunnel_obj.TBL_NAME, - ) - assert len(state_tunnel_entries) == ( - self._p4rt_gre_tunnel_obj.get_original_appl_state_db_entries_count() - ) - - # Verify that the tunnel_key no longer exists in application state - # database. - (status, fsv) = util.get_key( - self._p4rt_gre_tunnel_obj.appl_state_db, - self._p4rt_gre_tunnel_obj.APP_DB_TBL_NAME, - tunnel_key, - ) - assert status == False - # Query ASIC database for tunnel entries. runnel_entries = util.get_keys( self._p4rt_gre_tunnel_obj.asic_db, self._p4rt_gre_tunnel_obj.ASIC_DB_TBL_NAME @@ -1524,11 +1203,6 @@ def test_IPv4RouteAddWithInvalidNexthopFail(self, dvs, testlog): "%s:%s" % (self._p4rt_route_obj.APP_DB_TBL_NAME, self._p4rt_route_obj.TBL_NAME), ), - ( - self._p4rt_route_obj.appl_state_db, - "%s:%s" - % (self._p4rt_route_obj.APP_DB_TBL_NAME, self._p4rt_route_obj.TBL_NAME), - ), (self._p4rt_route_obj.asic_db, self._p4rt_route_obj.ASIC_DB_TBL_NAME), ) self._p4rt_route_obj.get_original_redis_entries(db_list) @@ -1558,25 +1232,6 @@ def test_IPv4RouteAddWithInvalidNexthopFail(self, dvs, testlog): assert status == True util.verify_attr(fvs, attr_list) - # Query application database for route entries (no new route entry - # expected). - state_route_entries = util.get_keys( - self._p4rt_route_obj.appl_state_db, - self._p4rt_route_obj.APP_DB_TBL_NAME + ":" + self._p4rt_route_obj.TBL_NAME, - ) - assert len(state_route_entries) == ( - self._p4rt_route_obj.get_original_appl_state_db_entries_count() - ) - - # Verify that the newly added route key does not exist in application - # state db. - (status, fvs) = util.get_key( - self._p4rt_route_obj.appl_state_db, - self._p4rt_route_obj.APP_DB_TBL_NAME, - route_key, - ) - assert status == False - # Query ASIC database for route entries (no new ASIC DB entry should be # created for route entry). route_entries = util.get_keys( @@ -1612,11 +1267,6 @@ def test_IPv6RouteAddWithInvalidWcmpFail(self, dvs, testlog): "%s:%s" % (self._p4rt_route_obj.APP_DB_TBL_NAME, self._p4rt_route_obj.TBL_NAME), ), - ( - self._p4rt_route_obj.appl_state_db, - "%s:%s" - % (self._p4rt_route_obj.APP_DB_TBL_NAME, self._p4rt_route_obj.TBL_NAME), - ), (self._p4rt_route_obj.asic_db, self._p4rt_route_obj.ASIC_DB_TBL_NAME), ) self._p4rt_route_obj.get_original_redis_entries(db_list) @@ -1648,25 +1298,6 @@ def test_IPv6RouteAddWithInvalidWcmpFail(self, dvs, testlog): assert status == True util.verify_attr(fvs, attr_list) - # Query application state database for route entries (no new APPL STATE DB - # entry should be created for route entry). - state_route_entries = util.get_keys( - self._p4rt_route_obj.appl_state_db, - self._p4rt_route_obj.APP_DB_TBL_NAME + ":" + self._p4rt_route_obj.TBL_NAME, - ) - assert len(state_route_entries) == ( - self._p4rt_route_obj.get_original_appl_state_db_entries_count() - ) - - # Verify that newly created route key does not exist in application - # state db. - (status, fvs) = util.get_key( - self._p4rt_route_obj.appl_state_db, - self._p4rt_route_obj.APP_DB_TBL_NAME, - route_key, - ) - assert status == False - # Query ASIC database for route entries (no new ASIC DB entry should be # created for route entry). route_entries = util.get_keys( @@ -1699,14 +1330,6 @@ def test_PruneAndRestoreNextHop(self, dvs, testlog): self._p4rt_wcmp_group_obj.TBL_NAME, ), ), - ( - self._p4rt_wcmp_group_obj.appl_state_db, - "%s:%s" - % ( - self._p4rt_wcmp_group_obj.APP_DB_TBL_NAME, - self._p4rt_wcmp_group_obj.TBL_NAME, - ), - ), ( self._p4rt_wcmp_group_obj.asic_db, self._p4rt_wcmp_group_obj.ASIC_DB_GROUP_TBL_NAME, @@ -1813,26 +1436,6 @@ def test_PruneAndRestoreNextHop(self, dvs, testlog): assert status == True util.verify_attr(fvs, attr_list) - # Query application state database for wcmp group entries. - state_wcmp_group_entries = util.get_keys( - self._p4rt_wcmp_group_obj.appl_state_db, - self._p4rt_wcmp_group_obj.APP_DB_TBL_NAME - + ":" - + self._p4rt_wcmp_group_obj.TBL_NAME, - ) - assert len(state_wcmp_group_entries) == ( - self._p4rt_wcmp_group_obj.get_original_appl_state_db_entries_count() + 1 - ) - - # Query application state database for newly created wcmp group key. - (status, fvs) = util.get_key( - self._p4rt_wcmp_group_obj.appl_state_db, - self._p4rt_wcmp_group_obj.APP_DB_TBL_NAME, - wcmp_group_key, - ) - assert status == True - util.verify_attr(fvs, attr_list) - # Query ASIC database for wcmp group entries. wcmp_group_entries = util.get_keys( self._p4rt_wcmp_group_obj.asic_db, @@ -1898,15 +1501,6 @@ def test_PruneAndRestoreNextHop(self, dvs, testlog): self._p4rt_wcmp_group_obj.get_original_asic_db_member_entries_count() ) - # Check APPL STATE DB to verify no change. - (status, fvs) = util.get_key( - self._p4rt_wcmp_group_obj.appl_state_db, - self._p4rt_wcmp_group_obj.APP_DB_TBL_NAME, - wcmp_group_key, - ) - assert status == True - util.verify_attr(fvs, attr_list) - # Force oper-up for associated port. util.set_interface_status(dvs, if_name, "up") @@ -1940,19 +1534,6 @@ def test_PruneAndRestoreNextHop(self, dvs, testlog): assert status == True assert len(fvs) == len(original_key_oid_info) + count - # Verify that APPL STATE DB is now updated. - state_wcmp_group_entries = util.get_keys( - self._p4rt_wcmp_group_obj.appl_state_db, - ( - self._p4rt_wcmp_group_obj.APP_DB_TBL_NAME - + ":" - + self._p4rt_wcmp_group_obj.TBL_NAME - ), - ) - assert len(state_wcmp_group_entries) == ( - self._p4rt_wcmp_group_obj.get_original_appl_state_db_entries_count() - ) - # Delete next hop. self._p4rt_nexthop_obj.remove_app_db_entry(nexthop_key) @@ -1994,14 +1575,6 @@ def test_PruneNextHopOnWarmBoot(self, dvs, testlog): self._p4rt_wcmp_group_obj.TBL_NAME, ), ), - ( - self._p4rt_wcmp_group_obj.appl_state_db, - "%s:%s" - % ( - self._p4rt_wcmp_group_obj.APP_DB_TBL_NAME, - self._p4rt_wcmp_group_obj.TBL_NAME, - ), - ), ( self._p4rt_wcmp_group_obj.asic_db, self._p4rt_wcmp_group_obj.ASIC_DB_GROUP_TBL_NAME, @@ -2108,26 +1681,6 @@ def test_PruneNextHopOnWarmBoot(self, dvs, testlog): assert status == True util.verify_attr(fvs, attr_list) - # Query application state database for wcmp group entries. - state_wcmp_group_entries = util.get_keys( - self._p4rt_wcmp_group_obj.appl_state_db, - self._p4rt_wcmp_group_obj.APP_DB_TBL_NAME - + ":" - + self._p4rt_wcmp_group_obj.TBL_NAME, - ) - assert len(state_wcmp_group_entries) == ( - self._p4rt_wcmp_group_obj.get_original_appl_state_db_entries_count() + 1 - ) - - # Query application state database for newly created wcmp group key. - (status, fvs) = util.get_key( - self._p4rt_wcmp_group_obj.appl_state_db, - self._p4rt_wcmp_group_obj.APP_DB_TBL_NAME, - wcmp_group_key, - ) - assert status == True - util.verify_attr(fvs, attr_list) - # Query ASIC database for wcmp group entries. wcmp_group_entries = util.get_keys( self._p4rt_wcmp_group_obj.asic_db, @@ -2219,19 +1772,6 @@ def test_PruneNextHopOnWarmBoot(self, dvs, testlog): assert status == True assert len(fvs) == len(original_key_oid_info) + count - # Verify that APPL STATE DB is updated. - state_wcmp_group_entries = util.get_keys( - self._p4rt_wcmp_group_obj.appl_state_db, - ( - self._p4rt_wcmp_group_obj.APP_DB_TBL_NAME - + ":" - + self._p4rt_wcmp_group_obj.TBL_NAME - ), - ) - assert len(state_wcmp_group_entries) == ( - self._p4rt_wcmp_group_obj.get_original_appl_state_db_entries_count() - ) - # Delete next hop. self._p4rt_nexthop_obj.remove_app_db_entry(nexthop_key) @@ -2273,14 +1813,6 @@ def test_CreateWcmpMemberForOperUpWatchportOnly(self, dvs, testlog): self._p4rt_wcmp_group_obj.TBL_NAME, ), ), - ( - self._p4rt_wcmp_group_obj.appl_state_db, - "%s:%s" - % ( - self._p4rt_wcmp_group_obj.APP_DB_TBL_NAME, - self._p4rt_wcmp_group_obj.TBL_NAME, - ), - ), ( self._p4rt_wcmp_group_obj.asic_db, self._p4rt_wcmp_group_obj.ASIC_DB_GROUP_TBL_NAME, @@ -2387,26 +1919,6 @@ def test_CreateWcmpMemberForOperUpWatchportOnly(self, dvs, testlog): assert status == True util.verify_attr(fvs, attr_list) - # Query application state database for wcmp group entries. - state_wcmp_group_entries = util.get_keys( - self._p4rt_wcmp_group_obj.appl_state_db, - self._p4rt_wcmp_group_obj.APP_DB_TBL_NAME - + ":" - + self._p4rt_wcmp_group_obj.TBL_NAME, - ) - assert len(state_wcmp_group_entries) == ( - self._p4rt_wcmp_group_obj.get_original_appl_state_db_entries_count() + 1 - ) - - # Query application state database for newly created wcmp group key. - (status, fvs) = util.get_key( - self._p4rt_wcmp_group_obj.appl_state_db, - self._p4rt_wcmp_group_obj.APP_DB_TBL_NAME, - wcmp_group_key, - ) - assert status == True - util.verify_attr(fvs, attr_list) - # Query ASIC database for wcmp group entries. wcmp_group_entries = util.get_keys( self._p4rt_wcmp_group_obj.asic_db, @@ -2496,19 +2008,6 @@ def test_CreateWcmpMemberForOperUpWatchportOnly(self, dvs, testlog): assert status == True assert len(fvs) == len(original_key_oid_info) + count - # Verify that APPL STATE DB is updated. - state_wcmp_group_entries = util.get_keys( - self._p4rt_wcmp_group_obj.appl_state_db, - ( - self._p4rt_wcmp_group_obj.APP_DB_TBL_NAME - + ":" - + self._p4rt_wcmp_group_obj.TBL_NAME - ), - ) - assert len(state_wcmp_group_entries) == ( - self._p4rt_wcmp_group_obj.get_original_appl_state_db_entries_count() - ) - # Delete next hop. self._p4rt_nexthop_obj.remove_app_db_entry(nexthop_key) @@ -2550,14 +2049,6 @@ def test_RemovePrunedWcmpGroupMember(self, dvs, testlog): self._p4rt_wcmp_group_obj.TBL_NAME, ), ), - ( - self._p4rt_wcmp_group_obj.appl_state_db, - "%s:%s" - % ( - self._p4rt_wcmp_group_obj.APP_DB_TBL_NAME, - self._p4rt_wcmp_group_obj.TBL_NAME, - ), - ), ( self._p4rt_wcmp_group_obj.asic_db, self._p4rt_wcmp_group_obj.ASIC_DB_GROUP_TBL_NAME, @@ -2664,26 +2155,6 @@ def test_RemovePrunedWcmpGroupMember(self, dvs, testlog): assert status == True util.verify_attr(fvs, attr_list) - # Query application state database for wcmp group entries. - state_wcmp_group_entries = util.get_keys( - self._p4rt_wcmp_group_obj.appl_db, - self._p4rt_wcmp_group_obj.APP_DB_TBL_NAME - + ":" - + self._p4rt_wcmp_group_obj.TBL_NAME, - ) - assert len(state_wcmp_group_entries) == ( - self._p4rt_wcmp_group_obj.get_original_appl_state_db_entries_count() + 1 - ) - - # Query application state database for newly created wcmp group key. - (status, fvs) = util.get_key( - self._p4rt_wcmp_group_obj.appl_state_db, - self._p4rt_wcmp_group_obj.APP_DB_TBL_NAME, - wcmp_group_key, - ) - assert status == True - util.verify_attr(fvs, attr_list) - # Query ASIC database for wcmp group entries. wcmp_group_entries = util.get_keys( self._p4rt_wcmp_group_obj.asic_db, @@ -2740,14 +2211,6 @@ def test_RemovePrunedWcmpGroupMember(self, dvs, testlog): assert status == True assert len(fvs) == len(original_key_oid_info) + count - # Verify that the next hop still exists in app state db. - (status, fvs) = util.get_key( - self._p4rt_nexthop_obj.appl_state_db, - self._p4rt_nexthop_obj.APP_DB_TBL_NAME, - nexthop_key, - ) - assert status == True - # Delete the pruned wcmp group member and try again. self._p4rt_wcmp_group_obj.remove_app_db_entry(wcmp_group_key) @@ -2757,19 +2220,6 @@ def test_RemovePrunedWcmpGroupMember(self, dvs, testlog): assert status == True assert len(fvs) == len(original_key_oid_info) + count - # Verify that APPL STATE DB is updated. - state_wcmp_group_entries = util.get_keys( - self._p4rt_wcmp_group_obj.appl_state_db, - ( - self._p4rt_wcmp_group_obj.APP_DB_TBL_NAME - + ":" - + self._p4rt_wcmp_group_obj.TBL_NAME - ), - ) - assert len(state_wcmp_group_entries) == ( - self._p4rt_wcmp_group_obj.get_original_appl_state_db_entries_count() - ) - # Verify that ASIC DB is updated. wcmp_group_entries = util.get_keys( self._p4rt_wcmp_group_obj.asic_db, @@ -2828,14 +2278,6 @@ def test_NexthopWithGreTunnelCreationFailIfDependenciesAreMissing(self, dvs, tes self._p4rt_nexthop_obj.TBL_NAME, ), ), - ( - self._p4rt_nexthop_obj.appl_state_db, - "%s:%s" - % ( - self._p4rt_nexthop_obj.APP_DB_TBL_NAME, - self._p4rt_nexthop_obj.TBL_NAME, - ), - ), (self._p4rt_nexthop_obj.asic_db, self._p4rt_nexthop_obj.ASIC_DB_TBL_NAME), ) @@ -2849,14 +2291,6 @@ def test_NexthopWithGreTunnelCreationFailIfDependenciesAreMissing(self, dvs, tes self._p4rt_gre_tunnel_obj.TBL_NAME, ), ), - ( - self._p4rt_gre_tunnel_obj.appl_state_db, - "%s:%s" - % ( - self._p4rt_gre_tunnel_obj.APP_DB_TBL_NAME, - self._p4rt_gre_tunnel_obj.TBL_NAME, - ), - ), (self._p4rt_gre_tunnel_obj.asic_db, self._p4rt_gre_tunnel_obj.ASIC_DB_TBL_NAME), ) @@ -2893,16 +2327,6 @@ def test_NexthopWithGreTunnelCreationFailIfDependenciesAreMissing(self, dvs, tes self._p4rt_gre_tunnel_obj.get_original_appl_db_entries_count() + 1 ) - # Query application state database for tunnel entries. - state_tunnel_entries = util.get_keys( - self._p4rt_gre_tunnel_obj.appl_state_db, - self._p4rt_gre_tunnel_obj.APP_DB_TBL_NAME + - ":" + self._p4rt_gre_tunnel_obj.TBL_NAME, - ) - assert len(state_tunnel_entries) == ( - self._p4rt_gre_tunnel_obj.get_original_appl_state_db_entries_count() - ) - # Query ASIC database for tunnel entries. tunnel_entries = util.get_keys( self._p4rt_gre_tunnel_obj.asic_db, self._p4rt_gre_tunnel_obj.ASIC_DB_TBL_NAME @@ -2934,15 +2358,6 @@ def test_NexthopWithGreTunnelCreationFailIfDependenciesAreMissing(self, dvs, tes self._p4rt_nexthop_obj.get_original_appl_db_entries_count() + 1 ) - # Query application state database for nexthop entries. - state_nexthop_entries = util.get_keys( - self._p4rt_nexthop_obj.appl_state_db, - self._p4rt_nexthop_obj.APP_DB_TBL_NAME + ":" + self._p4rt_nexthop_obj.TBL_NAME, - ) - assert len(state_nexthop_entries) == ( - self._p4rt_nexthop_obj.get_original_appl_state_db_entries_count() - ) - # Query ASIC database for nexthop entries. nexthop_entries = util.get_keys( self._p4rt_nexthop_obj.asic_db, self._p4rt_nexthop_obj.ASIC_DB_TBL_NAME diff --git a/tests/p4rt/test_l3_admit.py b/tests/p4rt/test_l3_admit.py index 81ffdf884a..8fc3bbb8d4 100644 --- a/tests/p4rt/test_l3_admit.py +++ b/tests/p4rt/test_l3_admit.py @@ -29,11 +29,6 @@ def test_DefaultL3AdmitAddDeletePass(self, dvs, testlog): "%s:%s" % (self._p4rt_l3_admit_obj.APP_DB_TBL_NAME, self._p4rt_l3_admit_obj.TBL_NAME), ), - ( - self._p4rt_l3_admit_obj.appl_state_db, - "%s:%s" - % (self._p4rt_l3_admit_obj.APP_DB_TBL_NAME, self._p4rt_l3_admit_obj.TBL_NAME), - ), (self._p4rt_l3_admit_obj.asic_db, self._p4rt_l3_admit_obj.ASIC_DB_TBL_NAME), ) @@ -86,25 +81,6 @@ def test_DefaultL3AdmitAddDeletePass(self, dvs, testlog): assert status == True util.verify_attr(fvs, attr_list) - # Query application state database for l3 admit entries. - state_l3_admit_entries = util.get_keys( - self._p4rt_l3_admit_obj.appl_state_db, - self._p4rt_l3_admit_obj.APP_DB_TBL_NAME + - ":" + self._p4rt_l3_admit_obj.TBL_NAME, - ) - assert len(state_l3_admit_entries) == ( - self._p4rt_l3_admit_obj.get_original_appl_state_db_entries_count() + 1 - ) - - # Query application state database for newly created l3 admit key. - (status, fvs) = util.get_key( - self._p4rt_l3_admit_obj.appl_state_db, - self._p4rt_l3_admit_obj.APP_DB_TBL_NAME, - l3_admit_key, - ) - assert status == True - util.verify_attr(fvs, attr_list) - # Query ASIC database for my mac entries. asic_l3_admit_entries = util.get_keys( self._p4rt_l3_admit_obj.asic_db, self._p4rt_l3_admit_obj.ASIC_DB_TBL_NAME @@ -170,24 +146,6 @@ def test_DefaultL3AdmitAddDeletePass(self, dvs, testlog): ) assert status == False - # Query application database for route entries. - state_l3_admit_entries = util.get_keys( - self._p4rt_l3_admit_obj.appl_state_db, - self._p4rt_l3_admit_obj.APP_DB_TBL_NAME + - ":" + self._p4rt_l3_admit_obj.TBL_NAME, - ) - assert len(state_l3_admit_entries) == ( - self._p4rt_l3_admit_obj.get_original_appl_state_db_entries_count() - ) - - # Verify that the route_key no longer exists in application database. - (status, fsv) = util.get_key( - self._p4rt_l3_admit_obj.appl_state_db, - self._p4rt_l3_admit_obj.APP_DB_TBL_NAME, - l3_admit_key, - ) - assert status == False - # Query ASIC database for my mac entries. my_mac_entries = util.get_keys( self._p4rt_l3_admit_obj.asic_db, self._p4rt_l3_admit_obj.ASIC_DB_TBL_NAME @@ -216,11 +174,6 @@ def test_InvalidL3AdmitKeyFailsToCreate(self, dvs, testlog): "%s:%s" % (self._p4rt_l3_admit_obj.APP_DB_TBL_NAME, self._p4rt_l3_admit_obj.TBL_NAME), ), - ( - self._p4rt_l3_admit_obj.appl_state_db, - "%s:%s" - % (self._p4rt_l3_admit_obj.APP_DB_TBL_NAME, self._p4rt_l3_admit_obj.TBL_NAME), - ), (self._p4rt_l3_admit_obj.asic_db, self._p4rt_l3_admit_obj.ASIC_DB_TBL_NAME), ) diff --git a/tests/p4rt/test_p4rt_acl.py b/tests/p4rt/test_p4rt_acl.py index cfa1c0fb45..515354e101 100644 --- a/tests/p4rt/test_p4rt_acl.py +++ b/tests/p4rt/test_p4rt_acl.py @@ -81,12 +81,6 @@ def test_AclRulesAddUpdateDelPass(self, dvs, testlog): + ":" + self._p4rt_acl_table_definition_obj.TBL_NAME, ) - original_appl_state_acl_tables = util.get_keys( - self._p4rt_acl_table_definition_obj.appl_state_db, - self._p4rt_acl_table_definition_obj.APP_DB_TBL_NAME - + ":" - + self._p4rt_acl_table_definition_obj.TBL_NAME, - ) original_asic_acl_tables = util.get_keys( self._p4rt_acl_table_definition_obj.asic_db, self._p4rt_acl_table_definition_obj.ASIC_DB_TBL_NAME, @@ -241,26 +235,6 @@ def test_AclRulesAddUpdateDelPass(self, dvs, testlog): assert status == True util.verify_attr(fvs, attr_list) - # query application state database for ACL tables - state_acl_tables = util.get_keys( - self._p4rt_acl_table_definition_obj.appl_state_db, - self._p4rt_acl_table_definition_obj.APP_DB_TBL_NAME - + ":" - + self._p4rt_acl_table_definition_obj.TBL_NAME, - ) - assert len(state_acl_tables) == len(original_appl_state_acl_tables) + 1 - - # query application state database for newly created ACL table - (status, fvs) = util.get_key( - self._p4rt_acl_table_definition_obj.appl_state_db, - self._p4rt_acl_table_definition_obj.APP_DB_TBL_NAME - + ":" - + self._p4rt_acl_table_definition_obj.TBL_NAME, - table_name, - ) - assert status == True - util.verify_attr(fvs, attr_list) - asic_udf_matches = util.get_keys( self._p4rt_udf_match_obj.asic_db, self._p4rt_udf_match_obj.ASIC_DB_TBL_NAME ) @@ -422,10 +396,6 @@ def test_AclRulesAddUpdateDelPass(self, dvs, testlog): self._p4rt_acl_rule_obj.appl_db, self._p4rt_acl_rule_obj.APP_DB_TBL_NAME + ":" + table_name, ) - original_appl_state_acl_rules = util.get_keys( - self._p4rt_acl_rule_obj.appl_state_db, - self._p4rt_acl_rule_obj.APP_DB_TBL_NAME + ":" + table_name, - ) original_asic_acl_rules = util.get_keys( self._p4rt_acl_rule_obj.asic_db, self._p4rt_acl_rule_obj.ASIC_DB_TBL_NAME ) @@ -480,22 +450,6 @@ def test_AclRulesAddUpdateDelPass(self, dvs, testlog): assert status == True util.verify_attr(fvs, attr_list) - # query application state database for ACL rules - state_acl_rules = util.get_keys( - self._p4rt_acl_rule_obj.appl_state_db, - self._p4rt_acl_rule_obj.APP_DB_TBL_NAME + ":" + table_name, - ) - assert len(state_acl_rules) == len(original_appl_state_acl_rules) + 1 - - # query application state database for newly created ACL rule - (status, fvs) = util.get_key( - self._p4rt_acl_rule_obj.appl_state_db, - self._p4rt_acl_table_definition_obj.APP_DB_TBL_NAME, - table_name_with_rule_key1, - ) - assert status == True - util.verify_attr(fvs, attr_list) - # query ASIC database for ACL counters acl_asic_counters = util.get_keys( self._p4rt_acl_counter_obj.asic_db, @@ -653,22 +607,6 @@ def test_AclRulesAddUpdateDelPass(self, dvs, testlog): assert status == True util.verify_attr(fvs, attr_list) - # query application state database for ACL rules - state_acl_rules = util.get_keys( - self._p4rt_acl_rule_obj.appl_state_db, - self._p4rt_acl_rule_obj.APP_DB_TBL_NAME + ":" + table_name, - ) - assert len(state_acl_rules) == len(original_appl_state_acl_rules) + 1 - - # query application state database for updated ACL rule - (status, fvs) = util.get_key( - self._p4rt_acl_rule_obj.appl_state_db, - self._p4rt_acl_table_definition_obj.APP_DB_TBL_NAME, - table_name_with_rule_key1, - ) - assert status == True - util.verify_attr(fvs, attr_list) - # query ASIC database for ACL counters acl_asic_counters = util.get_keys( self._p4rt_acl_counter_obj.asic_db, @@ -827,22 +765,6 @@ def test_AclRulesAddUpdateDelPass(self, dvs, testlog): assert status == True util.verify_attr(fvs, attr_list) - # query application state database for ACL rules - state_acl_rules = util.get_keys( - self._p4rt_acl_rule_obj.appl_state_db, - self._p4rt_acl_rule_obj.APP_DB_TBL_NAME + ":" + table_name, - ) - assert len(state_acl_rules) == len(original_appl_state_acl_rules) + 2 - - # query application state database for newly created ACL rule - (status, fvs) = util.get_key( - self._p4rt_acl_rule_obj.appl_state_db, - self._p4rt_acl_table_definition_obj.APP_DB_TBL_NAME, - table_name_with_rule_key2, - ) - assert status == True - util.verify_attr(fvs, attr_list) - # query ASIC database for ACL counters acl_asic_counters = util.get_keys( self._p4rt_acl_counter_obj.asic_db, @@ -1025,22 +947,6 @@ def test_AclRulesAddUpdateDelPass(self, dvs, testlog): assert status == True util.verify_attr(fvs, attr_list) - # query application state database for ACL rules - state_acl_rules = util.get_keys( - self._p4rt_acl_rule_obj.appl_state_db, - self._p4rt_acl_rule_obj.APP_DB_TBL_NAME + ":" + table_name, - ) - assert len(state_acl_rules) == len(original_appl_state_acl_rules) + 3 - - # query application state database for newly created ACL rule - (status, fvs) = util.get_key( - self._p4rt_acl_rule_obj.appl_state_db, - self._p4rt_acl_table_definition_obj.APP_DB_TBL_NAME, - table_name_with_rule_key3, - ) - assert status == True - util.verify_attr(fvs, attr_list) - # query ASIC database for ACL counters acl_asic_counters = util.get_keys( self._p4rt_acl_counter_obj.asic_db, @@ -1136,21 +1042,6 @@ def test_AclRulesAddUpdateDelPass(self, dvs, testlog): ) assert status == False - # query application state database for ACL rules - state_acl_rules = util.get_keys( - self._p4rt_acl_rule_obj.appl_state_db, - self._p4rt_acl_rule_obj.APP_DB_TBL_NAME + ":" + table_name, - ) - assert len(state_acl_rules) == len(original_appl_state_acl_rules) + 2 - - # verify that the ACL rule no longer exists in application state database - (status, fvs) = util.get_key( - self._p4rt_acl_rule_obj.appl_state_db, - self._p4rt_acl_rule_obj.APP_DB_TBL_NAME, - table_name_with_rule_key3, - ) - assert status == False - # query ASIC database for ACL rules acl_rules = util.get_keys( self._p4rt_acl_rule_obj.asic_db, self._p4rt_acl_rule_obj.ASIC_DB_TBL_NAME @@ -1194,21 +1085,6 @@ def test_AclRulesAddUpdateDelPass(self, dvs, testlog): ) assert status == False - # query application state database for ACL rules - state_acl_rules = util.get_keys( - self._p4rt_acl_rule_obj.appl_state_db, - self._p4rt_acl_rule_obj.APP_DB_TBL_NAME + ":" + table_name, - ) - assert len(state_acl_rules) == len(original_appl_state_acl_rules) + 1 - - # verify that the ACL rule no longer exists in application state database - (status, fvs) = util.get_key( - self._p4rt_acl_rule_obj.appl_state_db, - self._p4rt_acl_rule_obj.APP_DB_TBL_NAME, - table_name_with_rule_key1, - ) - assert status == False - # query ASIC database for ACL rules acl_rules = util.get_keys( self._p4rt_acl_rule_obj.asic_db, self._p4rt_acl_rule_obj.ASIC_DB_TBL_NAME @@ -1260,21 +1136,6 @@ def test_AclRulesAddUpdateDelPass(self, dvs, testlog): ) assert status == False - # query application state database for ACL rules - state_acl_rules = util.get_keys( - self._p4rt_acl_rule_obj.appl_state_db, - self._p4rt_acl_rule_obj.APP_DB_TBL_NAME + ":" + table_name, - ) - assert len(state_acl_rules) == len(original_appl_state_acl_rules) - - # verify that the ACL rule no longer exists in application state database - (status, fvs) = util.get_key( - self._p4rt_acl_rule_obj.appl_state_db, - self._p4rt_acl_rule_obj.APP_DB_TBL_NAME, - table_name_with_rule_key2, - ) - assert status == False - # query ASIC database for ACL rules acl_rules = util.get_keys( self._p4rt_acl_rule_obj.asic_db, self._p4rt_acl_rule_obj.ASIC_DB_TBL_NAME @@ -1333,23 +1194,6 @@ def test_AclRulesAddUpdateDelPass(self, dvs, testlog): ) assert status == False - # query application state database for ACL tables - state_acl_tables = util.get_keys( - self._p4rt_acl_table_definition_obj.appl_state_db, - self._p4rt_acl_table_definition_obj.APP_DB_TBL_NAME - + ":" - + self._p4rt_acl_table_definition_obj.TBL_NAME, - ) - assert len(state_acl_tables) == len(original_appl_state_acl_tables) - - # verify that the ACL table no longer exists in application state database - (status, fvs) = util.get_key( - self._p4rt_acl_table_definition_obj.appl_state_db, - self._p4rt_acl_table_definition_obj.APP_DB_TBL_NAME, - self._p4rt_acl_table_definition_obj.TBL_NAME + ":" + table_name, - ) - assert status == False - # query ASIC database for ACL tables acl_tables = util.get_keys( self._p4rt_acl_table_definition_obj.asic_db, @@ -1376,10 +1220,6 @@ def test_AclRuleAddWithoutTableDefinitionFails(self, dvs, testlog): self._p4rt_acl_rule_obj.appl_db, self._p4rt_acl_rule_obj.APP_DB_TBL_NAME + ":" + table_name, ) - original_appl_state_acl_rules = util.get_keys( - self._p4rt_acl_rule_obj.appl_state_db, - self._p4rt_acl_rule_obj.APP_DB_TBL_NAME + ":" + table_name, - ) original_asic_acl_rules = util.get_keys( self._p4rt_acl_rule_obj.asic_db, self._p4rt_acl_rule_obj.ASIC_DB_TBL_NAME ) @@ -1428,13 +1268,6 @@ def test_AclRuleAddWithoutTableDefinitionFails(self, dvs, testlog): assert status == True util.verify_attr(fvs, attr_list) - # query application state database for ACL rules - state_acl_rules = util.get_keys( - self._p4rt_acl_rule_obj.appl_state_db, - self._p4rt_acl_rule_obj.APP_DB_TBL_NAME + ":" + table_name, - ) - assert len(state_acl_rules) == len(original_appl_state_acl_rules) - # query ASIC database for ACL rules acl_asic_rules = util.get_keys( self._p4rt_acl_rule_obj.asic_db, self._p4rt_acl_rule_obj.ASIC_DB_TBL_NAME diff --git a/tests/p4rt/test_p4rt_mirror.py b/tests/p4rt/test_p4rt_mirror.py index c1327370c3..1584d9961d 100644 --- a/tests/p4rt/test_p4rt_mirror.py +++ b/tests/p4rt/test_p4rt_mirror.py @@ -56,9 +56,6 @@ def test_MirrorSessionAddModifyAndDelete(self, dvs, testlog): original_appl_mirror_entries = util.get_keys( self._p4rt_mirror_session_wrapper.appl_db, self._p4rt_mirror_session_wrapper.APP_DB_TBL_NAME + ":" + self._p4rt_mirror_session_wrapper.TBL_NAME) - original_appl_state_mirror_entries = util.get_keys( - self._p4rt_mirror_session_wrapper.appl_state_db, - self._p4rt_mirror_session_wrapper.APP_DB_TBL_NAME + ":" + self._p4rt_mirror_session_wrapper.TBL_NAME) original_asic_mirror_entries = util.get_keys( self._p4rt_mirror_session_wrapper.asic_db, self._p4rt_mirror_session_wrapper.ASIC_DB_TBL_NAME) @@ -108,20 +105,6 @@ def test_MirrorSessionAddModifyAndDelete(self, dvs, testlog): assert status == True util.verify_attr(fvs, attr_list_in_app_db) - # Query application state database for mirror entries - appl_state_mirror_entries = util.get_keys( - self._p4rt_mirror_session_wrapper.appl_state_db, - self._p4rt_mirror_session_wrapper.APP_DB_TBL_NAME + ":" + self._p4rt_mirror_session_wrapper.TBL_NAME) - assert len(appl_state_mirror_entries) == len( - original_appl_state_mirror_entries) + 1 - - # Query application state database for newly created mirror key - (status, fvs) = util.get_key(self._p4rt_mirror_session_wrapper.appl_state_db, - self._p4rt_mirror_session_wrapper.APP_DB_TBL_NAME, - mirror_session_key) - assert status == True - util.verify_attr(fvs, attr_list_in_app_db) - # Query ASIC database for mirror entries asic_mirror_entries = util.get_keys(self._p4rt_mirror_session_wrapper.asic_db, self._p4rt_mirror_session_wrapper.ASIC_DB_TBL_NAME) @@ -180,13 +163,6 @@ def test_MirrorSessionAddModifyAndDelete(self, dvs, testlog): assert status == True util.verify_attr(fvs, attr_list_in_app_db) - # Query application state database for the modified mirror key - (status, fvs) = util.get_key(self._p4rt_mirror_session_wrapper.appl_state_db, - self._p4rt_mirror_session_wrapper.APP_DB_TBL_NAME, - mirror_session_key) - assert status == True - util.verify_attr(fvs, attr_list_in_app_db) - # Query ASIC DB about the modified mirror session. expected_attr_list_in_asic_db[9] = ( self._p4rt_mirror_session_wrapper.SAI_MIRROR_SESSION_ATTR_DST_MAC_ADDRESS, new_dst_mac) @@ -214,19 +190,6 @@ def test_MirrorSessionAddModifyAndDelete(self, dvs, testlog): mirror_session_key) assert status == False - # Query application state database for mirror entries - appl_state_mirror_entries = util.get_keys( - self._p4rt_mirror_session_wrapper.appl_state_db, - self._p4rt_mirror_session_wrapper.APP_DB_TBL_NAME + ":" + self._p4rt_mirror_session_wrapper.TBL_NAME) - assert len(appl_state_mirror_entries) == len( - original_appl_state_mirror_entries) - - # Query application state database for the deleted mirror key - (status, fvs) = util.get_key(self._p4rt_mirror_session_wrapper.appl_state_db, - self._p4rt_mirror_session_wrapper.APP_DB_TBL_NAME, - mirror_session_key) - assert status == False - # Query ASIC database for mirror entries asic_mirror_entries = util.get_keys(self._p4rt_mirror_session_wrapper.asic_db, self._p4rt_mirror_session_wrapper.ASIC_DB_TBL_NAME) diff --git a/tests/p4rt/test_viplb.py b/tests/p4rt/test_viplb.py index fbb51ea48d..fd5e90e05d 100644 --- a/tests/p4rt/test_viplb.py +++ b/tests/p4rt/test_viplb.py @@ -69,9 +69,6 @@ def test_VIPv4LBWithGoodNexthopAddUpdateDeletePass(self, dvs, testlog): db_list = ((self._p4rt_viplb_obj.appl_db, "%s:%s" % (self._p4rt_viplb_obj.APP_DB_TBL_NAME, self._p4rt_viplb_obj.TBL_NAME)), - (self._p4rt_viplb_obj.appl_state_db, - "%s:%s" % (self._p4rt_viplb_obj.APP_DB_TBL_NAME, - self._p4rt_viplb_obj.TBL_NAME)), (self._p4rt_viplb_obj.asic_db, self._p4rt_viplb_obj.ASIC_DB_TBL_NAME)) self._p4rt_viplb_obj.get_original_redis_entries(db_list) @@ -150,22 +147,6 @@ def test_VIPv4LBWithGoodNexthopAddUpdateDeletePass(self, dvs, testlog): assert status == True util.verify_attr(fvs, attr_list) - # Query application state database for viplb entries. - state_viplb_entries = util.get_keys( - self._p4rt_viplb_obj.appl_state_db, - self._p4rt_viplb_obj.APP_DB_TBL_NAME + ":" + self._p4rt_viplb_obj.TBL_NAME) - assert len(state_viplb_entries) == ( - self._p4rt_viplb_obj.get_original_appl_state_db_entries_count() + 1 - ) - - # Query application state database for newly created viplb key. - (status, fvs) = util.get_key(self._p4rt_viplb_obj.appl_state_db, - self._p4rt_viplb_obj.APP_DB_TBL_NAME, - viplb_key) - assert status == True - util.verify_attr(fvs, attr_list) - - # get programmable_object_oid of newly created viplb viplb_oid = self._p4rt_viplb_obj.get_newly_created_programmable_object_oid() assert viplb_oid is not None diff --git a/tests/p4rt/util.py b/tests/p4rt/util.py index ac46a48587..7959aecb50 100644 --- a/tests/p4rt/util.py +++ b/tests/p4rt/util.py @@ -49,7 +49,8 @@ def prepend_param_field(param_field): def verify_response(consumer, key, attr_list, status, err_message = "SWSS_RC_SUCCESS"): """ Verifies a response.""" - consumer.readData() + if consumer.peek() <= 0: + consumer.readData() (op, data, values) = consumer.pop() assert data == key assert op == status