""" Test the "snabb lwaftr monitor" subcommand. Needs a NIC name and a TAP interface. 1. Execute "snabb lwaftr run" in on-a-stick mode and with the mirror option set. 2. Run "snabb lwaftr monitor" to set the counter and check its output. """ from random import randint from subprocess import call, check_call, PIPE, Popen import unittest from test_env import DATA_DIR, SNABB_CMD, BaseTestCase, nic_names DAEMON_PROC_NAME = 'monitor-test-daemon' SNABB_PCI0 = nic_names()[0] @unittest.skipUnless(SNABB_PCI0, 'NIC not configured') class TestMonitor(BaseTestCase): daemon_args = [ str(SNABB_CMD), 'lwaftr', 'run', '--name', DAEMON_PROC_NAME, '--bench-file', '/dev/null', '--conf', str(DATA_DIR / 'icmp_on_fail.conf'), '--on-a-stick',
""" Test the "snabb lwaftr loadtest" subcommand. Needs NIC names. Since there are only two NIC names available in snabb-bot, and we need to execute two programs networked to each other ("run" and "loadtest"), they are set to on-a-stick mode, so that they use one NIC each instead of two. """ import unittest from test_env import BENCHDATA_DIR, DATA_DIR, SNABB_CMD, BaseTestCase, nic_names SNABB_PCI0, SNABB_PCI1 = nic_names() @unittest.skipUnless(SNABB_PCI0 and SNABB_PCI1, 'NICs not configured') class TestLoadtest(BaseTestCase): daemon_args = ( str(SNABB_CMD), 'lwaftr', 'run', '--bench-file', '/dev/null', '--conf', str(DATA_DIR / 'icmp_on_fail.conf'), '--on-a-stick', SNABB_PCI0, ) loadtest_args = ( str(SNABB_CMD),
""" Test the "snabb lwaftr monitor" subcommand. Needs a NIC name and a TAP interface. 1. Execute "snabb lwaftr run" in on-a-stick mode and with the mirror option set. 2. Run "snabb lwaftr monitor" to set the counter and check its output. """ from random import randint from subprocess import call, check_call, PIPE, Popen import unittest from test_env import DATA_DIR, SNABB_CMD, BaseTestCase, nic_names DAEMON_PROC_NAME = 'monitor-test-daemon' SNABB_PCI0 = nic_names()[0] @unittest.skipUnless(SNABB_PCI0, 'NIC not configured') class TestMonitor(BaseTestCase): daemon_args = [ str(SNABB_CMD), 'lwaftr', 'run', '--name', DAEMON_PROC_NAME, '--bench-file', '/dev/null', '--conf', str(DATA_DIR / 'icmp_on_fail.conf'), '--on-a-stick', SNABB_PCI0, '--mirror', # TAP interface name added in setUpClass. ] monitor_args = ( str(SNABB_CMD), 'lwaftr', 'monitor', '--name', DAEMON_PROC_NAME, 'all')
""" Test the "snabb lwaftr run" subcommand. Needs NIC names. """ import unittest from test_env import DATA_DIR, SNABB_CMD, BaseTestCase, nic_names, ENC SNABB_PCI0, SNABB_PCI1 = nic_names() @unittest.skipUnless(SNABB_PCI0 and SNABB_PCI1, 'NICs not configured') class TestRun(BaseTestCase): cmd_args = ( str(SNABB_CMD), 'lwaftr', 'run', '--duration', '1', '--bench-file', '/dev/null', '--conf', str(DATA_DIR / 'icmp_on_fail.conf'), '--v4', SNABB_PCI0, '--v6', SNABB_PCI1 ) def test_run(self): output = self.run_cmd(self.cmd_args).decode(ENC) self.assertIn("Migrating instance", output) def test_run_on_a_stick_migration(self): # The LwAFTR should be abel to migrate from non-on-a-stick -> on-a-stick run_cmd = list(self.cmd_args)[:-4] run_cmd.extend((