@@ -11,36 +11,50 @@ import (
11
11
"time"
12
12
)
13
13
14
+
14
15
func TestMain (m * testing.M ) {
15
- framework . Main ( "filterchain_test" , m )
16
+
16
17
// TODO
17
18
// No need to enforce kube for filter chain
18
19
// set up envoy
19
20
// set up client and app
20
21
// set up pilot
22
+ print ("In TestMain" )
23
+ framework .Main ("filterchain_test" , m )
24
+
25
+ // NOTE: print(m) only run once no matter how many TestXX is given
26
+ print (m )
27
+ // no need to explicitly invoke os.Exit as it's part of framework.Main
28
+ // os.Exit(m.Run())
29
+ }
30
+
31
+ func TestBar (t * testing.T ) {
32
+ t .Log ("in TestBar" )
21
33
}
22
34
23
35
func TestFoo (t * testing.T ) {
36
+ t .Log ("in TestFoo" )
37
+ return
24
38
ctx := framework .NewContext (t )
25
39
defer ctx .Done (t )
26
40
27
- ctx .RequireOrSkip (t , environment .Native )
41
+ ctx .RequireOrSkip (t , environment .Kube )
28
42
29
43
pilot := pilotcomponent .NewOrFail (t , ctx , pilotcomponent.Config {})
30
44
31
45
applications := apps .NewOrFail (ctx , t , apps.Config {Pilot : pilot })
32
46
33
- aApp := applications .GetAppOrFail ("a" , t )
34
- bApp := applications .GetAppOrFail ("b" , t )
47
+ aApp := applications .GetAppOrFail ("a" , t ).(apps. KubeApp )
48
+ bApp := applications .GetAppOrFail ("b" , t ).(apps. KubeApp )
35
49
36
50
for _ , e := range bApp .Endpoints () {
37
51
t .Logf ("b end point %s" , e )
38
52
}
39
53
40
54
retry .UntilSuccessOrFail (t , func () error {
41
- bPort := bApp .EndpointsForProtocol ( apps . AppProtocolHTTP )[ 0 ]
55
+ bEndpoint := bApp .EndpointForPort ( 80 )
42
56
bProtocol := apps .AppProtocolHTTP
43
- results , err := aApp .Call (bPort ,
57
+ results , err := aApp .Call (bEndpoint ,
44
58
apps.AppCallOptions {
45
59
Protocol : apps .AppProtocol (bProtocol ),
46
60
})
@@ -54,7 +68,7 @@ func TestFoo(t *testing.T) {
54
68
fmt .Printf ("Result: %v\n " , results [0 ])
55
69
}
56
70
return fmt .Errorf ("%s to %s:%d using %s: expected success, actually failed" ,
57
- aApp .Name (), bApp .Name (), bPort , bProtocol )
71
+ aApp .Name (), bApp .Name (), 80 , bProtocol )
58
72
}
59
73
return nil
60
74
}, retry .Delay (time .Second ), retry .Timeout (10 * time .Second ))
0 commit comments