move the files of a test suite into their own dir
Change-Id: I1970c05700e61db116ca4b432f1dc7ecf769853d
diff --git a/tests/afrouter/suites/test2/test2.go b/tests/afrouter/suites/test2/test2.go
new file mode 100644
index 0000000..9f80d37
--- /dev/null
+++ b/tests/afrouter/suites/test2/test2.go
@@ -0,0 +1,75 @@
+/*
+ * 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
+ SerNo int
+}
+
+type suite struct {
+ CrTests []test
+ GetTests []test
+}
+
+const SUITE_LEN = 55000
+
+//const SUITE_LEN = 100
+
+func main() {
+
+ var ary suite
+
+ // 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 < SUITE_LEN; i++ {
+ ary.CrTests = append(ary.CrTests, test{Core: (i % 3) + 1, SerNo: i})
+ ary.GetTests = append(ary.GetTests, test{Core: (i % 3) + 1, SerNo: i + SUITE_LEN})
+ }
+
+ // Load the template to execute
+ t := template.Must(template.New("").ParseFiles("./test2.tmpl.json"))
+ if f, err := os.Create("test2.json"); err == nil {
+ 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/test2.tmpl.json b/tests/afrouter/suites/test2/test2.tmpl.json
new file mode 100644
index 0000000..8d8c6b1
--- /dev/null
+++ b/tests/afrouter/suites/test2/test2.tmpl.json
@@ -0,0 +1,226 @@
+{
+ "environment":{
+ "cmdLine":"afrouter -config arouter_test.json -logLevel 1",
+ "protoFiles": [
+ {
+ "importPath":"github.com/opencord/voltha-protos/go/",
+ "service":"VolthaService",
+ "package":"voltha"
+ },
+ {
+ "importPath":"github.com/opencord/voltha-protos/go/",
+ "service":"Configuration",
+ "package":"afrouter"
+ }
+ ],
+ "imports": [
+ "github.com/golang/protobuf/ptypes/empty",
+ "github.com/opencord/voltha-protos/go/common"
+ ],
+ "protoDesc":"voltha.pb",
+ "protoSubst": [
+ {
+ "from":"google.protobuf.Empty",
+ "to":"empty.Empty"
+ }
+ ],
+ "clients": {
+ "imports": [
+ "github.com/golang/protobuf/ptypes/empty",
+ "github.com/opencord/voltha-protos/go/openflow_13",
+ "github.com/opencord/voltha-protos/go/common"
+ ],
+ "endpoints": [
+ {
+ "name":"client",
+ "port":"5000"
+ },
+ {
+ "name":"stats",
+ "port":"55554"
+ }
+ ]
+ },
+ "servers": {
+ "imports": [
+ "github.com/golang/protobuf/ptypes/empty",
+ "github.com/opencord/voltha-protos/go/openflow_13",
+ "github.com/opencord/voltha-protos/go/omci",
+ "github.com/opencord/voltha-protos/go/common"
+ ],
+ "endpoints": [
+ {
+ "name":"core11",
+ "port":"5011"
+ },
+ {
+ "name":"core12",
+ "port":"5012"
+ },
+ {
+ "name":"core21",
+ "port":"5021"
+ },
+ {
+ "name":"core22",
+ "port":"5022"
+ },
+ {
+ "name":"core31",
+ "port":"5031"
+ },
+ {
+ "name":"core32",
+ "port":"5032"
+ }
+ ]
+ }
+ },
+ "tests":[
+ {{range $k,$v := .CrTests}}
+ {
+ "name":"Test CreateDevice",
+ "send": {
+ "client":"client",
+ "method":"CreateDevice",
+ "param":"{Type:\"simulated_olt\"}",
+ "expect":"{Id:\"abcd1234{{$k}}\",Type:\"simulated_olt\"}",
+ "_meta":""
+ },
+ "servers": [
+ {
+ "name":"core{{$v.Core}}1",
+ "meta": [
+ {
+ "key":"voltha_serial_number",
+ "value":"{{$v.SerNo}}"
+ }
+ ]
+ },
+ {
+ "name":"core{{$v.Core}}2",
+ "meta": [
+ {
+ "key":"voltha_serial_number",
+ "value":"{{$v.SerNo}}"
+ }
+ ]
+ }
+ ]
+ },
+ {{end}}
+ {{range $k,$v := .GetTests}}
+ {
+ "name":"Test EnableDevice",
+ "send": {
+ "client":"client",
+ "_method":"GetDevice",
+ "method":"EnableDevice",
+ "param":"{Id:\"abcd1234{{$k}}\"}",
+ "expect":"{}",
+ "_expect":"{Id:\"abcd1234{{$k}}\",Type:\"simulated_olt\"}",
+ "_meta":""
+ },
+ "servers": [
+ {
+ "name":"core{{$v.Core}}1",
+ "meta": [
+ {
+ "key":"voltha_serial_number",
+ "value":"{{$v.SerNo}}"
+ }
+ ]
+ },
+ {
+ "name":"core{{$v.Core}}2",
+ "meta": [
+ {
+ "key":"voltha_serial_number",
+ "value":"{{$v.SerNo}}"
+ }
+ ]
+ }
+ ]
+ },
+ {{end}}
+ {
+ "name":"Test GetDevice",
+ "send": {
+ "client":"client",
+ "method":"GetDevice",
+ "param":"{Id:\"abcd12340\"}",
+ "expect":"{Id:\"abcd12340\",Type:\"simulated_olt\"}",
+ "_meta":""
+ },
+ "servers": [
+ {
+ "name":"core11",
+ "meta": [
+ {
+ "key":"voltha_serial_number",
+ "value":"110000"
+ }
+ ]
+ },
+ {
+ "name":"core12",
+ "meta": [
+ {
+ "key":"voltha_serial_number",
+ "value":"110000"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "name":"Test Subscribe",
+ "send": {
+ "client":"client",
+ "method":"Subscribe",
+ "param":"{OfagentId:\"Agent007\"}",
+ "meta": [
+ {
+ "key":"voltha_backend_name",
+ "value":""
+ }
+ ],
+ "expect":"{OfagentId:\"Agent007\",VolthaId:\"core11\"}",
+ "expectMeta": [
+ {
+ "key":"voltha_backend_name",
+ "value":"vcore1"
+ }
+ ]
+ },
+ "servers": [
+ {
+ "name":"core11",
+ "meta": [
+ {
+ "key":"voltha_serial_number",
+ "value":"110001"
+ },
+ {
+ "key":"voltha_backend_name",
+ "value":""
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "_COMMENT":"If this test case fails, there could be a goroutine leak",
+ "name":"Get goroutine count",
+ "send": {
+ "client":"stats",
+ "method":"GetGoroutineCount",
+ "param":"{}",
+ "meta": [ ],
+ "expect":"{Count:39}",
+ "expectMeta": [ ]
+ },
+ "servers": [ ]
+ }
+ ]
+}