Skip to content

Commit 5e04a5c

Browse files
committed
feat: make smoke test use tls dimension
1 parent 689165e commit 5e04a5c

12 files changed

Lines changed: 139 additions & 171 deletions

tests/templates/kuttl/smoke/09-install-secretclass.yaml.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% if test_scenario['values']['use-tls'] == "true" %}
12
---
23
apiVersion: kuttl.dev/v1beta1
34
kind: TestStep
@@ -17,3 +18,5 @@ commands:
1718
secret:
1819
name: opa-tls-ca
1920
namespace: $NAMESPACE
21+
EOF
22+
{% endif %}

tests/templates/kuttl/smoke/10-assert.yaml.j2

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,12 @@ apiVersion: kuttl.dev/v1beta1
22
kind: TestAssert
33
timeout: 300
44
commands:
5-
- script: kubectl -n $NAMESPACE wait --for=condition=available opaclusters.opa.stackable.tech/test-opa-https --timeout 301s
6-
- script: kubectl -n $NAMESPACE wait --for=condition=available opaclusters.opa.stackable.tech/test-opa-http --timeout 301s
5+
- script: kubectl -n $NAMESPACE wait --for=condition=available opaclusters.opa.stackable.tech/test-opa --timeout 301s
76
---
87
apiVersion: apps/v1
98
kind: DaemonSet
109
metadata:
11-
name: test-opa-https-server-default
12-
spec:
13-
template:
14-
spec:
15-
containers:
16-
- name: opa
17-
resources:
18-
limits:
19-
cpu: 500m
20-
memory: 256Mi
21-
requests:
22-
cpu: 250m
23-
memory: 256Mi
24-
- name: bundle-builder
25-
resources:
26-
limits:
27-
cpu: 200m
28-
memory: 128Mi
29-
requests:
30-
cpu: 100m
31-
memory: 128Mi
32-
{% if lookup('env', 'VECTOR_AGGREGATOR') %}
33-
- name: vector
34-
{% endif %}
35-
terminationGracePeriodSeconds: 125 # 2 minutes + 5s safety buffer
36-
---
37-
apiVersion: apps/v1
38-
kind: DaemonSet
39-
metadata:
40-
name: test-opa-http-server-default
10+
name: test-opa-server-default
4111
spec:
4212
template:
4313
spec:
Lines changed: 48 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,57 @@
11
---
2-
apiVersion: v1
3-
kind: ConfigMap
4-
metadata:
5-
name: test
6-
labels:
7-
opa.stackable.tech/bundle: "true"
8-
data:
9-
test.rego: |
10-
package test
2+
apiVersion: kuttl.dev/v1beta1
3+
kind: TestStep
4+
commands:
5+
- script: |
6+
kubectl apply -n $NAMESPACE -f - <<EOF
7+
---
8+
apiVersion: v1
9+
kind: ConfigMap
10+
metadata:
11+
name: test
12+
labels:
13+
opa.stackable.tech/bundle: "true"
14+
data:
15+
test.rego: |
16+
package test
1117

12-
hello if {
13-
true
14-
}
18+
hello if {
19+
true
20+
}
1521

16-
world if {
17-
false
18-
}
19-
---
20-
apiVersion: opa.stackable.tech/v1alpha1
21-
kind: OpaCluster
22-
metadata:
23-
name: test-opa-https
24-
spec:
25-
image:
22+
world if {
23+
false
24+
}
25+
---
26+
apiVersion: opa.stackable.tech/v1alpha1
27+
kind: OpaCluster
28+
metadata:
29+
name: test-opa
30+
spec:
31+
image:
2632
{% if test_scenario['values']['opa'].find(",") > 0 %}
27-
custom: "{{ test_scenario['values']['opa'].split(',')[1] }}"
28-
productVersion: "{{ test_scenario['values']['opa'].split(',')[0] }}"
33+
custom: "{{ test_scenario['values']['opa'].split(',')[1] }}"
34+
productVersion: "{{ test_scenario['values']['opa'].split(',')[0] }}"
2935
{% else %}
30-
productVersion: "{{ test_scenario['values']['opa'] }}"
31-
{% endif %}
32-
pullPolicy: IfNotPresent
33-
clusterConfig:
34-
tls:
35-
serverSecretClass: opa-tls-$NAMESPACE
36-
{% if lookup('env', 'VECTOR_AGGREGATOR') %}
37-
vectorAggregatorConfigMapName: vector-aggregator-discovery
36+
productVersion: "{{ test_scenario['values']['opa'] }}"
3837
{% endif %}
39-
servers:
40-
config:
41-
logging:
42-
enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }}
43-
envOverrides:
44-
SERVER_ROLE_LEVEL_ENV_VAR: "SERVER_ROLE_LEVEL_ENV_VAR"
45-
roleGroups:
46-
default:
47-
envOverrides:
48-
SERVER_ROLE_GROUP_LEVEL_ENV_VAR: "SERVER_ROLE_GROUP_LEVEL_ENV_VAR"
49-
---
50-
apiVersion: opa.stackable.tech/v1alpha1
51-
kind: OpaCluster
52-
metadata:
53-
name: test-opa-http
54-
spec:
55-
image:
56-
{% if test_scenario['values']['opa'].find(",") > 0 %}
57-
custom: "{{ test_scenario['values']['opa'].split(',')[1] }}"
58-
productVersion: "{{ test_scenario['values']['opa'].split(',')[0] }}"
59-
{% else %}
60-
productVersion: "{{ test_scenario['values']['opa'] }}"
38+
pullPolicy: IfNotPresent
39+
clusterConfig:
40+
{% if test_scenario['values']['use-tls'] == "true" %}
41+
tls:
42+
serverSecretClass: opa-tls-$NAMESPACE
6143
{% endif %}
62-
pullPolicy: IfNotPresent
63-
clusterConfig:
6444
{% if lookup('env', 'VECTOR_AGGREGATOR') %}
65-
vectorAggregatorConfigMapName: vector-aggregator-discovery
45+
vectorAggregatorConfigMapName: vector-aggregator-discovery
6646
{% endif %}
67-
servers:
68-
config:
69-
logging:
70-
enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }}
71-
envOverrides:
72-
SERVER_ROLE_LEVEL_ENV_VAR: "SERVER_ROLE_LEVEL_ENV_VAR"
73-
roleGroups:
74-
default:
75-
envOverrides:
76-
SERVER_ROLE_GROUP_LEVEL_ENV_VAR: "SERVER_ROLE_GROUP_LEVEL_ENV_VAR"
47+
servers:
48+
config:
49+
logging:
50+
enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }}
51+
envOverrides:
52+
SERVER_ROLE_LEVEL_ENV_VAR: "SERVER_ROLE_LEVEL_ENV_VAR"
53+
roleGroups:
54+
default:
55+
envOverrides:
56+
SERVER_ROLE_GROUP_LEVEL_ENV_VAR: "SERVER_ROLE_GROUP_LEVEL_ENV_VAR"
57+
EOF

tests/templates/kuttl/smoke/11-assert.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,5 @@ kind: TestAssert
55
timeout: 600
66
commands:
77
- script: |
8-
FIRST_OPA_POD=$(kubectl get -n $NAMESPACE pods --field-selector=status.phase=Running --selector app.kubernetes.io/instance=test-opa-https -o jsonpath='{.items[0].metadata.name}')
9-
kubectl exec -n $NAMESPACE --container opa $FIRST_OPA_POD -- cat /stackable/log/containerdebug-state.json | jq --exit-status '"valid JSON"'
10-
- script: |
11-
FIRST_OPA_POD=$(kubectl get -n $NAMESPACE pods --field-selector=status.phase=Running --selector app.kubernetes.io/instance=test-opa-http -o jsonpath='{.items[0].metadata.name}')
8+
FIRST_OPA_POD=$(kubectl get -n $NAMESPACE pods --field-selector=status.phase=Running --selector app.kubernetes.io/instance=test-opa -o jsonpath='{.items[0].metadata.name}')
129
kubectl exec -n $NAMESPACE --container opa $FIRST_OPA_POD -- cat /stackable/log/containerdebug-state.json | jq --exit-status '"valid JSON"'

tests/templates/kuttl/smoke/20-install-test-opa.yaml

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
apiVersion: kuttl.dev/v1beta1
3+
kind: TestStep
4+
commands:
5+
- script: |
6+
kubectl apply -n $NAMESPACE -f - <<EOF
7+
---
8+
apiVersion: apps/v1
9+
kind: StatefulSet
10+
metadata:
11+
name: test-opa
12+
labels:
13+
app: test-opa
14+
spec:
15+
replicas: 1
16+
selector:
17+
matchLabels:
18+
app: test-opa
19+
template:
20+
metadata:
21+
labels:
22+
app: test-opa
23+
spec:
24+
securityContext:
25+
fsGroup: 1000
26+
containers:
27+
- name: test-opa
28+
image: oci.stackable.tech/sdp/testing-tools:0.2.0-stackable0.0.0-dev
29+
stdin: true
30+
tty: true
31+
resources:
32+
requests:
33+
memory: "128Mi"
34+
cpu: "512m"
35+
limits:
36+
memory: "128Mi"
37+
cpu: "1"
38+
{% if test_scenario['values']['use-tls'] == "true" %}
39+
volumeMounts:
40+
- name: tls
41+
mountPath: /tls
42+
volumes:
43+
- name: tls
44+
ephemeral:
45+
volumeClaimTemplate:
46+
metadata:
47+
annotations:
48+
secrets.stackable.tech/class: opa-tls-$NAMESPACE
49+
spec:
50+
storageClassName: secrets.stackable.tech
51+
accessModes:
52+
- ReadWriteOnce
53+
resources:
54+
requests:
55+
storage: "1"
56+
{% endif %}

tests/templates/kuttl/smoke/30-assert.yaml

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
apiVersion: kuttl.dev/v1beta1
3+
kind: TestAssert
4+
metadata:
5+
name: test-regorule
6+
commands:
7+
{% if test_scenario['values']['use-tls'] == "true" %}
8+
- script: kubectl exec -n $NAMESPACE test-opa-0 -- python /tmp/30_test-regorule.py -u "https://test-opa-server.$NAMESPACE.svc.cluster.local:8443/v1/data/test"
9+
{% else %}
10+
- script: kubectl exec -n $NAMESPACE test-opa-0 -- python /tmp/30_test-regorule.py -u "http://test-opa-server.$NAMESPACE.svc.cluster.local:8081/v1/data/test"
11+
{% endif %}

tests/templates/kuttl/smoke/31-assert.yaml

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
apiVersion: kuttl.dev/v1beta1
3+
kind: TestAssert
4+
metadata:
5+
name: test-metrics
6+
commands:
7+
{% if test_scenario['values']['use-tls'] == "true" %}
8+
- script: kubectl exec -n $NAMESPACE test-opa-0 -- python /tmp/30_test-metrics.py -u "https://test-opa-server-default-metrics.$NAMESPACE.svc.cluster.local:8443/metrics"
9+
{% else %}
10+
- script: kubectl exec -n $NAMESPACE test-opa-0 -- python /tmp/30_test-metrics.py -u "http://test-opa-server-default-metrics.$NAMESPACE.svc.cluster.local:8081/metrics"
11+
{% endif %}

0 commit comments

Comments
 (0)