Deployment E2E Testing
End-to-end testing for the deployment pipeline
๐งช Deployment E2E Testing
Comprehensive end-to-end tests for GitLab + Cloudflare deployment pipeline
Overview
The E2E test suite verifies the complete deployment pipeline:
- โ GitLab API connectivity
- โ GitLab project creation
- โ GitLab file push
- โ GitLab pipeline triggering
- โ Cloudflare API connectivity
- โ Cloudflare project creation
- โ Full pipeline flow
- โ Resource cleanup
Running Tests
Quick Commands
# Full E2E test suite
yarn e2e:pipeline
# Connection verification only
yarn e2e:pipeline:verify
# Run tests, keep test resources for inspection
yarn e2e:pipeline:keep
Direct Test Execution
# With environment variables
GITLAB_API_TOKEN=xxx CLOUDFLARE_API_TOKEN=xxx CLOUDFLARE_ACCOUNT_ID=xxx \
npx nx test backend-ai-api --testPathPattern='pipeline-e2e'
Test File Location
apis/backend-ai-api/src/app/workflow/tests/pipeline-e2e.spec.ts
Test Cases
GitLab Integration Tests
| Test | Description | Timeout |
|---|---|---|
should connect to GitLab API |
Verifies token authentication | 10s |
should create/find test group |
Uses existing gograbspace group |
10s |
should create project and push code |
Creates project, pushes files | 30s |
should create project with CI config and trigger pipeline |
Full CI test | 30s |
Cloudflare Integration Tests
| Test | Description | Timeout |
|---|---|---|
should connect to Cloudflare API |
Verifies token | 10s |
should list existing Pages projects |
Lists all projects | 10s |
should create and delete test project |
Full lifecycle | 30s |
Full Pipeline Integration
| Test | Description | Timeout |
|---|---|---|
should execute complete deployment flow |
GitLab โ Cloudflare flow | 60s |
Test Output Example
PASS backend-ai-api apis/backend-ai-api/src/app/workflow/tests/pipeline-e2e.spec.ts
Pipeline E2E Tests (Real Infrastructure)
GitLab Integration
โ should connect to GitLab API (288 ms)
โ should create/find test group (334 ms)
โ should create project and push code (4704 ms)
โ should create project with CI config and trigger pipeline (4163 ms)
Cloudflare Integration
โ should connect to Cloudflare API (212 ms)
โ should list existing Pages projects (730 ms)
โ should create and delete test project (2833 ms)
Full Pipeline Integration
โ should execute complete deployment flow (4506 ms)
Console Output:
โ
Connected to GitLab as: gograb-space
โ
Using test group: gograbspace (ID: 122455722)
โ
Created project: gograbspace/e2e-test-1769264009565
โ
Pushed 3 files, commit: b7105951
๐ Starting Full Pipeline E2E Test
1๏ธโฃ Created GitLab project: gograbspace/e2e-test-full-1769264024426
2๏ธโฃ Pushed 4 files including CI config
3๏ธโฃ Created Cloudflare Pages project: https://e2e-test-full-1769264024426.pages.dev
4๏ธโฃ Triggered pipeline #2284119171
URL: https://gitlab.com/gograbspace/e2e-test-full-1769264024426/-/pipelines/2284119171
โ
Full Pipeline E2E Test Complete!
Summary:
GitLab Project: https://gitlab.com/gograbspace/e2e-test-full-1769264024426
Cloudflare URL: https://e2e-test-full-1769264024426.pages.dev
Pipeline: https://gitlab.com/gograbspace/e2e-test-full-1769264024426/-/pipelines/2284119171
๐งน Cleaning up GitLab project: gograbspace/e2e-test-1769264009565
๐งน Cleaning up Cloudflare project: e2e-test-1769264024426
Configuration
Environment Variables
| Variable | Required | Description |
|---|---|---|
GITLAB_API_TOKEN |
Yes | GitLab API access |
CLOUDFLARE_ACCOUNT_ID |
Yes | Cloudflare account |
CLOUDFLARE_API_TOKEN |
Yes | Cloudflare API access |
GITLAB_TEST_GROUP |
No | Override test group (default: gograbspace) |
E2E_SKIP_CLEANUP |
No | Keep test resources |
Test Group
Tests use the existing gograbspace group (ID: 122455722) because:
- Token doesn't have group creation permissions
- Avoids creating unnecessary groups
Test Resource Naming
All test resources are prefixed for easy identification:
| Resource Type | Prefix | Example |
|---|---|---|
| GitLab projects | e2e-test- |
e2e-test-1769264009565 |
| Cloudflare projects | e2e-test- |
e2e-test-1769264024426 |
Cleanup
Automatic Cleanup
Tests automatically clean up resources in afterAll:
- Deletes all GitLab projects created
- Deletes all Cloudflare projects created
Skip Cleanup (Debug)
E2E_SKIP_CLEANUP=true yarn e2e:pipeline
Resources remain for inspection.
Manual Cleanup
# List test projects
curl -H "PRIVATE-TOKEN: $GITLAB_API_TOKEN" \
"https://gitlab.com/api/v4/groups/122455722/projects?search=e2e-test" | jq '.[].name'
# Delete specific project
curl -X DELETE -H "PRIVATE-TOKEN: $GITLAB_API_TOKEN" \
"https://gitlab.com/api/v4/projects/gograbspace%2Fe2e-test-xxx"
Known Limitations
GitLab Pipeline Triggering
Pipeline triggering requires GitLab identity verification:
- Go to https://gitlab.com/-/identity_verification
- Verify via credit card or phone (one-time)
- Pipelines work immediately after
CI Job Script Validation
GitLab validates CI YAML syntax strictly:
- Script must be string or array
- Multi-line scripts need proper formatting
Troubleshooting
"403 Forbidden" on Group Operations
Cause: Token lacks group creation permission
Solution: Tests use existing gograbspace group
"Identity verification required"
Cause: GitLab.com policy for CI/CD
Solution: Verify at https://gitlab.com/-/identity_verification
Tests Timeout
Cause: Network latency or API slowness
Solution: Increase timeout in test configuration
Cleanup Failures
Cause: Resource already deleted or network error
Impact: None (cleanup is best-effort)
CI Integration
Running in CI/CD
# .github/workflows/e2e.yml
e2e-deployment:
runs-on: ubuntu-latest
env:
GITLAB_API_TOKEN: ${{ secrets.GITLAB_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
steps:
- uses: actions/checkout@v4
- run: yarn install
- run: yarn e2e:pipeline