Updates to the affinity router test framework as
well as bug fixes to the affinity router found by
the test framework.
Change-Id: I90e6baa9e9ee11bd8034498b8651e9e14512e528
diff --git a/tests/afrouter/suites/main.json b/tests/afrouter/suites/main.json
index a1bc09c..594bc8a 100644
--- a/tests/afrouter/suites/main.json
+++ b/tests/afrouter/suites/main.json
@@ -2,6 +2,7 @@
"__COMMENT":"Top level test driver file",
"suites": [
"test1",
- "test2"
-]
+ "test2",
+ "test3"
+ ]
}
diff --git a/tests/afrouter/suites/test1.json b/tests/afrouter/suites/test1.json
index 9e749ac..77cc0ec 100644
--- a/tests/afrouter/suites/test1.json
+++ b/tests/afrouter/suites/test1.json
@@ -1,16 +1,26 @@
{
"environment":{
- "cmdLine":"afrouter -config arouter_test.json",
+ "cmdLine":"afrouter -logLevel 1 -config arouter_test.json",
"protoFiles": [
{
"importPath":"github.com/opencord/voltha-go/protos/",
"service":"VolthaService",
"package":"voltha"
+ },
+ {
+ "importPath":"github.com/opencord/voltha-go/protos/",
+ "service":"Configuration",
+ "package":"afrouter"
+ }
+ ],
+ "Junk": [
+ {
+ "importPath":"github.com/opencord/voltha-go/protos/",
+ "service":"Configuration",
+ "package":"afrouter"
}
],
"imports": [
- "github.com/golang/protobuf/ptypes/empty",
- "github.com/opencord/voltha-go/protos/openflow_13"
],
"protoDesc":"voltha.pb",
"protoSubst": [
@@ -19,13 +29,28 @@
"to":"empty.Empty"
}
],
- "clients": [
- {
- "name":"client",
- "port":"5000"
- }
- ],
- "servers": [
+ "clients": {
+ "imports": [
+ "github.com/golang/protobuf/ptypes/empty",
+ "github.com/opencord/voltha-go/protos/openflow_13"
+ ],
+ "endpoints": [
+ {
+ "name":"client",
+ "port":"5000"
+ },
+ {
+ "name":"stats",
+ "port":"55554"
+ }
+ ]
+ },
+ "servers": {
+ "imports": [
+ "github.com/golang/protobuf/ptypes/empty",
+ "github.com/opencord/voltha-go/protos/openflow_13"
+ ],
+ "endpoints": [
{
"name":"core11",
"port":"5011"
@@ -49,8 +74,21 @@
{
"name":"core32",
"port":"5032"
+ },
+ {
+ "name":"roCore1",
+ "port":"5001"
+ },
+ {
+ "name":"roCore2",
+ "port":"5002"
+ },
+ {
+ "name":"roCore3",
+ "port":"5003"
}
- ]
+ ]
+ }
},
"tests":[
{
@@ -150,6 +188,19 @@
]
}
]
+ },
+ {
+ "name":"Get goroutine count",
+ "infoOnly":true,
+ "send": {
+ "client":"stats",
+ "method":"GetGoroutineCount",
+ "param":"{}",
+ "meta": [ ],
+ "expect":"{Count:39}",
+ "expectMeta": [ ]
+ },
+ "servers": [ ]
}
]
}
diff --git a/tests/afrouter/suites/test2.go b/tests/afrouter/suites/test2.go
index fc0332e..80e3af3 100644
--- a/tests/afrouter/suites/test2.go
+++ b/tests/afrouter/suites/test2.go
@@ -33,28 +33,37 @@
//pb "github.com/golang/protobuf/protoc-gen-go/descriptor"
)
+type suite struct {
+ CrTests []test
+ GetTests[]test
+}
+
type test struct {
Core int
+ SerNo int
}
+const SUITE_LEN = 55000
+//const SUITE_LEN = 100
+
func main() {
- var ary []test
+ var ary suite
// Setup logging
if _, err := log.SetDefaultLogger(log.JSON, 0, nil); err != nil {
log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
}
- for i :=0; i<10000; i++ {
-
- ary = append(ary,test{Core:(i%3)+1})
+ for i :=0; i<SUITE_LEN; i++ {
+
+ ary.CrTests = append(ary.CrTests,test{Core:(i%3)+1, SerNo:i})
+ ary.GetTests = append(ary.GetTests,test{Core:(i%3)+1, SerNo:i+SUITE_LEN})
}
// Load the template to execute
t := template.Must(template.New("").ParseFiles("./test2.tmpl.json"))
if f,err := os.Create("test2.json"); err == nil {
- _=f
defer f.Close()
if err := t.ExecuteTemplate(f, "test2.tmpl.json", ary); err != nil {
log.Errorf("Unable to execute template for test2.tmpl.json: %v", err)
diff --git a/tests/afrouter/suites/test2.tmpl.json b/tests/afrouter/suites/test2.tmpl.json
index fc8ef1c..c8d040e 100644
--- a/tests/afrouter/suites/test2.tmpl.json
+++ b/tests/afrouter/suites/test2.tmpl.json
@@ -1,16 +1,20 @@
{
"environment":{
- "cmdLine":"afrouter -config arouter_test.json -grpclog",
+ "cmdLine":"afrouter -config arouter_test.json -logLevel 1",
"protoFiles": [
{
"importPath":"github.com/opencord/voltha-go/protos/",
"service":"VolthaService",
"package":"voltha"
+ },
+ {
+ "importPath":"github.com/opencord/voltha-go/protos/",
+ "service":"Configuration",
+ "package":"afrouter"
}
],
"imports": [
- "github.com/golang/protobuf/ptypes/empty",
- "github.com/opencord/voltha-go/protos/openflow_13"
+ "github.com/golang/protobuf/ptypes/empty"
],
"protoDesc":"voltha.pb",
"protoSubst": [
@@ -19,13 +23,28 @@
"to":"empty.Empty"
}
],
- "clients": [
- {
- "name":"client",
- "port":"5000"
- }
- ],
- "servers": [
+ "clients": {
+ "imports": [
+ "github.com/golang/protobuf/ptypes/empty",
+ "github.com/opencord/voltha-go/protos/openflow_13"
+ ],
+ "endpoints": [
+ {
+ "name":"client",
+ "port":"5000"
+ },
+ {
+ "name":"stats",
+ "port":"55554"
+ }
+ ]
+ },
+ "servers": {
+ "imports": [
+ "github.com/golang/protobuf/ptypes/empty",
+ "github.com/opencord/voltha-go/protos/openflow_13"
+ ],
+ "endpoints": [
{
"name":"core11",
"port":"5011"
@@ -50,10 +69,11 @@
"name":"core32",
"port":"5032"
}
- ]
+ ]
+ }
},
"tests":[
- {{range $k,$v := .}}
+ {{range $k,$v := .CrTests}}
{
"name":"Test CreateDevice",
"send": {
@@ -69,7 +89,7 @@
"meta": [
{
"key":"voltha_serial_number",
- "value":"{{$k}}"
+ "value":"{{$v.SerNo}}"
}
]
},
@@ -78,7 +98,41 @@
"meta": [
{
"key":"voltha_serial_number",
- "value":"{{$k}}"
+ "value":"{{$v.SerNo}}"
+ }
+ ]
+ }
+ ]
+ },
+ {{end}}
+ {{range $k,$v := .GetTests}}
+ {
+ "name":"Test EnableDevice",
+ "send": {
+ "client":"client",
+ "_method":"GetDevice",
+ "method":"EnableDevice",
+ "param":"{Id:\"abcd1234{{$k}}\"}",
+ "expect":"{}",
+ "_expect":"{Id:\"abcd1234{{$k}}\",Type:\"simulated_olt\"}",
+ "_meta":""
+ },
+ "servers": [
+ {
+ "name":"core{{$v.Core}}1",
+ "meta": [
+ {
+ "key":"voltha_serial_number",
+ "value":"{{$v.SerNo}}"
+ }
+ ]
+ },
+ {
+ "name":"core{{$v.Core}}2",
+ "meta": [
+ {
+ "key":"voltha_serial_number",
+ "value":"{{$v.SerNo}}"
}
]
}
@@ -100,7 +154,7 @@
"meta": [
{
"key":"voltha_serial_number",
- "value":"10000"
+ "value":"110000"
}
]
},
@@ -109,7 +163,7 @@
"meta": [
{
"key":"voltha_serial_number",
- "value":"10000"
+ "value":"110000"
}
]
}
@@ -141,7 +195,7 @@
"meta": [
{
"key":"voltha_serial_number",
- "value":"10001"
+ "value":"110001"
},
{
"key":"voltha_backend_name",
@@ -150,6 +204,19 @@
]
}
]
+ },
+ {
+ "_COMMENT":"If this test case fails, there could be a goroutine leak",
+ "name":"Get goroutine count",
+ "send": {
+ "client":"stats",
+ "method":"GetGoroutineCount",
+ "param":"{}",
+ "meta": [ ],
+ "expect":"{Count:39}",
+ "expectMeta": [ ]
+ },
+ "servers": [ ]
}
]
}
diff --git a/tests/afrouter/suites/test3.go b/tests/afrouter/suites/test3.go
new file mode 100644
index 0000000..88b4382
--- /dev/null
+++ b/tests/afrouter/suites/test3.go
@@ -0,0 +1,418 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "os"
+ "fmt"
+ //"flag"
+ //"path"
+ //"bufio"
+ "errors"
+ //"os/exec"
+ //"strconv"
+ "io/ioutil"
+ //"encoding/json"
+ "text/template"
+ //"github.com/golang/protobuf/proto"
+ "github.com/opencord/voltha-go/common/log"
+ //pb "github.com/golang/protobuf/protoc-gen-go/descriptor"
+)
+
+// This test suite validates that the different method types get routed
+// properly. That is, rw methods to the rw cores and ro methods to the
+// ro cores
+type test struct {
+ Name string
+ Core int
+ SerNo int
+ Method string
+ Param string
+ Expect string
+}
+
+type tests struct {
+ RoTests []test
+ RwTests []test
+ CtlTests []test
+}
+
+var roMethods []test = []test{
+ {
+ Name: "Test GetVoltha",
+ Method: "GetVoltha", // rpc GetVoltha(google.protobuf.Empty) returns(Voltha)
+ Param: "{}",
+ Expect:`{Version:\"abcdef\"}`,
+ },
+ /*
+ {
+ Name: "Test ListCoreInstances",
+ Method: "ListCoreInstances", // rpc ListCoreInstances(google.protobuf.Empty) returns(CoreInstances)
+ Param: "{}",
+ Expect: `{Items:[]*voltha.CoreInstance{&voltha.CoreInstance{InstanceId:\"ABC\",Health:&voltha.HealthStatus{State:0}}}}`,
+ },
+ {
+ Name: "Test GetCoreInstance",
+ Method: "GetCoreInstance", // rpc GetCoreInstance(ID) returns(CoreInstance)
+ Param: `{Id:\"arou8390\"}`,
+ Expect: `{InstanceId:\"arou8390\", Health:&voltha.HealthStatus{State:0}}`,
+ },*/
+ {
+ Name: "Test ListAdapters",
+ Method: "ListAdapters", // rpc ListAdapters(google.protobuf.Empty) returns(Adapters)
+ Param: "{}",
+ Expect: `{Items:[]*voltha.Adapter{&voltha.Adapter{Id:\"ABC\", Vendor:\"afrouterTest\", Version:\"Version 1.0\"}}}`,
+ },
+ {
+ Name: "Test ListLogicalDevices",
+ Method: "ListLogicalDevices", // rpc ListLogicalDevices(google.protobuf.Empty) returns(LogicalDevices)
+ Param: "{}",
+ Expect:`{Items:[]*voltha.LogicalDevice{&voltha.LogicalDevice{Id:\"LDevId\", DatapathId:64, RootDeviceId:\"Root\"}}}`,
+ },
+ {
+ Name: "Test GetLogicalDevice",
+ Method: "GetLogicalDevice", // rpc GetLogicalDevice(ID) returns(LogicalDevice)
+ Param: `{Id:\"ABC123XYZ\"}`,
+ Expect:`{Id:\"ABC123XYZ\", DatapathId:64, RootDeviceId:\"Root-of:ABC123XYZ\"}`,
+ },
+ {
+ Name: "Test ListLogicalDevicePorts",
+ Method: "ListLogicalDevicePorts", // rpc ListLogicalDevicePorts(ID) returns(LogicalPorts)
+ Param: `{Id:\"ABC123XYZ\"}`,
+ Expect:`{Items:[]*voltha.LogicalPort{&voltha.LogicalPort{Id:\"PortId-1\", DeviceId:\"ABC12XYZ\", DevicePortNo:64, RootPort:true},&voltha.LogicalPort{Id:\"PortId-2\", DeviceId:\"ABC12XYZ\", DevicePortNo:64, RootPort:false}}}`,
+ },
+ {
+ Name: "Test GetLogicalDevicePort",
+ Method: "GetLogicalDevicePort", // rpc GetLogicalDevicePort(LogicalPortId) returns(LogicalPort)
+ Param: `{Id:\"PortId-1\"}`,
+ Expect:`{Id:\"PortId-1\", DeviceId:\"ABC12XYZ\", DevicePortNo:64, RootPort:true}`,
+ },
+ {
+ Name: "Test ListLogicalDeviceFlows",
+ Method: "ListLogicalDeviceFlows", // rpc ListLogicalDeviceFlows(ID) returns(openflow_13.Flows)
+ Param: `{Id:\"Flow-ABC123XYZ\"}`,
+ Expect:`{Items:[]*openflow_13.OfpFlowStats{&openflow_13.OfpFlowStats{Id:1, TableId:2, DurationSec:12, Priority:0},&openflow_13.OfpFlowStats{Id:1, TableId:2, DurationSec:12, Priority:0}}}`,
+ },
+ {
+ Name: "Test ListLogicalDeviceFlowGroups",
+ Method: "ListLogicalDeviceFlowGroups", // rpc ListLogicalDeviceFlowGroups(ID) returns(openflow_13.FlowGroups)
+ Param: `{Id:\"Flow-ABC123XYZ\"}`,
+ Expect:`{Items:[]*openflow_13.OfpGroupEntry{&openflow_13.OfpGroupEntry{Desc:&openflow_13.OfpGroupDesc{GroupId:12}, Stats:&openflow_13.OfpGroupStats{GroupId:1, RefCount:1, PacketCount:3}}}}`,
+ },
+ {
+ Name: "Test ListDevices",
+ Method: "ListDevices", // rpc ListDevices(google.protobuf.Empty) returns(Devices)
+ Param: `{}`,
+ Expect:`{Items:[]*voltha.Device{&voltha.Device{Id:\"ABC123XYZ\", Type:\"SomeDeviceType\", Root:false, ParentId:\"ZYX321CBA\"},&voltha.Device{Id:\"ZYX321CBA\", Type:\"SomeDeviceType\", Root:true, ParentId:\"ROOT\"}}}`,
+ },
+ {
+ Name: "Test ListDeviceIds",
+ Method: "ListDeviceIds", // rpc ListDeviceIds(google.protobuf.Empty) returns(IDs)
+ Param: `{}`,
+ Expect:`{Items:[]*voltha.ID{&voltha.ID{Id:\"ABC123XYZ\"},&voltha.ID{Id:\"ZYX321CBA\"}}}`,
+ },
+ {
+ Name: "Test GetDevice",
+ Method: "GetDevice", // rpc GetDevice(ID) returns(Device)
+ Param: `{Id:\"ZYX321CBA\"}`,
+ Expect:`{Id:\"ABC123XYZ\", Type:\"SomeDeviceType\", Root:false, ParentId:\"ZYX321CBA\"}`,
+ },
+ {
+ Name: "Test GetImageDownloadStatus",
+ Method: "GetImageDownloadStatus", // rpc GetImageDownloadStatus(ImageDownload) returns(ImageDownload)
+ Param: `{Id:\"Image-ZYX321CBA\"}`,
+ Expect:`{Id:\"Image-ABC123XYZ\", Name:\"SomeName\", Url:\"Some URL\", Crc:123456}`,
+ },
+ {
+ Name: "Test GetImageDownload",
+ Method: "GetImageDownload", // rpc GetImageDownload(ImageDownload) returns(ImageDownload)
+ Param: `{Id:\"Image-ZYX321CBA\"}`,
+ Expect:`{Id:\"Image-ABC123XYZ\", Name:\"SomeName\", Url:\"Some URL\", Crc:123456}`,
+ },
+ {
+ Name: "Test ListImageDownloads",
+ Method: "ListImageDownloads", // rpc ListImageDownloads(ID) returns(ImageDownloads)
+ Param: `{Id:\"ZYX321CBA\"}`,
+ Expect:`{Items:[]*voltha.ImageDownload{&voltha.ImageDownload{Id:\"Image1-ABC123XYZ\", Name:\"SomeName\", Url:\"Some URL\", Crc:123456}, &voltha.ImageDownload{Id:\"Image2-ABC123XYZ\", Name:\"SomeName\", Url:\"Some other URL\", Crc:654321}}}`,
+ },
+ {
+ Name: "Test ListDevicePorts",
+ Method: "ListDevicePorts", // rpc ListDevicePorts(ID) returns(Ports)
+ Param: `{}`,
+ Expect:`{Items:[]*voltha.Port{&voltha.Port{PortNo:100000, Label:\"Port one hundred thousand\", DeviceId:\"ZYX321CBA\"},&voltha.Port{PortNo:100001, Label:\"Port one hundred thousand and one\", DeviceId:\"ZYX321CBA\"}}}`,
+ },
+ {
+ Name: "Test ListDevicePmConfigs",
+ Method: "ListDevicePmConfigs", // rpc ListDevicePmConfigs(ID) returns(PmConfigs)
+ Param: `{}`,
+ Expect:`{Id:\"ABC123XYZ\", DefaultFreq: 10000, Grouped:false, FreqOverride:false, Metrics:[]*voltha.PmConfig{&voltha.PmConfig{Name:\"Speed\", Enabled: true, SampleFreq:10000}, &voltha.PmConfig{Name:\"Errors\", Enabled: true, SampleFreq:10000}}}`,
+ },
+ {
+ Name: "Test ListDeviceFlows",
+ Method: "ListDeviceFlows", // rpc ListDeviceFlows(ID) returns(openflow_13.Flows)
+ Param: `{Id:\"Flow-ABC123XYZ\"}`,
+ Expect:`{Items:[]*openflow_13.OfpFlowStats{&openflow_13.OfpFlowStats{Id:1, TableId:2, DurationSec:12, Priority:0},&openflow_13.OfpFlowStats{Id:1, TableId:2, DurationSec:12, Priority:0}}}`,
+ },
+ {
+ Name: "Test ListDeviceFlowGroups",
+ Method: "ListDeviceFlowGroups", // rpc ListDeviceFlowGroups(ID) returns(openflow_13.FlowGroups)
+ Param: `{Id:\"Flow-ABC123XYZ\"}`,
+ Expect:`{Items:[]*openflow_13.OfpGroupEntry{&openflow_13.OfpGroupEntry{Desc:&openflow_13.OfpGroupDesc{GroupId:12}, Stats:&openflow_13.OfpGroupStats{GroupId:1, RefCount:1, PacketCount:3}}}}`,
+ },
+ {
+ Name: "Test ListDeviceTypes",
+ Method: "ListDeviceTypes", // rpc ListDeviceTypes(google.protobuf.Empty) returns(DeviceTypes)
+ Param: `{}`,
+ Expect:`{Items:[]*voltha.DeviceType{&voltha.DeviceType{Id:\"ABC123XYZ\", VendorId:\"Ciena\", Adapter:\"SAOS\"},&voltha.DeviceType{Id:\"ZYX321CBA\", VendorId:\"Ciena\", Adapter:\"SAOS-Tibit\"}}}`,
+ },
+ {
+ Name: "Test GetDeviceType",
+ Method: "GetDeviceType", // rpc GetDeviceType(ID) returns(DeviceType)
+ Param: `{Id:\"ZYX321CBA\"}`,
+ Expect:`{Id:\"ZYX321CBA\", VendorId:\"Ciena\", Adapter:\"SAOS-Tibit\"}`,
+ },
+ {
+ Name: "Test ListDeviceGroups",
+ Method: "ListDeviceGroups", // rpc ListDeviceGroups(google.protobuf.Empty) returns(DeviceGroups)
+ Param: `{}`,
+ Expect:`{Items:[]*voltha.DeviceGroup{&voltha.DeviceGroup{Id:\"group-ABC123XYZ\", LogicalDevices: []*voltha.LogicalDevice{&voltha.LogicalDevice{Id:\"LDevId\", DatapathId:64, RootDeviceId:\"Root\"}}, Devices: []*voltha.Device{&voltha.Device{Id:\"ABC123XYZ\", Type:\"SomeDeviceType\", Root:false, ParentId:\"ZYX321CBA\"},&voltha.Device{Id:\"ZYX321CBA\", Type:\"SomeDeviceType\", Root:true, ParentId:\"ROOT\"}}}}}`,
+ },
+ {
+ Name: "Test GetDeviceGroup",
+ Method: "GetDeviceGroup", // rpc GetDeviceGroup(ID) returns(DeviceGroup)
+ Param: `{Id:\"ZYX321CBA\"}`,
+ Expect:`{Id:\"group-ABC123XYZ\", LogicalDevices: []*voltha.LogicalDevice{&voltha.LogicalDevice{Id:\"LDevId\", DatapathId:64, RootDeviceId:\"Root\"}}, Devices: []*voltha.Device{&voltha.Device{Id:\"ABC123XYZ\", Type:\"SomeDeviceType\", Root:false, ParentId:\"ZYX321CBA\"},&voltha.Device{Id:\"ZYX321CBA\", Type:\"SomeDeviceType\", Root:true, ParentId:\"ROOT\"}}}`,
+ },
+ {
+ Name: "Test ListAlarmFilters",
+ Method: "ListAlarmFilters", // rpc ListAlarmFilters(google.protobuf.Empty) returns(AlarmFilters)
+ Param: `{}`,
+ Expect:`{Filters:[]*voltha.AlarmFilter{&voltha.AlarmFilter{Id:\"ABC123XYZ\", Rules: []*voltha.AlarmFilterRule{&voltha.AlarmFilterRule{Value:\"Rule Value\"}}}}}`,
+ },
+ {
+ Name: "Test GetAlarmFilter",
+ Method: "GetAlarmFilter", // rpc GetAlarmFilter(ID) returns(AlarmFilter)
+ Param: `{Id:\"ABC123XYZ\"}`,
+ Expect:`{Id:\"ABC123XYZ\", Rules: []*voltha.AlarmFilterRule{&voltha.AlarmFilterRule{Value:\"Rule Value\"}}}`,
+ },
+ {
+ Name: "Test GetImages",
+ Method: "GetImages", // rpc GetImages(ID) returns(Images)
+ Param: `{Id:\"ZYX321CBA\"}`,
+ Expect:`{Image: []*voltha.Image{&voltha.Image{Name:\"Image1\", Version: \"0.1\", Hash:\"123@\", InstallDatetime:\"Yesterday\", IsActive:true, IsCommitted:true, IsValid:false},&voltha.Image{Name:\"Image2\", Version: \"0.2\", Hash:\"ABC@\", InstallDatetime:\"Today\", IsActive:false, IsCommitted:false, IsValid:false}}}`,
+ },
+}
+
+var ctlMethods []test = []test {
+ {
+ Name: "Test UpdateLogLevel",
+ Method: "UpdateLogLevel", // rpc UpdateLogLevel(Logging) returns(google.protobuf.Empty)
+ Param: `{Level: 0, PackageName:\"abc123\"}`,
+ Expect: "{}",
+ },
+}
+
+var rwMethods []test = []test{
+ {
+ Name: "Test EnableLogicalDevicePort",
+ Method: "EnableLogicalDevicePort", // rpc EnableLogicalDevicePort(LogicalPortId) returns(google.protobuf.Empty)
+ Param: `{Id:\"ZYX321CBA\", PortId:\"100,000\"}`,
+ Expect:`{}`,
+ },
+ {
+ Name: "Test DisableLogicalDevicePort",
+ Method: "DisableLogicalDevicePort", // rpc DisableLogicalDevicePort(LogicalPortId) returns(google.protobuf.Empty)
+ Param: `{Id:\"ABC123XYZ\", PortId:\"100,000\"}`,
+ Expect:`{}`,
+ },
+ {
+ Name: "Test UpdateLogicalDeviceFlowTable",
+ Method: "UpdateLogicalDeviceFlowTable", // rpc UpdateLogicalDeviceFlowTable(openflow_13.FlowTableUpdate)
+ Param: `{Id:\"XYZ123ABC\", FlowMod:&openflow_13.OfpFlowMod{Cookie:10, CookieMask:255, TableId:10000, Command:openflow_13.OfpFlowModCommand_OFPFC_ADD}}`,
+ Expect:`{}`,
+ },
+ {
+ Name: "Test UpdateLogicalDeviceFlowGroupTable",
+ Method: "UpdateLogicalDeviceFlowGroupTable", // rpc UpdateLogicalDeviceFlowGroupTable(openflow_13.FlowGroupTableUpdate)
+ Param: `{Id:\"ZYX123ABC\", GroupMod:&openflow_13.OfpGroupMod{Command:openflow_13.OfpGroupModCommand_OFPGC_ADD, Type:openflow_13.OfpGroupType_OFPGT_INDIRECT, GroupId:255}}`,
+ Expect:`{}`,
+ },
+ //"ReconcileDevices", // rpc ReconcileDevices(IDs) returns(google.protobuf.Empty)
+ {
+ Name: "Test CreateDevice",
+ Method: "CreateDevice", // rpc CreateDevice(Device) returns(Device)
+ Param: `{Type:\"simulated_OLT\"}`,
+ Expect:`{Id:\"ZYX321ABC\", Type:\"\"}`,
+ },
+ {
+ Name: "Test EnableDevice",
+ Method: "EnableDevice", // rpc EnableDevice(ID) returns(google.protobuf.Empty)
+ Param: `{Id:\"XYZ321ABC\"}`,
+ Expect:`{}`,
+ },
+ {
+ Name: "Test DisableDevice",
+ Method: "DisableDevice", // rpc DisableDevice(ID) returns(google.protobuf.Empty)
+ Param: `{Id:\"XYZ123CBA\"}`,
+ Expect:`{}`,
+ },
+ {
+ Name: "Test RebootDevice",
+ Method: "RebootDevice", // rpc RebootDevice(ID) returns(google.protobuf.Empty)
+ Param: `{Id:\"ZYX123CBA\"}`,
+ Expect:`{}`,
+ },
+ {
+ Name: "Test DeleteDevice",
+ Method: "DeleteDevice", // rpc DeleteDevice(ID) returns(google.protobuf.Empty)
+ Param: `{Id:\"CBA123XYZ\"}`,
+ Expect:`{}`,
+ },
+ {
+ Name: "Test DownloadImage",
+ Method: "DownloadImage", // rpc DownloadImage(ImageDownload) returns(OperationResp)
+ Param: `{Id:\"CBA321XYZ\", Name:\"Image-1\", Crc: 54321}`,
+ Expect:`{Code:voltha.OperationResp_OPERATION_SUCCESS, AdditionalInfo:\"It worked!\"}`,
+ },
+ {
+ Name: "Test CancelImageDownload",
+ Method: "CancelImageDownload", // rpc CancelImageDownload(ImageDownload) returns(OperationResp)
+ Param: `{Id:\"CBA321ZYX\", Name:\"Image-1\", Crc: 54321}`,
+ Expect:`{Code:voltha.OperationResp_OPERATION_SUCCESS, AdditionalInfo:\"It worked!\"}`,
+ },
+ {
+ Name: "Test ActivateImageUpdate",
+ Method: "ActivateImageUpdate", // rpc ActivateImageUpdate(ImageDownload) returns(OperationResp)
+ Param: `{Id:\"ABC321ZYX\", Name:\"Image-1\", Crc: 54321}`,
+ Expect:`{Code:voltha.OperationResp_OPERATION_FAILURE, AdditionalInfo:\"It bombed!\"}`,
+ },
+ {
+ Name: "Test RevertImageUpdate",
+ Method: "RevertImageUpdate", // rpc RevertImageUpdate(ImageDownload) returns(OperationResp)
+ Param: `{Id:\"ABC123ZYX\", Name:\"Image-1\", Crc: 54321}`,
+ Expect:`{Code:voltha.OperationResp_OPERATION_FAILURE, AdditionalInfo:\"It bombed!\"}`,
+ },
+ {
+ Name: "Test UpdateDevicePmConfigs",
+ Method: "UpdateDevicePmConfigs", // rpc UpdateDevicePmConfigs(voltha.PmConfigs) returns(google.protobuf.Empty)
+ Param: `{Id:\"CBA123ZYX\", DefaultFreq:1000000, Grouped: false, FreqOverride: false}`,
+ Expect:`{}`,
+ },
+ {
+ Name: "Test CreateAlarmFilter",
+ Method: "CreateAlarmFilter", // rpc CreateAlarmFilter(AlarmFilter) returns(AlarmFilter)
+ Param: `{Id:\"abc123xyz\", Rules:[]*voltha.AlarmFilterRule{&voltha.AlarmFilterRule{Key:voltha.AlarmFilterRuleKey_type, Value:\"Type man, it's the type!\"}, &voltha.AlarmFilterRule{Key:voltha.AlarmFilterRuleKey_category, Value:\"Category yeah!\"}}}`,
+ Expect:`{Id:\"abc123xyz\", Rules: []*voltha.AlarmFilterRule{&voltha.AlarmFilterRule{Key:voltha.AlarmFilterRuleKey_type, Value:\"Type man, it's the type!\"}, &voltha.AlarmFilterRule{Key:voltha.AlarmFilterRuleKey_category, Value:\"Category yeah!\"}}}`,
+ },
+ {
+ Name: "Test UpdateAlarmFilter",
+ Method: "UpdateAlarmFilter", // rpc UpdateAlarmFilter(AlarmFilter) returns(AlarmFilter)
+ Param: `{Id:\"ABC321XYZ\", Rules:[]*voltha.AlarmFilterRule{&voltha.AlarmFilterRule{Key:voltha.AlarmFilterRuleKey_type, Value:\"Type man, it's the type!\"}, &voltha.AlarmFilterRule{Key:voltha.AlarmFilterRuleKey_category, Value:\"Category yeah!\"}}}`,
+ Expect:`{Id:\"ABC321XYZ\", Rules: []*voltha.AlarmFilterRule{&voltha.AlarmFilterRule{Key:voltha.AlarmFilterRuleKey_type, Value:\"Type man, it's the type!\"}, &voltha.AlarmFilterRule{Key:voltha.AlarmFilterRuleKey_category, Value:\"Category yeah!\"}}}`,
+ },
+ {
+ Name: "Test DeleteAlarmFilter",
+ Method: "DeleteAlarmFilter", // rpc DeleteAlarmFilter(ID) returns(google.protobuf.Empty)
+ Param: `{Id:\"acb123xyz\"}`,
+ Expect:`{}`,
+ },
+ {
+ Name: "Test SelfTest",
+ Method: "SelfTest", // rpc SelfTest(ID) returns(SelfTestResponse)
+ Param: `{Id:\"bac123xyz\"}`,
+ Expect:`{Result:voltha.SelfTestResponse_UNKNOWN_ERROR}`,
+ },
+} /*
+// "StreamPacketsOut", // rpc StreamPacketsOut(stream openflow_13.PacketOut)
+// "ReceivePacketsIn", // rpc ReceivePacketsIn(google.protobuf.Empty)
+// "ReceiveChangeEvents", // rpc ReceiveChangeEvents(google.protobuf.Empty)
+ "Subscribe ", // rpc Subscribe (OfAgentSubscriber) returns (OfAgentSubscriber)
+
+}
+*/
+
+func dumpFile(fileNm string) error {
+ // Dump the generated file for debugging purposes
+ if c,err := ioutil.ReadFile(fileNm); err == nil {
+ fmt.Print(string(c))
+ } else {
+ e := errors.New(fmt.Sprintf("Could not read the file '%s', %v", fileNm, err))
+ return e
+ }
+ return nil
+}
+
+func main() {
+
+ //var rwAry []test
+ //var roAry []test
+ var serNo int = 0
+
+ // Setup logging
+ if _, err := log.SetDefaultLogger(log.JSON, 0, nil); err != nil {
+ log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
+ }
+
+ core := 0
+ for k,_ := range roMethods {
+ roMethods[k].SerNo = serNo
+ roMethods[k].Core = (core%3) + 1
+ log.Infof("Processing method %s, serNo: %d", roMethods[k].Method, roMethods[k].SerNo)
+ serNo++
+ core++
+ }
+
+ // New round robin starts here because of the different route
+ core = 0
+ for k,_ := range rwMethods {
+ rwMethods[k].SerNo = serNo
+ rwMethods[k].Core = (core%3) + 1
+ log.Infof("Processing method %s, serNo: %d", rwMethods[k].Method, rwMethods[k].SerNo)
+ serNo++
+ core++
+ }
+
+ // New round robin starts here because of the different route
+ core = 0
+ for k,_ := range ctlMethods {
+ ctlMethods[k].SerNo = serNo
+ ctlMethods[k].Core = (core%3) + 1
+ log.Infof("Processing method %s, serNo: %d", ctlMethods[k].Method, ctlMethods[k].SerNo)
+ serNo++
+ core++
+ }
+
+ tsts := tests{RoTests: roMethods, RwTests: rwMethods, CtlTests: ctlMethods}
+
+ t := template.Must(template.New("").ParseFiles("./test3.tmpl.json"))
+ if f,err := os.Create("test3.json"); err == nil {
+ _=f
+ defer f.Close()
+ if err := t.ExecuteTemplate(f, "test3.tmpl.json", tsts); err != nil {
+ log.Errorf("Unable to execute template for test3.tmpl.json: %v", err)
+ }
+ } else {
+ log.Errorf("Couldn't create file test3.json: %v", err)
+ }
+
+ // Dump the generated file for debugging purposes
+ //if err := dumpFile("test3.json"); err != nil {
+ // log.Error(err)
+ //}
+
+
+}
diff --git a/tests/afrouter/suites/test3.json b/tests/afrouter/suites/test3.json
deleted file mode 100644
index 2d3d7ad..0000000
--- a/tests/afrouter/suites/test3.json
+++ /dev/null
@@ -1,87 +0,0 @@
-{
- "environment":{
- "cmdLine":"afrouter -config arouter_test.json",
- "protoFiles": [
- {
- "importPath":"github.com/opencord/voltha-go/protos/",
- "service":"VolthaService",
- "package":"voltha"
- }
- ],
- "imports": [
- "github.com/golang/protobuf/ptypes/empty",
- "github.com/opencord/voltha-go/protos/openflow_13"
- ],
- "protoDesc":"voltha.pb",
- "protoSubst": [
- {
- "from":"google.protobuf.Empty",
- "to":"empty.Empty"
- }
- ],
- "clients": [
- {
- "name":"client",
- "port":"5000"
- }
- ],
- "servers": [
- {
- "name":"core11",
- "port":"5011"
- },
- {
- "name":"core12",
- "port":"5012"
- },
- {
- "name":"core21",
- "port":"5021"
- },
- {
- "name":"core22",
- "port":"5022"
- },
- {
- "name":"core31",
- "port":"5031"
- },
- {
- "name":"core32",
- "port":"5032"
- }
- ]
- },
- "tests":[
- {
- "send": {
- "client":"client",
- "method":"CreateDevice",
- "param":"json struct",
- "_meta":""
- },
- "servers": [
- {
- "name":"server11",
- "meta": [
- {
- "key":"voltha_serial_number",
- "value":"1"
- }
- ],
- "param":"mirror_client"
- },
- {
- "name":"server12",
- "meta": [
- {
- "key":"voltha_serial_number",
- "value":"1"
- }
- ],
- "param":"mirror_client"
- }
- ]
- }
- ]
-}
diff --git a/tests/afrouter/suites/test3.tmpl.json b/tests/afrouter/suites/test3.tmpl.json
new file mode 100644
index 0000000..b3118ff
--- /dev/null
+++ b/tests/afrouter/suites/test3.tmpl.json
@@ -0,0 +1,235 @@
+{
+ "environment":{
+ "cmdLine":"afrouter -config arouter_test.json -logLevel 1",
+ "protoFiles": [
+ {
+ "importPath":"github.com/opencord/voltha-go/protos/",
+ "service":"VolthaService",
+ "package":"voltha"
+ },
+ {
+ "importPath":"github.com/opencord/voltha-go/protos/",
+ "service":"Configuration",
+ "package":"afrouter"
+ }
+ ],
+ "imports": [
+ "github.com/golang/protobuf/ptypes/empty",
+ "github.com/opencord/voltha-go/protos/openflow_13"
+ ],
+ "protoDesc":"voltha.pb",
+ "protoSubst": [
+ {
+ "from":"google.protobuf.Empty",
+ "to":"empty.Empty"
+ }
+ ],
+ "clients": {
+ "imports": [
+ "github.com/golang/protobuf/ptypes/empty",
+ "github.com/opencord/voltha-go/protos/openflow_13"
+ ],
+ "endpoints": [
+ {
+ "name":"client",
+ "port":"5000"
+ },
+ {
+ "name":"stats",
+ "port":"55554"
+ }
+ ]
+ },
+ "servers": {
+ "imports": [
+ "github.com/golang/protobuf/ptypes/empty",
+ "github.com/opencord/voltha-go/protos/openflow_13"
+ ],
+ "endpoints": [
+ {
+ "name":"core11",
+ "port":"5011"
+ },
+ {
+ "name":"core12",
+ "port":"5012"
+ },
+ {
+ "name":"core21",
+ "port":"5021"
+ },
+ {
+ "name":"core22",
+ "port":"5022"
+ },
+ {
+ "name":"core31",
+ "port":"5031"
+ },
+ {
+ "name":"core32",
+ "port":"5032"
+ },
+ {
+ "name":"roCore1",
+ "port":"5001"
+ },
+ {
+ "name":"roCore2",
+ "port":"5002"
+ },
+ {
+ "name":"roCore3",
+ "port":"5003"
+ }
+ ]
+ }
+ },
+ "tests":[
+ {{range $k,$v := .RoTests}}
+ {
+ "name":"{{$v.Name}}",
+ "send": {
+ "client":"client",
+ "method":"{{$v.Method}}",
+ "param":"{{$v.Param}}",
+ "expect":"{{$v.Expect}}",
+ "_meta":""
+ },
+ "servers": [
+ {
+ "name":"core{{$v.Core}}1",
+ "meta": [
+ {
+ "key":"voltha_serial_number",
+ "value":"{{$v.SerNo}}"
+ }
+ ]
+ },
+ {
+ "name":"core{{$v.Core}}2",
+ "meta": [
+ {
+ "key":"voltha_serial_number",
+ "value":"{{$v.SerNo}}"
+ }
+ ]
+ }
+ ]
+ },
+ {{end}}
+ {{range $k,$v := .RwTests}}
+ {
+ "name":"{{$v.Name}}",
+ "send": {
+ "client":"client",
+ "method":"{{$v.Method}}",
+ "param":"{{$v.Param}}",
+ "expect":"{{$v.Expect}}",
+ "_meta":""
+ },
+ "servers": [
+ {
+ "name":"core{{$v.Core}}1",
+ "meta": [
+ {
+ "key":"voltha_serial_number",
+ "value":"{{$v.SerNo}}"
+ }
+ ]
+ },
+ {
+ "name":"core{{$v.Core}}2",
+ "meta": [
+ {
+ "key":"voltha_serial_number",
+ "value":"{{$v.SerNo}}"
+ }
+ ]
+ }
+ ]
+ },
+ {{end}}
+ {{range $k,$v := .CtlTests}}
+ {
+ "name":"{{$v.Name}}",
+ "send": {
+ "client":"client",
+ "method":"{{$v.Method}}",
+ "param":"{{$v.Param}}",
+ "expect":"{{$v.Expect}}",
+ "_meta":""
+ },
+ "servers": [
+ {
+ "name":"core{{$v.Core}}1",
+ "meta": [
+ {
+ "key":"voltha_serial_number",
+ "value":"{{$v.SerNo}}"
+ }
+ ]
+ },
+ {
+ "name":"core{{$v.Core}}2",
+ "meta": [
+ {
+ "key":"voltha_serial_number",
+ "value":"{{$v.SerNo}}"
+ }
+ ]
+ }
+ ]
+ },
+ {{end}}
+ {
+ "name":"Test Subscribe",
+ "send": {
+ "client":"client",
+ "method":"Subscribe",
+ "param":"{OfagentId:\"Agent007\"}",
+ "meta": [
+ {
+ "key":"voltha_backend_name",
+ "value":""
+ }
+ ],
+ "expect":"{OfagentId:\"Agent007\",VolthaId:\"core11\"}",
+ "expectMeta": [
+ {
+ "key":"voltha_backend_name",
+ "value":"vcore1"
+ }
+ ]
+ },
+ "servers": [
+ {
+ "name":"core11",
+ "meta": [
+ {
+ "key":"voltha_serial_number",
+ "value":"44"
+ },
+ {
+ "key":"voltha_backend_name",
+ "value":""
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "_COMMENT":"If this test case fails, there could be a goroutine leak",
+ "name":"Get goroutine count",
+ "send": {
+ "client":"stats",
+ "method":"GetGoroutineCount",
+ "param":"{}",
+ "meta": [ ],
+ "expect":"{Count:39}",
+ "expectMeta": [ ]
+ },
+ "servers": [ ]
+ }
+ ]
+}