Changes to the test framework to support templating of
the json test files to enable the creation of very large
stress test suites. Still a work in progress.
Change-Id: I1a35e4143a2feb577c9ad6048a0339c7b9dc0f89
diff --git a/tests/afrouter/suites/main.json b/tests/afrouter/suites/main.json
index e4862c6..a1bc09c 100644
--- a/tests/afrouter/suites/main.json
+++ b/tests/afrouter/suites/main.json
@@ -1,6 +1,7 @@
{
"__COMMENT":"Top level test driver file",
"suites": [
- "test1.json"
+ "test1",
+ "test2"
]
}
diff --git a/tests/afrouter/suites/test2.go b/tests/afrouter/suites/test2.go
new file mode 100644
index 0000000..fc0332e
--- /dev/null
+++ b/tests/afrouter/suites/test2.go
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "os"
+ //"fmt"
+ //"flag"
+ //"path"
+ //"bufio"
+ //"errors"
+ //"os/exec"
+ //"strconv"
+ //"io/ioutil"
+ //"encoding/json"
+ "text/template"
+ //"github.com/golang/protobuf/proto"
+ "github.com/opencord/voltha-go/common/log"
+ //pb "github.com/golang/protobuf/protoc-gen-go/descriptor"
+)
+
+type test struct {
+ Core int
+}
+
+func main() {
+
+ var ary []test
+
+ // Setup logging
+ if _, err := log.SetDefaultLogger(log.JSON, 0, nil); err != nil {
+ log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
+ }
+
+ for i :=0; i<10000; i++ {
+
+ ary = append(ary,test{Core:(i%3)+1})
+ }
+
+ // Load the template to execute
+ t := template.Must(template.New("").ParseFiles("./test2.tmpl.json"))
+ if f,err := os.Create("test2.json"); err == nil {
+ _=f
+ defer f.Close()
+ if err := t.ExecuteTemplate(f, "test2.tmpl.json", ary); err != nil {
+ log.Errorf("Unable to execute template for test2.tmpl.json: %v", err)
+ }
+ } else {
+ log.Errorf("Couldn't create file test2.json: %v", err)
+ }
+ return
+}
diff --git a/tests/afrouter/suites/test2.json b/tests/afrouter/suites/test2.tmpl.json
similarity index 81%
rename from tests/afrouter/suites/test2.json
rename to tests/afrouter/suites/test2.tmpl.json
index bdecd95..fc8ef1c 100644
--- a/tests/afrouter/suites/test2.json
+++ b/tests/afrouter/suites/test2.tmpl.json
@@ -1,6 +1,6 @@
{
"environment":{
- "cmdLine":"afrouter -config arouter_test.json",
+ "cmdLine":"afrouter -config arouter_test.json -grpclog",
"protoFiles": [
{
"importPath":"github.com/opencord/voltha-go/protos/",
@@ -53,43 +53,45 @@
]
},
"tests":[
+ {{range $k,$v := .}}
{
"name":"Test CreateDevice",
"send": {
"client":"client",
"method":"CreateDevice",
"param":"{Type:\"simulated_olt\"}",
- "expect":"{Id:\"abcd1234\",Type:\"simulated_olt\"}",
+ "expect":"{Id:\"abcd1234{{$k}}\",Type:\"simulated_olt\"}",
"_meta":""
},
"servers": [
{
- "name":"core11",
+ "name":"core{{$v.Core}}1",
"meta": [
{
"key":"voltha_serial_number",
- "value":"0"
+ "value":"{{$k}}"
}
]
},
{
- "name":"core12",
+ "name":"core{{$v.Core}}2",
"meta": [
{
"key":"voltha_serial_number",
- "value":"0"
+ "value":"{{$k}}"
}
]
}
]
},
+ {{end}}
{
"name":"Test GetDevice",
"send": {
"client":"client",
"method":"GetDevice",
- "param":"{Id:\"abcd1234\"}",
- "expect":"{Id:\"abcd1234\",Type:\"simulated_olt\"}",
+ "param":"{Id:\"abcd12340\"}",
+ "expect":"{Id:\"abcd12340\",Type:\"simulated_olt\"}",
"_meta":""
},
"servers": [
@@ -98,7 +100,7 @@
"meta": [
{
"key":"voltha_serial_number",
- "value":"1"
+ "value":"10000"
}
]
},
@@ -107,7 +109,7 @@
"meta": [
{
"key":"voltha_serial_number",
- "value":"1"
+ "value":"10000"
}
]
}
@@ -129,7 +131,7 @@
"expectMeta": [
{
"key":"voltha_backend_name",
- "value":"core11"
+ "value":"vcore1"
}
]
},
@@ -139,11 +141,11 @@
"meta": [
{
"key":"voltha_serial_number",
- "value":"2"
+ "value":"10001"
},
{
"key":"voltha_backend_name",
- "value":"a"
+ "value":""
}
]
}