blob: 2fb561c391ae4aade7dfc811466bdeca1a726309 [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"
34 "github.com/opencord/voltha-go/common/log"
35 //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 {
203 Name: "Test ListAlarmFilters",
204 Method: "ListAlarmFilters", // rpc ListAlarmFilters(google.protobuf.Empty) returns(AlarmFilters)
205 Param: `{}`,
206 Expect: `{Filters:[]*voltha.AlarmFilter{&voltha.AlarmFilter{Id:\"ABC123XYZ\", Rules: []*voltha.AlarmFilterRule{&voltha.AlarmFilterRule{Value:\"Rule Value\"}}}}}`,
207 },
208 {
209 Name: "Test GetAlarmFilter",
210 Method: "GetAlarmFilter", // rpc GetAlarmFilter(ID) returns(AlarmFilter)
211 Param: `{Id:\"ABC123XYZ\"}`,
212 Expect: `{Id:\"ABC123XYZ\", Rules: []*voltha.AlarmFilterRule{&voltha.AlarmFilterRule{Value:\"Rule Value\"}}}`,
213 },
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 {
318 Name: "Test CreateAlarmFilter",
319 Method: "CreateAlarmFilter", // rpc CreateAlarmFilter(AlarmFilter) returns(AlarmFilter)
320 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!\"}}}`,
321 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!\"}}}`,
322 },
323 {
324 Name: "Test UpdateAlarmFilter",
325 Method: "UpdateAlarmFilter", // rpc UpdateAlarmFilter(AlarmFilter) returns(AlarmFilter)
326 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!\"}}}`,
327 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!\"}}}`,
328 },
329 {
330 Name: "Test DeleteAlarmFilter",
331 Method: "DeleteAlarmFilter", // rpc DeleteAlarmFilter(ID) returns(google.protobuf.Empty)
332 Param: `{Id:\"acb123xyz\"}`,
333 Expect: `{}`,
334 },
335 {
336 Name: "Test SelfTest",
337 Method: "SelfTest", // rpc SelfTest(ID) returns(SelfTestResponse)
338 Param: `{Id:\"bac123xyz\"}`,
339 Expect: `{Result:voltha.SelfTestResponse_UNKNOWN_ERROR}`,
340 },
341} /*
342// "StreamPacketsOut", // rpc StreamPacketsOut(stream openflow_13.PacketOut)
343// "ReceivePacketsIn", // rpc ReceivePacketsIn(google.protobuf.Empty)
344// "ReceiveChangeEvents", // rpc ReceiveChangeEvents(google.protobuf.Empty)
345 "Subscribe ", // rpc Subscribe (OfAgentSubscriber) returns (OfAgentSubscriber)
346
347}
348*/
349
350func dumpFile(fileNm string) error {
351 // Dump the generated file for debugging purposes
352 if c, err := ioutil.ReadFile(fileNm); err == nil {
353 fmt.Print(string(c))
354 } else {
355 e := errors.New(fmt.Sprintf("Could not read the file '%s', %v", fileNm, err))
356 return e
357 }
358 return nil
359}
360
361func main() {
362
363 //var rwAry []test
364 //var roAry []test
365 var serNo int = 0
366
367 // Setup logging
368 if _, err := log.SetDefaultLogger(log.JSON, 0, nil); err != nil {
369 log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
370 }
371
372 core := 0
373 for k, _ := range roMethods {
374 roMethods[k].SerNo = serNo
375 roMethods[k].Core = (core % 3) + 1
376 log.Infof("Processing method %s, serNo: %d", roMethods[k].Method, roMethods[k].SerNo)
377 serNo++
378 core++
379 }
380
381 // New round robin starts here because of the different route
382 core = 0
383 for k, _ := range rwMethods {
384 rwMethods[k].SerNo = serNo
385 rwMethods[k].Core = (core % 3) + 1
386 log.Infof("Processing method %s, serNo: %d", rwMethods[k].Method, rwMethods[k].SerNo)
387 serNo++
388 core++
389 }
390
391 // New round robin starts here because of the different route
392 core = 0
393 for k, _ := range ctlMethods {
394 ctlMethods[k].SerNo = serNo
395 ctlMethods[k].Core = (core % 3) + 1
396 log.Infof("Processing method %s, serNo: %d", ctlMethods[k].Method, ctlMethods[k].SerNo)
397 serNo++
398 core++
399 }
400
401 tsts := tests{RoTests: roMethods, RwTests: rwMethods, CtlTests: ctlMethods}
402
403 t := template.Must(template.New("").ParseFiles("./test3.tmpl.json"))
404 if f, err := os.Create("test3.json"); err == nil {
405 _ = f
406 defer f.Close()
407 if err := t.ExecuteTemplate(f, "test3.tmpl.json", tsts); err != nil {
408 log.Errorf("Unable to execute template for test3.tmpl.json: %v", err)
409 }
410 } else {
411 log.Errorf("Couldn't create file test3.json: %v", err)
412 }
413
414 // Dump the generated file for debugging purposes
415 //if err := dumpFile("test3.json"); err != nil {
416 // log.Error(err)
417 //}
418
419}