-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(test): substitute kuttl to bash e2e test (#411)
Signed-off-by: realanna <anna.reale@dynatrace.com>
- Loading branch information
Showing
11 changed files
with
316 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: kuttl.dev/v1 | ||
kind: TestSuite | ||
crdDir: ./config/crd/bases | ||
testDirs: | ||
- ./test/e2e/kuttl/scenarios/ | ||
timeout: 300 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: kuttl.dev/v1 | ||
kind: TestSuite | ||
crdDir: ./config/crd/bases | ||
testDirs: | ||
- ./test/e2e/kuttl/scenarios/ | ||
timeout: 150 | ||
skipDelete: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: flagd-query-test | ||
status: | ||
conditions: | ||
- type: Complete | ||
status: 'True' #this ensures flagd is running | ||
succeeded: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
# This configuration deploys the means to test the mutating injection webhook by proxying through an nginx server | ||
# to assert that flagd is reachable | ||
--- | ||
apiVersion: core.openfeature.dev/v1alpha1 | ||
kind: FeatureFlagConfiguration | ||
metadata: | ||
name: end-to-end-test | ||
spec: | ||
featureFlagSpec: | | ||
{ | ||
"flags": { | ||
"simple-flag": { | ||
"state": "ENABLED", | ||
"variants": { | ||
"on": true, | ||
"off": false | ||
}, | ||
"defaultVariant": "on" | ||
} | ||
} | ||
} | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: open-feature-e2e-test-sa | ||
automountServiceAccountToken: true | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: open-feature-e2e-nginx-conf | ||
data: | ||
nginx.conf: | | ||
events {} | ||
http { | ||
server { | ||
location / { | ||
proxy_pass http://127.0.0.1:8013; | ||
} | ||
} | ||
} | ||
--- | ||
# Deployment of nginx using our custom resource | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: open-feature-e2e-test-deployment | ||
labels: | ||
app: open-feature-e2e-test | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: open-feature-e2e-test | ||
template: | ||
metadata: | ||
annotations: | ||
openfeature.dev/enabled: "false" | ||
labels: | ||
app: open-feature-e2e-test | ||
spec: | ||
serviceAccountName: open-feature-e2e-test-sa | ||
volumes: | ||
- name: open-feature-e2e-nginx-conf | ||
configMap: | ||
name: open-feature-e2e-nginx-conf | ||
items: | ||
- key: nginx.conf | ||
path: nginx.conf | ||
containers: | ||
- name: open-feature-e2e-test | ||
image: nginx:stable-alpine | ||
ports: | ||
- containerPort: 80 | ||
volumeMounts: | ||
- name: open-feature-e2e-nginx-conf | ||
mountPath: /etc/nginx | ||
readOnly: true | ||
--- | ||
# Service exposed using NodePort | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: open-feature-e2e-failtest-service | ||
spec: | ||
type: ClusterIP | ||
selector: | ||
app: open-feature-e2e-test | ||
ports: | ||
- protocol: TCP | ||
port: 40000 | ||
targetPort: 80 | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: flagd-query-test | ||
spec: | ||
backoffLimit: 5 | ||
template: | ||
spec: | ||
containers: | ||
- name: test-flagd-endpoint | ||
image: curlimages/curl:7.72.0 | ||
args: | ||
- /bin/sh | ||
- -ec | ||
- | | ||
STATUS_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X POST "open-feature-e2e-failtest-service:40000/schema.v1.Service/ResolveBoolean" -d "{\"flagKey\":\"simple-flag\",\"context\":{}}" -H "Content-Type: application/json") | ||
if [ "$STATUS_CODE" -eq 200 ]; then | ||
echo "Expected curl to nginx reverse proxy to return non 200 status code when openfeature.dev/enabled annotation is false." | ||
exit 1 | ||
fi | ||
exit 0 | ||
restartPolicy: Never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
labels: | ||
app: open-feature-e2e-test | ||
status: | ||
phase: Running | ||
spec: | ||
containers: | ||
- name: open-feature-e2e-test | ||
image: nginx:stable-alpine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: flagd-query-test | ||
status: | ||
conditions: | ||
- type: Complete | ||
status: 'True' #this ensures flagd is running | ||
succeeded: 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# This configuration deploys the means to test the mutating injection webhook by proxying through an nginx server | ||
# to assert that flagd is reachable | ||
--- | ||
apiVersion: core.openfeature.dev/v1alpha1 | ||
kind: FeatureFlagConfiguration | ||
metadata: | ||
name: end-to-end-test | ||
spec: | ||
featureFlagSpec: | | ||
{ | ||
"flags": { | ||
"simple-flag": { | ||
"state": "ENABLED", | ||
"variants": { | ||
"on": true, | ||
"off": false | ||
}, | ||
"defaultVariant": "on" | ||
} | ||
} | ||
} | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: open-feature-e2e-test-sa | ||
automountServiceAccountToken: true | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: open-feature-e2e-nginx-conf | ||
data: | ||
nginx.conf: | | ||
events {} | ||
http { | ||
server { | ||
location / { | ||
proxy_pass http://127.0.0.1:8013; | ||
} | ||
} | ||
} | ||
--- | ||
# Deployment of nginx using our custom resource | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: open-feature-e2e-test-deployment | ||
labels: | ||
app: open-feature-e2e-test | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: open-feature-e2e-test | ||
template: | ||
metadata: | ||
labels: | ||
app: open-feature-e2e-test | ||
annotations: | ||
openfeature.dev/enabled: "true" | ||
openfeature.dev/featureflagconfiguration: "end-to-end-test" | ||
spec: | ||
serviceAccountName: open-feature-e2e-test-sa | ||
volumes: | ||
- name: open-feature-e2e-nginx-conf | ||
configMap: | ||
name: open-feature-e2e-nginx-conf | ||
items: | ||
- key: nginx.conf | ||
path: nginx.conf | ||
containers: | ||
- name: open-feature-e2e-test | ||
image: nginx:stable-alpine | ||
ports: | ||
- containerPort: 80 | ||
volumeMounts: | ||
- name: open-feature-e2e-nginx-conf | ||
mountPath: /etc/nginx | ||
readOnly: true | ||
--- | ||
# Service exposed using NodePort | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: open-feature-e2e-test-service | ||
spec: | ||
type: ClusterIP | ||
selector: | ||
app: open-feature-e2e-test | ||
ports: | ||
- protocol: TCP | ||
port: 30000 | ||
targetPort: 80 | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: flagd-query-test | ||
spec: | ||
backoffLimit: 5 | ||
template: | ||
spec: | ||
containers: | ||
- name: test-flagd-endpoint | ||
image: curlimages/curl:7.72.0 | ||
args: | ||
- /bin/sh | ||
- -ec | ||
- | | ||
EXPECTED_RESPONSE='{"value":true,"reason":"STATIC","variant":"on"}' | ||
RESPONSE=$(curl -s -X POST "open-feature-e2e-test-service:30000/schema.v1.Service/ResolveBoolean" -d '{"flagKey":"simple-flag","context":{}}' -H "Content-Type: application/json") | ||
RESPONSE="${RESPONSE//[[:space:]]/}" # strip whitespace from response | ||
if [ "$RESPONSE" == "$EXPECTED_RESPONSE" ] | ||
then | ||
exit 0 | ||
fi | ||
echo "Expected response: $EXPECTED_RESPONSE" | ||
echo "Got response: $RESPONSE" | ||
exit 1 | ||
restartPolicy: Never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
annotations: | ||
openfeature.dev/allowkubernetessync: "true" | ||
openfeature.dev/enabled: "true" | ||
openfeature.dev/featureflagconfiguration: end-to-end-test | ||
labels: | ||
app: open-feature-e2e-test | ||
status: | ||
phase: Running | ||
spec: | ||
containers: | ||
- name: open-feature-e2e-test | ||
image: nginx:stable-alpine | ||
- name: flagd # this part verifies flagd injection happened | ||
image: ghcr.io/open-feature/flagd:v0.4.4 |