-
Notifications
You must be signed in to change notification settings - Fork 27
232 lines (197 loc) · 8.89 KB
/
playwright-tests.yml
File metadata and controls
232 lines (197 loc) · 8.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
name: Playwright Tests
on:
workflow_call:
env:
TARGET_NAMESPACE: "console-namespace"
CI_CLUSTER: true
OLM_VERSION: "v0.28.0"
YQ_VERSION: "v4.44.1"
jobs:
Test:
runs-on: ubuntu-24.04
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Download Images
uses: actions/download-artifact@v8
with:
name: streamshub-images
- name: Setup Minikube Environment
uses: ./.github/actions/setup-minikube
with:
MEM: 8g
CPUS: 2
- name: Set Dynamic Environment Vars
run: |
echo "PROJECT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
echo "CLUSTER_DOMAIN=$(minikube ip).nip.io" >> $GITHUB_ENV
echo "CONSOLE_URL=https://example-console.$(minikube ip).nip.io" >> $GITHUB_ENV
# replace with resources in docs PR
- name: Install Operators
run: |
set -x
# Create the namespace for the test resources
kubectl create namespace $TARGET_NAMESPACE
# Create the CatalogSource with the Console operator bundle
yq ea '.spec.image = "localhost:5000/streamshub/console-operator-catalog:${{ env.PROJECT_VERSION }}"' \
./install/operator/olm/010-CatalogSource-console-operator-catalog.yaml \
| kubectl apply -n olm -f -
kubectl wait catalogsource/streamshub-console-catalog -n olm \
--for=jsonpath='{.status.connectionState.lastObservedState}'=READY \
--timeout=180s
STRIMZI_CHANNEL="strimzi-$(mvn help:evaluate -Dexpression=strimzi-api.version -q -DforceStdout | awk -F. '{ print $1"."$2 }').x"
# Install Strimzi Operator
echo '---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: strimzi-kafka-operator
spec:
channel: '${STRIMZI_CHANNEL}'
name: strimzi-kafka-operator
source: operatorhubio-catalog
sourceNamespace: olm' | kubectl apply -n operators -f -
# Install Console Operator
yq ea '.spec.sourceNamespace = "olm"' ./install/operator/olm/020-Subscription-console-operator.yaml \
| kubectl apply -n operators -f -
wait_operator() {
local OPERATOR=${1}
while [ $(kubectl get deployment --selector=operators.coreos.com/${OPERATOR}.operators -n operators -o name | wc -l) -lt 1 ] ; do
echo "Waiting for Deployment ${OPERATOR} to be present"
sleep 5
done
local OPERATOR_DEPLOYMENT=$(kubectl get deployment --selector=operators.coreos.com/${OPERATOR}.operators -n operators -o name | tail -1)
echo "Found Operator Deployment: ${OPERATOR_DEPLOYMENT}, waiting for condition 'Available'"
kubectl wait ${OPERATOR_DEPLOYMENT} --for=condition=available --timeout=180s -n operators
}
export -f wait_operator
timeout 300s bash -c 'wait_operator "strimzi-kafka-operator"'
timeout 300s bash -c 'wait_operator "streamshub-console-operator"'
# replace with resources in docs PR
- name: Deploy Kafka Cluster & Console
run: |
set -x
export LISTENER_TYPE=ingress
cat examples/kafka/*.yaml | envsubst | kubectl apply -n ${TARGET_NAMESPACE} -f -
kubectl wait kafka/console-kafka --for=condition=Ready --timeout=300s -n $TARGET_NAMESPACE
kubectl wait kafkauser/console-kafka-user1 --for=condition=Ready --timeout=60s -n $TARGET_NAMESPACE
# Display the resource
export KAFKA_NAMESPACE="${TARGET_NAMESPACE}"
cat examples/console/010-Console-example.yaml | envsubst && echo
# Apply the resource
cat examples/console/010-Console-example.yaml | envsubst | kubectl apply -n ${TARGET_NAMESPACE} -f -
kubectl wait console/example --for=condition=Ready --timeout=300s -n $TARGET_NAMESPACE
# Sleep to ensure ingress fully available
sleep 10
- name: Console Smoke Test
run: |
set -x
curl -kL ${CONSOLE_URL}
curl -kL ${CONSOLE_URL} | grep "StreamsHub Console"
- name: Deploy Data Generator
run: |
echo '---
apiVersion: apps/v1
kind: Deployment
metadata:
name: console-datagen
spec:
replicas: 1
revisionHistoryLimit: 3
selector:
matchLabels:
app: console-datagen
template:
metadata:
labels:
app: console-datagen
spec:
containers:
- name: console-datagen
image: quay.io/streamshub/console-datagen:0.5.0
ports:
- containerPort: 9080
livenessProbe:
httpGet:
path: /q/health/live
port: 9080
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
timeoutSeconds: 10
env:
- name: KAFKA_SECURITY_PROTOCOL
value: SASL_SSL
- name: KAFKA_SASL_MECHANISM
value: SCRAM-SHA-512
- name: DATAGEN_CONSUMER_GROUPS
value: "1"
- name: DATAGEN_TOPICS_PER_CONSUMER
value: "2"
- name: DATAGEN_PARTITIONS_PER_TOPIC
value: "3"
- name: DATAGEN_KAFKA_TEST_NAME
value: "TestKafka"
- name: DATAGEN_KAFKA_TEST_CONFIGS_BOOTSTRAP_SERVERS
value: "bootstrap.console-kafka.${CLUSTER_DOMAIN}:443"
- name: DATAGEN_KAFKA_TEST_CONFIGS_SSL_TRUSTSTORE_TYPE
value: PEM
- name: DATAGEN_KAFKA_TEST_CONFIGS_SSL_TRUSTSTORE_CERTIFICATES
valueFrom:
secretKeyRef:
name: console-kafka-cluster-ca-cert
key: ca.crt
- name: DATAGEN_KAFKA_TEST_CONFIGS_SASL_JAAS_CONFIG
valueFrom:
secretKeyRef:
key: sasl.jaas.config
name: console-kafka-user1' | \
envsubst | \
kubectl apply -n ${TARGET_NAMESPACE} -f -
kubectl wait deployment/console-datagen --for=condition=available --timeout=300s -n $TARGET_NAMESPACE
- name: Use Node.js
uses: actions/setup-node@v6
- name: Run Playwright Tests
working-directory: ./ui
run: |
set -x
npm ci
npm ls playwright --json=true
PLAYWRIGHT_VERSION="$(npm ls playwright --json=true | jq -r '.dependencies.playwright.version')"
docker run --rm \
-v$(pwd):/app:z \
-ePLAYWRIGHT_BASE_URL="${CONSOLE_URL}" \
-eCI_CLUSTER=true \
--network=host \
mcr.microsoft.com/playwright:v${PLAYWRIGHT_VERSION} \
/bin/bash -c 'cd /app && npm test'
- name: Backup Logs
if: always()
run: |
mkdir ./logs
kubectl logs -n operators -l strimzi.io/kind=cluster-operator --all-containers=true --tail -1 > ./logs/strimzi-cluster-operator-logs.txt
kubectl logs -n operators -l app.kubernetes.io/name=streamshub-console-operator --all-containers=true --tail -1 > ./logs/streamshub-console-operator-logs.txt
kubectl logs -n ${TARGET_NAMESPACE} -l app.kubernetes.io/instance=example-console-deployment --all-containers=true --tail -1 > ./logs/${TARGET_NAMESPACE}-console-logs.txt
kubectl logs -n ${TARGET_NAMESPACE} -l app=console-datagen --all-containers=true --tail -1 > ./logs/${TARGET_NAMESPACE}-datagen-logs.txt
- name: Archive Logs Backup
uses: actions/upload-artifact@v7
if: always()
with:
name: playwright-tests-k8s-logs
path: ./logs
- name: Backup Resources
if: failure()
run: |
mkdir ./resources
kubectl get all,catalogsources,operatorgroups -n olm -o yaml > ./resources/olm.yaml
kubectl get all,subscriptions,csv,operatorgroups,installplans -n operators -o yaml > ./resources/operators.yaml
kubectl get all -n ${TARGET_NAMESPACE} -o yaml > ./resources/${TARGET_NAMESPACE}.yaml
- name: Archive Resource Backup
uses: actions/upload-artifact@v7
if: failure()
with:
name: playwright-tests-k8s-resources-failed
path: ./resources