-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: introduce e2e tests for multiple source providers (#452)
Signed-off-by: odubajDT <[email protected]>
- Loading branch information
Showing
14 changed files
with
249 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
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: 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/flagsourceconfiguration: "source-configuration" | ||
spec: | ||
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 | ||
--- | ||
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: 10 | ||
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: OnFailure |
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,4 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestAssert | ||
commands: | ||
- command: kubectl wait --for=condition=complete job flagd-query-test -n $NAMESPACE |
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,14 @@ | ||
--- | ||
apiVersion: core.openfeature.dev/v1alpha3 | ||
kind: FlagSourceConfiguration | ||
metadata: | ||
name: source-configuration | ||
spec: | ||
metricsPort: 8080 | ||
evaluator: json | ||
defaultSyncProvider: filepath | ||
tag: v0.5.1 | ||
sources: | ||
- source: end-to-end-test | ||
provider: filepath | ||
probesEnabled: 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,4 @@ | ||
apiVersion: kuttl.dev/v1 | ||
kind: TestStep | ||
apply: | ||
- ../assets/manifests.yaml |
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,16 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
annotations: | ||
openfeature.dev/enabled: "true" | ||
openfeature.dev/flagsourceconfiguration: source-configuration | ||
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.5.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,4 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestAssert | ||
commands: | ||
- command: kubectl wait --for=condition=complete job flagd-query-test -n $NAMESPACE |
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,14 @@ | ||
--- | ||
apiVersion: core.openfeature.dev/v1alpha3 | ||
kind: FlagSourceConfiguration | ||
metadata: | ||
name: source-configuration | ||
spec: | ||
metricsPort: 8080 | ||
evaluator: json | ||
defaultSyncProvider: flagd-proxy | ||
tag: v0.5.1 | ||
sources: | ||
- source: end-to-end-test | ||
provider: flagd-proxy | ||
probesEnabled: 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,4 @@ | ||
apiVersion: kuttl.dev/v1 | ||
kind: TestStep | ||
apply: | ||
- ../assets/manifests.yaml |
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,16 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
annotations: | ||
openfeature.dev/enabled: "true" | ||
openfeature.dev/flagsourceconfiguration: source-configuration | ||
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.5.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,4 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestAssert | ||
commands: | ||
- command: kubectl wait --for=condition=complete job flagd-query-test -n $NAMESPACE |
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,14 @@ | ||
--- | ||
apiVersion: core.openfeature.dev/v1alpha3 | ||
kind: FlagSourceConfiguration | ||
metadata: | ||
name: source-configuration | ||
spec: | ||
metricsPort: 8080 | ||
evaluator: json | ||
defaultSyncProvider: kubernetes | ||
tag: v0.5.1 | ||
sources: | ||
- source: end-to-end-test | ||
provider: kubernetes | ||
probesEnabled: 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,4 @@ | ||
apiVersion: kuttl.dev/v1 | ||
kind: TestStep | ||
apply: | ||
- ../assets/manifests.yaml |
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/flagsourceconfiguration: source-configuration | ||
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.5.1 |