diff --git a/gnmi_server/server_test.go b/gnmi_server/server_test.go index 40a90abc..c0b00003 100644 --- a/gnmi_server/server_test.go +++ b/gnmi_server/server_test.go @@ -58,8 +58,8 @@ import ( "github.com/jipanyang/gnxi/utils/xpath" cacheclient "github.com/openconfig/gnmi/client" gnmipb "github.com/openconfig/gnmi/proto/gnmi" - gnoi_system_pb "github.com/openconfig/gnoi/system" gnoi_file_pb "github.com/openconfig/gnoi/file" + gnoi_system_pb "github.com/openconfig/gnoi/system" "github.com/sonic-net/sonic-gnmi/common_utils" "github.com/sonic-net/sonic-gnmi/swsscommon" ) @@ -917,7 +917,6 @@ func mergeStrMaps(sourceOrigin interface{}, updateOrigin interface{}) interface{ return update } -/* func TestGnmiSet(t *testing.T) { if !ENABLE_TRANSLIB_WRITE { t.Skip("skipping test in read-only mode.") @@ -959,14 +958,14 @@ func TestGnmiSet(t *testing.T) { wantRetCode: codes.Unknown, operation: Delete, }, - //{ - // desc: "Set OC Interface MTU", - // pathTarget: "OC_YANG", - // textPbPath: pathToPb("openconfig-interfaces:interfaces/interface[name=Ethernet4]/config"), - // attributeData: "../testdata/set_interface_mtu.json", - // wantRetCode: codes.OK, - // operation: Update, - //}, + { + desc: "Set OC Interface MTU", + pathTarget: "OC_YANG", + textPbPath: pathToPb("openconfig-interfaces:interfaces/interface[name=Ethernet4]/config"), + attributeData: "../testdata/set_interface_mtu.json", + wantRetCode: codes.OK, + operation: Update, + }, { desc: "Set OC Interface IP", pathTarget: "OC_YANG", @@ -1076,7 +1075,7 @@ func TestGnmiSet(t *testing.T) { } } s.Stop() -}*/ +} func TestGnmiSetReadOnly(t *testing.T) { s := createReadServer(t, 8081) @@ -1503,8 +1502,6 @@ func TestGnmiGetMultiNs(t *testing.T) { s.Stop() } - -/* func TestGnmiGetTranslib(t *testing.T) { //t.Log("Start server") s := createServer(t, 8081) @@ -1524,14 +1521,13 @@ func TestGnmiGetTranslib(t *testing.T) { defer conn.Close() gClient := pb.NewGNMIClient(conn) - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) - defer cancel() var emptyRespVal interface{} tds := []struct { desc string pathTarget string textPbPath string + timeout time.Duration wantRetCode codes.Code wantRespVal interface{} valTest bool @@ -1594,6 +1590,7 @@ func TestGnmiGetTranslib(t *testing.T) { textPbPath: ` elem: `, + timeout: 1 * time.Minute, wantRetCode: codes.OK, wantRespVal: emptyRespVal, valTest: false, @@ -1642,11 +1639,17 @@ func TestGnmiGetTranslib(t *testing.T) { for _, td := range tds { t.Run(td.desc, func(t *testing.T) { + if td.timeout == 0 { + td.timeout = 10 * time.Second + } + ctx, cancel := context.WithTimeout(context.Background(), td.timeout) + defer cancel() + runTestGet(t, ctx, gClient, td.pathTarget, td.textPbPath, td.wantRetCode, td.wantRespVal, td.valTest) }) } s.Stop() -}*/ +} type tablePathValue struct { dbName string @@ -3031,7 +3034,6 @@ func TestBundleVersion(t *testing.T) { }) } -/* func TestBulkSet(t *testing.T) { s := createServer(t, 8088) go runServer(t, s) @@ -3120,7 +3122,7 @@ func TestBulkSet(t *testing.T) { runTestSetRaw(t, ctx, gClient, req, codes.Unknown) }) -}*/ +} func newPbUpdate(path, value string) *pb.Update { p, _ := ygot.StringToStructuredPath(path) @@ -4244,7 +4246,6 @@ func TestParseOrigin(t *testing.T) { } } -/* func TestMasterArbitration(t *testing.T) { s := createServer(t, 8088) // Turn on Master Arbitration @@ -4436,7 +4437,7 @@ func TestMasterArbitration(t *testing.T) { t.Fatalf("Master EID update failed. Want %v, got %v", expectedEID10, s.masterEID) } }) -}*/ +} func TestSaveOnSet(t *testing.T) { // Fail client creation diff --git a/testdata/db_dump.json b/testdata/db_dump.json index f0c26f35..7e2ef712 100644 --- a/testdata/db_dump.json +++ b/testdata/db_dump.json @@ -5397,52 +5397,52 @@ "SAI_API_MCAST_FDB:SAI_API_MCAST_FDB":{"LOGLEVEL":"SAI_LOG_LEVEL_NOTICE","LOGOUTPUT":"SYSLOG"}, "SAI_API_SCHEDULER:SAI_API_SCHEDULER":{"LOGLEVEL":"SAI_LOG_LEVEL_NOTICE","LOGOUTPUT":"SYSLOG"}, "SAI_API_ACL:SAI_API_ACL":{"LOGLEVEL":"SAI_LOG_LEVEL_NOTICE","LOGOUTPUT":"SYSLOG"}},{ -"PORT|Ethernet92":{"index":"24","lanes":"25,26,27,28","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/24","admin_status":"down","speed":"100000"}, -"PORT|Ethernet68":{"index":"18","lanes":"101,102,103,104","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/18","admin_status":"down","speed":"100000"}, -"PORT|Ethernet40":{"index":"11","lanes":"45,46,47,48","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/11","admin_status":"down","speed":"100000"}, +"PORT|Ethernet92":{"index":"24","lanes":"25,26,27,28","mtu":"9100","alias":"hundredGigE1/24","admin_status":"down","speed":"100000"}, +"PORT|Ethernet68":{"index":"18","lanes":"101,102,103,104","mtu":"9100","alias":"hundredGigE1/18","admin_status":"down","speed":"100000"}, +"PORT|Ethernet40":{"index":"11","lanes":"45,46,47,48","mtu":"9100","alias":"hundredGigE1/11","admin_status":"down","speed":"100000"}, "CONFIG_DB_UPDATED":"1", "MGMT_PORT|eth0":{"admin_status":"up","speed":"1000","description":"Management0","autoneg":"true","mtu":"1500"}, -"PORT|Ethernet32":{"index":"9","lanes":"37,38,39,40","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/9","admin_status":"down","speed":"100000"}, -"PORT|Ethernet116":{"index":"30","lanes":"1,2,3,4","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/30","admin_status":"down","speed":"100000"}, -"PORT|Ethernet72":{"index":"19","lanes":"105,106,107,108","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/19","admin_status":"down","speed":"100000"}, -"PORT|Ethernet76":{"index":"20","lanes":"109,110,111,112","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/20","admin_status":"down","speed":"100000"}, +"PORT|Ethernet32":{"index":"9","lanes":"37,38,39,40","mtu":"9100","alias":"hundredGigE1/9","admin_status":"down","speed":"100000"}, +"PORT|Ethernet116":{"index":"30","lanes":"1,2,3,4","mtu":"9100","alias":"hundredGigE1/30","admin_status":"down","speed":"100000"}, +"PORT|Ethernet72":{"index":"19","lanes":"105,106,107,108","mtu":"9100","alias":"hundredGigE1/19","admin_status":"down","speed":"100000"}, +"PORT|Ethernet76":{"index":"20","lanes":"109,110,111,112","mtu":"9100","alias":"hundredGigE1/20","admin_status":"down","speed":"100000"}, "PTP_INSTANCE|GLOBAL":{"NULL":"NULL"}, "PTP_CLOCK|GLOBAL":{"domain-number":"1","two-step-flag":"1","slave-only":"0","priority1":"128","priority2":"128","network-transport":"L2","clock-type":"disable","domain-profile":"ieee1588","unicast-multicast":"multicast","udp6-scope":"0x0e"}, -"PORT|Ethernet112":{"index":"29","lanes":"5,6,7,8","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/29","admin_status":"down","speed":"100000"}, -"PORT|Ethernet52":{"index":"14","lanes":"85,86,87,88","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/14","admin_status":"down","speed":"100000"}, -"PORT|Ethernet44":{"index":"12","lanes":"41,42,43,44","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/12","admin_status":"down","speed":"100000"}, -"PORT|Ethernet0":{"index":"1","lanes":"49,50,51,52","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/1","admin_status":"down","speed":"100000"}, -"PORT|Ethernet80":{"index":"21","lanes":"21,22,23,24","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/21","admin_status":"down","speed":"100000"}, -"PORT|Ethernet4":{"index":"2","lanes":"53,54,55,56","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/2","admin_status":"down","speed":"100000"}, -"PORT|Ethernet120":{"index":"31","lanes":"13,14,15,16","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/31","admin_status":"down","speed":"100000"}, -"PORT|Ethernet108":{"index":"28","lanes":"121,122,123,124","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/28","admin_status":"down","speed":"100000"}, +"PORT|Ethernet112":{"index":"29","lanes":"5,6,7,8","mtu":"9100","alias":"hundredGigE1/29","admin_status":"down","speed":"100000"}, +"PORT|Ethernet52":{"index":"14","lanes":"85,86,87,88","mtu":"9100","alias":"hundredGigE1/14","admin_status":"down","speed":"100000"}, +"PORT|Ethernet44":{"index":"12","lanes":"41,42,43,44","mtu":"9100","alias":"hundredGigE1/12","admin_status":"down","speed":"100000"}, +"PORT|Ethernet0":{"index":"1","lanes":"49,50,51,52","mtu":"9100","alias":"hundredGigE1/1","admin_status":"down","speed":"100000"}, +"PORT|Ethernet80":{"index":"21","lanes":"21,22,23,24","mtu":"9100","alias":"hundredGigE1/21","admin_status":"down","speed":"100000"}, +"PORT|Ethernet4":{"index":"2","lanes":"53,54,55,56","mtu":"9100","alias":"hundredGigE1/2","admin_status":"down","speed":"100000"}, +"PORT|Ethernet120":{"index":"31","lanes":"13,14,15,16","mtu":"9100","alias":"hundredGigE1/31","admin_status":"down","speed":"100000"}, +"PORT|Ethernet108":{"index":"28","lanes":"121,122,123,124","mtu":"9100","alias":"hundredGigE1/28","admin_status":"down","speed":"100000"}, "CONFIG_DB_INITIALIZED":"1", -"PORT|Ethernet12":{"index":"4","lanes":"61,62,63,64","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/4","admin_status":"down","speed":"100000"}, -"PORT|Ethernet60":{"index":"16","lanes":"93,94,95,96","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/16","admin_status":"down","speed":"100000"}, -"PORT|Ethernet36":{"index":"10","lanes":"33,34,35,36","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/10","admin_status":"down","speed":"100000"}, -"PORT|Ethernet8":{"index":"3","lanes":"57,58,59,60","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/3","admin_status":"down","speed":"100000"}, +"PORT|Ethernet12":{"index":"4","lanes":"61,62,63,64","mtu":"9100","alias":"hundredGigE1/4","admin_status":"down","speed":"100000"}, +"PORT|Ethernet60":{"index":"16","lanes":"93,94,95,96","mtu":"9100","alias":"hundredGigE1/16","admin_status":"down","speed":"100000"}, +"PORT|Ethernet36":{"index":"10","lanes":"33,34,35,36","mtu":"9100","alias":"hundredGigE1/10","admin_status":"down","speed":"100000"}, +"PORT|Ethernet8":{"index":"3","lanes":"57,58,59,60","mtu":"9100","alias":"hundredGigE1/3","admin_status":"down","speed":"100000"}, "HARDWARE|ACCESS_LIST":{"TCAM_SHARING@":"","COUNTER_MODE":"per-rule","LOOKUP_MODE":"advanced"}, -"PORT|Ethernet16":{"index":"5","lanes":"65,66,67,68","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/5","admin_status":"down","speed":"100000"}, -"PORT|Ethernet28":{"index":"8","lanes":"77,78,79,80","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/8","admin_status":"down","speed":"100000"}, +"PORT|Ethernet16":{"index":"5","lanes":"65,66,67,68","mtu":"9100","alias":"hundredGigE1/5","admin_status":"down","speed":"100000"}, +"PORT|Ethernet28":{"index":"8","lanes":"77,78,79,80","mtu":"9100","alias":"hundredGigE1/8","admin_status":"down","speed":"100000"}, "DEVICE_METADATA|localhost":{"platform":"x86_64-dell_z9100_c2538-r0","mac":"4c:76:25:e5:1f:40","hwsku":"Force10-Z9100-C32","type":"LeafRouter","hostname":"sonic"}, -"PORT|Ethernet48":{"index":"13","lanes":"81,82,83,84","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/13","admin_status":"down","speed":"100000"}, -"PORT|Ethernet100":{"index":"26","lanes":"113,114,115,116","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/26","admin_status":"down","speed":"100000"}, +"PORT|Ethernet48":{"index":"13","lanes":"81,82,83,84","mtu":"9100","alias":"hundredGigE1/13","admin_status":"down","speed":"100000"}, +"PORT|Ethernet100":{"index":"26","lanes":"113,114,115,116","mtu":"9100","alias":"hundredGigE1/26","admin_status":"down","speed":"100000"}, "FLEX_COUNTER_TABLE|PFCWD":{"FLEX_COUNTER_STATUS":"enable"}, -"PORT|Ethernet20":{"index":"6","lanes":"69,70,71,72","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/6","admin_status":"down","speed":"100000"}, -"PORT|Ethernet88":{"index":"23","lanes":"29,30,31,32","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/23","admin_status":"down","speed":"100000"}, -"PORT|Ethernet84":{"index":"22","lanes":"17,18,19,20","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/22","admin_status":"down","speed":"100000"}, +"PORT|Ethernet20":{"index":"6","lanes":"69,70,71,72","mtu":"9100","alias":"hundredGigE1/6","admin_status":"down","speed":"100000"}, +"PORT|Ethernet88":{"index":"23","lanes":"29,30,31,32","mtu":"9100","alias":"hundredGigE1/23","admin_status":"down","speed":"100000"}, +"PORT|Ethernet84":{"index":"22","lanes":"17,18,19,20","mtu":"9100","alias":"hundredGigE1/22","admin_status":"down","speed":"100000"}, "FLEX_COUNTER_TABLE|QUEUE":{"FLEX_COUNTER_STATUS":"enable"}, "FLEX_COUNTER_TABLE|PORT":{"FLEX_COUNTER_STATUS":"enable"}, "CONFIG_DB_UPDATED_PORT":"1", -"PORT|Ethernet56":{"index":"15","lanes":"89,90,91,92","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/15","admin_status":"down","speed":"100000"}, +"PORT|Ethernet56":{"index":"15","lanes":"89,90,91,92","mtu":"9100","alias":"hundredGigE1/15","admin_status":"down","speed":"100000"}, "FLEX_COUNTER_TABLE|PG_WATERMARK":{"FLEX_COUNTER_STATUS":"enable"}, "FLEX_COUNTER_TABLE|QUEUE_WATERMARK":{"FLEX_COUNTER_STATUS":"enable"}, "SWITCH|switch":{"fdb_aging_time":"600"}, -"PORT|Ethernet96":{"index":"25","lanes":"117,118,119,120","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/25","admin_status":"down","speed":"100000"}, -"PORT|Ethernet24":{"index":"7","lanes":"73,74,75,76","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/7","admin_status":"down","speed":"100000"}, -"PORT|Ethernet64":{"index":"17","lanes":"97,98,99,100","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/17","admin_status":"down","speed":"100000"}, -"PORT|Ethernet104":{"index":"27","lanes":"125,126,127,128","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/27","admin_status":"down","speed":"100000"}, -"PORT|Ethernet124":{"index":"32","lanes":"9,10,11,12","valid_speeds":"100000,40000","mtu":"9100","alias":"hundredGigE1/32","admin_status":"down","speed":"100000"}},{ +"PORT|Ethernet96":{"index":"25","lanes":"117,118,119,120","mtu":"9100","alias":"hundredGigE1/25","admin_status":"down","speed":"100000"}, +"PORT|Ethernet24":{"index":"7","lanes":"73,74,75,76","mtu":"9100","alias":"hundredGigE1/7","admin_status":"down","speed":"100000"}, +"PORT|Ethernet64":{"index":"17","lanes":"97,98,99,100","mtu":"9100","alias":"hundredGigE1/17","admin_status":"down","speed":"100000"}, +"PORT|Ethernet104":{"index":"27","lanes":"125,126,127,128","mtu":"9100","alias":"hundredGigE1/27","admin_status":"down","speed":"100000"}, +"PORT|Ethernet124":{"index":"32","lanes":"9,10,11,12","mtu":"9100","alias":"hundredGigE1/32","admin_status":"down","speed":"100000"}},{ "FLEX_COUNTER_TABLE:QUEUE_WATERMARK_STAT_COUNTER:oid:0x15000000000289":{"QUEUE_COUNTER_ID_LIST":"SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES"}, "FLEX_COUNTER_TABLE:QUEUE_WATERMARK_STAT_COUNTER:oid:0x15000000000204":{"QUEUE_COUNTER_ID_LIST":"SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES"}, "FLEX_COUNTER_TABLE:QUEUE_STAT_COUNTER:oid:0x150000000002b5":{"QUEUE_COUNTER_ID_LIST":"SAI_QUEUE_STAT_PACKETS,SAI_QUEUE_STAT_BYTES,SAI_QUEUE_STAT_DROPPED_PACKETS,SAI_QUEUE_STAT_DROPPED_BYTES"},