Skip to content

Commit

Permalink
get webhook_test.TestInject working.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jianfei Hu committed Dec 12, 2018
1 parent 06f517c commit fcca1f8
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
"value": {
"name": "istio-proxy",
"image": "example.com/proxy:latest",
"args": [
"--statusPort",
"15020"
],
"resources": {}
}
},
Expand Down Expand Up @@ -60,5 +64,46 @@
"value": {
"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\"]}"
}
},
{
"op": "replace",
"path": "/spec/containers/1/readinessProbe",
"value": {
"path": "/ready",
"port": 15020,
"httpHeaders": [
{
"name": "istio-app-probe-port",
"value": "3333"
}
]
}
},
{
"op": "replace",
"path": "/spec/containers/1/livenessProbe",
"value": {
"path": "/live",
"port": 15020,
"httpHeaders": [
{
"name": "istio-app-probe-port",
"value": "0"
}
]
}
},
{
"op": "replace",
"path": "/spec/containers/2/livenessProbe",
"value": {
"port": 15020,
"httpHeaders": [
{
"name": "istio-app-probe-port",
"value": "9000"
}
]
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ initContainers:
containers:
- name: istio-proxy
image: example.com/proxy:latest
args:
- --statusPort
- 15020
imagePullSecrets:
- name: istio-image-pull-secrets
volumes:
Expand Down
154 changes: 76 additions & 78 deletions pilot/pkg/kube/inject/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,82 +518,82 @@ func TestInject(t *testing.T) {
inputFile string
wantFile string
}{
// {
// inputFile: "TestWebhookInject.yaml",
// wantFile: "TestWebhookInject.patch",
// },
// {
// inputFile: "TestWebhookInject_no_initContainers.yaml",
// wantFile: "TestWebhookInject_no_initContainers.patch",
// },
// {
// inputFile: "TestWebhookInject_no_containers.yaml",
// wantFile: "TestWebhookInject_no_containers.patch",
// },
// {
// inputFile: "TestWebhookInject_no_volumes.yaml",
// wantFile: "TestWebhookInject_no_volumes.patch",
// },
// {
// inputFile: "TestWebhookInject_no_imagePullSecrets.yaml",
// wantFile: "TestWebhookInject_no_imagePullSecrets.patch",
// },
// {
// inputFile: "TestWebhookInject_no_volumes_imagePullSecrets.yaml",
// wantFile: "TestWebhookInject_no_volumes_imagePullSecrets.patch",
// },
// {
// inputFile: "TestWebhookInject_no_containers_volumes_imagePullSecrets.yaml",
// wantFile: "TestWebhookInject_no_containers_volumes_imagePullSecrets.patch",
// },
// {
// inputFile: "TestWebhookInject_no_containers_volumes.yaml",
// wantFile: "TestWebhookInject_no_containers_volumes.patch",
// },
// {
// inputFile: "TestWebhookInject_no_containers_imagePullSecrets.yaml",
// wantFile: "TestWebhookInject_no_containers_imagePullSecrets.patch",
// },
// {
// inputFile: "TestWebhookInject_no_initContainers_containers.yaml",
// wantFile: "TestWebhookInject_no_initContainers_containers.patch",
// },
// {
// inputFile: "TestWebhookInject_no_initContainers_volumes.yaml",
// wantFile: "TestWebhookInject_no_initContainers_volumes.patch",
// },
// {
// inputFile: "TestWebhookInject_no_initContainers_imagePullSecrets.yaml",
// wantFile: "TestWebhookInject_no_initContainers_imagePullSecrets.patch",
// },
// {
// inputFile: "TestWebhookInject_no_containers_volumes_imagePullSecrets.yaml",
// wantFile: "TestWebhookInject_no_containers_volumes_imagePullSecrets.patch",
// },
// {
// inputFile: "TestWebhookInject_no_initContainers_volumes_imagePullSecrets.yaml",
// wantFile: "TestWebhookInject_no_initContainers_volumes_imagePullSecrets.patch",
// },
// {
// inputFile: "TestWebhookInject_no_initContainers_containers_volumes.yaml",
// wantFile: "TestWebhookInject_no_initContainers_containers_volumes.patch",
// },
// {
// inputFile: "TestWebhookInject_no_initContainers_containers_imagePullSecrets.yaml",
// wantFile: "TestWebhookInject_no_initContainers_containers_imagePullSecrets.patch",
// },
// {
// inputFile: "TestWebhookInject_no_initContainers_containers_volumes_imagePullSecrets.yaml",
// wantFile: "TestWebhookInject_no_initcontainers_containers_volumes_imagePullSecrets.patch",
// },
// {
// inputFile: "TestWebhookInject_replace.yaml",
// wantFile: "TestWebhookInject_replace.patch",
// },
// {
// inputFile: "TestWebhookInject_replace_backwards_compat.yaml",
// wantFile: "TestWebhookInject_replace_backwards_compat.patch",
// },
{
inputFile: "TestWebhookInject.yaml",
wantFile: "TestWebhookInject.patch",
},
{
inputFile: "TestWebhookInject_no_initContainers.yaml",
wantFile: "TestWebhookInject_no_initContainers.patch",
},
{
inputFile: "TestWebhookInject_no_containers.yaml",
wantFile: "TestWebhookInject_no_containers.patch",
},
{
inputFile: "TestWebhookInject_no_volumes.yaml",
wantFile: "TestWebhookInject_no_volumes.patch",
},
{
inputFile: "TestWebhookInject_no_imagePullSecrets.yaml",
wantFile: "TestWebhookInject_no_imagePullSecrets.patch",
},
{
inputFile: "TestWebhookInject_no_volumes_imagePullSecrets.yaml",
wantFile: "TestWebhookInject_no_volumes_imagePullSecrets.patch",
},
{
inputFile: "TestWebhookInject_no_containers_volumes_imagePullSecrets.yaml",
wantFile: "TestWebhookInject_no_containers_volumes_imagePullSecrets.patch",
},
{
inputFile: "TestWebhookInject_no_containers_volumes.yaml",
wantFile: "TestWebhookInject_no_containers_volumes.patch",
},
{
inputFile: "TestWebhookInject_no_containers_imagePullSecrets.yaml",
wantFile: "TestWebhookInject_no_containers_imagePullSecrets.patch",
},
{
inputFile: "TestWebhookInject_no_initContainers_containers.yaml",
wantFile: "TestWebhookInject_no_initContainers_containers.patch",
},
{
inputFile: "TestWebhookInject_no_initContainers_volumes.yaml",
wantFile: "TestWebhookInject_no_initContainers_volumes.patch",
},
{
inputFile: "TestWebhookInject_no_initContainers_imagePullSecrets.yaml",
wantFile: "TestWebhookInject_no_initContainers_imagePullSecrets.patch",
},
{
inputFile: "TestWebhookInject_no_containers_volumes_imagePullSecrets.yaml",
wantFile: "TestWebhookInject_no_containers_volumes_imagePullSecrets.patch",
},
{
inputFile: "TestWebhookInject_no_initContainers_volumes_imagePullSecrets.yaml",
wantFile: "TestWebhookInject_no_initContainers_volumes_imagePullSecrets.patch",
},
{
inputFile: "TestWebhookInject_no_initContainers_containers_volumes.yaml",
wantFile: "TestWebhookInject_no_initContainers_containers_volumes.patch",
},
{
inputFile: "TestWebhookInject_no_initContainers_containers_imagePullSecrets.yaml",
wantFile: "TestWebhookInject_no_initContainers_containers_imagePullSecrets.patch",
},
{
inputFile: "TestWebhookInject_no_initContainers_containers_volumes_imagePullSecrets.yaml",
wantFile: "TestWebhookInject_no_initcontainers_containers_volumes_imagePullSecrets.patch",
},
{
inputFile: "TestWebhookInject_replace.yaml",
wantFile: "TestWebhookInject_replace.patch",
},
{
inputFile: "TestWebhookInject_replace_backwards_compat.yaml",
wantFile: "TestWebhookInject_replace_backwards_compat.patch",
},
{
inputFile: "TestWebhookInject_http_probe_rewrite.yaml",
wantFile: "TestWebhookInject_http_probe_rewrite.patch",
Expand Down Expand Up @@ -621,9 +621,7 @@ func TestInject(t *testing.T) {
if err := json.Indent(&prettyPatch, got.Patch, "", " "); err != nil {
t.Fatalf(err.Error())
}
fmt.Println("jianfeih debug got ", string(prettyPatch.String()))
util.CompareContent(prettyPatch.Bytes(), want, t)

})
}
}
Expand Down

0 comments on commit fcca1f8

Please sign in to comment.