Skip to content

Commit

Permalink
Use real MeshConfig for injection tests (#24808)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgn authored Jun 19, 2020
1 parent 8201457 commit 2fdf6cd
Show file tree
Hide file tree
Showing 60 changed files with 274 additions and 78 deletions.
14 changes: 6 additions & 8 deletions pkg/kube/inject/inject_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,10 @@ func TestIntoResourceFile(t *testing.T) {
testName := fmt.Sprintf("[%02d] %s", i, c.want)
t.Run(testName, func(t *testing.T) {
t.Parallel()
m := mesh.DefaultMeshConfig()
sidecarTemplate, valuesConfig, m := loadInjectionSettings(t, c.setFlags, c.inFilePath)
if c.mesh != nil {
c.mesh(&m)
c.mesh(m)
}
sidecarTemplate, valuesConfig := loadInjectionConfigMap(t, c.setFlags, c.inFilePath)
inputFilePath := "testdata/inject/" + c.in
wantFilePath := "testdata/inject/" + c.want
in, err := os.Open(inputFilePath)
Expand All @@ -315,7 +314,7 @@ func TestIntoResourceFile(t *testing.T) {
}
defer func() { _ = in.Close() }()
var got bytes.Buffer
if err = IntoResourceFile(sidecarTemplate.Template, valuesConfig, "", &m, in, &got); err != nil {
if err = IntoResourceFile(sidecarTemplate.Template, valuesConfig, "", m, in, &got); err != nil {
t.Fatalf("IntoResourceFile(%v) returned an error: %v", inputFilePath, err)
}

Expand Down Expand Up @@ -414,8 +413,7 @@ func TestRewriteAppProbe(t *testing.T) {
for i, c := range cases {
testName := fmt.Sprintf("[%02d] %s", i, c.want)
t.Run(testName, func(t *testing.T) {
m := mesh.DefaultMeshConfig()
sidecarTemplate, valuesConfig := loadInjectionConfigMap(t, nil, "")
sidecarTemplate, valuesConfig, m := loadInjectionSettings(t, nil, "")
inputFilePath := "testdata/inject/app_probe/" + c.in
wantFilePath := "testdata/inject/app_probe/" + c.want
in, err := os.Open(inputFilePath)
Expand All @@ -424,7 +422,7 @@ func TestRewriteAppProbe(t *testing.T) {
}
defer func() { _ = in.Close() }()
var got bytes.Buffer
if err = IntoResourceFile(sidecarTemplate.Template, valuesConfig, "", &m, in, &got); err != nil {
if err = IntoResourceFile(sidecarTemplate.Template, valuesConfig, "", m, in, &got); err != nil {
t.Fatalf("IntoResourceFile(%v) returned an error: %v", inputFilePath, err)
}

Expand Down Expand Up @@ -469,7 +467,7 @@ func TestInvalidAnnotations(t *testing.T) {
m := mesh.DefaultMeshConfig()
for _, c := range cases {
t.Run(c.annotation, func(t *testing.T) {
sidecarTemplate, valuesConfig := loadInjectionConfigMap(t, nil, "")
sidecarTemplate, valuesConfig, _ := loadInjectionSettings(t, nil, "")
inputFilePath := "testdata/inject/" + c.in
in, err := os.Open(inputFilePath)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ spec:
fieldPath: metadata.labels['service.istio.io/canonical-revision']
- name: PROXY_CONFIG
value: |
{}
{"proxyMetadata":{"DNS_AGENT":""}}
- name: ISTIO_META_POD_PORTS
value: |-
[
Expand All @@ -131,6 +131,7 @@ spec:
value: kubernetes://apis/apps/v1/namespaces/default/deployments/hello
- name: ISTIO_META_MESH_ID
value: cluster.local
- name: DNS_AGENT
- name: ISTIO_KUBE_APP_PROBERS
value: '{"/app-health/hello/livez":{"httpGet":{"port":80}},"/app-health/hello/readyz":{"httpGet":{"port":3333}},"/app-health/world/livez":{"httpGet":{"port":90}}}'
image: gcr.io/istio-testing/proxyv2:latest
Expand Down Expand Up @@ -194,6 +195,8 @@ spec:
- '*'
- -d
- 15090,15021,15020
env:
- name: DNS_AGENT
image: gcr.io/istio-testing/proxyv2:latest
imagePullPolicy: Always
name: istio-init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ spec:
fieldPath: metadata.labels['service.istio.io/canonical-revision']
- name: PROXY_CONFIG
value: |
{}
{"proxyMetadata":{"DNS_AGENT":""}}
- name: ISTIO_META_POD_PORTS
value: |-
[
Expand All @@ -128,6 +128,7 @@ spec:
value: kubernetes://apis/apps/v1/namespaces/default/deployments/hello
- name: ISTIO_META_MESH_ID
value: cluster.local
- name: DNS_AGENT
image: gcr.io/istio-testing/proxyv2:latest
imagePullPolicy: Always
name: istio-proxy
Expand Down Expand Up @@ -189,6 +190,8 @@ spec:
- '*'
- -d
- 15090,15021,15020
env:
- name: DNS_AGENT
image: gcr.io/istio-testing/proxyv2:latest
imagePullPolicy: Always
name: istio-init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ spec:
fieldPath: metadata.labels['service.istio.io/canonical-revision']
- name: PROXY_CONFIG
value: |
{}
{"proxyMetadata":{"DNS_AGENT":""}}
- name: ISTIO_META_POD_PORTS
value: |-
[
Expand All @@ -127,6 +127,7 @@ spec:
value: kubernetes://apis/apps/v1/namespaces/default/deployments/hello
- name: ISTIO_META_MESH_ID
value: cluster.local
- name: DNS_AGENT
- name: ISTIO_KUBE_APP_PROBERS
value: '{"/app-health/hello/livez":{"httpGet":{"port":80}},"/app-health/hello/readyz":{"httpGet":{"port":3333}},"/app-health/world/livez":{"httpGet":{"port":90}}}'
image: gcr.io/istio-testing/proxyv2:latest
Expand Down Expand Up @@ -190,6 +191,8 @@ spec:
- '*'
- -d
- 15090,15021,15020
env:
- name: DNS_AGENT
image: gcr.io/istio-testing/proxyv2:latest
imagePullPolicy: Always
name: istio-init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ spec:
fieldPath: metadata.labels['service.istio.io/canonical-revision']
- name: PROXY_CONFIG
value: |
{}
{"proxyMetadata":{"DNS_AGENT":""}}
- name: ISTIO_META_POD_PORTS
value: |-
[
Expand All @@ -106,6 +106,7 @@ spec:
value: kubernetes://apis/apps/v1/namespaces/default/deployments/hello
- name: ISTIO_META_MESH_ID
value: cluster.local
- name: DNS_AGENT
- name: ISTIO_KUBE_APP_PROBERS
value: '{"/app-health/hello/readyz":{"httpGet":{"path":"/ip","port":8000}}}'
image: gcr.io/istio-testing/proxyv2:latest
Expand Down Expand Up @@ -169,6 +170,8 @@ spec:
- '*'
- -d
- 15090,15021,15020
env:
- name: DNS_AGENT
image: gcr.io/istio-testing/proxyv2:latest
imagePullPolicy: Always
name: istio-init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ spec:
fieldPath: metadata.labels['service.istio.io/canonical-revision']
- name: PROXY_CONFIG
value: |
{}
{"proxyMetadata":{"DNS_AGENT":""}}
- name: ISTIO_META_POD_PORTS
value: |-
[
Expand All @@ -128,6 +128,7 @@ spec:
value: kubernetes://apis/apps/v1/namespaces/default/deployments/hello
- name: ISTIO_META_MESH_ID
value: cluster.local
- name: DNS_AGENT
- name: ISTIO_KUBE_APP_PROBERS
value: '{"/app-health/hello/livez":{"httpGet":{"port":80}},"/app-health/hello/readyz":{"httpGet":{"port":3333,"scheme":"HTTPS"}},"/app-health/world/livez":{"httpGet":{"port":90}}}'
image: gcr.io/istio-testing/proxyv2:latest
Expand Down Expand Up @@ -191,6 +192,8 @@ spec:
- '*'
- -d
- 15090,15021,15020
env:
- name: DNS_AGENT
image: gcr.io/istio-testing/proxyv2:latest
imagePullPolicy: Always
name: istio-init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ spec:
fieldPath: metadata.labels['service.istio.io/canonical-revision']
- name: PROXY_CONFIG
value: |
{}
{"proxyMetadata":{"DNS_AGENT":""}}
- name: ISTIO_META_POD_PORTS
value: |-
[
Expand All @@ -106,6 +106,7 @@ spec:
value: kubernetes://apis/apps/v1/namespaces/default/deployments/hello
- name: ISTIO_META_MESH_ID
value: cluster.local
- name: DNS_AGENT
- name: ISTIO_KUBE_APP_PROBERS
value: '{"/app-health/hello/readyz":{"httpGet":{"port":80}}}'
image: gcr.io/istio-testing/proxyv2:latest
Expand Down Expand Up @@ -169,6 +170,8 @@ spec:
- '*'
- -d
- 15090,15021,15020
env:
- name: DNS_AGENT
image: gcr.io/istio-testing/proxyv2:latest
imagePullPolicy: Always
name: istio-init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ spec:
fieldPath: metadata.labels['service.istio.io/canonical-revision']
- name: PROXY_CONFIG
value: |
{}
{"proxyMetadata":{"DNS_AGENT":""}}
- name: ISTIO_META_POD_PORTS
value: |-
[
Expand All @@ -110,6 +110,7 @@ spec:
value: kubernetes://apis/apps/v1/namespaces/default/deployments/hello
- name: ISTIO_META_MESH_ID
value: cluster.local
- name: DNS_AGENT
- name: ISTIO_KUBE_APP_PROBERS
value: '{"/app-health/hello/livez":{"httpGet":{"port":80}},"/app-health/hello/readyz":{"httpGet":{"port":3333}}}'
image: gcr.io/istio-testing/proxyv2:latest
Expand Down Expand Up @@ -173,6 +174,8 @@ spec:
- '*'
- -d
- 15090,15021,15020
env:
- name: DNS_AGENT
image: gcr.io/istio-testing/proxyv2:latest
imagePullPolicy: Always
name: istio-init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ spec:
fieldPath: metadata.labels['service.istio.io/canonical-revision']
- name: PROXY_CONFIG
value: |
{}
{"proxyMetadata":{"DNS_AGENT":""}}
- name: ISTIO_META_POD_PORTS
value: |-
[
Expand All @@ -127,6 +127,7 @@ spec:
value: kubernetes://apis/apps/v1/namespaces/default/deployments/hello
- name: ISTIO_META_MESH_ID
value: cluster.local
- name: DNS_AGENT
- name: ISTIO_KUBE_APP_PROBERS
value: '{"/app-health/hello/livez":{"httpGet":{"port":80}},"/app-health/hello/readyz":{"httpGet":{"port":3333}},"/app-health/world/livez":{"httpGet":{"port":90}}}'
image: gcr.io/istio-testing/proxyv2:latest
Expand Down Expand Up @@ -190,6 +191,8 @@ spec:
- '*'
- -d
- 15090,15021,15020
env:
- name: DNS_AGENT
image: gcr.io/istio-testing/proxyv2:latest
imagePullPolicy: Always
name: istio-init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ spec:
fieldPath: metadata.labels['service.istio.io/canonical-revision']
- name: PROXY_CONFIG
value: |
{}
{"proxyMetadata":{"DNS_AGENT":""}}
- name: ISTIO_META_POD_PORTS
value: |-
[
Expand All @@ -106,6 +106,7 @@ spec:
value: kubernetes://apis/apps/v1/namespaces/default/deployments/hello
- name: ISTIO_META_MESH_ID
value: cluster.local
- name: DNS_AGENT
- name: ISTIO_KUBE_APP_PROBERS
value: '{"/app-health/hello/readyz":{"httpGet":{"port":3333}}}'
image: gcr.io/istio-testing/proxyv2:latest
Expand Down Expand Up @@ -169,6 +170,8 @@ spec:
- '*'
- -d
- 15090,15021,15020
env:
- name: DNS_AGENT
image: gcr.io/istio-testing/proxyv2:latest
imagePullPolicy: Always
name: istio-init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ spec:
fieldPath: metadata.labels['service.istio.io/canonical-revision']
- name: PROXY_CONFIG
value: |
{}
{"proxyMetadata":{"DNS_AGENT":""}}
- name: ISTIO_META_POD_PORTS
value: |-
[
Expand All @@ -127,6 +127,7 @@ spec:
value: kubernetes://apis/apps/v1/namespaces/default/deployments/hello
- name: ISTIO_META_MESH_ID
value: cluster.local
- name: DNS_AGENT
- name: ISTIO_KUBE_APP_PROBERS
value: '{"/app-health/hello/livez":{"httpGet":{"port":80}},"/app-health/hello/startupz":{"httpGet":{"port":3333}},"/app-health/world/livez":{"httpGet":{"port":90}}}'
image: gcr.io/istio-testing/proxyv2:latest
Expand Down Expand Up @@ -190,6 +191,8 @@ spec:
- '*'
- -d
- 15090,15021,15020
env:
- name: DNS_AGENT
image: gcr.io/istio-testing/proxyv2:latest
imagePullPolicy: Always
name: istio-init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ spec:
fieldPath: metadata.labels['service.istio.io/canonical-revision']
- name: PROXY_CONFIG
value: |
{}
{"proxyMetadata":{"DNS_AGENT":""}}
- name: ISTIO_META_POD_PORTS
value: |-
[
Expand All @@ -106,6 +106,7 @@ spec:
value: kubernetes://apis/apps/v1/namespaces/default/deployments/hello
- name: ISTIO_META_MESH_ID
value: cluster.local
- name: DNS_AGENT
- name: ISTIO_KUBE_APP_PROBERS
value: '{"/app-health/hello/startupz":{"httpGet":{"port":3333}}}'
image: gcr.io/istio-testing/proxyv2:latest
Expand Down Expand Up @@ -169,6 +170,8 @@ spec:
- '*'
- -d
- 15090,15021,15020
env:
- name: DNS_AGENT
image: gcr.io/istio-testing/proxyv2:latest
imagePullPolicy: Always
name: istio-init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ spec:
fieldPath: metadata.labels['service.istio.io/canonical-revision']
- name: PROXY_CONFIG
value: |
{}
{"proxyMetadata":{"DNS_AGENT":""}}
- name: ISTIO_META_POD_PORTS
value: |-
[
Expand All @@ -135,6 +135,7 @@ spec:
value: kubernetes://apis/apps/v1/namespaces/default/deployments/hello
- name: ISTIO_META_MESH_ID
value: cluster.local
- name: DNS_AGENT
- name: ISTIO_KUBE_APP_PROBERS
value: '{"/app-health/hello/livez":{"httpGet":{"port":80}},"/app-health/hello/readyz":{"httpGet":{"port":3333}},"/app-health/hello/startupz":{"httpGet":{"port":3333}},"/app-health/world/livez":{"httpGet":{"port":90}},"/app-health/world/startupz":{"httpGet":{"port":90}}}'
image: gcr.io/istio-testing/proxyv2:latest
Expand Down Expand Up @@ -198,6 +199,8 @@ spec:
- '*'
- -d
- 15090,15021,15020
env:
- name: DNS_AGENT
image: gcr.io/istio-testing/proxyv2:latest
imagePullPolicy: Always
name: istio-init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ spec:
fieldPath: metadata.labels['service.istio.io/canonical-revision']
- name: PROXY_CONFIG
value: |
{}
{"proxyMetadata":{"DNS_AGENT":""}}
- name: ISTIO_META_POD_PORTS
value: |-
[
Expand All @@ -118,6 +118,7 @@ spec:
value: kubernetes://apis/apps/v1/namespaces/default/deployments/hello
- name: ISTIO_META_MESH_ID
value: cluster.local
- name: DNS_AGENT
- name: ISTIO_KUBE_APP_PROBERS
value: '{"/app-health/hello/readyz":{"httpGet":{"path":"/ip","port":8000}},"/app-health/world/readyz":{"httpGet":{"path":"/ipv6","port":9000}}}'
image: gcr.io/istio-testing/proxyv2:latest
Expand Down Expand Up @@ -181,6 +182,8 @@ spec:
- '*'
- -d
- 15090,15021,15020
env:
- name: DNS_AGENT
image: gcr.io/istio-testing/proxyv2:latest
imagePullPolicy: Always
name: istio-init
Expand Down
Loading

0 comments on commit 2fdf6cd

Please sign in to comment.