Skip to content

Commit

Permalink
test: introduce e2e tests for multiple source providers (#452)
Browse files Browse the repository at this point in the history
Signed-off-by: odubajDT <[email protected]>
  • Loading branch information
odubajDT authored Apr 25, 2023
1 parent 50151ff commit 92134cc
Show file tree
Hide file tree
Showing 14 changed files with 249 additions and 1 deletion.
23 changes: 22 additions & 1 deletion renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,28 @@
"depNameTemplate": "open-feature/flagd",
"datasourceTemplate": "github-releases",
"extractVersionTemplate": "^flagd-proxy/(?<version>.*)$"
},
{
"fileMatch": [
"^test/e2e/kuttl/fsconfig-flagd-proxy-sync/01-assert.yaml$",
"^test/e2e/kuttl/fsconfig-k8s-sync/01-assert.yaml$",
"^test/e2e/kuttl/fsconfig-file-sync/01-assert.yaml$"
],
"matchStrings": ["image: ghcr\\.io\/open-feature\/flagd:(?<currentValue>.*?)\\s"],
"depNameTemplate": "open-feature/flagd",
"datasourceTemplate": "github-releases",
"extractVersionTemplate": "^flagd-proxy/(?<version>.*)$"
},
{
"fileMatch": [
"^test/e2e/kuttl/fsconfig-flagd-proxy-sync/00-install.yaml$",
"^test/e2e/kuttl/fsconfig-k8s-sync/00-install.yaml$",
"^test/e2e/kuttl/fsconfig-file-sync/00-install.yaml$"
],
"matchStrings": ["tag: (?<currentValue>.*?)\\s"],
"depNameTemplate": "open-feature/flagd",
"datasourceTemplate": "github-releases",
"extractVersionTemplate": "^flagd-proxy/(?<version>.*)$"
}
]

}
112 changes: 112 additions & 0 deletions test/e2e/kuttl/assets/manifests.yaml
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
4 changes: 4 additions & 0 deletions test/e2e/kuttl/fsconfig-file-sync/00-assert.yaml
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
14 changes: 14 additions & 0 deletions test/e2e/kuttl/fsconfig-file-sync/00-install.yaml
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
4 changes: 4 additions & 0 deletions test/e2e/kuttl/fsconfig-file-sync/00-teststep.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kuttl.dev/v1
kind: TestStep
apply:
- ../assets/manifests.yaml
16 changes: 16 additions & 0 deletions test/e2e/kuttl/fsconfig-file-sync/01-assert.yaml
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
4 changes: 4 additions & 0 deletions test/e2e/kuttl/fsconfig-flagd-proxy-sync/00-assert.yaml
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
14 changes: 14 additions & 0 deletions test/e2e/kuttl/fsconfig-flagd-proxy-sync/00-install.yaml
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
4 changes: 4 additions & 0 deletions test/e2e/kuttl/fsconfig-flagd-proxy-sync/00-teststep.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kuttl.dev/v1
kind: TestStep
apply:
- ../assets/manifests.yaml
16 changes: 16 additions & 0 deletions test/e2e/kuttl/fsconfig-flagd-proxy-sync/01-assert.yaml
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
4 changes: 4 additions & 0 deletions test/e2e/kuttl/fsconfig-k8s-sync/00-assert.yaml
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
14 changes: 14 additions & 0 deletions test/e2e/kuttl/fsconfig-k8s-sync/00-install.yaml
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
4 changes: 4 additions & 0 deletions test/e2e/kuttl/fsconfig-k8s-sync/00-teststep.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kuttl.dev/v1
kind: TestStep
apply:
- ../assets/manifests.yaml
17 changes: 17 additions & 0 deletions test/e2e/kuttl/fsconfig-k8s-sync/01-assert.yaml
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

0 comments on commit 92134cc

Please sign in to comment.