Skip to content

Commit 6adcd3e

Browse files
wen587StormLiangMS
authored andcommitted
[GCU] Ignore bgpraw table in GCU operation (#2628)
What I did After the previous fix #2623 , GCU still fails in the rollback operation. The bgpraw table should be discard in all GCU operation. Thus, I change get_config_db_as_json function to crop out "bgpraw" table. How I did it Pop "bgpraw" table if exists. How to verify it Unittest
1 parent c65bdc3 commit 6adcd3e

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

generic_config_updater/gu_common.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ def __init__(self, yang_dir = YANG_DIR):
5151

5252
def get_config_db_as_json(self):
5353
text = self._get_config_db_as_text()
54-
return json.loads(text)
54+
config_db_json = json.loads(text)
55+
config_db_json.pop("bgpraw", None)
56+
return config_db_json
5557

5658
def _get_config_db_as_text(self):
5759
# TODO: Getting configs from CLI is very slow, need to get it from sonic-cffgen directly

tests/generic_config_updater/gu_common_test.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,24 @@
33
import jsonpatch
44
import sonic_yang
55
import unittest
6-
from unittest.mock import MagicMock, Mock
6+
from unittest.mock import MagicMock, Mock, patch
77

88
from .gutest_helpers import create_side_effect_dict, Files
99
import generic_config_updater.gu_common as gu_common
1010

1111
class TestDryRunConfigWrapper(unittest.TestCase):
12+
@patch('generic_config_updater.gu_common.subprocess.Popen')
13+
def test_get_config_db_as_json(self, mock_popen):
14+
config_wrapper = gu_common.DryRunConfigWrapper()
15+
mock_proc = MagicMock()
16+
mock_proc.communicate = MagicMock(
17+
return_value=('{"PORT": {}, "bgpraw": ""}', None))
18+
mock_proc.returncode = 0
19+
mock_popen.return_value = mock_proc
20+
actual = config_wrapper.get_config_db_as_json()
21+
expected = {"PORT": {}}
22+
self.assertDictEqual(actual, expected)
23+
1224
def test_get_config_db_as_json__returns_imitated_config_db(self):
1325
# Arrange
1426
config_wrapper = gu_common.DryRunConfigWrapper(Files.CONFIG_DB_AS_JSON)

0 commit comments

Comments
 (0)