diff --git a/Makefile b/Makefile index 817d853f..be08056a 100644 --- a/Makefile +++ b/Makefile @@ -49,8 +49,8 @@ go.mod: $(GO_DEPS): go.mod $(PATCHES) swsscommon_wrap $(GO) mod vendor - $(GO) mod download github.com/jipanyang/gnxi@v0.0.0-20181221084354-f0a90cca6fd0 - cp -r $(GOPATH)/pkg/mod/github.com/jipanyang/gnxi@v0.0.0-20181221084354-f0a90cca6fd0/* vendor/github.com/jipanyang/gnxi/ + $(GO) mod download github.com/google/gnxi@v0.0.0-20181220173256-89f51f0ce1e2 + cp -r $(GOPATH)/pkg/mod/github.com/google/gnxi@v0.0.0-20181220173256-89f51f0ce1e2/* vendor/github.com/google/gnxi/ # Apply patch from sonic-mgmt-common, ignore glog.patch because glog version changed sed -i 's/patch -d $${DEST_DIR}\/github.com\/golang\/glog/\#patch -d $${DEST_DIR}\/github.com\/golang\/glog/g' $(MGMT_COMMON_DIR)/patches/apply.sh @@ -103,12 +103,12 @@ endif git apply patches/0001-Updated-to-filter-and-write-to-file.patch ifeq ($(CROSS_BUILD_ENVIRON),y) - $(GO) build -o ${GOBIN}/gnmi_get -mod=vendor github.com/jipanyang/gnxi/gnmi_get - $(GO) build -o ${GOBIN}/gnmi_set -mod=vendor github.com/jipanyang/gnxi/gnmi_set + $(GO) build -o ${GOBIN}/gnmi_get -mod=vendor github.com/google/gnxi/gnmi_get + $(GO) build -o ${GOBIN}/gnmi_set -mod=vendor github.com/google/gnxi/gnmi_set $(GO) build -o ${GOBIN}/gnmi_cli -mod=vendor github.com/openconfig/gnmi/cmd/gnmi_cli else - $(GO) install -mod=vendor github.com/jipanyang/gnxi/gnmi_get - $(GO) install -mod=vendor github.com/jipanyang/gnxi/gnmi_set + $(GO) install -mod=vendor github.com/google/gnxi/gnmi_get + $(GO) install -mod=vendor github.com/google/gnxi/gnmi_set $(GO) install -mod=vendor github.com/openconfig/gnmi/cmd/gnmi_cli endif diff --git a/gnmi_server/server_test.go b/gnmi_server/server_test.go index 4b4da0e3..a991f0bd 100644 --- a/gnmi_server/server_test.go +++ b/gnmi_server/server_test.go @@ -54,8 +54,8 @@ import ( "github.com/agiledragon/gomonkey/v2" linuxproc "github.com/c9s/goprocinfo/linux" "github.com/godbus/dbus/v5" - gclient "github.com/jipanyang/gnmi/client/gnmi" - "github.com/jipanyang/gnxi/utils/xpath" + gclient "github.com/openconfig/gnmi/client/gnmi" + "github.com/google/gnxi/utils/xpath" cacheclient "github.com/openconfig/gnmi/client" gnmipb "github.com/openconfig/gnmi/proto/gnmi" gnoi_system_pb "github.com/openconfig/gnoi/system" @@ -1841,9 +1841,9 @@ func runTestSubscribe(t *testing.T, namespace string) { }}, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS_PORT_NAME_MAP"}, TS: time.Unix(0, 200), Val: countersPortNameMapJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS_PORT_NAME_MAP"}, TS: time.Unix(0, 200), Val: countersPortNameMapJson}, client.Sync{}, - client.Update{Path: []string{"COUNTERS_PORT_NAME_MAP"}, TS: time.Unix(0, 200), Val: countersPortNameMapJsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS_PORT_NAME_MAP"}, TS: time.Unix(0, 200), Val: countersPortNameMapJsonUpdate}, }, }, { @@ -1869,9 +1869,9 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68"}, TS: time.Unix(0, 200), Val: countersEthernet68Json}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68"}, TS: time.Unix(0, 200), Val: countersEthernet68Json}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68"}, TS: time.Unix(0, 200), Val: countersEthernet68JsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68"}, TS: time.Unix(0, 200), Val: countersEthernet68JsonUpdate}, }, }, { @@ -1897,9 +1897,9 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68/1"}, TS: time.Unix(0, 200), Val: countersEthernet68Json}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68/1"}, TS: time.Unix(0, 200), Val: countersEthernet68Json}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68/1"}, TS: time.Unix(0, 200), Val: countersEthernet68JsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68/1"}, TS: time.Unix(0, 200), Val: countersEthernet68JsonUpdate}, }, }, { @@ -1925,9 +1925,9 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "2"}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "2"}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "3"}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "3"}, }, }, { @@ -1953,9 +1953,9 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68/1", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "2"}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68/1", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "2"}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68/1", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "3"}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68/1", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "3"}, }, }, { @@ -1981,9 +1981,9 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdJson}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdJsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdJsonUpdate}, }, }, { @@ -2009,9 +2009,9 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68/1", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdAliasJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68/1", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdAliasJson}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68/1", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdAliasJsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68/1", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdAliasJsonUpdate}, }, }, { @@ -2037,9 +2037,9 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*"}, TS: time.Unix(0, 200), Val: countersEthernetWildcardJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*"}, TS: time.Unix(0, 200), Val: countersEthernetWildcardJson}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*"}, TS: time.Unix(0, 200), Val: countersEtherneWildcardJsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*"}, TS: time.Unix(0, 200), Val: countersEtherneWildcardJsonUpdate}, }, }, { @@ -2057,9 +2057,9 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: countersEthernetWildcardPfcJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: countersEthernetWildcardPfcJson}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: singlePortPfcJsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: singlePortPfcJsonUpdate}, }, }, { @@ -2077,9 +2077,9 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernetWildPfcwdJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernetWildPfcwdJson}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdAliasJsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdAliasJsonUpdate}, }, }, { @@ -2100,13 +2100,13 @@ func runTestSubscribe(t *testing.T, namespace string) { wantNoti: []client.Notification{ client.Connected{}, // We are starting from the result data of "stream query for table with update of new field", - client.Update{Path: []string{"COUNTERS_PORT_NAME_MAP"}, TS: time.Unix(0, 200), Val: countersPortNameMapJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS_PORT_NAME_MAP"}, TS: time.Unix(0, 200), Val: countersPortNameMapJson}, client.Sync{}, - client.Update{Path: []string{"COUNTERS_PORT_NAME_MAP"}, TS: time.Unix(0, 200), Val: countersPortNameMapJsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS_PORT_NAME_MAP"}, TS: time.Unix(0, 200), Val: countersPortNameMapJsonUpdate}, client.Sync{}, - client.Update{Path: []string{"COUNTERS_PORT_NAME_MAP"}, TS: time.Unix(0, 200), Val: countersPortNameMapJsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS_PORT_NAME_MAP"}, TS: time.Unix(0, 200), Val: countersPortNameMapJsonUpdate}, client.Sync{}, - client.Update{Path: []string{"COUNTERS_PORT_NAME_MAP"}, TS: time.Unix(0, 200), Val: countersPortNameMapJsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS_PORT_NAME_MAP"}, TS: time.Unix(0, 200), Val: countersPortNameMapJsonUpdate}, client.Sync{}, }, }, @@ -2138,13 +2138,13 @@ func runTestSubscribe(t *testing.T, namespace string) { wantNoti: []client.Notification{ client.Connected{}, // We are starting from the result data of "stream query for table with update of new field", - client.Update{Path: []string{"COUNTERS_PORT_NAME_MAP"}, TS: time.Unix(0, 200), Val: countersPortNameMapJsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS_PORT_NAME_MAP"}, TS: time.Unix(0, 200), Val: countersPortNameMapJsonUpdate}, client.Sync{}, - client.Update{Path: []string{"COUNTERS_PORT_NAME_MAP"}, TS: time.Unix(0, 200), Val: countersPortNameMapJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS_PORT_NAME_MAP"}, TS: time.Unix(0, 200), Val: countersPortNameMapJson}, client.Sync{}, - client.Update{Path: []string{"COUNTERS_PORT_NAME_MAP"}, TS: time.Unix(0, 200), Val: countersPortNameMapJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS_PORT_NAME_MAP"}, TS: time.Unix(0, 200), Val: countersPortNameMapJson}, client.Sync{}, - client.Update{Path: []string{"COUNTERS_PORT_NAME_MAP"}, TS: time.Unix(0, 200), Val: countersPortNameMapJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS_PORT_NAME_MAP"}, TS: time.Unix(0, 200), Val: countersPortNameMapJson}, client.Sync{}, }, }, @@ -2169,13 +2169,13 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "2"}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "2"}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "4"}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "4"}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "4"}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "4"}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "4"}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "4"}, client.Sync{}, }, }, @@ -2200,13 +2200,13 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68/1", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "2"}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68/1", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "2"}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68/1", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "4"}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68/1", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "4"}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68/1", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "4"}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68/1", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "4"}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68/1", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "4"}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68/1", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "4"}, client.Sync{}, }, }, @@ -2231,13 +2231,13 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdJson}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdPollUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdPollUpdate}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdPollUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdPollUpdate}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdPollUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdPollUpdate}, client.Sync{}, }, }, @@ -2262,13 +2262,13 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68/1", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdAliasJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68/1", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdAliasJson}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68/1", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdAliasPollUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68/1", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdAliasPollUpdate}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68/1", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdAliasPollUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68/1", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdAliasPollUpdate}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68/1", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdAliasPollUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68/1", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdAliasPollUpdate}, client.Sync{}, }, }, @@ -2293,13 +2293,13 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*"}, TS: time.Unix(0, 200), Val: countersEthernetWildcardJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*"}, TS: time.Unix(0, 200), Val: countersEthernetWildcardJson}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*"}, TS: time.Unix(0, 200), Val: countersFieldUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*"}, TS: time.Unix(0, 200), Val: countersFieldUpdate}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*"}, TS: time.Unix(0, 200), Val: countersFieldUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*"}, TS: time.Unix(0, 200), Val: countersFieldUpdate}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*"}, TS: time.Unix(0, 200), Val: countersFieldUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*"}, TS: time.Unix(0, 200), Val: countersFieldUpdate}, client.Sync{}, }, }, @@ -2324,13 +2324,13 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: countersEthernetWildcardPfcJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: countersEthernetWildcardPfcJson}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: allPortPfcJsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: allPortPfcJsonUpdate}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: allPortPfcJsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: allPortPfcJsonUpdate}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: allPortPfcJsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: allPortPfcJsonUpdate}, client.Sync{}, }, }, @@ -2355,13 +2355,13 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernetWildPfcwdJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernetWildPfcwdJson}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernetWildPfcwdUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernetWildPfcwdUpdate}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernetWildPfcwdUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernetWildPfcwdUpdate}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernetWildPfcwdUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernetWildPfcwdUpdate}, client.Sync{}, }, }, @@ -2376,9 +2376,9 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*", "Queues"}, TS: time.Unix(0, 200), Val: countersEthernetWildQueuesJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*", "Queues"}, TS: time.Unix(0, 200), Val: countersEthernetWildQueuesJson}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*", "Queues"}, TS: time.Unix(0, 200), Val: countersEthernetWildQueuesJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*", "Queues"}, TS: time.Unix(0, 200), Val: countersEthernetWildQueuesJson}, client.Sync{}, }, }, @@ -2403,13 +2403,13 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68", "Queues"}, TS: time.Unix(0, 200), Val: countersEthernet68QueuesJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68", "Queues"}, TS: time.Unix(0, 200), Val: countersEthernet68QueuesJson}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68", "Queues"}, TS: time.Unix(0, 200), Val: countersEthernet68QueuesJsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68", "Queues"}, TS: time.Unix(0, 200), Val: countersEthernet68QueuesJsonUpdate}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68", "Queues"}, TS: time.Unix(0, 200), Val: countersEthernet68QueuesJsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68", "Queues"}, TS: time.Unix(0, 200), Val: countersEthernet68QueuesJsonUpdate}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68", "Queues"}, TS: time.Unix(0, 200), Val: countersEthernet68QueuesJsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68", "Queues"}, TS: time.Unix(0, 200), Val: countersEthernet68QueuesJsonUpdate}, client.Sync{}, }, }, @@ -2434,13 +2434,13 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68/1", "Queues"}, TS: time.Unix(0, 200), Val: countersEthernet68QueuesAliasJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68/1", "Queues"}, TS: time.Unix(0, 200), Val: countersEthernet68QueuesAliasJson}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68/1", "Queues"}, TS: time.Unix(0, 200), Val: countersEthernet68QueuesAliasJsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68/1", "Queues"}, TS: time.Unix(0, 200), Val: countersEthernet68QueuesAliasJsonUpdate}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68/1", "Queues"}, TS: time.Unix(0, 200), Val: countersEthernet68QueuesAliasJsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68/1", "Queues"}, TS: time.Unix(0, 200), Val: countersEthernet68QueuesAliasJsonUpdate}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68/1", "Queues"}, TS: time.Unix(0, 200), Val: countersEthernet68QueuesAliasJsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68/1", "Queues"}, TS: time.Unix(0, 200), Val: countersEthernet68QueuesAliasJsonUpdate}, client.Sync{}, }, }, @@ -2460,9 +2460,9 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68"}, TS: time.Unix(0, 200), Val: countersEthernet68Json}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68"}, TS: time.Unix(0, 200), Val: countersEthernet68Json}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68"}, TS: time.Unix(0, 200), Val: countersEthernet68JsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68"}, TS: time.Unix(0, 200), Val: countersEthernet68JsonUpdate}, }, }, { @@ -2475,10 +2475,10 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "2"}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "2"}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "3"}, - client.Update{Path: []string{"COUNTERS", "Ethernet68", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "3"}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "3"}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: "3"}, }, }, { @@ -2491,10 +2491,10 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68/1"}, TS: time.Unix(0, 200), Val: countersEthernet68Json}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68/1"}, TS: time.Unix(0, 200), Val: countersEthernet68Json}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68/1"}, TS: time.Unix(0, 200), Val: countersEthernet68JsonUpdate}, - client.Update{Path: []string{"COUNTERS", "Ethernet68/1"}, TS: time.Unix(0, 200), Val: countersEthernet68JsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68/1"}, TS: time.Unix(0, 200), Val: countersEthernet68JsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68/1"}, TS: time.Unix(0, 200), Val: countersEthernet68JsonUpdate}, }, }, { @@ -2507,10 +2507,10 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdJson}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68", "Pfcwd"}, TS: time.Unix(0, 200), Val: mergeStrMaps(countersEthernet68PfcwdJson, countersEthernet68PfcwdJsonUpdate)}, - client.Update{Path: []string{"COUNTERS", "Ethernet68", "Pfcwd"}, TS: time.Unix(0, 200), Val: mergeStrMaps(countersEthernet68PfcwdJson, countersEthernet68PfcwdJsonUpdate)}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68", "Pfcwd"}, TS: time.Unix(0, 200), Val: mergeStrMaps(countersEthernet68PfcwdJson, countersEthernet68PfcwdJsonUpdate)}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68", "Pfcwd"}, TS: time.Unix(0, 200), Val: mergeStrMaps(countersEthernet68PfcwdJson, countersEthernet68PfcwdJsonUpdate)}, }, }, { @@ -2523,10 +2523,10 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68/1", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdAliasJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68/1", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdAliasJson}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet68/1", "Pfcwd"}, TS: time.Unix(0, 200), Val: mergeStrMaps(countersEthernet68PfcwdAliasJson, countersEthernet68PfcwdAliasJsonUpdate)}, - client.Update{Path: []string{"COUNTERS", "Ethernet68/1", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdAliasJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68/1", "Pfcwd"}, TS: time.Unix(0, 200), Val: mergeStrMaps(countersEthernet68PfcwdAliasJson, countersEthernet68PfcwdAliasJsonUpdate)}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet68/1", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdAliasJson}, }, }, { @@ -2538,9 +2538,9 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*"}, TS: time.Unix(0, 200), Val: countersEthernetWildcardJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*"}, TS: time.Unix(0, 200), Val: countersEthernetWildcardJson}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*"}, TS: time.Unix(0, 200), Val: mergeStrMaps(countersEthernetWildcardJson, countersEtherneWildcardJsonUpdate)}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*"}, TS: time.Unix(0, 200), Val: mergeStrMaps(countersEthernetWildcardJson, countersEtherneWildcardJsonUpdate)}, }, }, { @@ -2554,11 +2554,11 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*"}, TS: time.Unix(0, 200), Val: countersEthernetWildcardJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*"}, TS: time.Unix(0, 200), Val: countersEthernetWildcardJson}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*"}, TS: time.Unix(0, 200), Val: map[string]interface{}{}}, //empty update - client.Update{Path: []string{"COUNTERS", "Ethernet*"}, TS: time.Unix(0, 200), Val: countersEtherneWildcardJsonUpdate}, - client.Update{Path: []string{"COUNTERS", "Ethernet*"}, TS: time.Unix(0, 200), Val: map[string]interface{}{}}, //empty update + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*"}, TS: time.Unix(0, 200), Val: map[string]interface{}{}}, //empty update + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*"}, TS: time.Unix(0, 200), Val: countersEtherneWildcardJsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*"}, TS: time.Unix(0, 200), Val: map[string]interface{}{}}, //empty update }, }, /* @@ -2589,9 +2589,9 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: countersEthernetWildcardPfcJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: countersEthernetWildcardPfcJson}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: mergeStrMaps(countersEthernetWildcardPfcJson, singlePortPfcJsonUpdate)}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*", "SAI_PORT_STAT_PFC_7_RX_PKTS"}, TS: time.Unix(0, 200), Val: mergeStrMaps(countersEthernetWildcardPfcJson, singlePortPfcJsonUpdate)}, }, }, { @@ -2603,9 +2603,9 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernetWildPfcwdJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernetWildPfcwdJson}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*", "Pfcwd"}, TS: time.Unix(0, 200), Val: mergeStrMaps(countersEthernetWildPfcwdJson, countersEthernet68PfcwdAliasJsonUpdate)}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*", "Pfcwd"}, TS: time.Unix(0, 200), Val: mergeStrMaps(countersEthernetWildPfcwdJson, countersEthernet68PfcwdAliasJsonUpdate)}, }, }, { @@ -2619,11 +2619,11 @@ func runTestSubscribe(t *testing.T, namespace string) { }, wantNoti: []client.Notification{ client.Connected{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernetWildPfcwdJson}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernetWildPfcwdJson}, client.Sync{}, - client.Update{Path: []string{"COUNTERS", "Ethernet*", "Pfcwd"}, TS: time.Unix(0, 200), Val: map[string]interface{}{}}, //empty update - client.Update{Path: []string{"COUNTERS", "Ethernet*", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdAliasJsonUpdate}, - client.Update{Path: []string{"COUNTERS", "Ethernet*", "Pfcwd"}, TS: time.Unix(0, 200), Val: map[string]interface{}{}}, //empty update + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*", "Pfcwd"}, TS: time.Unix(0, 200), Val: map[string]interface{}{}}, //empty update + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*", "Pfcwd"}, TS: time.Unix(0, 200), Val: countersEthernet68PfcwdAliasJsonUpdate}, + client.Update{Path: []string{"COUNTERS_DB", "COUNTERS", "Ethernet*", "Pfcwd"}, TS: time.Unix(0, 200), Val: map[string]interface{}{}}, //empty update }, }, } @@ -3242,8 +3242,8 @@ func TestTableKeyOnDeletion(t *testing.T) { desc: "Testing deletion of NEIGH_STATE_TABLE:10.0.0.57", q: createStateDbQueryOnChangeMode(t, "NEIGH_STATE_TABLE"), wantNoti: []client.Notification{ - client.Update{Path: []string{"NEIGH_STATE_TABLE"}, TS: time.Unix(0, 200), Val: neighStateTableJson}, - client.Update{Path: []string{"NEIGH_STATE_TABLE"}, TS: time.Unix(0, 200), Val: neighStateTableDeletedJson57}, + client.Update{Path: []string{"STATE_DB", "NEIGH_STATE_TABLE"}, TS: time.Unix(0, 200), Val: neighStateTableJson}, + client.Update{Path: []string{"STATE_DB", "NEIGH_STATE_TABLE"}, TS: time.Unix(0, 200), Val: neighStateTableDeletedJson57}, }, paths: []string{ "NEIGH_STATE_TABLE|10.0.0.57", @@ -3253,9 +3253,9 @@ func TestTableKeyOnDeletion(t *testing.T) { desc: "Testing deletion of NEIGH_STATE_TABLE:10.0.0.59 and NEIGH_STATE_TABLE 10.0.0.61", q: createStateDbQueryOnChangeMode(t, "NEIGH_STATE_TABLE"), wantNoti: []client.Notification{ - client.Update{Path: []string{"NEIGH_STATE_TABLE"}, TS: time.Unix(0, 200), Val: neighStateTableJsonTwo}, - client.Update{Path: []string{"NEIGH_STATE_TABLE"}, TS: time.Unix(0, 200), Val: neighStateTableDeletedJson59}, - client.Update{Path: []string{"NEIGH_STATE_TABLE"}, TS: time.Unix(0, 200), Val: neighStateTableDeletedJson61}, + client.Update{Path: []string{"STATE_DB", "NEIGH_STATE_TABLE"}, TS: time.Unix(0, 200), Val: neighStateTableJsonTwo}, + client.Update{Path: []string{"STATE_DB", "NEIGH_STATE_TABLE"}, TS: time.Unix(0, 200), Val: neighStateTableDeletedJson59}, + client.Update{Path: []string{"STATE_DB", "NEIGH_STATE_TABLE"}, TS: time.Unix(0, 200), Val: neighStateTableDeletedJson61}, }, paths: []string{ "NEIGH_STATE_TABLE|10.0.0.59", @@ -3517,8 +3517,8 @@ func TestWildcardTableNoError(t *testing.T) { TLS: &tls.Config{InsecureSkipVerify: true}, }, wantNoti: []client.Notification{ - client.Update{Path: []string{"NEIGH_STATE_TABLE"}, TS: time.Unix(0, 200), Val: neighStateTableJson}, - client.Update{Path: []string{"NEIGH_STATE_TABLE"}, TS: time.Unix(0, 200), Val: neighStateTableJson}, + client.Update{Path: []string{"STATE_DB", "NEIGH_STATE_TABLE"}, TS: time.Unix(0, 200), Val: neighStateTableJson}, + client.Update{Path: []string{"STATE_DB", "NEIGH_STATE_TABLE"}, TS: time.Unix(0, 200), Val: neighStateTableJson}, }, }, } @@ -3609,8 +3609,8 @@ func TestNonExistentTableNoError(t *testing.T) { TLS: &tls.Config{InsecureSkipVerify: true}, }, wantNoti: []client.Notification{ - client.Update{Path: []string{"TRANSCEIVER_DOM_SENSOR"}, TS: time.Unix(0, 200), Val: transceiverDomSensorTableJson}, - client.Update{Path: []string{"TRANSCEIVER_DOM_SENSOR"}, TS: time.Unix(0, 200), Val: transceiverDomSensorTableJson}, + client.Update{Path: []string{"STATE_DB", "TRANSCEIVER_DOM_SENSOR"}, TS: time.Unix(0, 200), Val: transceiverDomSensorTableJson}, + client.Update{Path: []string{"STATE_DB", "TRANSCEIVER_DOM_SENSOR"}, TS: time.Unix(0, 200), Val: transceiverDomSensorTableJson}, }, }, } diff --git a/gnmi_server/transl_sub_test.go b/gnmi_server/transl_sub_test.go index 032af080..ff748ee8 100644 --- a/gnmi_server/transl_sub_test.go +++ b/gnmi_server/transl_sub_test.go @@ -128,12 +128,12 @@ func TestTranslSubscribe(t *testing.T) { sub := doSubscribe(t, req, codes.OK) sub.Verify( - Updated(acl1Path+"/name", "ONE"), - Updated(acl1Path+"/type", "ACL_IPV4"), - Updated(acl1Path+"/config/name", "ONE"), - Updated(acl1Path+"/config/type", "ACL_IPV4"), - Updated(acl1Path+"/state/name", "ONE"), - Updated(acl1Path+"/state/type", "ACL_IPV4"), + Updated("/openconfig"+acl1Path+"/name", "ONE"), + Updated("/openconfig"+acl1Path+"/type", "ACL_IPV4"), + Updated("/openconfig"+acl1Path+"/config/name", "ONE"), + Updated("/openconfig"+acl1Path+"/config/type", "ACL_IPV4"), + Updated("/openconfig"+acl1Path+"/state/name", "ONE"), + Updated("/openconfig"+acl1Path+"/state/type", "ACL_IPV4"), client.Sync{}, ) }) @@ -160,8 +160,8 @@ func TestTranslSubscribe(t *testing.T) { t.Logf("Verify poll updates include ACL1 data") sub.Poll() sub.Verify( - Updated(acl1Path+"/config/name", "ONE"), - Updated(acl1Path+"/config/type", "ACL_IPV4"), + Updated("/openconfig"+acl1Path+"/config/name", "ONE"), + Updated("/openconfig"+acl1Path+"/config/type", "ACL_IPV4"), client.Sync{}, ) @@ -172,11 +172,11 @@ func TestTranslSubscribe(t *testing.T) { t.Logf("Verify poll updates include both ACL1 and ACL2 data") sub.Poll() sub.Verify( - Updated(acl1Path+"/config/name", "ONE"), - Updated(acl1Path+"/config/type", "ACL_IPV4"), - Updated(acl2Path+"/config/name", "TWO"), - Updated(acl2Path+"/config/type", "ACL_IPV4"), - Updated(acl2Path+"/config/description", "foo"), + Updated("/openconfig"+acl1Path+"/config/name", "ONE"), + Updated("/openconfig"+acl1Path+"/config/type", "ACL_IPV4"), + Updated("/openconfig"+acl2Path+"/config/name", "TWO"), + Updated("/openconfig"+acl2Path+"/config/type", "ACL_IPV4"), + Updated("/openconfig"+acl2Path+"/config/description", "foo"), client.Sync{}, ) @@ -187,8 +187,8 @@ func TestTranslSubscribe(t *testing.T) { t.Logf("Verify poll updates now include ACL1 data only") sub.Poll() sub.Verify( - Updated(acl1Path+"/config/name", "ONE"), - Updated(acl1Path+"/config/type", "ACL_IPV4"), + Updated("/openconfig"+acl1Path+"/config/name", "ONE"), + Updated("/openconfig"+acl1Path+"/config/type", "ACL_IPV4"), client.Sync{}, ) }) @@ -213,9 +213,9 @@ func TestTranslSubscribe(t *testing.T) { t.Logf("Verify update notifications for ACL2 data") sub.Verify( - Updated(acl2Path+"/config/name", "TWO"), - Updated(acl2Path+"/config/type", "ACL_IPV4"), - Updated(acl2Path+"/config/description", "foo"), + Updated("/openconfig"+acl2Path+"/config/name", "TWO"), + Updated("/openconfig"+acl2Path+"/config/type", "ACL_IPV4"), + Updated("/openconfig"+acl2Path+"/config/description", "foo"), ) t.Logf("Create ACL1 and delete description of ACL2") @@ -223,9 +223,9 @@ func TestTranslSubscribe(t *testing.T) { t.Logf("Verify delete notification for ACL2 description and updates for ACL1 data") sub.Verify( - Updated(acl1Path+"/config/name", "ONE"), - Updated(acl1Path+"/config/type", "ACL_IPV4"), - Deleted(acl2Path+"/config/description"), + Updated("/openconfig"+acl1Path+"/config/name", "ONE"), + Updated("/openconfig"+acl1Path+"/config/type", "ACL_IPV4"), + Deleted("/openconfig"+acl2Path+"/config/description"), ) t.Logf("Delete ACL1 and set description for ACL2") @@ -233,8 +233,8 @@ func TestTranslSubscribe(t *testing.T) { t.Logf("Verify delete for ACL1 and update for ACL2 description") sub.Verify( - Deleted(acl1Path+"/config"), - Updated(acl2Path+"/config/description", "new"), + Deleted("/openconfig"+acl1Path+"/config"), + Updated("/openconfig"+acl2Path+"/config/description", "new"), ) }) @@ -272,8 +272,8 @@ func TestTranslSubscribe(t *testing.T) { t.Logf("Verify initial updates include ACL1 data only") sub.Verify( - Updated(acl1Path+"/state/name", "ONE"), - Updated(acl1Path+"/state/type", "ACL_IPV4"), + Updated("/openconfig"+acl1Path+"/state/name", "ONE"), + Updated("/openconfig"+acl1Path+"/state/type", "ACL_IPV4"), client.Sync{}, ) @@ -285,11 +285,11 @@ func TestTranslSubscribe(t *testing.T) { t.Logf("interval %d", i) sub.VerifyT(sampleInterval - 3*time.Second) // check no notifications before the interval sub.Verify( - Updated(acl1Path+"/state/name", "ONE"), - Updated(acl1Path+"/state/type", "ACL_IPV4"), - Updated(acl2Path+"/state/name", "TWO"), - Updated(acl2Path+"/state/type", "ACL_IPV4"), - Updated(acl2Path+"/state/description", "foo"), + Updated("/openconfig"+acl1Path+"/state/name", "ONE"), + Updated("/openconfig"+acl1Path+"/state/type", "ACL_IPV4"), + Updated("/openconfig"+acl2Path+"/state/name", "TWO"), + Updated("/openconfig"+acl2Path+"/state/type", "ACL_IPV4"), + Updated("/openconfig"+acl2Path+"/state/description", "foo"), ) } @@ -299,17 +299,17 @@ func TestTranslSubscribe(t *testing.T) { t.Logf("Verify next iteration includes deletes and updates (for remaining ACL2 data)") sub.VerifyT(sampleInterval - 3*time.Second) sub.Verify( - Deleted(acl1Path+"/state"), - Deleted(acl2Path+"/state/description"), - Updated(acl2Path+"/state/name", "TWO"), - Updated(acl2Path+"/state/type", "ACL_IPV4"), + Deleted("/openconfig"+acl1Path+"/state"), + Deleted("/openconfig"+acl2Path+"/state/description"), + Updated("/openconfig"+acl2Path+"/state/name", "TWO"), + Updated("/openconfig"+acl2Path+"/state/type", "ACL_IPV4"), ) t.Logf("Verify next iteration has updates only") sub.VerifyT(sampleInterval - 3*time.Second) sub.Verify( - Updated(acl2Path+"/state/name", "TWO"), - Updated(acl2Path+"/state/type", "ACL_IPV4"), + Updated("/openconfig"+acl2Path+"/state/name", "TWO"), + Updated("/openconfig"+acl2Path+"/state/type", "ACL_IPV4"), ) }) @@ -334,11 +334,11 @@ func TestTranslSubscribe(t *testing.T) { t.Logf("Verify initial updates") sub.Verify( - Updated(acl1Path+"/config/name", "ONE"), - Updated(acl1Path+"/config/type", "ACL_IPV4"), - Updated(acl2Path+"/config/name", "TWO"), - Updated(acl2Path+"/config/type", "ACL_IPV4"), - Updated(acl2Path+"/config/description", "foo"), + Updated("/openconfig"+acl1Path+"/config/name", "ONE"), + Updated("/openconfig"+acl1Path+"/config/type", "ACL_IPV4"), + Updated("/openconfig"+acl2Path+"/config/name", "TWO"), + Updated("/openconfig"+acl2Path+"/config/type", "ACL_IPV4"), + Updated("/openconfig"+acl2Path+"/config/description", "foo"), client.Sync{}, ) @@ -351,8 +351,8 @@ func TestTranslSubscribe(t *testing.T) { t.Logf("Verify next iteration includes deletes and updates for modified paths only") sub.VerifyT( sampleInterval+3*time.Second, - Deleted(acl1Path+"/config"), - Updated(acl2Path+"/config/description", "new"), + Deleted("/openconfig"+acl1Path+"/config"), + Updated("/openconfig"+acl2Path+"/config/description", "new"), ) t.Logf("Delete ACL2 description") @@ -361,7 +361,7 @@ func TestTranslSubscribe(t *testing.T) { t.Logf("Verify next iteration includes description delete only") sub.VerifyT( sampleInterval+3*time.Second, - Deleted(acl2Path+"/config/description"), + Deleted("/openconfig"+acl2Path+"/config/description"), ) t.Logf("Verify next iteration has no data") @@ -393,7 +393,7 @@ func TestTranslSubscribe(t *testing.T) { t.Logf("Verify next iteration has the description value") sub.VerifyT(sampleInterval - 3*time.Second) // check no notifications before the interval sub.Verify( - Updated(acl2Path+"/state/description", "foo"), + Updated("/openconfig"+acl2Path+"/state/description", "foo"), ) t.Logf("Update ACL2 description") @@ -402,7 +402,7 @@ func TestTranslSubscribe(t *testing.T) { t.Logf("Verify next iteration has the updated description") sub.VerifyT(sampleInterval - 3*time.Second) sub.Verify( - Updated(acl2Path+"/state/description", "new"), + Updated("/openconfig"+acl2Path+"/state/description", "new"), ) t.Logf("Delete ACL2") @@ -411,7 +411,7 @@ func TestTranslSubscribe(t *testing.T) { t.Logf("Verify next iteration has delete notification") sub.VerifyT(sampleInterval - 3*time.Second) sub.Verify( - Deleted(acl2Path + "/state/description"), + Deleted("/openconfig"+acl2Path + "/state/description"), ) t.Logf("Verify next iteration has no notifications") @@ -458,7 +458,7 @@ func TestTranslSubscribe(t *testing.T) { t.Logf("Verify updates are received after default interval") sub.VerifyT( (translib.MinSubscribeInterval+2)*time.Second, - Updated(acl2Path+"/state/description", "foo"), + Updated("/openconfig"+acl2Path+"/state/description", "foo"), ) }) diff --git a/go.mod b/go.mod index 1607686a..6282b059 100644 --- a/go.mod +++ b/go.mod @@ -14,9 +14,7 @@ require ( github.com/gogo/protobuf v1.3.2 github.com/golang/glog v1.2.0 github.com/golang/protobuf v1.5.4 - github.com/google/gnxi v0.0.0-20191016182648-6697a080bc2d - github.com/jipanyang/gnmi v0.0.0-20180820232453-cb4d464fa018 - github.com/jipanyang/gnxi v0.0.0-20181221084354-f0a90cca6fd0 + github.com/google/gnxi v0.0.0-20181220173256-89f51f0ce1e2 github.com/kylelemons/godebug v1.1.0 github.com/msteinert/pam v0.0.0-20201130170657-e61372126161 github.com/openconfig/gnmi v0.0.0-20200617225440-d2b4e6a45802 diff --git a/go.sum b/go.sum index 38b55147..8802e8ee 100644 --- a/go.sum +++ b/go.sum @@ -58,8 +58,6 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/google/gnxi v0.0.0-20191016182648-6697a080bc2d h1:OtErLAncPdsEEhOI4ueR48dr6uThRIPkwWcOAdQ4LyI= -github.com/google/gnxi v0.0.0-20191016182648-6697a080bc2d/go.mod h1:6kkMbKS62iZMyk1q0zukcqkEJwnIhcbgg/hmoFmRDZk= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -73,10 +71,8 @@ github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/jipanyang/gnmi v0.0.0-20180820232453-cb4d464fa018 h1:M++7b2XCTGqQwqu+AB0B3XzXiV+vVawnXJ4tvxUMrTU= -github.com/jipanyang/gnmi v0.0.0-20180820232453-cb4d464fa018/go.mod h1:+aiusdWGFuKzi7B8/Y75kTlIA3UDF+sUBfY5+1e2NLs= -github.com/jipanyang/gnxi v0.0.0-20181221084354-f0a90cca6fd0 h1:Dr/hrfbZxVlT/VvLfv8glHZAf9dLfuTSCJQq7cRGydo= -github.com/jipanyang/gnxi v0.0.0-20181221084354-f0a90cca6fd0/go.mod h1:vL9tMB3I625wwTPrEWmJ+kWrsHHFN/J79IEQD9knVi0= +github.com/google/gnxi v0.0.0-20181220173256-89f51f0ce1e2 h1:Cb0tImy52kinqtUXYR59HSNXYz83Y69yD8/zoKScE3s= +github.com/google/gnxi v0.0.0-20181220173256-89f51f0ce1e2/go.mod h1:6kkMbKS62iZMyk1q0zukcqkEJwnIhcbgg/hmoFmRDZk= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= diff --git a/patches/gnmi_cli.all.patch b/patches/gnmi_cli.all.patch index 14af1c74..6f96d023 100644 --- a/patches/gnmi_cli.all.patch +++ b/patches/gnmi_cli.all.patch @@ -1,6 +1,23 @@ ---- ./github.com/openconfig/gnmi/client/gnmi/client.go 2019-11-22 14:03:29.839103602 -0800 +patch--- ./github.com/openconfig/gnmi/client/gnmi/client.go 2019-11-22 14:03:29.839103602 -0800 +++ ./github.com/openconfig/gnmi/client/gnmi/client.go 2019-10-11 13:48:49.226145599 -0700 -@@ -257,7 +257,7 @@ +@@ -37,7 +37,6 @@ + "github.com/openconfig/gnmi/client" + "github.com/openconfig/gnmi/client/grpcutil" + "github.com/openconfig/gnmi/path" +- "github.com/openconfig/gnmi/value" + + gpb "github.com/openconfig/gnmi/proto/gnmi" + ) +@@ -246,7 +245,7 @@ + s := &gpb.SubscribeRequest_Subscribe{ + Subscribe: &gpb.SubscriptionList{ + Mode: getType(q.Type), +- Prefix: &gpb.Path{Target: q.Target}, ++ Prefix: &gpb.Path{Target: q.Target, Origin: q.Origin}, + }, + } + if q.UpdatesOnly { +@@ -257,11 +256,58 @@ if err != nil { return nil, fmt.Errorf("invalid query path %q: %v", qq, err) } @@ -9,6 +26,66 @@ } return &gpb.SubscribeRequest{Request: s}, nil } + ++// decimalToFloat converts a *gnmi_proto.Decimal64 to a float32. Downcasting to float32 is performed as the ++// precision of a float64 is not required. ++func decimalToFloat(d *gpb.Decimal64) float32 { ++ return float32(float64(d.Digits) / math.Pow(10, float64(d.Precision))) ++} ++ ++// ToScalar will convert TypedValue scalar types to a Go native type. It will ++// return an error if the TypedValue does not contain a scalar type. ++func toScalar(tv *gpb.TypedValue) (interface{}, error) { ++ var i interface{} ++ switch tv.Value.(type) { ++ case *gpb.TypedValue_DecimalVal: ++ i = decimalToFloat(tv.GetDecimalVal()) ++ case *gpb.TypedValue_StringVal: ++ i = tv.GetStringVal() ++ case *gpb.TypedValue_IntVal: ++ i = tv.GetIntVal() ++ case *gpb.TypedValue_UintVal: ++ i = tv.GetUintVal() ++ case *gpb.TypedValue_BoolVal: ++ i = tv.GetBoolVal() ++ case *gpb.TypedValue_FloatVal: ++ i = tv.GetFloatVal() ++ case *gpb.TypedValue_LeaflistVal: ++ elems := tv.GetLeaflistVal().GetElement() ++ ss := make([]interface{}, len(elems)) ++ for x, e := range elems { ++ v, err := toScalar(e) ++ if err != nil { ++ return nil, fmt.Errorf("ToScalar for ScalarArray %+v: %v", e.Value, err) ++ } ++ ss[x] = v ++ } ++ i = ss ++ case *gpb.TypedValue_BytesVal: ++ i = tv.GetBytesVal() ++ case *gpb.TypedValue_JsonIetfVal: ++ var val interface{} ++ val = tv.GetJsonIetfVal() ++ json.Unmarshal(val.([]byte), &i) ++ //i = tv.GetJsonIetfVal() ++ default: ++ return nil, fmt.Errorf("non-scalar type %+v", tv.Value) ++ } ++ return i, nil ++} ++ + func noti(prefix []string, pp *gpb.Path, ts time.Time, u *gpb.Update) (client.Notification, error) { + sp := path.ToStrings(pp, false) + // Make a full new copy of prefix + u.Path to avoid any reuse of underlying +@@ -274,7 +320,7 @@ + return client.Delete{Path: p, TS: ts}, nil + } + if u.Val != nil { +- val, err := value.ToScalar(u.Val) ++ val, err := toScalar(u.Val) + if err != nil { + return nil, err + } --- ./github.com/openconfig/gnmi/cmd/gnmi_cli/gnmi_cli.go 2019-11-22 14:03:29.839103602 -0800 +++ ./github.com/openconfig/gnmi/cmd/gnmi_cli/gnmi_cli.go 2019-11-21 09:30:52.453893674 -0800 @@ -76,6 +76,11 @@ @@ -87,15 +164,3 @@ default: return nil, fmt.Errorf("non-scalar type %+v", tv.Value) } - ---- ./github.com/openconfig/gnmi/client/gnmi/client.go 2019-11-22 14:03:29.847103498 -0800 -+++ ./github.com/openconfig/gnmi/client/gnmi/client.go 2019-10-11 13:48:49.234145530 -0700 -@@ -246,7 +246,7 @@ - s := &gpb.SubscribeRequest_Subscribe{ - Subscribe: &gpb.SubscriptionList{ - Mode: getType(q.Type), -- Prefix: &gpb.Path{Target: q.Target}, -+ Prefix: &gpb.Path{Target: q.Target, Origin: q.Origin}, - }, - } - if q.UpdatesOnly { diff --git a/patches/gnmi_get.patch b/patches/gnmi_get.patch index 39a1eea9..cf451f3c 100644 --- a/patches/gnmi_get.patch +++ b/patches/gnmi_get.patch @@ -1,5 +1,5 @@ ---- ./github.com/jipanyang/gnxi/gnmi_get/gnmi_get.go 2019-11-26 15:44:07.303598063 -0800 -+++ ./github.com/jipanyang/gnxi/gnmi_get/gnmi_get.go 2019-12-19 19:56:11.364223008 -0800 +--- ./github.com/google/gnxi/gnmi_get/gnmi_get.go 2019-11-26 15:44:07.303598063 -0800 ++++ ./github.com/google/gnxi/gnmi_get/gnmi_get.go 2019-12-19 19:56:11.364223008 -0800 @@ -21,6 +21,7 @@ "fmt" "strings" @@ -11,17 +11,16 @@ @@ -30,7 +31,7 @@ "github.com/google/gnxi/utils" "github.com/google/gnxi/utils/credentials" - "github.com/jipanyang/gnxi/utils/xpath" + "github.com/google/gnxi/utils/xpath" - + "google.golang.org/grpc/metadata" pb "github.com/openconfig/gnmi/proto/gnmi" ) -@@ -63,17 +64,20 @@ +@@ -63,16 +64,20 @@ xPathFlags arrayFlags pbPathFlags arrayFlags pbModelDataFlags arrayFlags -- pathTarget = flag.String("xpath_target", "CONFIG_DB", "name of the target for which the path is a member") + protoFileFlags arrayFlags + pathTarget = flag.String("xpath_target", "", "name of the target for which the path is a member") targetAddr = flag.String("target_addr", "localhost:10161", "The target address in the format of host:port") @@ -39,7 +38,7 @@ flag.Parse() opts := credentials.ClientCredentials(*targetName) -@@ -88,6 +92,10 @@ +@@ -87,6 +92,10 @@ ctx, cancel := context.WithTimeout(context.Background(), *timeOut) defer cancel() @@ -50,7 +49,31 @@ encoding, ok := pb.Encoding_value[*encodingName] if !ok { var gnmiEncodingList []string -@@ -139,4 +147,20 @@ +@@ -96,12 +105,14 @@ + log.Exitf("Supported encodings: %s", strings.Join(gnmiEncodingList, ", ")) + } + ++ var prefix pb.Path ++ prefix.Target = *pathTarget + var pbPathList []*pb.Path + var pbModelDataList []*pb.ModelData + for _, xPath := range xPathFlags { + pbPath, err := xpath.ToGNMIPath(xPath) + if err != nil { +- log.Exitf("error in parsing xpath %q to gnmi path", xPath) ++ log.Exitf("error in parsing xpath %q to gnmi path, %v", xPath, err) + } + pbPathList = append(pbPathList, pbPath) + } +@@ -120,6 +131,7 @@ + } + + getRequest := &pb.GetRequest{ ++ Prefix: &prefix, + Encoding: pb.Encoding(encoding), + Path: pbPathList, + UseModels: pbModelDataList, +@@ -135,4 +147,20 @@ fmt.Println("== getResponse:") utils.PrintProto(getResponse) diff --git a/patches/gnmi_path.patch b/patches/gnmi_path.patch index 8098aeee..62571f0f 100644 --- a/patches/gnmi_path.patch +++ b/patches/gnmi_path.patch @@ -1,7 +1,7 @@ Update path.go to support origin field, use ":" in the first element to get origin field ---- ./github.com/jipanyang/gnxi/utils/xpath/path.go -+++ ./github.com/jipanyang/gnxi/utils/xpath/path.go +--- ./github.com/google/gnxi/utils/xpath/path.go ++++ ./github.com/google/gnxi/utils/xpath/path.go @@ -18,6 +18,7 @@ package xpath import ( diff --git a/patches/gnmi_set.patch b/patches/gnmi_set.patch index 933e61d1..33e81844 100644 --- a/patches/gnmi_set.patch +++ b/patches/gnmi_set.patch @@ -1,5 +1,5 @@ ---- ./github.com/jipanyang/gnxi/gnmi_set/gnmi_set.go 2019-11-26 15:44:07.303598063 -0800 -+++ ./github.com/jipanyang/gnxi/gnmi_set/gnmi_set.go 2020-02-12 10:13:46.247988021 -0800 +--- ./github.com/google/gnxi/gnmi_set/gnmi_set.go 2019-11-26 15:44:07.303598063 -0800 ++++ ./github.com/google/gnxi/gnmi_set/gnmi_set.go 2020-02-12 10:13:46.247988021 -0800 @@ -31,8 +31,9 @@ "github.com/google/gnxi/utils" @@ -7,7 +7,7 @@ - "github.com/google/gnxi/utils/xpath" - + //"github.com/google/gnxi/utils/xpath" -+ "github.com/jipanyang/gnxi/utils/xpath" ++ "github.com/google/gnxi/utils/xpath" + "google.golang.org/grpc/metadata" pb "github.com/openconfig/gnmi/proto/gnmi" ) diff --git a/patches/gnmi_xpath.patch b/patches/gnmi_xpath.patch index 6e36443d..168d7f5b 100644 --- a/patches/gnmi_xpath.patch +++ b/patches/gnmi_xpath.patch @@ -1,21 +1,30 @@ -Use escaped '/' to support ip prefix in path element ---- ./github.com/jipanyang/gnxi/utils/xpath/xpath.go -+++ ./github.com/jipanyang/gnxi/utils/xpath/xpath.go -@@ -88,11 +88,15 @@ - for end < len(str) { - switch str[end] { - case '/': -- if !insideBrackets { -+ if end != 0 && str[end-1] == '\\' { -+ // Ignore escaped '/' -+ end++ -+ } else if !insideBrackets { - // Current '/' is a valid path element - // separator. - if end > begin { -- path = append(path, str[begin:end]) -+ val := strings.Replace(str[begin:end], `\/`, `/`, -1) -+ path = append(path, val) - } - end++ - begin = end +Use escaped '/' to support ip prefix in path element +--- ./github.com/google/gnxi/utils/xpath/xpath.go ++++ ./github.com/google/gnxi/utils/xpath/xpath.go +@@ -88,11 +88,15 @@ + for end < len(str) { + switch str[end] { + case '/': +- if !insideBrackets { ++ if end != 0 && str[end-1] == '\\' { ++ // Ignore escaped '/' ++ end++ ++ } else if !insideBrackets { + // Current '/' is a valid path element + // separator. + if end > begin { +- path = append(path, str[begin:end]) ++ val := strings.Replace(str[begin:end], `\/`, `/`, -1) ++ path = append(path, val) + } + end++ + begin = end +@@ -211,7 +215,7 @@ + i := strings.Index(elem, "[") + if i < 0 { + if !idRe.MatchString(elem) { +- return nil, fmt.Errorf("invalid node name: %q", elem) ++ //return nil, fmt.Errorf("invalid node name: %q", elem) + } + return []interface{}{elem}, nil + } diff --git a/sonic_data_client/client_test.go b/sonic_data_client/client_test.go index 55cadaf4..29317585 100644 --- a/sonic_data_client/client_test.go +++ b/sonic_data_client/client_test.go @@ -13,7 +13,7 @@ import ( "github.com/Workiva/go-datastructures/queue" "github.com/agiledragon/gomonkey/v2" - "github.com/jipanyang/gnxi/utils/xpath" + "github.com/google/gnxi/utils/xpath" "github.com/sonic-net/sonic-gnmi/swsscommon" "github.com/sonic-net/sonic-gnmi/test_utils" gnmipb "github.com/openconfig/gnmi/proto/gnmi"