From 363e3564a930a939adfd465fefc21b2198299794 Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Fri, 13 Sep 2024 17:05:38 +0000 Subject: [PATCH] Do not "grep" the output of an empty list If a command returns an empty list, the "grep" command will exit with error. In the ``OvnFdbAgingTest`` test case, we need to retrieve the OVN SB FDB table to read the MAC address. The output is something like this (one single register): $ ovn-sbctl list FDB _uuid : 7422a4fb-fb01-47b5-b408-1b59470f0e9d dp_key : 1 mac : "fa:16:3e:69:a9:f9" port_key : 7 timestamp : 1726246598759 It is possible to output the MAC address by adding the needed filters to the command: $ ovn-sbctl --format=list --bare --columns=mac list FDB fa:16:3e:69:a9:f9 Related-Bug: #OSPRH-893 Change-Id: Iaca410d9943a39e76f86ec51b5292ed896f8088b --- whitebox_neutron_tempest_plugin/tests/scenario/test_ovn_fdb.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/whitebox_neutron_tempest_plugin/tests/scenario/test_ovn_fdb.py b/whitebox_neutron_tempest_plugin/tests/scenario/test_ovn_fdb.py index 4138ee1..0ede642 100644 --- a/whitebox_neutron_tempest_plugin/tests/scenario/test_ovn_fdb.py +++ b/whitebox_neutron_tempest_plugin/tests/scenario/test_ovn_fdb.py @@ -38,7 +38,8 @@ class OvnFdbAgingTest(wb_base.BaseTempestTestCaseOvn): def _check_mac_in_ovn_sb_fdb(self, mac_address, is_present=True): def _check_mac(): - cmd = '{} list FDB | grep mac'.format(self.sbctl) + cmd = ('{} --format=list --bare --columns=mac list FDB; ' + 'true').format(self.sbctl) fdb_list = self.run_on_master_controller(cmd).lower() if is_present: return mac_address.lower() in fdb_list