|
| 1 | +from importlib import reload |
| 2 | + |
1 | 3 | from click.testing import CliRunner
|
2 | 4 |
|
3 | 5 | from utilities_common.db import Db
|
|
76 | 78 | --------- --------------
|
77 | 79 | database always_enabled
|
78 | 80 | """
|
| 81 | +config_feature_bgp_inconsistent_state_output="""\ |
| 82 | +Feature 'bgp' state is not consistent across namespaces |
| 83 | +""" |
| 84 | +config_feature_bgp_inconsistent_autorestart_output="""\ |
| 85 | +Feature 'bgp' auto-restart is not consistent across namespaces |
| 86 | +""" |
79 | 87 |
|
80 | 88 | class TestFeature(object):
|
81 | 89 | @classmethod
|
@@ -217,3 +225,102 @@ def test_config_unknown_feature(self, get_cmd_module):
|
217 | 225 | @classmethod
|
218 | 226 | def teardown_class(cls):
|
219 | 227 | print("TEARDOWN")
|
| 228 | + |
| 229 | +class TestFeatureMultiAsic(object): |
| 230 | + @classmethod |
| 231 | + def setup_class(cls): |
| 232 | + print("SETUP") |
| 233 | + |
| 234 | + def test_config_bgp_feature_inconsistent_state(self, get_cmd_module): |
| 235 | + from .mock_tables import dbconnector |
| 236 | + from .mock_tables import mock_multi_asic_3_asics |
| 237 | + reload(mock_multi_asic_3_asics) |
| 238 | + dbconnector.load_namespace_config() |
| 239 | + (config, show) = get_cmd_module |
| 240 | + db = Db() |
| 241 | + runner = CliRunner() |
| 242 | + result = runner.invoke(config.config.commands["feature"].commands["state"], ["bgp", "disabled"], obj=db) |
| 243 | + print(result.exit_code) |
| 244 | + print(result.output) |
| 245 | + assert result.exit_code == 1 |
| 246 | + assert result.output == config_feature_bgp_inconsistent_state_output |
| 247 | + result = runner.invoke(config.config.commands["feature"].commands["state"], ["bgp", "enabled"], obj=db) |
| 248 | + print(result.exit_code) |
| 249 | + print(result.output) |
| 250 | + assert result.exit_code == 1 |
| 251 | + assert result.output == config_feature_bgp_inconsistent_state_output |
| 252 | + |
| 253 | + def test_config_bgp_feature_inconsistent_autorestart(self, get_cmd_module): |
| 254 | + from .mock_tables import dbconnector |
| 255 | + from .mock_tables import mock_multi_asic_3_asics |
| 256 | + reload(mock_multi_asic_3_asics) |
| 257 | + dbconnector.load_namespace_config() |
| 258 | + (config, show) = get_cmd_module |
| 259 | + db = Db() |
| 260 | + runner = CliRunner() |
| 261 | + result = runner.invoke(config.config.commands["feature"].commands["autorestart"], ["bgp", "disabled"], obj=db) |
| 262 | + print(result.exit_code) |
| 263 | + print(result.output) |
| 264 | + assert result.exit_code == 1 |
| 265 | + assert result.output == config_feature_bgp_inconsistent_autorestart_output |
| 266 | + result = runner.invoke(config.config.commands["feature"].commands["autorestart"], ["bgp", "enabled"], obj=db) |
| 267 | + print(result.exit_code) |
| 268 | + print(result.output) |
| 269 | + assert result.exit_code == 1 |
| 270 | + assert result.output == config_feature_bgp_inconsistent_autorestart_output |
| 271 | + |
| 272 | + def test_config_bgp_feature_consistent_state(self, get_cmd_module): |
| 273 | + from .mock_tables import dbconnector |
| 274 | + from .mock_tables import mock_multi_asic |
| 275 | + reload(mock_multi_asic) |
| 276 | + dbconnector.load_namespace_config() |
| 277 | + (config, show) = get_cmd_module |
| 278 | + db = Db() |
| 279 | + runner = CliRunner() |
| 280 | + result = runner.invoke(config.config.commands["feature"].commands["state"], ["bgp", "disabled"], obj=db) |
| 281 | + print(result.exit_code) |
| 282 | + assert result.exit_code == 0 |
| 283 | + result = runner.invoke(show.cli.commands["feature"].commands["status"], ["bgp"], obj=db) |
| 284 | + print(result.output) |
| 285 | + assert result.exit_code == 0 |
| 286 | + assert result.output == show_feature_bgp_disabled_status_output |
| 287 | + result = runner.invoke(config.config.commands["feature"].commands["state"], ["bgp", "enabled"], obj=db) |
| 288 | + print(result.exit_code) |
| 289 | + print(result.output) |
| 290 | + assert result.exit_code == 0 |
| 291 | + result = runner.invoke(show.cli.commands["feature"].commands["status"], ["bgp"], obj=db) |
| 292 | + print(result.output) |
| 293 | + assert result.exit_code == 0 |
| 294 | + assert result.output == show_feature_bgp_status_output |
| 295 | + |
| 296 | + def test_config_bgp_feature_consistent_autorestart(self, get_cmd_module): |
| 297 | + from .mock_tables import dbconnector |
| 298 | + from .mock_tables import mock_multi_asic |
| 299 | + reload(mock_multi_asic) |
| 300 | + dbconnector.load_namespace_config() |
| 301 | + (config, show) = get_cmd_module |
| 302 | + db = Db() |
| 303 | + runner = CliRunner() |
| 304 | + result = runner.invoke(config.config.commands["feature"].commands["autorestart"], ["bgp", "disabled"], obj=db) |
| 305 | + print(result.exit_code) |
| 306 | + assert result.exit_code == 0 |
| 307 | + result = runner.invoke(show.cli.commands["feature"].commands["autorestart"], ["bgp"], obj=db) |
| 308 | + print(result.output) |
| 309 | + print(result.exit_code) |
| 310 | + assert result.exit_code == 0 |
| 311 | + assert result.output == show_feature_bgp_disabled_autorestart_output |
| 312 | + result = runner.invoke(config.config.commands["feature"].commands["autorestart"], ["bgp", "enabled"], obj=db) |
| 313 | + print(result.exit_code) |
| 314 | + assert result.exit_code == 0 |
| 315 | + result = runner.invoke(show.cli.commands["feature"].commands["autorestart"], ["bgp"], obj=db) |
| 316 | + print(result.output) |
| 317 | + print(result.exit_code) |
| 318 | + assert result.exit_code == 0 |
| 319 | + assert result.output == show_feature_bgp_autorestart_output |
| 320 | + |
| 321 | + |
| 322 | + @classmethod |
| 323 | + def teardown_class(cls): |
| 324 | + print("TEARDOWN") |
| 325 | + from .mock_tables import mock_single_asic |
| 326 | + reload(mock_single_asic) |
0 commit comments