Skip to content

Commit 05a62ef

Browse files
committed
test: e2e
1 parent ba2ccc4 commit 05a62ef

File tree

7 files changed

+401
-43
lines changed

7 files changed

+401
-43
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
root = true
2+
13
[*.ts]
24
indent_style = space
35
indent_size = 2
6+
7+
[*]
8+
charset = utf-8
9+
end_of_line = lf
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true
12+
13+
[*.{yaml,yml}]
14+
indent_style = space
15+
indent_size = 2
16+
quote_type = single

.github/workflows/test.yml

Lines changed: 72 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,42 @@ jobs:
2828
- name: Test
2929
run: make test
3030

31+
e2e:
32+
runs-on: ubuntu-latest
33+
services:
34+
loki:
35+
image: grafana/loki:3.5.1
36+
ports:
37+
- 3100:3100
38+
options: >-
39+
--health-cmd "wget --no-verbose --tries=1 --spider http://localhost:3100/ready || exit 1"
40+
--health-interval 10s
41+
--health-timeout 5s
42+
--health-retries 5
43+
steps:
44+
- name: Install Go
45+
uses: buildjet/setup-go@v5
46+
with:
47+
go-version: 1.24.x
48+
- name: Checkout code
49+
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
50+
- uses: buildjet/cache@v4
51+
with:
52+
path: |
53+
~/go/pkg/mod
54+
~/.cache/go-build
55+
.bin
56+
key: cache-${{ hashFiles('**/go.sum') }}-${{ hashFiles('.bin/*') }}
57+
restore-keys: |
58+
cache-
59+
- name: E2E Test
60+
run: |
61+
make ginkgo
62+
ginkgo -r tests/e2e/
63+
env:
64+
DUTY_DB_DISABLE_RLS: 'true'
65+
LOKI_URL: http://localhost:3100
66+
3167
test-prod:
3268
runs-on: ubuntu-latest
3369
timeout-minutes: 20
@@ -55,57 +91,56 @@ jobs:
5591
test-clickhouse:
5692
runs-on: ubuntu-latest
5793
steps:
58-
- name: Checkout code
59-
uses: actions/checkout@v4
94+
- name: Checkout code
95+
uses: actions/checkout@v4
6096

61-
- name: Kubernetes KinD Cluster
62-
uses: container-tools/kind-action@v2
97+
- name: Kubernetes KinD Cluster
98+
uses: container-tools/kind-action@v2
6399

64-
- name: Install Helm
65-
uses: azure/setup-helm@v3
100+
- name: Install Helm
101+
uses: azure/setup-helm@v3
66102

67-
- name: Verify cluster is ready
68-
run: |
69-
echo "Waiting for cluster to be ready..."
70-
kubectl wait --for=condition=Ready nodes --all --timeout=300s
71-
kubectl get nodes
72-
kubectl get pods -A
103+
- name: Verify cluster is ready
104+
run: |
105+
echo "Waiting for cluster to be ready..."
106+
kubectl wait --for=condition=Ready nodes --all --timeout=300s
107+
kubectl get nodes
108+
kubectl get pods -A
73109
74-
- name: Build and push Docker image
75-
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
76-
with:
77-
context: .
78-
file: ./build/Dockerfile
79-
push: true
80-
tags: localhost:5000/flanksource/config-db:latest
81-
cache-from: type=registry,ref=docker.io/flanksource/config-db
110+
- name: Build and push Docker image
111+
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
112+
with:
113+
context: .
114+
file: ./build/Dockerfile
115+
push: true
116+
tags: localhost:5000/flanksource/config-db:latest
117+
cache-from: type=registry,ref=docker.io/flanksource/config-db
82118

83-
- name: Package helm chart
84-
run: |
85-
helm dependency build ./chart
86-
helm package ./chart --version 1.0.0
119+
- name: Package helm chart
120+
run: |
121+
helm dependency build ./chart
122+
helm package ./chart --version 1.0.0
87123
88-
- name: Install Helm chart
89-
run: |
90-
helm install config-db config-db-1.0.0.tgz \
91-
--namespace default \
92-
--set clickhouse.enabled=true \
93-
--set imageRegistry="kind-registry:5000"
124+
- name: Install Helm chart
125+
run: |
126+
helm install config-db config-db-1.0.0.tgz \
127+
--namespace default \
128+
--set clickhouse.enabled=true \
129+
--set imageRegistry="kind-registry:5000"
94130
95-
- name: Check pod status
96-
run: |
131+
- name: Check pod status
132+
run: |
97133
sleep 60
98134
kubectl get pods
99135
kubectl describe pods
100136
sleep 60
101137
kubectl get pods
102138
kubectl describe pods
103-
104139
105-
- name: Run clickhouse fixture
106-
run: |
107-
kubectl cp fixtures/clickhouse.yaml config-db-0:/app/clickhouse.yaml
108-
kubectl exec -it config-db-0 -- /app/config-db run /app/clickhouse.yaml
140+
- name: Run clickhouse fixture
141+
run: |
142+
kubectl cp fixtures/clickhouse.yaml config-db-0:/app/clickhouse.yaml
143+
kubectl exec -it config-db-0 -- /app/config-db run /app/clickhouse.yaml
109144
110145
test-load:
111146
if: false # disabled for now

Makefile

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ test-load:
7373

7474
.PHONY: gotest
7575
gotest:
76-
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out
76+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" \
77+
ginkgo -r -v --skip-package=tests/e2e -coverprofile cover.out ./...
7778

7879
.PHONY: gotest-prod
7980
gotest-prod:
@@ -86,8 +87,24 @@ gotest-load:
8687

8788
.PHONY: env
8889
env: envtest ## Run tests.
89-
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out
90+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" \
91+
ginkgo -r -v --skip-package=tests/e2e -coverprofile cover.out
9092

93+
.PHONY: ginkgo
94+
ginkgo:
95+
go install github.com/onsi/ginkgo/v2/ginkgo
96+
97+
.PHONY: test-e2e
98+
test-e2e: ginkgo
99+
cd tests/e2e && docker-compose up -d && \
100+
echo 'Running tests' && \
101+
(ginkgo -v; TEST_EXIT_CODE=$$?; docker-compose down; exit $$TEST_EXIT_CODE)
102+
103+
.PHONY: e2e-services
104+
e2e-services: ## Run e2e test services in foreground with automatic cleanup on exit
105+
cd tests/e2e && \
106+
trap 'docker-compose down -v && docker-compose rm -f' EXIT INT TERM && \
107+
docker-compose up --remove-orphans
91108

92109
fmt:
93110
go fmt ./...
@@ -157,10 +174,6 @@ dev:
157174
watch:
158175
watchexec -c make build install
159176

160-
.PHONY: test-e2e
161-
test-e2e: bin
162-
./test/e2e.sh
163-
164177
.bin/upx: .bin
165178
wget -nv -O upx.tar.xz https://github.com/upx/upx/releases/download/v3.96/upx-3.96-$(ARCH)_$(OS).tar.xz
166179
tar xf upx.tar.xz

tests/e2e/docker-compose.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
services:
2+
loki:
3+
image: grafana/loki:3.5.1
4+
ports:
5+
- "3100:3100"
6+
command: -config.file=/etc/loki/local-config.yaml
7+
healthcheck:
8+
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3100/ready || exit 1"]
9+
interval: 10s
10+
timeout: 5s
11+
retries: 5
12+
start_period: 10s

0 commit comments

Comments
 (0)