Skip to content

Commit

Permalink
feat(tests): added test for restarter (#199)
Browse files Browse the repository at this point in the history
* fix(doc): typo

* feat(tests): added test for restarter

* fix(test): yamllint
  • Loading branch information
razvan authored Jan 11, 2024
1 parent 0872c6a commit af56115
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/modules/commons-operator/pages/index.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
= Stackable Commons Operator

This is an operator for Kubernetes that provides and manages common Object of the Stackable Data Platform.
This is an operator for Kubernetes that provides and manages common objects of
the Stackable Data Platform.
30 changes: 30 additions & 0 deletions tests/templates/kuttl/restarter/00-rbac.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: use-integration-tests-scc
rules:
{% if test_scenario['values']['openshift'] == "true" %}
- apiGroups: ["security.openshift.io"]
resources: ["securitycontextconstraints"]
resourceNames: ["privileged"]
verbs: ["use"]
{% endif %}
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: integration-tests-sa
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: use-integration-tests-scc
subjects:
- kind: ServiceAccount
name: integration-tests-sa
roleRef:
kind: Role
name: use-integration-tests-scc
apiGroup: rbac.authorization.k8s.io

12 changes: 12 additions & 0 deletions tests/templates/kuttl/restarter/10-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
timeout: 30
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: sleep
status:
readyReplicas: 1
replicas: 1
43 changes: 43 additions & 0 deletions tests/templates/kuttl/restarter/10-sleep.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: sleep
data:
property: value
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: sleep
labels:
restarter.stackable.tech/enabled: "true"
spec:
selector:
matchLabels:
app: sleep
serviceName: "sleep"
replicas: 1
template:
metadata:
labels:
app: sleep
spec:
serviceAccount: integration-tests-sa
volumes:
- name: config
configMap:
name: sleep
items:
- key: property
path: property
containers:
- name: sleep
image: alpine
command:
- sleep
args:
- infinity
volumeMounts:
- name: config
mountPath: /config
6 changes: 6 additions & 0 deletions tests/templates/kuttl/restarter/20-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
timeout: 180
commands:
- script: test "restarted" = $(kubectl exec sleep-0 -c sleep -n $NAMESPACE -- cat /config/property)
7 changes: 7 additions & 0 deletions tests/templates/kuttl/restarter/20-update-cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: sleep
data:
property: restarted
16 changes: 16 additions & 0 deletions tests/test-definition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
dimensions:
- name: openshift
values:
- "false"
tests:
- name: restarter
dimensions:
- openshift
suites:
- name: nightly
- name: openshift
patch:
- dimensions:
- name: openshift
expr: "true"

0 comments on commit af56115

Please sign in to comment.