Skip to content

Commit 22cd268

Browse files
authored
Merge pull request #53906 from yashpimple/quality-test/gatekeeper
quality: extend test gatekeeper package
2 parents 0ced88a + 028ecae commit 22cd268

File tree

1 file changed

+64
-1
lines changed

1 file changed

+64
-1
lines changed

gatekeeper-3.18.yaml

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package:
22
name: gatekeeper-3.18
33
version: "3.18.3"
4-
epoch: 1
4+
epoch: 2
55
description: Gatekeeper - Policy Controller for Kubernetes
66
copyright:
77
- license: Apache-2.0
@@ -109,7 +109,70 @@ update:
109109
tag-filter: v3.18.
110110

111111
test:
112+
environment:
113+
contents:
114+
packages:
115+
- ${{package.name}}-gator
116+
- openssl
117+
- curl
118+
- kubectl
112119
pipeline:
113120
# AUTOGENERATED
114121
- runs: |
115122
manager --help
123+
gator --version | grep -q v"${{package.version}}"
124+
- name: gator verify constraint
125+
uses: test/daemon-check-output
126+
with:
127+
setup: |
128+
cat > constraint.yaml <<EOF
129+
apiVersion: constraints.gatekeeper.sh/v1beta1
130+
kind: K8sRequiredLabels
131+
metadata:
132+
name: ns-must-have-gk
133+
spec:
134+
match:
135+
kinds:
136+
- apiGroups: [""]
137+
kinds: ["Namespace"]
138+
parameters:
139+
labels: ["gatekeeper"]
140+
EOF
141+
start: |
142+
gator verify constraint.yaml
143+
timeout: 10
144+
expected_output: |
145+
PASS
146+
- uses: test/kwok/cluster
147+
- name: Run Gatekeeper manager in KWOK
148+
uses: test/daemon-check-output
149+
with:
150+
setup: |
151+
export KUBERNETES_SERVICE_HOST="127.0.0.1"
152+
export KUBERNETES_SERVICE_PORT="32764"
153+
154+
kubectl config view --minify --raw > /tmp/kwok-kubeconfig.yaml
155+
# Create dummy certificates in /tmp
156+
echo "Creating dummy certificates..."
157+
openssl req -x509 -newkey rsa:4096 -sha256 -days 365 -nodes -keyout /tmp/tls.key -out /tmp/tls.crt -subj "/CN=gatekeeper-webhook-service.gatekeeper-system.svc"
158+
159+
kubectl create ns gatekeeper-system
160+
kubectl -n gatekeeper-system create secret tls gatekeeper-webhook-server-cert --cert=/tmp/tls.crt --key=/tmp/tls.key
161+
start: |
162+
manager -operation=webhook -metrics-addr=:8080 -logtostderr -v=2 -cert-dir=/tmp -kubeconfig=/tmp/kwok-kubeconfig.yaml
163+
timeout: 30
164+
expected_output: |
165+
setting up cert rotation
166+
starting manager
167+
Starting metrics server
168+
Starting workers
169+
post: |
170+
echo "Checking health endpoint:"
171+
HEALTH_OUTPUT=$(curl -sf http://localhost:9090/healthz)
172+
echo "$HEALTH_OUTPUT"
173+
if echo "$HEALTH_OUTPUT" | grep -i "ok" > /dev/null; then
174+
echo "Health endpoint check PASSED"
175+
else
176+
echo "Health endpoint check FAILED"
177+
exit 1
178+
fi

0 commit comments

Comments
 (0)