Skip to content

feat(GDB-11898) Run cypress test in parallel with Testcontainers#1898

Draft
teodossidossev wants to merge 1 commit intomasterfrom
GDB-11898-cypress-run-parallel
Draft

feat(GDB-11898) Run cypress test in parallel with Testcontainers#1898
teodossidossev wants to merge 1 commit intomasterfrom
GDB-11898-cypress-run-parallel

Conversation

@teodossidossev
Copy link
Copy Markdown
Contributor

WHAT

  • Added detailed sections on how Docker containers for GraphDB and Workbench are managed dynamically via Testcontainers.
  • Included instructions on how custom Cypress tasks and hooks are used to start and stop containers, ensuring proper cleanup after tests.
  • Adjusted the Cypress configuration (cypress.config.js) to conditionally set the host and dynamically determine the free port.
  • Updated the Docker Compose file to set the correct build context and Dockerfile for the cypress-tests service
  • Updated the developers guide to document the E2E testing setup using Cypress and Testcontainers.

WHY

  • To enable end-to-end testing with Cypress by dynamically managing dependent Docker containers (GraphDB and Workbench) using Testcontainers.
  • To ensure that each Cypress instance runs on its own unique free port, thereby avoiding conflicts during parallel test execution.
  • To allow every test spec to run both locally and within a Docker environment (e.g., on Jenkins) with fresh started containers (GraphDB and Workbench).

HOW

  • Revised the test-cypress/Dockerfile to use proper relative paths (e.g., COPY ../docker-rootfs/ /workbench/docker-rootfs/) when the build context is set to the project root via Docker Compose.
  • In test-cypress/support/index.js and test-cypress/plugins/index.js, added detailed comments describing the logic of custom tasks (start/stop of GraphDB and Workbench) and the corresponding hooks (before and after) that ensure containers are running and are cleaned up after tests.
  • Adjusted the cypress.config.js to use an asynchronous function that imports get-port, determines a free port, and sets the baseUrl dynamically. It also checks the IS_DOCKER environment variable to set the appropriate host (using 172.17.0.1 when running in Docker).
  • Updated the docker-compose.yml to set the build context as the project root (.) and to use the correct Dockerfile (test-cypress/Dockerfile) for the cypress-tests service. Also added the mounting of /var/run/docker.sock to allow Testcontainers to interact with the host Docker daemon.
  • Modified docs/developers-guide.md to include a new section that explains the end-to-end testing setup with Cypress and Testcontainers. The guide now details:
    • How Docker containers for GraphDB and Workbench are started and stopped via custom Cypress tasks.
    • How dynamic port allocation is implemented with get-port.
    • How the Cypress configuration (cypress.config.js) dynamically sets the baseUrl based on the runtime environment.

Checklist

  • Branch name
  • Target branch
  • Commit messages
  • Squash commits
  • MR name
  • MR Description
  • Tests

@teodossidossev teodossidossev force-pushed the GDB-11898-cypress-run-parallel branch 7 times, most recently from 04356ed to f5820db Compare March 21, 2025 06:53
@sonarqubecloud
Copy link
Copy Markdown

@teodossidossev teodossidossev force-pushed the GDB-11898-cypress-run-parallel branch 22 times, most recently from 1aa4cce to 169c6fb Compare March 26, 2025 13:05
@teodossidossev teodossidossev force-pushed the GDB-11898-cypress-run-parallel branch 8 times, most recently from ea23389 to 06451b8 Compare March 27, 2025 07:31
## WHAT
- Added detailed sections on how Docker containers for GraphDB and Workbench are managed dynamically via Testcontainers.
- Included instructions on how custom Cypress tasks and hooks are used to start and stop containers, ensuring proper cleanup after tests.
- Adjusted the Cypress configuration (`cypress.config.js`) to conditionally set the host and dynamically determine the free port.
- Updated the Docker Compose file to set the correct build context and Dockerfile for the `cypress-tests` service
- Updated the developers guide to document the E2E testing setup using Cypress and Testcontainers.

## WHY
- To enable end-to-end testing with Cypress by dynamically managing dependent Docker containers (GraphDB and Workbench) using Testcontainers.
- To ensure that each Cypress instance runs on its own unique free port, thereby avoiding conflicts during parallel test execution.
- To allow every test spec to run both locally and within a Docker environment (e.g., on Jenkins) with fresh started containers (GraphDB and Workbench).

## HOW
- Revised the `test-cypress/Dockerfile` to use proper relative paths (e.g., `COPY ../docker-rootfs/ /workbench/docker-rootfs/`) when the build context is set to the project root via Docker Compose.
- In `test-cypress/support/index.js` and `test-cypress/plugins/index.js`, added detailed comments describing the logic of custom tasks (start/stop of GraphDB and Workbench) and the corresponding hooks (`before` and `after`) that ensure containers are running and are cleaned up after tests.
- Adjusted the `cypress.config.js` to use an asynchronous function that imports `get-port`, determines a free port, and sets the `baseUrl` dynamically. It also checks the `IS_DOCKER` environment variable to set the appropriate host (using `172.17.0.1` when running in Docker).
- Updated the `docker-compose.yml` to set the build context as the project root (`.`) and to use the correct Dockerfile (`test-cypress/Dockerfile`) for the `cypress-tests` service. Also added the mounting of `/var/run/docker.sock` to allow Testcontainers to interact with the host Docker daemon.
- Modified `docs/developers-guide.md` to include a new section that explains the end-to-end testing setup with Cypress and Testcontainers. The guide now details:
  - How Docker containers for GraphDB and Workbench are started and stopped via custom Cypress tasks.
  - How dynamic port allocation is implemented with `get-port`.
  - How the Cypress configuration (`cypress.config.js`) dynamically sets the `baseUrl` based on the runtime environment.
@teodossidossev teodossidossev force-pushed the GDB-11898-cypress-run-parallel branch from 06451b8 to 0c70e1a Compare March 27, 2025 07:36
@svilenvelikov svilenvelikov marked this pull request as draft July 14, 2025 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant