Skip to content

Commit 50ebb04

Browse files
authored
Merge branch 'main' into renovate/gcr.io-kubebuilder-kube-rbac-proxy-0.x
2 parents 86953f6 + 6850649 commit 50ebb04

File tree

7 files changed

+207
-4
lines changed

7 files changed

+207
-4
lines changed

.github/workflows/pr-checks.yml

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ on:
44
push:
55
branches:
66
- main
7+
paths-ignore:
8+
- '**.md'
79
pull_request:
10+
paths-ignore:
11+
- '**.md'
812
env:
913
# Default minimum version of Go to support.
1014
DEFAULT_GO_VERSION: 1.18
@@ -68,8 +72,6 @@ jobs:
6872
steps:
6973
- name: Checkout
7074
uses: actions/checkout@v3
71-
with:
72-
submodules: recursive
7375
- name: Set up QEMU
7476
uses: docker/setup-qemu-action@master
7577
with:
@@ -80,9 +82,10 @@ jobs:
8082
- name: Build
8183
uses: docker/build-push-action@v3
8284
with:
85+
builder: ${{ steps.buildx.outputs.name }}
8386
context: .
8487
outputs: type=docker,dest=${{ github.workspace }}/open-feature-operator-local.tar
85-
tags: open-feature-operator-local:test
88+
tags: open-feature-operator-local:${{ github.sha }}
8689
- name: Run Trivy vulnerability scanner
8790
uses: aquasecurity/trivy-action@master
8891
with:
@@ -95,3 +98,39 @@ jobs:
9598
uses: github/codeql-action/upload-sarif@v2
9699
with:
97100
sarif_file: "trivy-results.sarif"
101+
- name: Upload image as artifact
102+
uses: actions/upload-artifact@v3
103+
with:
104+
name: open-feature-operator-local-${{ github.sha }}
105+
path: ${{ github.workspace }}/open-feature-operator-local.tar
106+
107+
e2e-test:
108+
runs-on: ubuntu-latest
109+
needs: docker-local
110+
steps:
111+
- name: Install Go
112+
uses: actions/setup-go@v3
113+
with:
114+
go-version: ${{ env.DEFAULT_GO_VERSION }}
115+
- name: Checkout
116+
uses: actions/checkout@v3
117+
- name: Download image
118+
uses: actions/download-artifact@v3
119+
with:
120+
name: open-feature-operator-local-${{ github.sha }}
121+
path: ${{ github.workspace }}
122+
- name: Load open-feature-operator image into docker
123+
run: |
124+
docker load --input ${{ github.workspace }}/open-feature-operator-local.tar
125+
- name: Create k8s Kind Cluster
126+
uses: helm/[email protected]
127+
with:
128+
config: ./test/e2e/kind-cluster.yml
129+
cluster_name: open-feature-operator-test
130+
- name: Load open-feature-operator image into Kind cluster
131+
run: |
132+
kind load docker-image open-feature-operator-local:${{ github.sha }} --name open-feature-operator-test
133+
- name: Run e2e test
134+
run: |
135+
IMG=open-feature-operator-local:${{ github.sha }} make deploy-operator
136+
IMG=open-feature-operator-local:${{ github.sha }} make e2e-test

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ vet: ## Run go vet against code.
6666
test: manifests generate fmt vet envtest ## Run tests.
6767
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out
6868

69+
## Requires the operator to be deployed
70+
.PHONY: e2e-test
71+
e2e-test: manifests generate fmt vet
72+
kubectl -n open-feature-operator-system apply -f ./test/e2e/e2e.yml
73+
kubectl wait --for=condition=Available=True deploy --all -n 'open-feature-operator-system'
74+
./test/e2e/e2e.sh '{"value":true,"reason":"DEFAULT","variant":"on"}'
75+
6976
.PHONY: lint
7077
lint:
7178
go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest

config/manager/manager.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ spec:
3131
- /manager
3232
args:
3333
- --leader-elect
34-
imagePullPolicy: Always
34+
imagePullPolicy: IfNotPresent
3535
image: controller:main
3636
name: manager
3737
env:

test/e2e/DEVELOPER.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# E2E Testing
2+
3+
This suite tests the end-to-end deployment of open-feature-operator by deploying an nginx reverse proxy and asserting that a curl to the proxy reaches the flagd sidecar created by open-feature-operator.
4+
5+
## Running on a Kind cluster
6+
7+
```shell
8+
kind create cluster --config ./test/e2e/kind-cluster.yml
9+
IMG=ghcr.io/open-feature/open-feature-operator:main make deploy-operator
10+
IMG=ghcr.io/open-feature/open-feature-operator:main make e2e-test
11+
```
12+
13+
## Running on a Kind cluster using a locally built image
14+
15+
```shell
16+
kind create cluster --config ./test/e2e/kind-cluster.yml
17+
kind load docker-image local-image-tag:latest
18+
IMG=local-image-tag:latest make deploy-operator
19+
IMG=local-image-tag:latest make e2e-test
20+
```
21+

test/e2e/e2e.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
EXPECTED_RESPONSE="$1"
4+
5+
# attempt up to 5 times
6+
ATTEMPT_COUNTER=0
7+
MAX_ATTEMPTS=5
8+
until RESPONSE=$(curl -s -X POST "localhost:30000/schema.v1.Service/ResolveBoolean" -d '{"flagKey":"simple-flag","context":{}}' -H "Content-Type: application/json"); do
9+
if [ ${ATTEMPT_COUNTER} -eq ${MAX_ATTEMPTS} ];then
10+
echo "Max attempts reached"
11+
exit 1
12+
fi
13+
14+
printf '.'
15+
ATTEMPT_COUNTER=$((ATTEMPT_COUNTER+1))
16+
sleep 1
17+
done
18+
19+
RESPONSE="${RESPONSE//[[:space:]]/}" # strip whitespace from response
20+
21+
if [ "$RESPONSE" == "$EXPECTED_RESPONSE" ]
22+
then
23+
echo "Success."
24+
exit 0
25+
else
26+
echo "Expected response: $EXPECTED_RESPONSE"
27+
echo "Got response: $RESPONSE"
28+
exit 1
29+
fi

test/e2e/e2e.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# This configuration deploys the means to test the mutating injection webhook by proxying through an nginx server
2+
# to assert that flagd is reachable
3+
---
4+
apiVersion: core.openfeature.dev/v1alpha1
5+
kind: FeatureFlagConfiguration
6+
metadata:
7+
name: end-to-end-test
8+
spec:
9+
featureFlagSpec: |
10+
{
11+
"flags": {
12+
"simple-flag": {
13+
"state": "ENABLED",
14+
"variants": {
15+
"on": true,
16+
"off": false
17+
},
18+
"defaultVariant": "on"
19+
}
20+
}
21+
}
22+
---
23+
apiVersion: v1
24+
kind: ServiceAccount
25+
metadata:
26+
name: open-feature-e2e-test-sa
27+
automountServiceAccountToken: true
28+
---
29+
apiVersion: v1
30+
kind: ConfigMap
31+
metadata:
32+
name: open-feature-e2e-nginx-conf
33+
data:
34+
nginx.conf: |
35+
events {}
36+
http {
37+
server {
38+
location / {
39+
proxy_pass http://127.0.0.1:8013;
40+
}
41+
}
42+
}
43+
---
44+
# Deployment of nginx using our custom resource
45+
apiVersion: apps/v1
46+
kind: Deployment
47+
metadata:
48+
name: open-feature-e2e-test-deployment
49+
labels:
50+
app: open-feature-e2e-test
51+
spec:
52+
replicas: 1
53+
selector:
54+
matchLabels:
55+
app: open-feature-e2e-test
56+
template:
57+
metadata:
58+
labels:
59+
app: open-feature-e2e-test
60+
annotations:
61+
openfeature.dev: "enabled"
62+
openfeature.dev/featureflagconfiguration: "end-to-end-test"
63+
spec:
64+
serviceAccountName: open-feature-e2e-test-sa
65+
volumes:
66+
- name: open-feature-e2e-nginx-conf
67+
configMap:
68+
name: open-feature-e2e-nginx-conf
69+
items:
70+
- key: nginx.conf
71+
path: nginx.conf
72+
containers:
73+
- name: open-feature-e2e-test
74+
image: nginx:stable-alpine
75+
ports:
76+
- containerPort: 80
77+
volumeMounts:
78+
- name: open-feature-e2e-nginx-conf
79+
mountPath: /etc/nginx
80+
readOnly: true
81+
---
82+
# Service exposed using NodePort
83+
apiVersion: v1
84+
kind: Service
85+
metadata:
86+
name: open-feature-e2e-test-service
87+
spec:
88+
type: NodePort
89+
selector:
90+
app: open-feature-e2e-test
91+
ports:
92+
- protocol: TCP
93+
port: 30000
94+
targetPort: 80
95+
nodePort: 30000

test/e2e/kind-cluster.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: kind.x-k8s.io/v1alpha4
2+
kind: Cluster
3+
nodes:
4+
- role: control-plane
5+
extraPortMappings:
6+
- containerPort: 30000
7+
hostPort: 30000
8+
listenAddress: "0.0.0.0" # Optional, defaults to "0.0.0.0"
9+
protocol: tcp # Optional, defaults to tcp
10+
- role: worker
11+
- role: worker
12+
- role: worker

0 commit comments

Comments
 (0)