Skip to content

Commit 0d5e68f

Browse files
authored
[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 22757b1 commit 0d5e68f

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

generic_config_updater/change_applier.py

-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ class ChangeApplier:
7676
def __init__(self):
7777
self.config_db = get_config_db()
7878
self.backend_tables = [
79-
"bgpraw",
8079
"BUFFER_PG",
8180
"BUFFER_PROFILE",
8281
"FLEX_COUNTER_TABLE"

generic_config_updater/gu_common.py

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

5555
def get_config_db_as_json(self):
5656
text = self._get_config_db_as_text()
57-
return json.loads(text)
57+
config_db_json = json.loads(text)
58+
config_db_json.pop("bgpraw", None)
59+
return config_db_json
5860

5961
def _get_config_db_as_text(self):
6062
# 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)