Skip to content

Commit c7b4dce

Browse files
committed
some comments and experiments on TestMain
1 parent 4936329 commit c7b4dce

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

tests/integration/pilot/filterchain/filterchain_test.go

+21-7
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,50 @@ import (
1111
"time"
1212
)
1313

14+
1415
func TestMain(m *testing.M) {
15-
framework.Main("filterchain_test", m)
16+
1617
// TODO
1718
// No need to enforce kube for filter chain
1819
// set up envoy
1920
// set up client and app
2021
// 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")
2133
}
2234

2335
func TestFoo(t *testing.T) {
36+
t.Log("in TestFoo")
37+
return
2438
ctx := framework.NewContext(t)
2539
defer ctx.Done(t)
2640

27-
ctx.RequireOrSkip(t, environment.Native)
41+
ctx.RequireOrSkip(t, environment.Kube)
2842

2943
pilot := pilotcomponent.NewOrFail(t, ctx, pilotcomponent.Config{})
3044

3145
applications := apps.NewOrFail(ctx, t, apps.Config{Pilot: pilot})
3246

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)
3549

3650
for _, e := range bApp.Endpoints() {
3751
t.Logf("b end point %s", e)
3852
}
3953

4054
retry.UntilSuccessOrFail(t, func() error {
41-
bPort := bApp.EndpointsForProtocol(apps.AppProtocolHTTP)[0]
55+
bEndpoint := bApp.EndpointForPort(80)
4256
bProtocol := apps.AppProtocolHTTP
43-
results, err := aApp.Call(bPort,
57+
results, err := aApp.Call(bEndpoint,
4458
apps.AppCallOptions{
4559
Protocol: apps.AppProtocol(bProtocol),
4660
})
@@ -54,7 +68,7 @@ func TestFoo(t *testing.T) {
5468
fmt.Printf("Result: %v\n", results[0])
5569
}
5670
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)
5872
}
5973
return nil
6074
}, retry.Delay(time.Second), retry.Timeout(10*time.Second))

0 commit comments

Comments
 (0)