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