Commit 9942ab9d by Guangbo Chen Committed by Craig Jellick

Add istio helm unittest

parent 4bd1f8a5
suite: Test Galley Deployment
templates:
- deployment.yaml
tests:
- it: should pass all kinds of assertion
asserts:
- equal:
path: spec.replicas
value: 1
- equal:
path: spec.template.spec.containers[0].ports
value:
- containerPort: 443
- containerPort: 15014
- containerPort: 9901
- isNull:
path: spec.template.nodeSelector
- isNotNull:
path: spec.template
- isNotEmpty:
path: spec.template.spec.containers[0].resources
- isNotEmpty:
path: spec.template.spec.containers[0]
- isKind:
of: Deployment
- isAPIVersion:
of: extensions/v1beta1
- hasDocuments:
count: 1
suite: Test Galley RBAC
templates:
- clusterrole.yaml
tests:
- it: should pass all kinds of assertion
set:
asserts:
- isNotNull:
path: rules
- isNotEmpty:
path: rules
- contains:
path: rules
content:
apiGroups: ["admissionregistration.k8s.io"]
resources: ["validatingwebhookconfigurations"]
verbs: ["*"]
- isKind:
of: ClusterRole
- isAPIVersion:
of: rbac.authorization.k8s.io/v1
- hasDocuments:
count: 1
suite: Test Gateway Deployment
templates:
- deployment.yaml
tests:
- it: should pass all kinds of assertion
set:
istio-ingressgateway.enabled: true
istio-ilbgateway.enabled: false
istio-egressgateway.enabled: false
istio-ingressgateway.autoscaleEnabled: true
asserts:
- isNull:
path: spec.replicas
- contains:
path: spec.template.spec.containers[0].ports
content:
containerPort: 80
- contains:
path: spec.template.spec.containers[0].ports
content:
containerPort: 443
- isNull:
path: spec.template.nodeSelector
- isNotNull:
path: spec.template
- isNotEmpty:
path: spec.template.spec.containers[0].resources
- isNotEmpty:
path: spec.template.spec.containers[0]
- isKind:
of: Deployment
- isAPIVersion:
of: extensions/v1beta1
- hasDocuments:
count: 1
- it: should deploy 3 gateways
set:
istio-ingressgateway.enabled: true
istio-ilbgateway.enabled: true
istio-egressgateway.enabled: true
asserts:
- isKind:
of: Deployment
- isAPIVersion:
of: extensions/v1beta1
- hasDocuments:
count: 3
- it: should not deploy gateways
set:
istio-ingressgateway.enabled: false
istio-ilbgateway.enabled: false
istio-egressgateway.enabled: false
asserts:
- hasDocuments:
count: 0
suite: Test Istio Grafana Deployment
templates:
- deployment.yaml
tests:
- it: should pass all kinds of assertion
set:
replicaCount: 1
asserts:
- equal:
path: spec.replicas
value: 1
- isNull:
path: spec.template.nodeSelector
- isNotNull:
path: spec.template
- isNotEmpty:
path: spec.template.spec.containers[0].resources
- isNotEmpty:
path: spec.template.spec.containers[0]
- isKind:
of: Deployment
- isAPIVersion:
of: extensions/v1beta1
- hasDocuments:
count: 1
suite: Test Istio Kiali Deployment
templates:
- deployment.yaml
tests:
- it: should pass all kinds of assertion
set:
replicaCount: 1
asserts:
- equal:
path: spec.replicas
value: 1
- isNull:
path: spec.template.nodeSelector
- isNotNull:
path: spec.template
- isNotEmpty:
path: spec.template.spec.containers[0].resources
- isNotEmpty:
path: spec.template.spec.containers[0]
- isKind:
of: Deployment
- isAPIVersion:
of: extensions/v1beta1
- hasDocuments:
count: 1
suite: Test Istio Mixer Deployment
templates:
- deployment.yaml
tests:
- it: should pass all kinds of assertion
set:
policy.enabled: true
telemetry.enabled: false
asserts:
- isNull:
path: spec.replicas
- isNull:
path: spec.template.nodeSelector
- isNotNull:
path: spec.template
- isNotEmpty:
path: spec.template.spec.containers[0].resources
- isNotEmpty:
path: spec.template.spec.containers[0]
- isKind:
of: Deployment
- isAPIVersion:
of: extensions/v1beta1
- hasDocuments:
count: 1
- it: should pass all kinds of assertion
set:
policy.enabled: false
telemetry.enabled: true
asserts:
- isNull:
path: spec.replicas
- isNull:
path: spec.template.nodeSelector
- isNotNull:
path: spec.template
- isNotEmpty:
path: spec.template.spec.containers[0].resources
- isNotEmpty:
path: spec.template.spec.containers[0]
- isKind:
of: Deployment
- isAPIVersion:
of: extensions/v1beta1
- hasDocuments:
count: 1
- it: should pass all kinds of assertion
set:
policy.enabled: true
telemetry.enabled: true
asserts:
- isKind:
of: Deployment
- isAPIVersion:
of: extensions/v1beta1
- hasDocuments:
count: 2
suite: Test Pilot Deployment
templates:
- deployment.yaml
tests:
- it: should pass all kinds of assertion
set:
service.internalPort: 8080
sidecar: true
asserts:
- equal:
path: spec.template.spec.containers[0].image
value: istio/pilot:1.1.5
- notEqual:
path: spec.template.spec.containers[0].image
value: istio/pilot:1.1
- matchRegex:
path: metadata.name
pattern: .*istio-pilot.*
- contains:
path: spec.template.spec.containers[0].ports
content:
containerPort: 8080
- isNull:
path: spec.template.nodeSelector
- isNotNull:
path: spec.template
- isNotEmpty:
path: spec.template.spec.containers[0].resources
- isNotEmpty:
path: spec.template.spec.containers[0]
- isKind:
of: Deployment
- isAPIVersion:
of: extensions/v1beta1
- hasDocuments:
count: 1
# sidecar tests
- equal:
path: spec.template.spec.containers[1].name
value: istio-proxy
- notContains:
path: spec.template.spec.containers[0].ports
content:
containerPort: 15011
- it: should not set replicas
set:
autoscaleEnabled: true
asserts:
- equal:
path: spec.replicas
value: null
- it: should not add sidecar
set:
sidecar: false
asserts:
- contains:
path: spec.template.spec.containers[0].ports
content:
containerPort: 15011
- contains:
path: spec.template.spec.containers[0].args
content:
--secureGrpcAddr
suite: Test Istio Prometheus Deployment
templates:
- deployment.yaml
tests:
- it: should pass all kinds of assertion
set:
replicaCount: 1
asserts:
- equal:
path: spec.replicas
value: 1
- isNull:
path: spec.template.nodeSelector
- isNotNull:
path: spec.template
- isNotEmpty:
path: spec.template.spec.containers[0].resources
- isNotEmpty:
path: spec.template.spec.containers[0]
- isKind:
of: Deployment
- isAPIVersion:
of: extensions/v1beta1
- hasDocuments:
count: 1
suite: Test Istio Citadel Deployment
templates:
- deployment.yaml
tests:
- it: should pass all kinds of assertion
set:
replicaCount: 1
asserts:
- equal:
path: spec.replicas
value: 1
- isNull:
path: spec.template.nodeSelector
- isNotNull:
path: spec.template
- isNotEmpty:
path: spec.template.spec.containers[0].resources
- isNotEmpty:
path: spec.template.spec.containers[0]
- isKind:
of: Deployment
- isAPIVersion:
of: extensions/v1beta1
- hasDocuments:
count: 1
suite: Test SidecarInjectorWebhook MutatingWebhook
templates:
- mutatingwebhook.yaml
tests:
- it: should pass all kinds of assertion
set:
enableNamespacesByDefault: false
asserts:
- isNull:
path: webhooks[0].namespaceSelector.matchExpressions
- isEmpty:
path: webhooks[0].namespaceSelector.matchExpressions
- isNotNull:
path: webhooks[0].namespaceSelector.matchLabels
- isNotEmpty:
path: webhooks[0].namespaceSelector.matchLabels
- contains:
path: webhooks[0].rules
content:
operations: [ "CREATE" ]
apiGroups: [""]
apiVersions: ["v1"]
resources: ["pods"]
- isKind:
of: MutatingWebhookConfiguration
- isAPIVersion:
of: admissionregistration.k8s.io/v1beta1
- hasDocuments:
count: 1
- it: should not set autoInjection selector
set:
enableNamespacesByDefault: true
asserts:
- isNotNull:
path: webhooks[0].namespaceSelector.matchExpressions
- isNotEmpty:
path: webhooks[0].namespaceSelector.matchExpressions
- isNull:
path: webhooks[0].namespaceSelector.matchLabels
- isEmpty:
path: webhooks[0].namespaceSelector.matchLabels
suite: Test SidecarInjectorWebhook RBAC
templates:
- clusterrole.yaml
tests:
- it: should pass all kinds of assertion
set:
provider: jaeger
asserts:
- isNotNull:
path: rules
- isNotEmpty:
path: rules
- contains:
path: rules
content:
apiGroups: ["admissionregistration.k8s.io"]
resources: ["mutatingwebhookconfigurations"]
verbs: ["get", "list", "watch", "patch"]
- isKind:
of: ClusterRole
- isAPIVersion:
of: rbac.authorization.k8s.io/v1
- hasDocuments:
count: 1
suite: Test Jaeger Deployment
templates:
- deployment-jaeger.yaml
- deployment-zipkin.yaml
tests:
- it: should pass all kinds of assertion
set:
provider: jaeger
asserts:
- equal:
path: spec.template.spec.containers[0].image
value: jaegertracing/all-in-one:1.9
- equal:
path: spec.template.metadata.labels.app
value: jaeger
- equal:
path: spec.template.spec.containers[0].name
value: jaeger
- isNull:
path: spec.template.nodeSelector
- isNotNull:
path: spec.template
- isNotEmpty:
path: spec.template.spec.containers[0].resources
- isNotEmpty:
path: spec.template.spec.containers[0]
- isKind:
of: Deployment
- isAPIVersion:
of: extensions/v1beta1
- hasDocuments:
count: 1
- it: should not deploy jaeger
set:
provider: zipkin
asserts:
- hasDocuments:
count: 0
suite: Test Zipkinn Deployment
templates:
- deployment-zipkin.yaml
tests:
- it: should pass all kinds of assertion
set:
provider: zipkin
asserts:
- equal:
path: spec.template.spec.containers[0].image
value: openzipkin/zipkin:2
- equal:
path: spec.template.metadata.labels.app
value: zipkin
- equal:
path: spec.template.spec.containers[0].name
value: tracing
- isNull:
path: spec.template.nodeSelector
- isNotNull:
path: spec.template
- isNotEmpty:
path: spec.template.spec.containers[0].resources
- isNotEmpty:
path: spec.template.spec.containers[0]
- isKind:
of: Deployment
- isAPIVersion:
of: extensions/v1beta1
- hasDocuments:
count: 1
- it: should not deploy zipkin
set:
provider: jaeger
asserts:
- hasDocuments:
count: 0
suite: Test Certmanager CRDs
templates:
- crd-certmanager.yaml
tests:
- it: should create certmanager CRDs
set:
enableCRDs: true
certmanager.enabled: true
asserts:
- hasDocuments:
count: 5
- isKind:
of: CustomResourceDefinition
- it: should not render certmanager CRDs
set:
enableCRDs: true
certmanager.enabled: false
asserts:
- hasDocuments:
count: 0
- it: should set helm crd hook annotations
set:
enableCRDs: true
certmanager.enabled: true
asserts:
- equal:
path: metadata.annotations
value:
helm.sh/resource-policy: keep
helm.sh/hook: "crd-install"
suite: Test Istio CRDs
templates:
- crds.yaml
tests:
- it: should create custom resource definition
set:
enableCRDs: true
asserts:
- hasDocuments:
count: 53 #istio v1.1.5 contains total 53 CRDs
- isKind:
of: CustomResourceDefinition
- it: should not render custom resource definition
set:
enableCRDs: false
asserts:
- hasDocuments:
count: 0
- it: should set helm crd hook annotations
set:
enableCRDs: true
asserts:
- equal:
path: metadata.annotations
value:
helm.sh/resource-policy: keep
helm.sh/hook: "crd-install"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment