Skip to content

Commit 7142e96

Browse files
author
Jianfei Hu
committed
starting to work on serious test
1 parent a3dfb97 commit 7142e96

File tree

4 files changed

+146
-118
lines changed

4 files changed

+146
-118
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
[
2+
{
3+
"op": "remove",
4+
"path": "/spec/initContainers/0"
5+
},
6+
{
7+
"op": "remove",
8+
"path": "/spec/containers/0"
9+
},
10+
{
11+
"op": "add",
12+
"path": "/spec/initContainers/-",
13+
"value": {
14+
"name": "istio-init",
15+
"image": "example.com/init:latest",
16+
"resources": {}
17+
}
18+
},
19+
{
20+
"op": "add",
21+
"path": "/spec/containers/-",
22+
"value": {
23+
"name": "istio-proxy",
24+
"image": "example.com/proxy:latest",
25+
"resources": {}
26+
}
27+
},
28+
{
29+
"op": "add",
30+
"path": "/spec/volumes/-",
31+
"value": {
32+
"name": "istio-envoy",
33+
"emptyDir": {
34+
"medium": "Memory"
35+
}
36+
}
37+
},
38+
{
39+
"op": "add",
40+
"path": "/spec/volumes/-",
41+
"value": {
42+
"name": "istio-certs",
43+
"secret": {
44+
"secretName": "istio.default"
45+
}
46+
}
47+
},
48+
{
49+
"op": "add",
50+
"path": "/spec/imagePullSecrets",
51+
"value": [
52+
{
53+
"name": "istio-image-pull-secrets"
54+
}
55+
]
56+
},
57+
{
58+
"op": "add",
59+
"path": "/metadata/annotations",
60+
"value": {
61+
"sidecar.istio.io/status": "{\"version\":\"unit-test-fake-version\",\"initContainers\":[\"istio-init\"],\"containers\":[\"istio-proxy\"],\"volumes\":[\"istio-envoy\",\"istio-certs\"],\"imagePullSecrets\":[\"istio-image-pull-secrets\"]}"
62+
}
63+
}
64+
]

pilot/pkg/kube/inject/testdata/webhook/probe-rewrite.yaml renamed to pilot/pkg/kube/inject/testdata/webhook/TestWebhookInject_http_probe_rewrite.yaml

File renamed without changes.

pilot/pkg/kube/inject/testdata/webhook/probe-rewrite.patch

Lines changed: 0 additions & 43 deletions
This file was deleted.

pilot/pkg/kube/inject/webhook_test.go

Lines changed: 82 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -518,81 +518,85 @@ func TestInject(t *testing.T) {
518518
inputFile string
519519
wantFile string
520520
}{
521-
{
522-
inputFile: "TestWebhookInject.yaml",
523-
wantFile: "TestWebhookInject.patch",
524-
},
525-
{
526-
inputFile: "TestWebhookInject_no_initContainers.yaml",
527-
wantFile: "TestWebhookInject_no_initContainers.patch",
528-
},
529-
{
530-
inputFile: "TestWebhookInject_no_containers.yaml",
531-
wantFile: "TestWebhookInject_no_containers.patch",
532-
},
533-
{
534-
inputFile: "TestWebhookInject_no_volumes.yaml",
535-
wantFile: "TestWebhookInject_no_volumes.patch",
536-
},
537-
{
538-
inputFile: "TestWebhookInject_no_imagePullSecrets.yaml",
539-
wantFile: "TestWebhookInject_no_imagePullSecrets.patch",
540-
},
541-
{
542-
inputFile: "TestWebhookInject_no_volumes_imagePullSecrets.yaml",
543-
wantFile: "TestWebhookInject_no_volumes_imagePullSecrets.patch",
544-
},
545-
{
546-
inputFile: "TestWebhookInject_no_containers_volumes_imagePullSecrets.yaml",
547-
wantFile: "TestWebhookInject_no_containers_volumes_imagePullSecrets.patch",
548-
},
549-
{
550-
inputFile: "TestWebhookInject_no_containers_volumes.yaml",
551-
wantFile: "TestWebhookInject_no_containers_volumes.patch",
552-
},
553-
{
554-
inputFile: "TestWebhookInject_no_containers_imagePullSecrets.yaml",
555-
wantFile: "TestWebhookInject_no_containers_imagePullSecrets.patch",
556-
},
557-
{
558-
inputFile: "TestWebhookInject_no_initContainers_containers.yaml",
559-
wantFile: "TestWebhookInject_no_initContainers_containers.patch",
560-
},
561-
{
562-
inputFile: "TestWebhookInject_no_initContainers_volumes.yaml",
563-
wantFile: "TestWebhookInject_no_initContainers_volumes.patch",
564-
},
565-
{
566-
inputFile: "TestWebhookInject_no_initContainers_imagePullSecrets.yaml",
567-
wantFile: "TestWebhookInject_no_initContainers_imagePullSecrets.patch",
568-
},
569-
{
570-
inputFile: "TestWebhookInject_no_containers_volumes_imagePullSecrets.yaml",
571-
wantFile: "TestWebhookInject_no_containers_volumes_imagePullSecrets.patch",
572-
},
573-
{
574-
inputFile: "TestWebhookInject_no_initContainers_volumes_imagePullSecrets.yaml",
575-
wantFile: "TestWebhookInject_no_initContainers_volumes_imagePullSecrets.patch",
576-
},
577-
{
578-
inputFile: "TestWebhookInject_no_initContainers_containers_volumes.yaml",
579-
wantFile: "TestWebhookInject_no_initContainers_containers_volumes.patch",
580-
},
581-
{
582-
inputFile: "TestWebhookInject_no_initContainers_containers_imagePullSecrets.yaml",
583-
wantFile: "TestWebhookInject_no_initContainers_containers_imagePullSecrets.patch",
584-
},
585-
{
586-
inputFile: "TestWebhookInject_no_initContainers_containers_volumes_imagePullSecrets.yaml",
587-
wantFile: "TestWebhookInject_no_initcontainers_containers_volumes_imagePullSecrets.patch",
588-
},
589-
{
590-
inputFile: "TestWebhookInject_replace.yaml",
591-
wantFile: "TestWebhookInject_replace.patch",
592-
},
593-
{
594-
inputFile: "TestWebhookInject_replace_backwards_compat.yaml",
595-
wantFile: "TestWebhookInject_replace_backwards_compat.patch",
521+
// {
522+
// inputFile: "TestWebhookInject.yaml",
523+
// wantFile: "TestWebhookInject.patch",
524+
// },
525+
// {
526+
// inputFile: "TestWebhookInject_no_initContainers.yaml",
527+
// wantFile: "TestWebhookInject_no_initContainers.patch",
528+
// },
529+
// {
530+
// inputFile: "TestWebhookInject_no_containers.yaml",
531+
// wantFile: "TestWebhookInject_no_containers.patch",
532+
// },
533+
// {
534+
// inputFile: "TestWebhookInject_no_volumes.yaml",
535+
// wantFile: "TestWebhookInject_no_volumes.patch",
536+
// },
537+
// {
538+
// inputFile: "TestWebhookInject_no_imagePullSecrets.yaml",
539+
// wantFile: "TestWebhookInject_no_imagePullSecrets.patch",
540+
// },
541+
// {
542+
// inputFile: "TestWebhookInject_no_volumes_imagePullSecrets.yaml",
543+
// wantFile: "TestWebhookInject_no_volumes_imagePullSecrets.patch",
544+
// },
545+
// {
546+
// inputFile: "TestWebhookInject_no_containers_volumes_imagePullSecrets.yaml",
547+
// wantFile: "TestWebhookInject_no_containers_volumes_imagePullSecrets.patch",
548+
// },
549+
// {
550+
// inputFile: "TestWebhookInject_no_containers_volumes.yaml",
551+
// wantFile: "TestWebhookInject_no_containers_volumes.patch",
552+
// },
553+
// {
554+
// inputFile: "TestWebhookInject_no_containers_imagePullSecrets.yaml",
555+
// wantFile: "TestWebhookInject_no_containers_imagePullSecrets.patch",
556+
// },
557+
// {
558+
// inputFile: "TestWebhookInject_no_initContainers_containers.yaml",
559+
// wantFile: "TestWebhookInject_no_initContainers_containers.patch",
560+
// },
561+
// {
562+
// inputFile: "TestWebhookInject_no_initContainers_volumes.yaml",
563+
// wantFile: "TestWebhookInject_no_initContainers_volumes.patch",
564+
// },
565+
// {
566+
// inputFile: "TestWebhookInject_no_initContainers_imagePullSecrets.yaml",
567+
// wantFile: "TestWebhookInject_no_initContainers_imagePullSecrets.patch",
568+
// },
569+
// {
570+
// inputFile: "TestWebhookInject_no_containers_volumes_imagePullSecrets.yaml",
571+
// wantFile: "TestWebhookInject_no_containers_volumes_imagePullSecrets.patch",
572+
// },
573+
// {
574+
// inputFile: "TestWebhookInject_no_initContainers_volumes_imagePullSecrets.yaml",
575+
// wantFile: "TestWebhookInject_no_initContainers_volumes_imagePullSecrets.patch",
576+
// },
577+
// {
578+
// inputFile: "TestWebhookInject_no_initContainers_containers_volumes.yaml",
579+
// wantFile: "TestWebhookInject_no_initContainers_containers_volumes.patch",
580+
// },
581+
// {
582+
// inputFile: "TestWebhookInject_no_initContainers_containers_imagePullSecrets.yaml",
583+
// wantFile: "TestWebhookInject_no_initContainers_containers_imagePullSecrets.patch",
584+
// },
585+
// {
586+
// inputFile: "TestWebhookInject_no_initContainers_containers_volumes_imagePullSecrets.yaml",
587+
// wantFile: "TestWebhookInject_no_initcontainers_containers_volumes_imagePullSecrets.patch",
588+
// },
589+
// {
590+
// inputFile: "TestWebhookInject_replace.yaml",
591+
// wantFile: "TestWebhookInject_replace.patch",
592+
// },
593+
// {
594+
// inputFile: "TestWebhookInject_replace_backwards_compat.yaml",
595+
// wantFile: "TestWebhookInject_replace_backwards_compat.patch",
596+
// },
597+
{
598+
inputFile: "TestWebhookInject_http_probe_rewrite.yaml",
599+
wantFile: "TestWebhookInject_http_probe_rewrite.patch",
596600
},
597601
}
598602

@@ -614,10 +618,13 @@ func TestInject(t *testing.T) {
614618
},
615619
})
616620
var prettyPatch bytes.Buffer
621+
fmt.Println("jianfeih debug got ", string(got.Patch))
617622
if err := json.Indent(&prettyPatch, got.Patch, "", " "); err != nil {
618623
t.Fatalf(err.Error())
619624
}
625+
fmt.Println("jianfeih debug got ", string(prettyPatch.String()))
620626
util.CompareContent(prettyPatch.Bytes(), want, t)
627+
621628
})
622629
}
623630
}

0 commit comments

Comments
 (0)