4
4
"encoding/json"
5
5
"fmt"
6
6
"testing"
7
+ "time"
7
8
8
9
harness "github.com/kudobuilder/kuttl/pkg/apis/testharness/v1beta1"
9
10
"github.com/kudobuilder/kuttl/pkg/report"
@@ -29,70 +30,78 @@ type Results struct {
29
30
}
30
31
31
32
func RunTest (meshConfig ServiceMesh , annotations map [string ]string ) Results {
32
- manifestDirs := []string {}
33
- output := Results {}
34
- results := & report.Testsuites {}
35
33
36
- // Run all testCases
37
- testToRun := ""
38
- // Run only traffic-split
39
- // testToRun := "traffic-split"
34
+ c := make (chan Results )
35
+ go func () {
36
+ manifestDirs := []string {}
37
+ results := & report.Testsuites {}
38
+ output := Results {}
40
39
41
- startKIND := false
42
- options := harness.TestSuite {}
40
+ // Run all testCases
41
+ testToRun := ""
42
+ // Run only traffic-split
43
+ // testToRun := "traffic-split"
43
44
44
- args := []string {"./test-yamls/" }
45
+ startKIND := false
46
+ options := harness.TestSuite {}
45
47
46
- options .TestDirs = args
47
- options .Timeout = 30
48
- options .Parallel = 1
49
- options .TestDirs = manifestDirs
50
- options .StartKIND = startKIND
51
- options .SkipDelete = true
48
+ args := []string {"./test-yamls/" }
52
49
53
- if options .KINDContext == "" {
54
- options .KINDContext = harness .DefaultKINDContext
55
- }
56
-
57
- if len (args ) != 0 {
58
50
options .TestDirs = args
59
- }
60
-
61
- // annotations := make(map[string]string)
62
- // Namespace Injection
63
- // annotations["linkerd.io/inject"] = "enabled"
64
-
65
- serviceMeshConfObj := SMIConformance {
66
- SMObj : meshConfig ,
67
- }
51
+ options . Timeout = 30
52
+ options . Parallel = 1
53
+ options . TestDirs = manifestDirs
54
+ options . StartKIND = startKIND
55
+ options . SkipDelete = true
56
+
57
+ if options . KINDContext == "" {
58
+ options . KINDContext = harness . DefaultKINDContext
59
+ }
68
60
69
- testHandlers := make (map [string ]map [string ]test.CustomTest )
70
- testHandlers ["traffic-access" ] = serviceMeshConfObj .TrafficAccessGetTests ()
71
- testHandlers ["traffic-spec" ] = serviceMeshConfObj .TrafficSpecGetTests ()
72
- testHandlers ["traffic-split" ] = serviceMeshConfObj .TrafficSplitGetTests ()
73
-
74
- testutils .RunTests ("kudo" , testToRun , options .Parallel , func (t * testing.T ) {
75
- harness := test.Harness {
76
- TestSuite : options ,
77
- T : t ,
78
- SuiteCustomTests : testHandlers ,
79
- NamespaceAnnotations : annotations ,
61
+ if len (args ) != 0 {
62
+ options .TestDirs = args
80
63
}
81
64
82
- // Runs the test using the inCluster kubeConfig (runs only when the code is running inside the pod)
83
- harness .InCluster = true
84
-
85
- s , _ := json .MarshalIndent (options , "" , " " )
86
- fmt .Printf ("Running integration tests with following options:\n %s\n " , string (s ))
87
- results = harness .Run ()
88
- data , _ := json .Marshal (results )
89
- // Results of the test
90
- fmt .Printf ("Results :\n %v\n " , string (data ))
91
- err := json .Unmarshal ([]byte (data ), & output )
92
- if err != nil {
93
- fmt .Printf ("Unable to unmarshal results" )
65
+ // annotations := make(map[string]string)
66
+ // Namespace Injection
67
+ // annotations["linkerd.io/inject"] = "enabled"
68
+
69
+ serviceMeshConfObj := SMIConformance {
70
+ SMObj : meshConfig ,
94
71
}
95
- })
96
72
97
- return output
73
+ testHandlers := make (map [string ]map [string ]test.CustomTest )
74
+ testHandlers ["traffic-access" ] = serviceMeshConfObj .TrafficAccessGetTests ()
75
+ testHandlers ["traffic-spec" ] = serviceMeshConfObj .TrafficSpecGetTests ()
76
+ testHandlers ["traffic-split" ] = serviceMeshConfObj .TrafficSplitGetTests ()
77
+
78
+ testutils .RunTests ("kudo" , testToRun , options .Parallel , func (t * testing.T ) {
79
+ harness := test.Harness {
80
+ TestSuite : options ,
81
+ T : t ,
82
+ SuiteCustomTests : testHandlers ,
83
+ NamespaceAnnotations : annotations ,
84
+ }
85
+
86
+ // Runs the test using the inCluster kubeConfig (runs only when the code is running inside the pod)
87
+ harness .InCluster = true
88
+
89
+ s , _ := json .MarshalIndent (options , "" , " " )
90
+ fmt .Printf ("Running integration tests with following options:\n %s\n " , string (s ))
91
+ results = harness .Run ()
92
+ data , _ := json .Marshal (results )
93
+ // Results of the test
94
+ fmt .Printf ("Results :\n %v\n " , string (data ))
95
+ err := json .Unmarshal ([]byte (data ), & output )
96
+ if err != nil {
97
+ fmt .Printf ("Unable to unmarshal results" )
98
+ }
99
+ c <- output
100
+ time .Sleep (5 * time .Second )
101
+ })
102
+ }()
103
+ select {
104
+ case x := <- c :
105
+ return x
106
+ }
98
107
}
0 commit comments