From b91c63aa378d908685066098045564808f8463ca Mon Sep 17 00:00:00 2001 From: liuh-80 Date: Wed, 25 Sep 2024 02:31:08 +0000 Subject: [PATCH 1/9] Add mgmt VRF support --- orchagent/main.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/orchagent/main.cpp b/orchagent/main.cpp index 0a804eb38c..84387cf956 100644 --- a/orchagent/main.cpp +++ b/orchagent/main.cpp @@ -91,6 +91,7 @@ void usage() cout << " -j sairedis_rec_filename: sairedis record log filename(default sairedis.rec)" << endl; cout << " -k max bulk size in bulk mode (default 1000)" << endl; cout << " -q zmq_server_address: ZMQ server address (default disable ZMQ)" << endl; + cout << " -v vrf: VRF name (default empty)" << endl; cout << " -c counter mode (traditional|asic_db), default: asic_db" << endl; } @@ -342,11 +343,12 @@ int main(int argc, char **argv) string swss_rec_filename = Recorder::SWSS_FNAME; string sairedis_rec_filename = Recorder::SAIREDIS_FNAME; string zmq_server_address = "tcp://127.0.0.1:" + to_string(ORCH_ZMQ_PORT); + string vrf; bool enable_zmq = false; string responsepublisher_rec_filename = Recorder::RESPPUB_FNAME; int record_type = 3; // Only swss and sairedis recordings enabled by default. - while ((opt = getopt(argc, argv, "b:m:r:f:j:d:i:hsz:k:q:c:")) != -1) + while ((opt = getopt(argc, argv, "b:m:r:f:j:d:i:hsz:k:q:v:c:")) != -1) { switch (opt) { @@ -437,6 +439,12 @@ int main(int argc, char **argv) enable_zmq = true; } break; + case 'v': + if (optarg) + { + vrf = optarg; + } + break; default: /* '?' */ exit(EXIT_FAILURE); } @@ -481,8 +489,8 @@ int main(int argc, char **argv) shared_ptr zmq_server = nullptr; if (enable_zmq) { - SWSS_LOG_NOTICE("Instantiate ZMQ server : %s", zmq_server_address.c_str()); - zmq_server = make_shared(zmq_server_address.c_str()); + SWSS_LOG_NOTICE("Instantiate ZMQ server : %s, %s", zmq_server_address.c_str(), vrf.c_str()); + zmq_server = make_shared(zmq_server_address.c_str(), vrf.c_str()); } else { From c5d3f7db8ba02ee0861b92529233d5c8526a1328 Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Sat, 12 Oct 2024 15:26:54 +0800 Subject: [PATCH 2/9] Update dash_db.py --- tests/dash/dash_db.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/dash/dash_db.py b/tests/dash/dash_db.py index a26e0b5091..c38a1321d7 100644 --- a/tests/dash/dash_db.py +++ b/tests/dash/dash_db.py @@ -59,11 +59,11 @@ def __setitem__(self, key: str, pairs: typing.Union[dict, list, tuple]): for k, v in pairs: pairs_str.append((to_string(k), to_string(v))) self.set(key, pairs_str) - time.sleep(1) + time.sleep(3) def __delitem__(self, key: str): self.delete(str(key)) - time.sleep(1) + time.sleep(3) class Table(swsscommon.Table): From 54543c093c87a8d51ee0640aebeab5982120ded7 Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Mon, 14 Oct 2024 17:17:02 +0800 Subject: [PATCH 3/9] Update test_zmq.py --- tests/test_zmq.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_zmq.py b/tests/test_zmq.py index 4894df0751..98835ff66f 100644 --- a/tests/test_zmq.py +++ b/tests/test_zmq.py @@ -59,7 +59,7 @@ def enable_orchagent_zmq(self, dvs): # change orchagent to use ZMQ # change orchagent to use custom create_switch_timeout dvs.runcmd("cp /usr/bin/orchagent.sh /usr/bin/orchagent.sh_zmq_ut_backup") - dvs.runcmd("sed -i.bak 's/\/usr\/bin\/orchagent /\/usr\/bin\/orchagent -q tcp:\/\/127.0.0.1:8100 -t 60 /g' /usr/bin/orchagent.sh") + dvs.runcmd("sed -i.bak 's/\/usr\/bin\/orchagent /\/usr\/bin\/orchagent -q tcp:\/\/127.0.0.1:8100 -t 60 -v \'\'/g' /usr/bin/orchagent.sh") dvs.stop_swss() dvs.start_swss() From 88ae6974db347bb702e3590934f362b451fabfe1 Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Mon, 14 Oct 2024 17:18:29 +0800 Subject: [PATCH 4/9] Update main.cpp --- orchagent/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orchagent/main.cpp b/orchagent/main.cpp index 7fb2f0bf5b..d50508f6ce 100644 --- a/orchagent/main.cpp +++ b/orchagent/main.cpp @@ -73,7 +73,7 @@ uint32_t create_switch_timeout = 0; void usage() { - cout << "usage: orchagent [-h] [-r record_type] [-d record_location] [-f swss_rec_filename] [-j sairedis_rec_filename] [-b batch_size] [-m MAC] [-i INST_ID] [-s] [-z mode] [-k bulk_size] [-q zmq_server_address] [-c mode] [-t create_switch_timeout]" << endl; + cout << "usage: orchagent [-h] [-r record_type] [-d record_location] [-f swss_rec_filename] [-j sairedis_rec_filename] [-b batch_size] [-m MAC] [-i INST_ID] [-s] [-z mode] [-k bulk_size] [-q zmq_server_address] [-c mode] [-t create_switch_timeout] [-v VRF]" << endl; cout << " -h: display this message" << endl; cout << " -r record_type: record orchagent logs with type (default 3)" << endl; cout << " Bit 0: sairedis.rec, Bit 1: swss.rec, Bit 2: responsepublisher.rec. For example:" << endl; From fafc3b74c023c930198b5dc41462b65670cc04cb Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Tue, 15 Oct 2024 16:58:11 +0800 Subject: [PATCH 5/9] Update test_zmq.py --- tests/test_zmq.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_zmq.py b/tests/test_zmq.py index 98835ff66f..4894df0751 100644 --- a/tests/test_zmq.py +++ b/tests/test_zmq.py @@ -59,7 +59,7 @@ def enable_orchagent_zmq(self, dvs): # change orchagent to use ZMQ # change orchagent to use custom create_switch_timeout dvs.runcmd("cp /usr/bin/orchagent.sh /usr/bin/orchagent.sh_zmq_ut_backup") - dvs.runcmd("sed -i.bak 's/\/usr\/bin\/orchagent /\/usr\/bin\/orchagent -q tcp:\/\/127.0.0.1:8100 -t 60 -v \'\'/g' /usr/bin/orchagent.sh") + dvs.runcmd("sed -i.bak 's/\/usr\/bin\/orchagent /\/usr\/bin\/orchagent -q tcp:\/\/127.0.0.1:8100 -t 60 /g' /usr/bin/orchagent.sh") dvs.stop_swss() dvs.start_swss() From c9f49eb434075f794edb0806806e977eb6327d69 Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Tue, 15 Oct 2024 17:14:43 +0800 Subject: [PATCH 6/9] Update test_zmq.py --- tests/test_zmq.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_zmq.py b/tests/test_zmq.py index 4894df0751..107ef99db2 100644 --- a/tests/test_zmq.py +++ b/tests/test_zmq.py @@ -59,7 +59,7 @@ def enable_orchagent_zmq(self, dvs): # change orchagent to use ZMQ # change orchagent to use custom create_switch_timeout dvs.runcmd("cp /usr/bin/orchagent.sh /usr/bin/orchagent.sh_zmq_ut_backup") - dvs.runcmd("sed -i.bak 's/\/usr\/bin\/orchagent /\/usr\/bin\/orchagent -q tcp:\/\/127.0.0.1:8100 -t 60 /g' /usr/bin/orchagent.sh") + dvs.runcmd("sed -i.bak 's/\/usr\/bin\/orchagent /\/usr\/bin\/orchagent -q tcp:\/\/127.0.0.1:8100 -t 60 -v "" /g' /usr/bin/orchagent.sh") dvs.stop_swss() dvs.start_swss() From 6043509c4a731d06c4c32c2d75ba80331becd8df Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Wed, 16 Oct 2024 09:57:07 +0800 Subject: [PATCH 7/9] Update test_zmq.py --- tests/test_zmq.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_zmq.py b/tests/test_zmq.py index 107ef99db2..4894df0751 100644 --- a/tests/test_zmq.py +++ b/tests/test_zmq.py @@ -59,7 +59,7 @@ def enable_orchagent_zmq(self, dvs): # change orchagent to use ZMQ # change orchagent to use custom create_switch_timeout dvs.runcmd("cp /usr/bin/orchagent.sh /usr/bin/orchagent.sh_zmq_ut_backup") - dvs.runcmd("sed -i.bak 's/\/usr\/bin\/orchagent /\/usr\/bin\/orchagent -q tcp:\/\/127.0.0.1:8100 -t 60 -v "" /g' /usr/bin/orchagent.sh") + dvs.runcmd("sed -i.bak 's/\/usr\/bin\/orchagent /\/usr\/bin\/orchagent -q tcp:\/\/127.0.0.1:8100 -t 60 /g' /usr/bin/orchagent.sh") dvs.stop_swss() dvs.start_swss() From 94d3e5ce5ffe1bece992886a27a88e38e135e17e Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Wed, 16 Oct 2024 14:43:37 +0800 Subject: [PATCH 8/9] Update dash_db.py --- tests/dash/dash_db.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/dash/dash_db.py b/tests/dash/dash_db.py index c38a1321d7..a26e0b5091 100644 --- a/tests/dash/dash_db.py +++ b/tests/dash/dash_db.py @@ -59,11 +59,11 @@ def __setitem__(self, key: str, pairs: typing.Union[dict, list, tuple]): for k, v in pairs: pairs_str.append((to_string(k), to_string(v))) self.set(key, pairs_str) - time.sleep(3) + time.sleep(1) def __delitem__(self, key: str): self.delete(str(key)) - time.sleep(3) + time.sleep(1) class Table(swsscommon.Table): From cbb1c45618deca293f8b1af89ea3a87b9c47508c Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Fri, 18 Oct 2024 09:09:10 +0800 Subject: [PATCH 9/9] Update test_zmq.py --- tests/test_zmq.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_zmq.py b/tests/test_zmq.py index 4894df0751..0f7e5359f3 100644 --- a/tests/test_zmq.py +++ b/tests/test_zmq.py @@ -103,3 +103,20 @@ def test_appliance(self, dvs): for fv in fvs.items(): if fv[0] == "SAI_VIP_ENTRY_ATTR_ACTION": assert fv[1] == "SAI_VIP_ENTRY_ACTION_ACCEPT" + + def test_vrf(self, dvs): + # Improve test code coverage, change orchagent to use VRF + dvs.runcmd("cp /usr/bin/orchagent.sh /usr/bin/orchagent.sh_vrf_ut_backup") + dvs.runcmd("sed -i.bak 's/\/usr\/bin\/orchagent /\/usr\/bin\/orchagent -v mgmt /g' /usr/bin/orchagent.sh") + dvs.stop_swss() + dvs.start_swss() + + # wait orchagent start + time.sleep(3) + process_statue = dvs.runcmd("ps -ef") + zmq_logger.debug("Process status: {}".format(process_statue)) + + # revert change + dvs.runcmd("cp /usr/bin/orchagent.sh_vrf_ut_backup /usr/bin/orchagent.sh") + dvs.stop_swss() + dvs.start_swss()