Add more kubernetes Service tests (#62581)
* Add more kubernetes Service tests Services can often go wrong, and one of the main motivations for apply was being able to correctly modify them, so more tests are good * Remove a port from a service for k8s testing * Add a Service check mode to k8s tests
This commit is contained in:
parent
8d1aa42e7b
commit
07ed860c2b
1 changed files with 86 additions and 0 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue