Kent Hagerman | 0ab4cb2 | 2019-04-24 13:13:35 -0400 | [diff] [blame] | 1 | // +build integration |
| 2 | |
sslobodr | 1318284 | 2019-02-08 14:40:30 -0500 | [diff] [blame] | 3 | /* |
| 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 | |
| 19 | package main |
| 20 | |
| 21 | import ( |
| 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" |
serkant.uluderya | 2ae470f | 2020-01-21 11:13:09 -0800 | [diff] [blame] | 34 | "github.com/opencord/voltha-lib-go/v3/pkg/log" |
sslobodr | 1318284 | 2019-02-08 14:40:30 -0500 | [diff] [blame] | 35 | //pb "github.com/golang/protobuf/protoc-gen-go/descriptor" |
| 36 | ) |
| 37 | |
| 38 | type test struct { |
David Bainbridge | 3122174 | 2019-04-19 19:49:51 +0000 | [diff] [blame] | 39 | Core int |
sslobodr | 1d1e50b | 2019-03-14 09:17:40 -0400 | [diff] [blame] | 40 | SerNo int |
sslobodr | 1318284 | 2019-02-08 14:40:30 -0500 | [diff] [blame] | 41 | } |
| 42 | |
David Bainbridge | 3122174 | 2019-04-19 19:49:51 +0000 | [diff] [blame] | 43 | type suite struct { |
| 44 | CrTests []test |
| 45 | GetTests []test |
| 46 | } |
| 47 | |
sslobodr | 1d1e50b | 2019-03-14 09:17:40 -0400 | [diff] [blame] | 48 | const SUITE_LEN = 55000 |
David Bainbridge | 3122174 | 2019-04-19 19:49:51 +0000 | [diff] [blame] | 49 | |
sslobodr | 1d1e50b | 2019-03-14 09:17:40 -0400 | [diff] [blame] | 50 | //const SUITE_LEN = 100 |
| 51 | |
sslobodr | 1318284 | 2019-02-08 14:40:30 -0500 | [diff] [blame] | 52 | func main() { |
| 53 | |
sslobodr | 1d1e50b | 2019-03-14 09:17:40 -0400 | [diff] [blame] | 54 | var ary suite |
sslobodr | 1318284 | 2019-02-08 14:40:30 -0500 | [diff] [blame] | 55 | |
| 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 Bainbridge | 3122174 | 2019-04-19 19:49:51 +0000 | [diff] [blame] | 61 | 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}) |
sslobodr | 1318284 | 2019-02-08 14:40:30 -0500 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | // Load the template to execute |
| 67 | t := template.Must(template.New("").ParseFiles("./test2.tmpl.json")) |
David Bainbridge | 3122174 | 2019-04-19 19:49:51 +0000 | [diff] [blame] | 68 | if f, err := os.Create("test2.json"); err == nil { |
sslobodr | 1318284 | 2019-02-08 14:40:30 -0500 | [diff] [blame] | 69 | 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 | } |