blob: 6bf545b87ebeda61cd77aeab0ab7b32f39f5d2d5 [file] [log] [blame]
Kent Hagerman0ab4cb22019-04-24 13:13:35 -04001// +build integration
2
sslobodr13182842019-02-08 14:40:30 -05003/*
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 "os"
23 //"fmt"
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"
sslobodr13182842019-02-08 14:40:30 -050035 //pb "github.com/golang/protobuf/protoc-gen-go/descriptor"
36)
37
38type test struct {
David Bainbridge31221742019-04-19 19:49:51 +000039 Core int
sslobodr1d1e50b2019-03-14 09:17:40 -040040 SerNo int
sslobodr13182842019-02-08 14:40:30 -050041}
42
David Bainbridge31221742019-04-19 19:49:51 +000043type suite struct {
44 CrTests []test
45 GetTests []test
46}
47
sslobodr1d1e50b2019-03-14 09:17:40 -040048const SUITE_LEN = 55000
David Bainbridge31221742019-04-19 19:49:51 +000049
sslobodr1d1e50b2019-03-14 09:17:40 -040050//const SUITE_LEN = 100
51
sslobodr13182842019-02-08 14:40:30 -050052func main() {
53
sslobodr1d1e50b2019-03-14 09:17:40 -040054 var ary suite
sslobodr13182842019-02-08 14:40:30 -050055
56 // Setup logging
57 if _, err := log.SetDefaultLogger(log.JSON, 0, nil); err != nil {
58 log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
59 }
60
David Bainbridge31221742019-04-19 19:49:51 +000061 for i := 0; i < SUITE_LEN; i++ {
62 ary.CrTests = append(ary.CrTests, test{Core: (i % 3) + 1, SerNo: i})
63 ary.GetTests = append(ary.GetTests, test{Core: (i % 3) + 1, SerNo: i + SUITE_LEN})
sslobodr13182842019-02-08 14:40:30 -050064 }
65
66 // Load the template to execute
67 t := template.Must(template.New("").ParseFiles("./test2.tmpl.json"))
David Bainbridge31221742019-04-19 19:49:51 +000068 if f, err := os.Create("test2.json"); err == nil {
sslobodr13182842019-02-08 14:40:30 -050069 defer f.Close()
70 if err := t.ExecuteTemplate(f, "test2.tmpl.json", ary); err != nil {
71 log.Errorf("Unable to execute template for test2.tmpl.json: %v", err)
72 }
73 } else {
74 log.Errorf("Couldn't create file test2.json: %v", err)
75 }
76 return
77}