From 1da25f5e09fd071074a1bd65deb1af63a73f5ce0 Mon Sep 17 00:00:00 2001 From: Anders Linn Date: Thu, 17 Apr 2025 19:49:10 +0000 Subject: [PATCH] Issue #22362: Call ConfigReload on full config gnmi update The full config update handler already saves the config to a file and does yang validation on it. The previous implementation relied on the Reboot command to trigger a ConfigReload, but that command has been implemented on the system level and no longer performs a reload, leaving this operation non-functional. However, we can call ConfigReload directly from the handler and bypass the Reboot, restoring this operation. Modify unit tests to expect test D-Bus calls. --- sonic_data_client/mixed_db_client.go | 10 +++++++++- test/test_gnmi_configdb.py | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/sonic_data_client/mixed_db_client.go b/sonic_data_client/mixed_db_client.go index 1a8212c7a..bd6f0566d 100644 --- a/sonic_data_client/mixed_db_client.go +++ b/sonic_data_client/mixed_db_client.go @@ -1397,7 +1397,15 @@ func (c *MixedDbClient) SetFullConfig(delete []*gnmipb.Path, replace []*gnmipb.U return fmt.Errorf("Yang validation failed!") } - return nil + if err == nil { + var sc ssc.Service + sc, err = ssc.NewDbusClient() + if err != nil { + return err + } + err = sc.ConfigReload(fileName) + } + return err } func (c *MixedDbClient) SetDB(delete []*gnmipb.Path, replace []*gnmipb.Update, update []*gnmipb.Update) error { diff --git a/test/test_gnmi_configdb.py b/test/test_gnmi_configdb.py index d933faffa..dee44c2bf 100644 --- a/test/test_gnmi_configdb.py +++ b/test/test_gnmi_configdb.py @@ -270,6 +270,9 @@ def test_gnmi_incremental_replace(self, test_data): assert new_cnt == old_cnt+1, 'DBUS API is not invoked' def test_gnmi_full(self): + ret, old_cnt = gnmi_dump("DBUS config reload") + assert ret == 0, 'Failed to read counter' + test_data = { 'field_01': '20001', 'field_02': '20002', @@ -291,7 +294,14 @@ def test_gnmi_full(self): config_json = json.load(cf) assert test_data == config_json, "Wrong config file" + ret, new_cnt = gnmi_dump("DBUS config reload") + assert ret == 0, 'Failed to read counter' + assert new_cnt == old_cnt + 1, 'DBUS API is not invoked' + def test_gnmi_full_negative(self): + ret, old_cnt = gnmi_dump("DBUS config reload") + assert ret == 0, 'Failed to read counter' + delete_list = ['/sonic-db:CONFIG_DB/localhost/'] update_list = ['/sonic-db:CONFIG_DB/localhost/' + ':abc'] @@ -299,6 +309,10 @@ def test_gnmi_full_negative(self): assert ret != 0, 'Invalid ietf_json_val' assert 'IETF JSON' in msg + ret, new_cnt = gnmi_dump("DBUS config reload") + assert ret == 0, 'Failed to read counter' + assert new_cnt == old_cnt, 'DBUS API should not have been invoked' + @pytest.mark.parametrize("test_data", test_data_checkpoint) def test_gnmi_get_checkpoint(self, test_data): if os.path.isfile(checkpoint_file):