|
| 1 | +import json |
1 | 2 | import os
|
2 | 3 |
|
3 | 4 | import pytest
|
@@ -481,6 +482,110 @@ def test_bgp_summary_no_v6_neigh(
|
481 | 482 | assert result.exit_code == 0
|
482 | 483 | assert result.output == show_error_no_v6_neighbor_single_asic
|
483 | 484 |
|
| 485 | + @pytest.mark.parametrize('setup_single_bgp_instance', |
| 486 | + ['v4'], indirect=['setup_single_bgp_instance']) |
| 487 | + def test_bgp_summary_raw_missing_peergroup_count( |
| 488 | + self, |
| 489 | + setup_bgp_commands, |
| 490 | + setup_single_bgp_instance): |
| 491 | + show = setup_bgp_commands |
| 492 | + runner = CliRunner() |
| 493 | + # mock vtysh cli output that does not have peergroup count |
| 494 | + mock_json = { |
| 495 | + "ipv4Unicast": { |
| 496 | + "routerId": "10.1.0.32", |
| 497 | + "as": 65100, |
| 498 | + "localAS": 65100, |
| 499 | + "vrfId": 0, |
| 500 | + "tableVersion": 1, |
| 501 | + "totalPeers": 0, |
| 502 | + "dynamicPeers": 0, |
| 503 | + "bestPaths": 0, |
| 504 | + "peerCount": 2, |
| 505 | + "peerMemory": 2048, |
| 506 | + "ribCount": 10, |
| 507 | + "ribMemory": 1024, |
| 508 | + "peers": { |
| 509 | + "10.0.0.33": { |
| 510 | + "remoteAs": 64001, |
| 511 | + "version": 4, |
| 512 | + "msgRcvd": 0, |
| 513 | + "msgSent": 0, |
| 514 | + "tableVersion": 0, |
| 515 | + "outq": 0, |
| 516 | + "inq": 0, |
| 517 | + "peerUptime": "never", |
| 518 | + "peerUptimeMsec": 0, |
| 519 | + "prefixReceivedCount": 0, |
| 520 | + "pfxRcd": 0, |
| 521 | + "state": "Active", |
| 522 | + "connectionsEstablished": 0, |
| 523 | + "connectionsDropped": 0, |
| 524 | + "idType": "ipv4" |
| 525 | + } |
| 526 | + } |
| 527 | + } |
| 528 | + } |
| 529 | + |
| 530 | + with patch('utilities_common.bgp_util.run_bgp_command', return_value=json.dumps(mock_json)): |
| 531 | + result = runner.invoke( |
| 532 | + show.cli.commands["ip"].commands["bgp"].commands["summary"], []) |
| 533 | + # verify that the CLI handles missing peergroup count gracefully |
| 534 | + assert result.exit_code == 0 |
| 535 | + assert "Peer groups 0, using 0 bytes of memory" in result.output |
| 536 | + |
| 537 | + @pytest.mark.parametrize('setup_single_bgp_instance', |
| 538 | + ['v6'], indirect=['setup_single_bgp_instance']) |
| 539 | + def test_bgp_summary_raw_missing_peergroup_count_v6( |
| 540 | + self, |
| 541 | + setup_bgp_commands, |
| 542 | + setup_single_bgp_instance): |
| 543 | + show = setup_bgp_commands |
| 544 | + runner = CliRunner() |
| 545 | + # mock vtysh cli output that does not have peergroup count |
| 546 | + mock_json = { |
| 547 | + "ipv6Unicast": { |
| 548 | + "routerId": "10.1.0.32", |
| 549 | + "as": 65100, |
| 550 | + "localAS": 65100, |
| 551 | + "vrfId": 0, |
| 552 | + "tableVersion": 1, |
| 553 | + "totalPeers": 0, |
| 554 | + "dynamicPeers": 0, |
| 555 | + "bestPaths": 0, |
| 556 | + "peerCount": 2, |
| 557 | + "peerMemory": 2048, |
| 558 | + "ribCount": 10, |
| 559 | + "ribMemory": 1024, |
| 560 | + "peers": { |
| 561 | + "fc00::42": { |
| 562 | + "remoteAs": 64001, |
| 563 | + "version": 4, |
| 564 | + "msgRcvd": 0, |
| 565 | + "msgSent": 0, |
| 566 | + "tableVersion": 0, |
| 567 | + "outq": 0, |
| 568 | + "inq": 0, |
| 569 | + "peerUptime": "never", |
| 570 | + "peerUptimeMsec": 0, |
| 571 | + "prefixReceivedCount": 0, |
| 572 | + "pfxRcd": 0, |
| 573 | + "state": "Active", |
| 574 | + "connectionsEstablished": 0, |
| 575 | + "connectionsDropped": 0, |
| 576 | + "idType": "ipv6" |
| 577 | + } |
| 578 | + } |
| 579 | + } |
| 580 | + } |
| 581 | + |
| 582 | + with patch('utilities_common.bgp_util.run_bgp_command', return_value=json.dumps(mock_json)): |
| 583 | + result = runner.invoke( |
| 584 | + show.cli.commands["ipv6"].commands["bgp"].commands["summary"], []) |
| 585 | + # verify that the CLI handles missing peergroup count gracefully |
| 586 | + assert result.exit_code == 0 |
| 587 | + assert "Peer groups 0, using 0 bytes of memory" in result.output |
| 588 | + |
484 | 589 | @classmethod
|
485 | 590 | def teardown_class(cls):
|
486 | 591 | print("TEARDOWN")
|
|
0 commit comments