blob: 79ea6c159badb334511dd4c3f26f07dded1190ec [file] [log] [blame]
Kent Hagerman0ab4cb22019-04-24 13:13:35 -04001// +build integration
2
David Bainbridge31221742019-04-19 19:49:51 +00003/*
4 * Copyright 2018-present Open Networking Foundation
5
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9
10 * http://www.apache.org/licenses/LICENSE-2.0
11
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19package main
20
21import (
22 "fmt"
23 "os"
24 //"flag"
25 //"path"
26 //"bufio"
27 "errors"
28 //"os/exec"
29 //"strconv"
30 "io/ioutil"
31 //"encoding/json"
32 "text/template"
33 //"github.com/golang/protobuf/proto"
Scott Baker807addd2019-10-24 15:16:21 -070034 "github.com/opencord/voltha-lib-go/v2/pkg/log"
David Bainbridge31221742019-04-19 19:49:51 +000035 //pb "github.com/golang/protobuf/protoc-gen-go/descriptor"
36)
37
38// This test suite validates that the different method types get routed
39// properly. That is, rw methods to the rw cores and ro methods to the
40// ro cores
41type test struct {
42 Name string
43 Core int
44 SerNo int
45 Method string
46 Param string
47 Expect string
48}
49
50type tests struct {
51 RoTests []test
52 RwTests []test
53 CtlTests []test
54}
55
56var roMethods []test = []test{
57 {
58 Name: "Test GetVoltha",
59 Method: "GetVoltha", // rpc GetVoltha(google.protobuf.Empty) returns(Voltha)
60 Param: "{}",
61 Expect: `{Version:\"abcdef\"}`,
62 },
63 /*
64 {
65 Name: "Test ListCoreInstances",
66 Method: "ListCoreInstances", // rpc ListCoreInstances(google.protobuf.Empty) returns(CoreInstances)
67 Param: "{}",
68 Expect: `{Items:[]*voltha.CoreInstance{&voltha.CoreInstance{InstanceId:\"ABC\",Health:&voltha.HealthStatus{State:0}}}}`,
69 },
70 {
71 Name: "Test GetCoreInstance",
72 Method: "GetCoreInstance", // rpc GetCoreInstance(ID) returns(CoreInstance)
73 Param: `{Id:\"arou8390\"}`,
74 Expect: `{InstanceId:\"arou8390\", Health:&voltha.HealthStatus{State:0}}`,
75 },*/
76 {
77 Name: "Test ListAdapters",
78 Method: "ListAdapters", // rpc ListAdapters(google.protobuf.Empty) returns(Adapters)
79 Param: "{}",
80 Expect: `{Items:[]*voltha.Adapter{&voltha.Adapter{Id:\"ABC\", Vendor:\"afrouterTest\", Version:\"Version 1.0\"}}}`,
81 },
82 {
83 Name: "Test ListLogicalDevices",
84 Method: "ListLogicalDevices", // rpc ListLogicalDevices(google.protobuf.Empty) returns(LogicalDevices)
85 Param: "{}",
86 Expect: `{Items:[]*voltha.LogicalDevice{&voltha.LogicalDevice{Id:\"LDevId\", DatapathId:64, RootDeviceId:\"Root\"}}}`,
87 },
88 {
89 Name: "Test GetLogicalDevice",
90 Method: "GetLogicalDevice", // rpc GetLogicalDevice(ID) returns(LogicalDevice)
91 Param: `{Id:\"ABC123XYZ\"}`,
92 Expect: `{Id:\"ABC123XYZ\", DatapathId:64, RootDeviceId:\"Root-of:ABC123XYZ\"}`,
93 },
94 {
95 Name: "Test ListLogicalDevicePorts",
96 Method: "ListLogicalDevicePorts", // rpc ListLogicalDevicePorts(ID) returns(LogicalPorts)
97 Param: `{Id:\"ABC123XYZ\"}`,
98 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}}}`,
99 },
100 {
101 Name: "Test GetLogicalDevicePort",
102 Method: "GetLogicalDevicePort", // rpc GetLogicalDevicePort(LogicalPortId) returns(LogicalPort)
103 Param: `{Id:\"PortId-1\"}`,
104 Expect: `{Id:\"PortId-1\", DeviceId:\"ABC12XYZ\", DevicePortNo:64, RootPort:true}`,
105 },
106 {
107 Name: "Test ListLogicalDeviceFlows",
108 Method: "ListLogicalDeviceFlows", // rpc ListLogicalDeviceFlows(ID) returns(openflow_13.Flows)
109 Param: `{Id:\"Flow-ABC123XYZ\"}`,
110 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}}}`,
111 },
112 {
113 Name: "Test ListLogicalDeviceFlowGroups",
114 Method: "ListLogicalDeviceFlowGroups", // rpc ListLogicalDeviceFlowGroups(ID) returns(openflow_13.FlowGroups)
115 Param: `{Id:\"Flow-ABC123XYZ\"}`,
116 Expect: `{Items:[]*openflow_13.OfpGroupEntry{&openflow_13.OfpGroupEntry{Desc:&openflow_13.OfpGroupDesc{GroupId:12}, Stats:&openflow_13.OfpGroupStats{GroupId:1, RefCount:1, PacketCount:3}}}}`,
117 },
118 {
119 Name: "Test ListDevices",
120 Method: "ListDevices", // rpc ListDevices(google.protobuf.Empty) returns(Devices)
121 Param: `{}`,
122 Expect: `{Items:[]*voltha.Device{&voltha.Device{Id:\"ABC123XYZ\", Type:\"SomeDeviceType\", Root:false, ParentId:\"ZYX321CBA\"},&voltha.Device{Id:\"ZYX321CBA\", Type:\"SomeDeviceType\", Root:true, ParentId:\"ROOT\"}}}`,
123 },
124 {
125 Name: "Test ListDeviceIds",
126 Method: "ListDeviceIds", // rpc ListDeviceIds(google.protobuf.Empty) returns(IDs)
127 Param: `{}`,
128 Expect: `{Items:[]*voltha.ID{&voltha.ID{Id:\"ABC123XYZ\"},&voltha.ID{Id:\"ZYX321CBA\"}}}`,
129 },
130 {
131 Name: "Test GetDevice",
132 Method: "GetDevice", // rpc GetDevice(ID) returns(Device)
133 Param: `{Id:\"ZYX321CBA\"}`,
134 Expect: `{Id:\"ABC123XYZ\", Type:\"SomeDeviceType\", Root:false, ParentId:\"ZYX321CBA\"}`,
135 },
136 {
137 Name: "Test GetImageDownloadStatus",
138 Method: "GetImageDownloadStatus", // rpc GetImageDownloadStatus(ImageDownload) returns(ImageDownload)
139 Param: `{Id:\"Image-ZYX321CBA\"}`,
140 Expect: `{Id:\"Image-ABC123XYZ\", Name:\"SomeName\", Url:\"Some URL\", Crc:123456}`,
141 },
142 {
143 Name: "Test GetImageDownload",
144 Method: "GetImageDownload", // rpc GetImageDownload(ImageDownload) returns(ImageDownload)
145 Param: `{Id:\"Image-ZYX321CBA\"}`,
146 Expect: `{Id:\"Image-ABC123XYZ\", Name:\"SomeName\", Url:\"Some URL\", Crc:123456}`,
147 },
148 {
149 Name: "Test ListImageDownloads",
150 Method: "ListImageDownloads", // rpc ListImageDownloads(ID) returns(ImageDownloads)
151 Param: `{Id:\"ZYX321CBA\"}`,
152 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}}}`,
153 },
154 {
155 Name: "Test ListDevicePorts",
156 Method: "ListDevicePorts", // rpc ListDevicePorts(ID) returns(Ports)
157 Param: `{}`,
158 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\"}}}`,
159 },
160 {
161 Name: "Test ListDevicePmConfigs",
162 Method: "ListDevicePmConfigs", // rpc ListDevicePmConfigs(ID) returns(PmConfigs)
163 Param: `{}`,
164 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}}}`,
165 },
166 {
167 Name: "Test ListDeviceFlows",
168 Method: "ListDeviceFlows", // rpc ListDeviceFlows(ID) returns(openflow_13.Flows)
169 Param: `{Id:\"Flow-ABC123XYZ\"}`,
170 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}}}`,
171 },
172 {
173 Name: "Test ListDeviceFlowGroups",
174 Method: "ListDeviceFlowGroups", // rpc ListDeviceFlowGroups(ID) returns(openflow_13.FlowGroups)
175 Param: `{Id:\"Flow-ABC123XYZ\"}`,
176 Expect: `{Items:[]*openflow_13.OfpGroupEntry{&openflow_13.OfpGroupEntry{Desc:&openflow_13.OfpGroupDesc{GroupId:12}, Stats:&openflow_13.OfpGroupStats{GroupId:1, RefCount:1, PacketCount:3}}}}`,
177 },
178 {
179 Name: "Test ListDeviceTypes",
180 Method: "ListDeviceTypes", // rpc ListDeviceTypes(google.protobuf.Empty) returns(DeviceTypes)
181 Param: `{}`,
182 Expect: `{Items:[]*voltha.DeviceType{&voltha.DeviceType{Id:\"ABC123XYZ\", VendorId:\"Ciena\", Adapter:\"SAOS\"},&voltha.DeviceType{Id:\"ZYX321CBA\", VendorId:\"Ciena\", Adapter:\"SAOS-Tibit\"}}}`,
183 },
184 {
185 Name: "Test GetDeviceType",
186 Method: "GetDeviceType", // rpc GetDeviceType(ID) returns(DeviceType)
187 Param: `{Id:\"ZYX321CBA\"}`,
188 Expect: `{Id:\"ZYX321CBA\", VendorId:\"Ciena\", Adapter:\"SAOS-Tibit\"}`,
189 },
190 {
191 Name: "Test ListDeviceGroups",
192 Method: "ListDeviceGroups", // rpc ListDeviceGroups(google.protobuf.Empty) returns(DeviceGroups)
193 Param: `{}`,
194 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\"}}}}}`,
195 },
196 {
197 Name: "Test GetDeviceGroup",
198 Method: "GetDeviceGroup", // rpc GetDeviceGroup(ID) returns(DeviceGroup)
199 Param: `{Id:\"ZYX321CBA\"}`,
200 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\"}}}`,
201 },
202 {
Devmalya Paulc594bb32019-11-06 07:34:27 +0000203 Name: "Test ListEventFilters",
204 Method: "ListEventFilters", // rpc ListEventFilters(google.protobuf.Empty) returns(EventFilters)
David Bainbridge31221742019-04-19 19:49:51 +0000205 Param: `{}`,
Devmalya Paulc594bb32019-11-06 07:34:27 +0000206 Expect: `{Filters:[]*voltha.EventFilter{&voltha.EventFilter{Id:\"ABC123XYZ\", DeviceId: \"Device123\", Enable: \"True\", EventType: \"DeviceEvent\", Rules: []*voltha.EventFilterRule{&voltha.EventFilterRule{Value:\"Rule Value\"}}}}}`,
David Bainbridge31221742019-04-19 19:49:51 +0000207 },
208 {
Devmalya Paulc594bb32019-11-06 07:34:27 +0000209 Name: "Test GetEventFilter",
210 Method: "GetEventFilter", // rpc GetEventFilter(ID) returns(EventFilters)
David Bainbridge31221742019-04-19 19:49:51 +0000211 Param: `{Id:\"ABC123XYZ\"}`,
Devmalya Paulc594bb32019-11-06 07:34:27 +0000212 Expect: `{Filters:[]*voltha.EventFilter{&voltha.EventFilter{Id:\"ABC123XYZ\", DeviceId: \"Device123\", Enable: \"True\", EventType: \"DeviceEvent\", Rules: []*voltha.EventFilterRule{&voltha.EventFilterRule{Value:\"Rule Value\"}}}}}`,
David Bainbridge31221742019-04-19 19:49:51 +0000213 },
214 {
215 Name: "Test GetImages",
216 Method: "GetImages", // rpc GetImages(ID) returns(Images)
217 Param: `{Id:\"ZYX321CBA\"}`,
218 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}}}`,
219 },
220}
221
222var ctlMethods []test = []test{
223 {
224 Name: "Test UpdateLogLevel",
225 Method: "UpdateLogLevel", // rpc UpdateLogLevel(Logging) returns(google.protobuf.Empty)
226 Param: `{Level: 0, PackageName:\"abc123\"}`,
227 Expect: "{}",
228 },
229}
230
231var rwMethods []test = []test{
232 {
233 Name: "Test EnableLogicalDevicePort",
234 Method: "EnableLogicalDevicePort", // rpc EnableLogicalDevicePort(LogicalPortId) returns(google.protobuf.Empty)
235 Param: `{Id:\"ZYX321CBA\", PortId:\"100,000\"}`,
236 Expect: `{}`,
237 },
238 {
239 Name: "Test DisableLogicalDevicePort",
240 Method: "DisableLogicalDevicePort", // rpc DisableLogicalDevicePort(LogicalPortId) returns(google.protobuf.Empty)
241 Param: `{Id:\"ABC123XYZ\", PortId:\"100,000\"}`,
242 Expect: `{}`,
243 },
244 {
245 Name: "Test UpdateLogicalDeviceFlowTable",
246 Method: "UpdateLogicalDeviceFlowTable", // rpc UpdateLogicalDeviceFlowTable(openflow_13.FlowTableUpdate)
247 Param: `{Id:\"XYZ123ABC\", FlowMod:&openflow_13.OfpFlowMod{Cookie:10, CookieMask:255, TableId:10000, Command:openflow_13.OfpFlowModCommand_OFPFC_ADD}}`,
248 Expect: `{}`,
249 },
250 {
251 Name: "Test UpdateLogicalDeviceFlowGroupTable",
252 Method: "UpdateLogicalDeviceFlowGroupTable", // rpc UpdateLogicalDeviceFlowGroupTable(openflow_13.FlowGroupTableUpdate)
253 Param: `{Id:\"ZYX123ABC\", GroupMod:&openflow_13.OfpGroupMod{Command:openflow_13.OfpGroupModCommand_OFPGC_ADD, Type:openflow_13.OfpGroupType_OFPGT_INDIRECT, GroupId:255}}`,
254 Expect: `{}`,
255 },
256 //"ReconcileDevices", // rpc ReconcileDevices(IDs) returns(google.protobuf.Empty)
257 {
258 Name: "Test CreateDevice",
259 Method: "CreateDevice", // rpc CreateDevice(Device) returns(Device)
260 Param: `{Type:\"simulated_OLT\"}`,
261 Expect: `{Id:\"ZYX321ABC\", Type:\"\"}`,
262 },
263 {
264 Name: "Test EnableDevice",
265 Method: "EnableDevice", // rpc EnableDevice(ID) returns(google.protobuf.Empty)
266 Param: `{Id:\"XYZ321ABC\"}`,
267 Expect: `{}`,
268 },
269 {
270 Name: "Test DisableDevice",
271 Method: "DisableDevice", // rpc DisableDevice(ID) returns(google.protobuf.Empty)
272 Param: `{Id:\"XYZ123CBA\"}`,
273 Expect: `{}`,
274 },
275 {
276 Name: "Test RebootDevice",
277 Method: "RebootDevice", // rpc RebootDevice(ID) returns(google.protobuf.Empty)
278 Param: `{Id:\"ZYX123CBA\"}`,
279 Expect: `{}`,
280 },
281 {
282 Name: "Test DeleteDevice",
283 Method: "DeleteDevice", // rpc DeleteDevice(ID) returns(google.protobuf.Empty)
284 Param: `{Id:\"CBA123XYZ\"}`,
285 Expect: `{}`,
286 },
287 {
288 Name: "Test DownloadImage",
289 Method: "DownloadImage", // rpc DownloadImage(ImageDownload) returns(OperationResp)
290 Param: `{Id:\"CBA321XYZ\", Name:\"Image-1\", Crc: 54321}`,
291 Expect: `{Code:voltha.OperationResp_OPERATION_SUCCESS, AdditionalInfo:\"It worked!\"}`,
292 },
293 {
294 Name: "Test CancelImageDownload",
295 Method: "CancelImageDownload", // rpc CancelImageDownload(ImageDownload) returns(OperationResp)
296 Param: `{Id:\"CBA321ZYX\", Name:\"Image-1\", Crc: 54321}`,
297 Expect: `{Code:voltha.OperationResp_OPERATION_SUCCESS, AdditionalInfo:\"It worked!\"}`,
298 },
299 {
300 Name: "Test ActivateImageUpdate",
301 Method: "ActivateImageUpdate", // rpc ActivateImageUpdate(ImageDownload) returns(OperationResp)
302 Param: `{Id:\"ABC321ZYX\", Name:\"Image-1\", Crc: 54321}`,
303 Expect: `{Code:voltha.OperationResp_OPERATION_FAILURE, AdditionalInfo:\"It bombed!\"}`,
304 },
305 {
306 Name: "Test RevertImageUpdate",
307 Method: "RevertImageUpdate", // rpc RevertImageUpdate(ImageDownload) returns(OperationResp)
308 Param: `{Id:\"ABC123ZYX\", Name:\"Image-1\", Crc: 54321}`,
309 Expect: `{Code:voltha.OperationResp_OPERATION_FAILURE, AdditionalInfo:\"It bombed!\"}`,
310 },
311 {
312 Name: "Test UpdateDevicePmConfigs",
313 Method: "UpdateDevicePmConfigs", // rpc UpdateDevicePmConfigs(voltha.PmConfigs) returns(google.protobuf.Empty)
314 Param: `{Id:\"CBA123ZYX\", DefaultFreq:1000000, Grouped: false, FreqOverride: false}`,
315 Expect: `{}`,
316 },
317 {
Devmalya Paulc594bb32019-11-06 07:34:27 +0000318 Name: "Test CreateEventFilter",
319 Method: "CreateEventFilter", // rpc CreateEventFilter(EventFilter) returns(EventFilter)
320 // Param: `{Id:\"abc123xyz\", Rules:[]*voltha.EventFilterRule{&voltha.AlarmFilterRule{Key:voltha.AlarmFilterRuleKey_type, Value:\"Type man, it's the type!\"}, &voltha.AlarmFilterRule{Key:voltha.AlarmFilterRuleKey_category, Value:\"Category yeah!\"}}}`,
321 Param: `{Id:\"abc123xyz\", DeviceId: \"Device123\", Enable: True, EventType: \"device_event\", Rules:[]*voltha.EventFilterRule{&voltha.EventFilterRule{Key:voltha.EventFilterRuleKey_category, Value:\"Equipment\"}, &voltha.EventFilterRule{Key:voltha.EventFilterRuleKey_sub_category, Value:\"ONU\"}, &voltha.EventFilterRule{Key:voltha.EventFilterRuleKey_device_event_type, Value:\"dying_gasp_event\"}}}`,
322 Expect: `{Id:\"abc123xyz\", DeviceId: \"Device123\", Enable: True, EventType: \"device_event\", Rules:[]*voltha.EventFilterRule{&voltha.EventFilterRule{Key:voltha.EventFilterRuleKey_category, Value:\"Equipment\"}, &voltha.EventFilterRule{Key:voltha.EventFilterRuleKey_sub_category, Value:\"ONU\"}, &voltha.EventFilterRule{Key:voltha.EventFilterRuleKey_device_event_type, Value:\"dying_gasp_event\"}}}`,
David Bainbridge31221742019-04-19 19:49:51 +0000323 },
324 {
Devmalya Paulc594bb32019-11-06 07:34:27 +0000325 Name: "Test UpdateEventFilter",
326 Method: "UpdateEventFilter", // rpc UpdateEventFilter(EventFilter) returns(EventFilter)
327 Param: `{Id:\"abc123xyz\", DeviceId: \"Device123\", Enable: True, EventType: \"device_event\", Rules:[]*voltha.EventFilterRule{&voltha.EventFilterRule{Key:voltha.EventFilterRuleKey_category, Value:\"Equipment\"}, &voltha.EventFilterRule{Key:voltha.EventFilterRuleKey_sub_category, Value:\"ONU\"}, &voltha.EventFilterRule{Key:voltha.EventFilterRuleKey_device_event_type, Value:\"dying_gasp_event\"}}}`,
328 Expect: `{Id:\"abc123xyz\", DeviceId: \"Device123\", Enable: True, EventType: \"device_event\", Rules:[]*voltha.EventFilterRule{&voltha.EventFilterRule{Key:voltha.EventFilterRuleKey_category, Value:\"Equipment\"}, &voltha.EventFilterRule{Key:voltha.EventFilterRuleKey_sub_category, Value:\"ONU\"}, &voltha.EventFilterRule{Key:voltha.EventFilterRuleKey_device_event_type, Value:\"dying_gasp_event\"}}}`,
David Bainbridge31221742019-04-19 19:49:51 +0000329 },
330 {
Devmalya Paulc594bb32019-11-06 07:34:27 +0000331 Name: "Test DeleteEventFilter",
332 Method: "DeleteEventFilter", // rpc DeleteEventFilter(EventFilter) returns(google.protobuf.Empty)
David Bainbridge31221742019-04-19 19:49:51 +0000333 Param: `{Id:\"acb123xyz\"}`,
334 Expect: `{}`,
335 },
336 {
337 Name: "Test SelfTest",
338 Method: "SelfTest", // rpc SelfTest(ID) returns(SelfTestResponse)
339 Param: `{Id:\"bac123xyz\"}`,
340 Expect: `{Result:voltha.SelfTestResponse_UNKNOWN_ERROR}`,
341 },
342} /*
343// "StreamPacketsOut", // rpc StreamPacketsOut(stream openflow_13.PacketOut)
344// "ReceivePacketsIn", // rpc ReceivePacketsIn(google.protobuf.Empty)
345// "ReceiveChangeEvents", // rpc ReceiveChangeEvents(google.protobuf.Empty)
346 "Subscribe ", // rpc Subscribe (OfAgentSubscriber) returns (OfAgentSubscriber)
347
348}
349*/
350
351func dumpFile(fileNm string) error {
352 // Dump the generated file for debugging purposes
353 if c, err := ioutil.ReadFile(fileNm); err == nil {
354 fmt.Print(string(c))
355 } else {
356 e := errors.New(fmt.Sprintf("Could not read the file '%s', %v", fileNm, err))
357 return e
358 }
359 return nil
360}
361
362func main() {
363
364 //var rwAry []test
365 //var roAry []test
366 var serNo int = 0
367
368 // Setup logging
369 if _, err := log.SetDefaultLogger(log.JSON, 0, nil); err != nil {
370 log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
371 }
372
373 core := 0
374 for k, _ := range roMethods {
375 roMethods[k].SerNo = serNo
376 roMethods[k].Core = (core % 3) + 1
377 log.Infof("Processing method %s, serNo: %d", roMethods[k].Method, roMethods[k].SerNo)
378 serNo++
379 core++
380 }
381
382 // New round robin starts here because of the different route
383 core = 0
384 for k, _ := range rwMethods {
385 rwMethods[k].SerNo = serNo
386 rwMethods[k].Core = (core % 3) + 1
387 log.Infof("Processing method %s, serNo: %d", rwMethods[k].Method, rwMethods[k].SerNo)
388 serNo++
389 core++
390 }
391
392 // New round robin starts here because of the different route
393 core = 0
394 for k, _ := range ctlMethods {
395 ctlMethods[k].SerNo = serNo
396 ctlMethods[k].Core = (core % 3) + 1
397 log.Infof("Processing method %s, serNo: %d", ctlMethods[k].Method, ctlMethods[k].SerNo)
398 serNo++
399 core++
400 }
401
402 tsts := tests{RoTests: roMethods, RwTests: rwMethods, CtlTests: ctlMethods}
403
404 t := template.Must(template.New("").ParseFiles("./test3.tmpl.json"))
405 if f, err := os.Create("test3.json"); err == nil {
406 _ = f
407 defer f.Close()
408 if err := t.ExecuteTemplate(f, "test3.tmpl.json", tsts); err != nil {
409 log.Errorf("Unable to execute template for test3.tmpl.json: %v", err)
410 }
411 } else {
412 log.Errorf("Couldn't create file test3.json: %v", err)
413 }
414
415 // Dump the generated file for debugging purposes
416 //if err := dumpFile("test3.json"); err != nil {
417 // log.Error(err)
418 //}
419
420}