sslobodr | 1318284 | 2019-02-08 14:40:30 -0500 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package main |
| 18 | |
| 19 | import ( |
| 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 | type test struct { |
David Bainbridge | 3122174 | 2019-04-19 19:49:51 +0000 | [diff] [blame] | 37 | Core int |
sslobodr | 1d1e50b | 2019-03-14 09:17:40 -0400 | [diff] [blame] | 38 | SerNo int |
sslobodr | 1318284 | 2019-02-08 14:40:30 -0500 | [diff] [blame] | 39 | } |
| 40 | |
David Bainbridge | 3122174 | 2019-04-19 19:49:51 +0000 | [diff] [blame] | 41 | type suite struct { |
| 42 | CrTests []test |
| 43 | GetTests []test |
| 44 | } |
| 45 | |
sslobodr | 1d1e50b | 2019-03-14 09:17:40 -0400 | [diff] [blame] | 46 | const SUITE_LEN = 55000 |
David Bainbridge | 3122174 | 2019-04-19 19:49:51 +0000 | [diff] [blame] | 47 | |
sslobodr | 1d1e50b | 2019-03-14 09:17:40 -0400 | [diff] [blame] | 48 | //const SUITE_LEN = 100 |
| 49 | |
sslobodr | 1318284 | 2019-02-08 14:40:30 -0500 | [diff] [blame] | 50 | func main() { |
| 51 | |
sslobodr | 1d1e50b | 2019-03-14 09:17:40 -0400 | [diff] [blame] | 52 | var ary suite |
sslobodr | 1318284 | 2019-02-08 14:40:30 -0500 | [diff] [blame] | 53 | |
| 54 | // Setup logging |
| 55 | if _, err := log.SetDefaultLogger(log.JSON, 0, nil); err != nil { |
| 56 | log.With(log.Fields{"error": err}).Fatal("Cannot setup logging") |
| 57 | } |
| 58 | |
David Bainbridge | 3122174 | 2019-04-19 19:49:51 +0000 | [diff] [blame] | 59 | for i := 0; i < SUITE_LEN; i++ { |
| 60 | ary.CrTests = append(ary.CrTests, test{Core: (i % 3) + 1, SerNo: i}) |
| 61 | ary.GetTests = append(ary.GetTests, test{Core: (i % 3) + 1, SerNo: i + SUITE_LEN}) |
sslobodr | 1318284 | 2019-02-08 14:40:30 -0500 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | // Load the template to execute |
| 65 | t := template.Must(template.New("").ParseFiles("./test2.tmpl.json")) |
David Bainbridge | 3122174 | 2019-04-19 19:49:51 +0000 | [diff] [blame] | 66 | if f, err := os.Create("test2.json"); err == nil { |
sslobodr | 1318284 | 2019-02-08 14:40:30 -0500 | [diff] [blame] | 67 | defer f.Close() |
| 68 | if err := t.ExecuteTemplate(f, "test2.tmpl.json", ary); err != nil { |
| 69 | log.Errorf("Unable to execute template for test2.tmpl.json: %v", err) |
| 70 | } |
| 71 | } else { |
| 72 | log.Errorf("Couldn't create file test2.json: %v", err) |
| 73 | } |
| 74 | return |
| 75 | } |