diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-03-31 19:56:39 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-03-31 20:02:52 +0200 |
commit | c147d97a26cd554524e7390c52c749cc3f308787 (patch) | |
tree | 2529c692398b59f5b8eb70a224b492b14a175190 /smoketest/scripts/cli | |
parent | f22fa8e6454b1cd2539ddb7c354ac9eeeac725c5 (diff) | |
download | vyos-1x-c147d97a26cd554524e7390c52c749cc3f308787.tar.gz vyos-1x-c147d97a26cd554524e7390c52c749cc3f308787.zip |
smoketest: bfd: only evaluate individual profile section
When validating FRR profiles, only load the configuration for each individual
profile instead of all profiles. This is done by a new argument to getFRRconfig()
named endsection='^!' which tells what is the delimiter when a config section
of FRR ends, this is usually "^!", but for BFD profiles this is "^ !", as this
is a new level under the FRR CLI.
Diffstat (limited to 'smoketest/scripts/cli')
-rw-r--r-- | smoketest/scripts/cli/base_vyostest_shim.py | 4 | ||||
-rwxr-xr-x | smoketest/scripts/cli/test_protocols_bfd.py | 35 |
2 files changed, 21 insertions, 18 deletions
diff --git a/smoketest/scripts/cli/base_vyostest_shim.py b/smoketest/scripts/cli/base_vyostest_shim.py index 18e4e567e..18e49f47f 100644 --- a/smoketest/scripts/cli/base_vyostest_shim.py +++ b/smoketest/scripts/cli/base_vyostest_shim.py @@ -71,9 +71,9 @@ class VyOSUnitTestSHIM: def cli_commit(self): self._session.commit() - def getFRRconfig(self, string, end='$'): + def getFRRconfig(self, string, end='$', endsection='^!'): """ Retrieve current "running configuration" from FRR """ - command = f'vtysh -c "show run" | sed -n "/^{string}{end}/,/^!/p"' + command = f'vtysh -c "show run" | sed -n "/^{string}{end}/,/{endsection}/p"' count = 0 tmp = '' diff --git a/smoketest/scripts/cli/test_protocols_bfd.py b/smoketest/scripts/cli/test_protocols_bfd.py index acc88f596..a57f8d5f2 100755 --- a/smoketest/scripts/cli/test_protocols_bfd.py +++ b/smoketest/scripts/cli/test_protocols_bfd.py @@ -112,21 +112,22 @@ class TestProtocolsBFD(VyOSUnitTestSHIM.TestCase): peerconfig = self.getFRRconfig(f' peer {peer}', end='') if 'echo_mode' in peer_config: - self.assertIn(f' echo-mode', peerconfig) + self.assertIn(f'echo-mode', peerconfig) if 'intv_echo' in peer_config: - self.assertIn(f' echo-interval {peer_config["intv_echo"]}', peerconfig) + self.assertIn(f'echo-interval {peer_config["intv_echo"]}', peerconfig) if 'intv_mult' in peer_config: - self.assertIn(f' detect-multiplier {peer_config["intv_mult"]}', peerconfig) + self.assertIn(f'detect-multiplier {peer_config["intv_mult"]}', peerconfig) if 'intv_rx' in peer_config: - self.assertIn(f' receive-interval {peer_config["intv_rx"]}', peerconfig) + self.assertIn(f'receive-interval {peer_config["intv_rx"]}', peerconfig) if 'intv_tx' in peer_config: - self.assertIn(f' transmit-interval {peer_config["intv_tx"]}', peerconfig) - if 'shutdown' not in peer_config: - self.assertIn(f' no shutdown', peerconfig) + self.assertIn(f'transmit-interval {peer_config["intv_tx"]}', peerconfig) + if 'shutdown' in peer_config: + self.assertIn(f'shutdown', peerconfig) + else: + self.assertNotIn(f'shutdown', peerconfig) def test_bfd_profile(self): peer = '192.0.2.10' - self.debug = True for profile, profile_config in profiles.items(): if 'echo_mode' in profile_config: @@ -149,19 +150,21 @@ class TestProtocolsBFD(VyOSUnitTestSHIM.TestCase): # Verify FRR bgpd configuration for profile, profile_config in profiles.items(): - config = self.getFRRconfig(f' profile {profile}', end='') + config = self.getFRRconfig(f' profile {profile}', endsection='^ !') if 'echo_mode' in profile_config: - self.assertIn(f' echo-mode', config) + self.assertIn(f'echo-mode', config) if 'intv_echo' in profile_config: - self.assertIn(f' echo-interval {profile_config["intv_echo"]}', config) + self.assertIn(f'echo-interval {profile_config["intv_echo"]}', config) if 'intv_mult' in profile_config: - self.assertIn(f' detect-multiplier {profile_config["intv_mult"]}', config) + self.assertIn(f'detect-multiplier {profile_config["intv_mult"]}', config) if 'intv_rx' in profile_config: - self.assertIn(f' receive-interval {profile_config["intv_rx"]}', config) + self.assertIn(f'receive-interval {profile_config["intv_rx"]}', config) if 'intv_tx' in profile_config: - self.assertIn(f' transmit-interval {profile_config["intv_tx"]}', config) - if 'shutdown' not in profile_config: - self.assertIn(f' no shutdown', config) + self.assertIn(f'transmit-interval {profile_config["intv_tx"]}', config) + if 'shutdown' in profile_config: + self.assertIn(f'shutdown', config) + else: + self.assertNotIn(f'shutdown', config) if __name__ == '__main__': unittest.main(verbosity=2) |