Skip to content

Commit afb3f17

Browse files
committed
smoketest: T3871: add running_in_smoketest_harness() base class method
Replace repeated `os.path.exists('/tmp/vyos.smoketests.hint')` checks across multiple test files with a shared method on VyOSUnitTestSHIM.TestCase, following the existing debug_on() convention.
1 parent 8bafd28 commit afb3f17

4 files changed

Lines changed: 10 additions & 6 deletions

File tree

smoketest/scripts/cli/base_vyostest_shim.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,16 @@ class TestCase(unittest.TestCase):
4848
# certain failure condition.
4949
debug = False
5050
mgmt_daemon_pid = 0
51+
smoketest_hint_file = '/tmp/vyos.smoketests.hint'
5152

5253
@staticmethod
5354
def debug_on():
5455
return os.path.exists('/tmp/vyos.smoketest.debug')
5556

57+
@classmethod
58+
def running_in_smoketest_harness(cls):
59+
return os.path.exists(cls.smoketest_hint_file)
60+
5661
@classmethod
5762
def setUpClass(cls):
5863
cls._session = ConfigSession(os.getpid())

smoketest/scripts/cli/test_interfaces_bonding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ def test_bonding_evpn_multihoming(self):
366366
def test_bonding_member_mtu(self):
367367
# This Smoketest only works on our CI platform where we force the NIC
368368
# to virtio and an MTU of only 1500 bytes max
369-
if not os.path.exists('/tmp/vyos.smoketests.hint'):
369+
if not self.running_in_smoketest_harness():
370370
self.skipTest('Not running under VyOS CI/CD QEMU environment!')
371371

372372
for interface in self._interfaces:

smoketest/scripts/cli/test_protocols_static.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ def test_05_dhcp_default_route(self):
596596
# When running via vyos-build under the QEMU environment a local DHCP
597597
# server is available. This test verifies that the default route is set.
598598
# When not running under the VyOS QEMU environment, this test is skipped.
599-
if not os.path.exists('/tmp/vyos.smoketests.hint'):
599+
if not self.running_in_smoketest_harness():
600600
self.skipTest('Not running under VyOS CI/CD QEMU environment!')
601601

602602
interface = 'eth0'
@@ -635,7 +635,7 @@ def test_06_dhcp_default_route_for_vrf(self):
635635
# When running via vyos-build under the QEMU environment a local DHCP
636636
# server is available. This test verifies that the default route is set.
637637
# When not running under the VyOS QEMU environment, this test is skipped.
638-
if not os.path.exists('/tmp/vyos.smoketests.hint'):
638+
if not self.running_in_smoketest_harness():
639639
self.skipTest('Not running under VyOS CI/CD QEMU environment!')
640640

641641
interface = 'eth0'
@@ -683,7 +683,7 @@ def test_07_dhcp_interface_static_routes(self):
683683
# When running via vyos-build under the QEMU environment a local DHCP
684684
# server is available. This test verifies that static routes with
685685
# dhcp-interface are configured correctly.
686-
if not os.path.exists('/tmp/vyos.smoketests.hint'):
686+
if not self.running_in_smoketest_harness():
687687
self.skipTest('Not running under VyOS CI/CD QEMU environment!')
688688

689689
dhcp_interface = 'eth0'

smoketest/scripts/cli/test_system_console.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
import os
1817
import unittest
1918

2019
from base_vyostest_shim import VyOSUnitTestSHIM
@@ -60,7 +59,7 @@ def test_multiple_kernel_consoles(self):
6059
self.cli_commit()
6160

6261
def test_fbcon_and_serial_con_switch(self):
63-
if not os.path.exists('/tmp/vyos.smoketests.hint'):
62+
if not self.running_in_smoketest_harness():
6463
self.skipTest('Not running under VyOS CI/CD QEMU environment!')
6564

6665
grub_vars = get_grub_vars()

0 commit comments

Comments
 (0)