Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: E2E

on:
push:
branches: [main]
pull_request:
workflow_dispatch:

permissions:
contents: read

concurrency:
group: e2e-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
e2e:
runs-on: ubuntu-latest
timeout-minutes: 60
env:
E2E_SUITES: go-core
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Provision cluster
uses: agynio/bootstrap/.github/actions/provision@main

- name: Setup DevSpace
uses: agynio/e2e/.github/actions/setup-devspace@main

- name: Deploy users from source
run: devspace dev

- name: Run E2E tests
uses: agynio/e2e/.github/actions/run-tests@main
with:
service: users
tag: svc_gateway
include_smoke: false
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ devspace dev
devspace dev -w
```

### Run tests
### Run E2E tests

```bash
devspace run test:e2e
git clone https://github.com/agynio/e2e.git
cd e2e
devspace run test-e2e --tag svc_users
```

See [E2E Testing](https://github.com/agynio/architecture/blob/main/architecture/operations/e2e-testing.md).
72 changes: 17 additions & 55 deletions devspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ version: v2beta1

vars:
USERS_NAMESPACE: platform
E2E_IMAGE: ghcr.io/agynio/devcontainer-go:1

functions:
disable_argocd_sync: |-
Expand All @@ -27,7 +26,7 @@ functions:
fi
patch_deployment: |-
echo "Patching users deployment for DevSpace..."
kubectl patch deployment users-users -n ${USERS_NAMESPACE} --type strategic --patch "$(cat <<'EOF'
kubectl patch deployment users -n ${USERS_NAMESPACE} --type strategic --patch "$(cat <<'EOF'
spec:
template:
spec:
Expand All @@ -40,7 +39,7 @@ functions:
emptyDir: {}
containers:
- name: users
image: ghcr.io/agynio/devcontainer-go:1 # keep in sync with E2E_IMAGE
image: ghcr.io/agynio/devcontainer-go:1 # dev container for source deploy
workingDir: /opt/app/data
command:
- sh
Expand All @@ -57,6 +56,9 @@ functions:
volumeMounts:
- name: data
mountPath: /opt/app/data
livenessProbe: null
readinessProbe: null
startupProbe: null
resources:
requests:
cpu: 500m
Expand All @@ -77,26 +79,6 @@ functions:
EOF
)"

deployments:
e2e-runner:
namespace: ${USERS_NAMESPACE}
helm:
chart:
name: component-chart
repo: https://charts.devspace.sh
values:
containers:
- image: ${E2E_IMAGE}
env:
- name: USERS_ADDR
value: "users:50051"
labels:
app.kubernetes.io/name: users-e2e

commands:
test:e2e: |-
devspace run-pipeline test:e2e $@

pipelines:
dev:
flags:
Expand All @@ -109,38 +91,26 @@ pipelines:
if [ "$(get_flag "watch")" == "true" ]; then
start_dev --disable-pod-replace users
else
start_dev --disable-pod-replace users
kubectl rollout status deployment/users -n ${USERS_NAMESPACE} --timeout=180s
start_dev --disable-pod-replace users &
echo "Waiting for users to be healthy on :50051..."
healthy=false
for i in $(seq 1 60); do
if exec_container --label-selector=app.kubernetes.io/name=users -n ${USERS_NAMESPACE} -- bash -c 'nc -z localhost 50051 >/dev/null 2>&1 || (echo > /dev/tcp/localhost/50051) >/dev/null 2>&1'; then
for i in $(seq 1 120); do
if kubectl exec deploy/users -n ${USERS_NAMESPACE} -c users -- bash -c 'nc -z localhost 50051 >/dev/null 2>&1 || (echo > /dev/tcp/localhost/50051) >/dev/null 2>&1'; then
healthy=true
break
fi
sleep 2
done
if [ "$healthy" != "true" ]; then
echo "ERROR: Users did not become healthy within 120s" >&2
stop_dev users || true
echo "ERROR: Users did not become healthy within 240s" >&2
exit 1
fi
echo "Dev environment ready. Stopping dev session."
stop_dev users
fi

test:e2e:
run: |-
create_deployments e2e-runner
start_dev e2e-runner &
sleep 5
exec_container \
--label-selector "app.kubernetes.io/name=users-e2e" \
-n ${USERS_NAMESPACE} \
-- bash -c 'cd /opt/app/data && buf generate buf.build/agynio/api --path agynio/api/users/v1 --path agynio/api/authorization/v1 --path agynio/api/identity/v1 --path agynio/api/ziti_management/v1 && go test -v -count=1 -tags e2e ./test/e2e/'
EXIT_CODE=$?
stop_dev e2e-runner
purge_deployments e2e-runner
exit $EXIT_CODE

hooks:
- name: restore-argocd-auto-sync
events:
Expand All @@ -165,33 +135,25 @@ dev:
- .git/
- .devspace/
- /.gen/
- /bootstrap/
- /e2e/
- /tmp/
uploadExcludePaths:
- .git/
- .devspace/
- /.gen/
- /bootstrap/
- /e2e/
- /tmp/
downloadExcludePaths:
- .git/
- .devspace/
- /.gen/
- /bootstrap/
- /e2e/
- /tmp/
logs:
enabled: true
lastLines: 200
ports:
- port: "50051"

e2e-runner:
namespace: ${USERS_NAMESPACE}
labelSelector:
app.kubernetes.io/name: users-e2e
command: ["sleep", "infinity"]
workingDir: /opt/app/data
sync:
- path: ./:/opt/app/data
excludePaths:
- .git/
- .devspace/
- /.gen/
- /tmp/
195 changes: 0 additions & 195 deletions test/e2e/api_tokens_e2e_test.go

This file was deleted.

Loading
Loading