Skip to content

Commit cefaabb

Browse files
committed
pass
Singed-off-by: YaoZengzeng <[email protected]>
1 parent d50a9c5 commit cefaabb

File tree

3 files changed

+25
-20
lines changed

3 files changed

+25
-20
lines changed

test/e2e/baseline_test.go

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -585,55 +585,60 @@ var CheckDeny = check.Or(
585585
func TestAuthorizationL4(t *testing.T) {
586586
framework.NewTest(t).Run(func(t framework.TestContext) {
587587
t.NewSubTest("allow").Run(func(t framework.TestContext) {
588-
src := apps.ServiceWithWaypointAtServiceGranularity
588+
if len(apps.ServiceWithWaypointAtServiceGranularity) == 0 {
589+
t.Fatal(fmt.Errorf("need at least 1 instance of apps.ServiceWithWaypointAtServiceGranularity"))
590+
}
591+
src := apps.ServiceWithWaypointAtServiceGranularity[0]
592+
589593
clients := src.WorkloadsOrFail(t)
590594
dst := apps.EnrolledToKmesh
591595

592596
addresses := clients.Addresses()
593597
if len(addresses) < 2 {
594598
t.Fatal(fmt.Errorf("need at least 2 clients"))
595599
}
596-
selectedAddress = addresses[0]
600+
selectedAddress := addresses[0]
597601
t.ConfigIstio().Eval(apps.Namespace.Name(), map[string]string{
598602
"Destination": dst.Config().Service,
599-
"Namespace": apps.Namespace.Name(),
600603
"Ip": selectedAddress,
601-
}, `
602-
apiVersion: security.istio.io/v1beta1
604+
}, `apiVersion: security.istio.io/v1beta1
603605
kind: AuthorizationPolicy
604606
metadata:
605607
name: policy
606-
namespace: "{{ .Namespace }}"
607608
spec:
608609
selector:
609610
matchLabels:
610-
app: "{{ .Destination }}"
611+
app: "{{.Destination}}"
611612
action: ALLOW
612613
rules:
613614
- from:
614615
- source:
615-
ipBlocks:
616-
- "{{ .Ip }}"
616+
ipBlocks:
617+
- "{{.Ip}}"
617618
`).ApplyOrFail(t)
618619

619-
for _, clent := range clients {
620+
for _, client := range clients {
620621
opt := echo.CallOptions{
621622
To: dst,
622-
Port: echo.Port{Name: "http"},
623-
Scheme: scheme.HTTP,
623+
Port: echo.Port{Name: "tcp"},
624+
Scheme: scheme.TCP,
624625
Count: 10,
625626
// Due to the mechanism of Kmesh L4 authorization, we need to set the timeout slightly longer.
626627
NewConnectionPerRequest: true,
627628
Timeout: time.Minute * 2,
628629
Check: check.OK(),
629630
}
630631

632+
fmt.Printf("--- client.Address() is %v, selectedAddress is %v\n", client.Address(), selectedAddress)
633+
631634
if client.Address() != selectedAddress {
635+
fmt.Printf("--- Use CheckDeny\n")
632636
opt.Check = CheckDeny
633637
}
634638

635-
t.NewSubTestf("%v", opt.Scheme).RunParallel(func(t framework.TestContext) {
636-
src.WithWorkloads(client).CallOrFail(t, opt)
639+
t.NewSubTestf("%v", opt.Scheme).Run(func(t framework.TestContext) {
640+
result := src.WithWorkloads(client).CallOrFail(t, opt)
641+
fmt.Printf("-- call result is %v\n", result.Responses)
637642
})
638643
}
639644
})

test/e2e/main_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,17 @@ func SetupApps(t resource.Context, i istio.Instance, apps *EchoDeployments) erro
163163
Replicas: 1,
164164
Version: "v1",
165165
Labels: map[string]string{
166-
"app": EnrolledToKmesh,
167-
"version": "v1"
168-
}
166+
"app": EnrolledToKmesh,
167+
"version": "v1",
168+
},
169169
},
170170
{
171171
Replicas: 1,
172172
Version: "v2",
173173
Labels: map[string]string{
174-
"app": EnrolledToKmesh,
174+
"app": EnrolledToKmesh,
175175
"version": "v2",
176-
}
176+
},
177177
},
178178
},
179179
})

test/e2e/run_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,6 @@ if [[ -z "${SKIP_SETUP:-}" ]]; then
240240
setup_kmesh
241241
fi
242242

243-
cmd="go test -v -tags=integ $ROOT_DIR/test/e2e/... -count=1 $PARAMS"
243+
cmd="go test -v -tags=integ $ROOT_DIR/test/e2e/... -count=1 -istio.test.nocleanup $PARAMS"
244244

245245
bash -c "$cmd"

0 commit comments

Comments
 (0)