Skip to content

Commit

Permalink
Implemented Entity clone in Go (enh. CiscoDevNet#967)
Browse files Browse the repository at this point in the history
  • Loading branch information
ygorelik committed Nov 19, 2019
1 parent 256f3d0 commit 9111b22
Show file tree
Hide file tree
Showing 8 changed files with 589 additions and 444 deletions.
2 changes: 1 addition & 1 deletion sdk/cpp/gnmi/samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ set(samples
bgp_gnmi_service
bgp_gnmi_subscribe
# gnmi_ifc_read
# xr_int_oper_gnmi_subscribe
xr_int_oper_gnmi_subscribe
)

# set default build type if not specified by user
Expand Down
12 changes: 6 additions & 6 deletions sdk/cpp/gnmi/tests/test_gnmi_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ void read_sub(const char * subscribe_response)

void gnmi_service_subscribe_callback(const char * subscribe_response)
{
//read_sub(subscribe_response);
string response = subscribe_response;
REQUIRE(response.find(int_update) != string::npos);
//read_sub(subscribe_response);
string response = subscribe_response;
REQUIRE(response.find(int_update) != string::npos);
}

void gnmi_service_subscribe_multiples_callback(const char * subscribe_response)
{
//read_sub(subscribe_response);
string response = subscribe_response;
REQUIRE(response.find(int_update) != string::npos);
//read_sub(subscribe_response);
string response = subscribe_response;
REQUIRE(response.find(int_update) != string::npos);
REQUIRE(response.find(bgp_update) != string::npos);
}

Expand Down
22 changes: 17 additions & 5 deletions sdk/go/core/tests/service_codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ func (suite *CodecTestSuite) TestXMLEncodeDecodeMultiple() {

config := types.NewConfig(&runnerConfig, &nativeConfig)

suite.Provider.Encoding = encoding.XML
suite.Provider.Encoding = encoding.XML
payload := suite.Codec.Encode(&suite.Provider, &config)

entity := suite.Codec.Decode(&suite.Provider, payload)
Expand All @@ -483,7 +483,7 @@ func (suite *CodecTestSuite) TestPassiveInterfaceCodec() {
runner.One.Ospf = append(runner.One.Ospf, &ospf)
suite.Provider.Encoding = encoding.XML
payload := suite.Codec.Encode(&suite.Provider, &runner)
suite.Equal(payload,
suite.Equal(payload,
`<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">
<one>
<ospf xmlns="http://cisco.com/ns/yang/ydktest-sanity-augm">
Expand Down Expand Up @@ -531,7 +531,7 @@ func (suite *CodecTestSuite) TestOneKeyList() {
suite.NotNil(entity)
ydk.YLogDebug(fmt.Sprintf("For key: %v, Found Entity: %v", key, types.EntityToString(entity)))
}

// Remove element from the ylist
i, rdata := ylist.Get(runner.TwoList.Ldata, 22)
suite.Equal(i, 1)
Expand Down Expand Up @@ -559,6 +559,17 @@ func (suite *CodecTestSuite) TestListNoKeys() {
suite.Equal(types.EntityEqual(&runner, runnerDecode), true)
}

func (suite *CodecTestSuite) TestLeafList() {
runner := ysanity.Runner{}
runner.Ytypes.BuiltInT.EnumLlist = append(runner.Ytypes.BuiltInT.EnumLlist, ysanity.YdkEnumTest_local)
runner.Ytypes.BuiltInT.EnumLlist = append(runner.Ytypes.BuiltInT.EnumLlist, ysanity.YdkEnumTest_remote)

payload := suite.Codec.Encode(&suite.Provider, &runner)
fmt.Printf("%s\n", payload)
runnerDecode := suite.Codec.Decode(&suite.Provider, payload)
suite.True(types.EntityEqual(&runner, runnerDecode))
}

func (suite *CodecTestSuite) TestNative() {
// Build loopback configuration
address := ysanity.Native_Interface_Loopback_Ipv4_Address{}
Expand All @@ -571,12 +582,13 @@ func (suite *CodecTestSuite) TestNative() {

native := ysanity.Native{}
native.Interface.Loopback = append(native.Interface.Loopback, &loopback)

suite.Provider.Encoding = encoding.JSON
payload := suite.Codec.Encode(&suite.Provider, &native)
fmt.Printf("%s\n", payload)
runnerDecode := suite.Codec.Decode(&suite.Provider, payload)
suite.Equal(types.EntityEqual(&native, runnerDecode), true)}
suite.Equal(types.EntityEqual(&native, runnerDecode), true)
}

func TestCodecTestSuite(t *testing.T) {
if testing.Verbose() {
Expand Down
Loading

0 comments on commit 9111b22

Please sign in to comment.