diff --git a/test/integration/targets/k8s/tasks/apply.yml b/test/integration/targets/k8s/tasks/apply.yml index abfda06acfc..cf51123124d 100644 --- a/test/integration/targets/k8s/tasks/apply.yml +++ b/test/integration/targets/k8s/tasks/apply.yml @@ -132,6 +132,7 @@ - name: http port: 8080 targetPort: 8080 + type: NodePort apply: yes register: k8s_service @@ -150,6 +151,7 @@ - name: http port: 8080 targetPort: 8080 + type: NodePort apply: yes register: k8s_service_2 @@ -173,6 +175,7 @@ - name: http port: 8081 targetPort: 8081 + type: NodePort apply: yes register: k8s_service_3 @@ -183,6 +186,89 @@ - k8s_service_3.result.spec.ports | length == 1 - k8s_service_3.result.spec.ports[0].port == 8081 + - name: insert new service port + k8s: + definition: + apiVersion: v1 + kind: Service + metadata: + name: apply-svc + namespace: "{{ apply_namespace }}" + spec: + selector: + app: whatever + ports: + - name: mesh + port: 8080 + targetPort: 8080 + - name: http + port: 8081 + targetPort: 8081 + type: NodePort + apply: yes + register: k8s_service_4 + + - name: check ports are correct + assert: + that: + - k8s_service_4 is changed + - k8s_service_4.result.spec.ports | length == 2 + - k8s_service_4.result.spec.ports[0].port == 8080 + - k8s_service_4.result.spec.ports[1].port == 8081 + + - name: remove new service port (check mode) + k8s: + definition: + apiVersion: v1 + kind: Service + metadata: + name: apply-svc + namespace: "{{ apply_namespace }}" + spec: + selector: + app: whatever + ports: + - name: http + port: 8081 + targetPort: 8081 + type: NodePort + apply: yes + check_mode: yes + register: k8s_service_check + + - name: check ports are correct + assert: + that: + - k8s_service_check is changed + - k8s_service_check.result.spec.ports | length == 1 + - k8s_service_check.result.spec.ports[0].port == 8081 + + - name: remove new service port + k8s: + definition: + apiVersion: v1 + kind: Service + metadata: + name: apply-svc + namespace: "{{ apply_namespace }}" + spec: + selector: + app: whatever + ports: + - name: http + port: 8081 + targetPort: 8081 + type: NodePort + apply: yes + register: k8s_service_5 + + - name: check ports are correct + assert: + that: + - k8s_service_5 is changed + - k8s_service_5.result.spec.ports | length == 1 + - k8s_service_5.result.spec.ports[0].port == 8081 + always: - name: remove namespace k8s: