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:

  1. โœ… GitLab API connectivity
  2. โœ… GitLab project creation
  3. โœ… GitLab file push
  4. โœ… GitLab pipeline triggering
  5. โœ… Cloudflare API connectivity
  6. โœ… Cloudflare project creation
  7. โœ… Full pipeline flow
  8. โœ… 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:


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:

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:

CI Job Script Validation

GitLab validates CI YAML syntax strictly:


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

See Also