Skip to content

Add modular e2e test infrastructure with ClickHouse test data - #34

Open
inodb wants to merge 10 commits into
mainfrom
add-clickhouse-test-image
Open

inodb wants to merge 10 commits into
mainfrom
add-clickhouse-test-image

Conversation

@inodb

@inodb inodb commented Mar 23, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Add ClickHouse test data Docker image build script and CI workflow (mirrors mysql:8.0-database-test)
  • Add self-contained docker-compose.e2e.yml with swappable components (frontend, backend, database, test runner)
  • Inline Caddy reverse proxy config via Compose configs block — no repo clone needed, just curl + docker compose run
  • Add documentation for e2e architecture, usage, and component swapping

Test plan

  • docker compose -f docker-compose.e2e.yml config validates successfully
  • docker compose -f docker-compose.e2e.yml run test-runner runs e2e tests end-to-end
  • ClickHouse test data image builds via docker/clickhouse/build.sh

🤖 Generated with Claude Code

inodb and others added 3 commits March 20, 2026 22:18
docker/clickhouse/build.sh builds a ClickHouse image pre-loaded with
all test study data, mirroring the MySQL test image for the column store.

Includes:
- 5 CI test studies (ascn_test_study, study_es_0, study_hg38,
  teststudy_genepanels, lgg_ucsf_2014_test_generic_assay)
- All Sling-created derived tables
- Gene panels (TESTPANEL1, TESTPANEL2, WES)

GitHub Action rebuilds automatically when build script or data changes.

Usage: ghcr.io/cbioportal/clickhouse-test:latest
docker-compose.e2e.yml wires 4 swappable images:
- Frontend (static-web-server + React app)
- Backend (Go or Java API)
- Database (ClickHouse with test data)
- Test runner (Chrome + WebDriverIO + specs)

Swap any component via environment variables:
  BACKEND_IMAGE=inodb/cbioportal-api:latest
  FRONTEND_IMAGE=cbioportal/frontend:pr-1234

Uses Caddy as reverse proxy (/api/* -> backend, /* -> frontend).
Results written to ./e2e-results/ volume.
The compose file is now fully self-contained — users can curl it and
run without cloning the repo. Also updates usage comments and README
to use `docker compose run test-runner`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@inodb inodb changed the title Inline Caddyfile into docker-compose.e2e.yml Add modular e2e test infrastructure with ClickHouse test data Mar 23, 2026
@inodb
inodb requested a review from Copilot March 23, 2026 22:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a modular, self-contained E2E testing setup that can be run via Docker Compose with swappable frontend/backend/database/test-runner images, and introduces automation/scripts to build a ClickHouse test-data image for CI and local use.

Changes:

  • Added docker-compose.e2e.yml for a modular E2E stack (frontend, backend, ClickHouse DB, Caddy proxy, test runner).
  • Added ClickHouse test-data image build script plus a GitHub Actions workflow to build/push the image.
  • Added documentation for the E2E architecture/usage and the ClickHouse test-data image.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
docker/e2e/README.md Documents the modular E2E architecture and how to swap components.
docker/clickhouse/build.sh Script to assemble a ClickHouse image preloaded with CI test data via MySQL → Sling import.
docker/clickhouse/README.md Documents the ClickHouse test-data image usage and how it’s built/updated.
docker-compose.e2e.yml Compose definition wiring DB/backend/frontend/proxy/test-runner with configurable images.
.github/workflows/build-clickhouse-image.yml CI workflow to build and push the ClickHouse test-data image to GHCR.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docker/clickhouse/build.sh Outdated
Comment on lines +49 to +66
for i in $(seq 1 90); do
if docker exec ch-build-mysql mysql -ucbio_user -psomepassword cbioportal -e "SELECT 1" >/dev/null 2>&1; then
echo " MySQL ready after ${i}s"
break
fi
sleep 2
done

# Wait for ClickHouse
echo "Waiting for ClickHouse to be ready..."
for i in $(seq 1 30); do
if docker exec ch-build-clickhouse clickhouse-client --user cbio_user --password somepassword -q "SELECT 1" >/dev/null 2>&1; then
echo " ClickHouse ready after ${i}s"
break
fi
sleep 2
done

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MySQL readiness loop always falls through after the timeout, even if MySQL never becomes reachable, so the script can continue and produce a broken/empty image. Consider tracking success and exit 1 if the loop completes without a successful query; also the log message uses ${i}s but you sleep 2s per iteration (so it under-reports elapsed time).

Suggested change
for i in $(seq 1 90); do
if docker exec ch-build-mysql mysql -ucbio_user -psomepassword cbioportal -e "SELECT 1" >/dev/null 2>&1; then
echo " MySQL ready after ${i}s"
break
fi
sleep 2
done
# Wait for ClickHouse
echo "Waiting for ClickHouse to be ready..."
for i in $(seq 1 30); do
if docker exec ch-build-clickhouse clickhouse-client --user cbio_user --password somepassword -q "SELECT 1" >/dev/null 2>&1; then
echo " ClickHouse ready after ${i}s"
break
fi
sleep 2
done
mysql_ready=0
for i in $(seq 1 90); do
if docker exec ch-build-mysql mysql -ucbio_user -psomepassword cbioportal -e "SELECT 1" >/dev/null 2>&1; then
echo " MySQL ready after $((i * 2))s"
mysql_ready=1
break
fi
sleep 2
done
if [ "$mysql_ready" -ne 1 ]; then
echo "MySQL did not become ready within $((90 * 2))s, aborting."
exit 1
fi
# Wait for ClickHouse
echo "Waiting for ClickHouse to be ready..."
clickhouse_ready=0
for i in $(seq 1 30); do
if docker exec ch-build-clickhouse clickhouse-client --user cbio_user --password somepassword -q "SELECT 1" >/dev/null 2>&1; then
echo " ClickHouse ready after $((i * 2))s"
clickhouse_ready=1
break
fi
sleep 2
done
if [ "$clickhouse_ready" -ne 1 ]; then
echo "ClickHouse did not become ready within $((30 * 2))s, aborting."
exit 1
fi

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — readiness loops now track success and exit 1 on timeout. Elapsed time reports i*2 seconds.

Comment on lines +49 to +65
for i in $(seq 1 90); do
if docker exec ch-build-mysql mysql -ucbio_user -psomepassword cbioportal -e "SELECT 1" >/dev/null 2>&1; then
echo " MySQL ready after ${i}s"
break
fi
sleep 2
done

# Wait for ClickHouse
echo "Waiting for ClickHouse to be ready..."
for i in $(seq 1 30); do
if docker exec ch-build-clickhouse clickhouse-client --user cbio_user --password somepassword -q "SELECT 1" >/dev/null 2>&1; then
echo " ClickHouse ready after ${i}s"
break
fi
sleep 2
done

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ClickHouse readiness loop has the same problem as the MySQL loop: if ClickHouse never becomes ready, the script continues anyway. Please fail the build when the timeout is reached (and consider reporting actual elapsed seconds since each iteration sleeps 2s).

Suggested change
for i in $(seq 1 90); do
if docker exec ch-build-mysql mysql -ucbio_user -psomepassword cbioportal -e "SELECT 1" >/dev/null 2>&1; then
echo " MySQL ready after ${i}s"
break
fi
sleep 2
done
# Wait for ClickHouse
echo "Waiting for ClickHouse to be ready..."
for i in $(seq 1 30); do
if docker exec ch-build-clickhouse clickhouse-client --user cbio_user --password somepassword -q "SELECT 1" >/dev/null 2>&1; then
echo " ClickHouse ready after ${i}s"
break
fi
sleep 2
done
MYSQL_READY=0
for i in $(seq 1 90); do
if docker exec ch-build-mysql mysql -ucbio_user -psomepassword cbioportal -e "SELECT 1" >/dev/null 2>&1; then
echo " MySQL ready after $((i * 2))s"
MYSQL_READY=1
break
fi
sleep 2
done
if [ "$MYSQL_READY" -ne 1 ]; then
echo "MySQL did not become ready within $((90 * 2))s" >&2
exit 1
fi
# Wait for ClickHouse
echo "Waiting for ClickHouse to be ready..."
CLICKHOUSE_READY=0
for i in $(seq 1 30); do
if docker exec ch-build-clickhouse clickhouse-client --user cbio_user --password somepassword -q "SELECT 1" >/dev/null 2>&1; then
echo " ClickHouse ready after $((i * 2))s"
CLICKHOUSE_READY=1
break
fi
sleep 2
done
if [ "$CLICKHOUSE_READY" -ne 1 ]; then
echo "ClickHouse did not become ready within $((30 * 2))s" >&2
exit 1
fi

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in same change as above.

cleanup() {
echo "Cleaning up..."
docker rm -f ch-build-mysql ch-build-clickhouse 2>/dev/null || true
docker network rm "$NETWORK" 2>/dev/null || true

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleanup() only removes containers and the network; if the script errors after creating $TMPDIR / $COMPOSE_DIR, those temp directories will be left behind. Consider creating them before trap is set (or adding them to cleanup() with guards) so failures don't leak temp files.

Suggested change
docker network rm "$NETWORK" 2>/dev/null || true
docker network rm "$NETWORK" 2>/dev/null || true
if [ -n "${TMPDIR:-}" ] && [ -d "$TMPDIR" ]; then
rm -rf "$TMPDIR" || true
fi
if [ -n "${COMPOSE_DIR:-}" ] && [ -d "$COMPOSE_DIR" ]; then
rm -rf "$COMPOSE_DIR" || true
fi

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — cleanup() now removes TMPDIR and COMPOSE_DIR with guards.

Comment thread docker/clickhouse/build.sh Outdated
Comment on lines +76 to +77
git clone --depth 1 https://github.com/cBioPortal/cbioportal-docker-compose.git "$COMPOSE_DIR" 2>/dev/null

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These commands silence stderr (2>/dev/null), which makes CI failures very hard to diagnose and can hide important errors (e.g., schema path changes or clone failures). It’s better to let stderr through, or at least print a clear error when expected files/scripts are missing.

Suggested change
git clone --depth 1 https://github.com/cBioPortal/cbioportal-docker-compose.git "$COMPOSE_DIR" 2>/dev/null
if ! git clone --depth 1 https://github.com/cBioPortal/cbioportal-docker-compose.git "$COMPOSE_DIR"; then
echo "Error: Failed to clone cBioPortal Docker Compose repository into $COMPOSE_DIR" >&2
exit 1
fi
# Verify expected Sling init scripts exist
if [ ! -f "$COMPOSE_DIR/addon/clickhouse/init.sh" ] || [ ! -f "$COMPOSE_DIR/addon/clickhouse/sync-databases.sh" ]; then
echo "Error: Expected Sling ClickHouse init scripts not found in cloned repository at:" >&2
echo " $COMPOSE_DIR/addon/clickhouse/init.sh" >&2
echo " $COMPOSE_DIR/addon/clickhouse/sync-databases.sh" >&2
exit 1
fi

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — removed 2>/dev/null from git clone, added explicit error check and validation that expected scripts exist.

Comment thread docker-compose.e2e.yml Outdated
database:
image: ${DB_IMAGE:-ghcr.io/cbioportal/clickhouse-test:latest}
healthcheck:
test: ["CMD", "clickhouse-client", "--query", "SELECT 1"]

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The database healthcheck runs clickhouse-client --query "SELECT 1" without specifying user/password/database, but the rest of this setup (and the ClickHouse README) implies a non-default user (cbio_user) and password. If the image disables the default user or requires auth, this healthcheck will fail and block the stack. Update the healthcheck to use the same credentials/DB as the DSN (or use an unauthenticated ping endpoint if that’s the intent).

Suggested change
test: ["CMD", "clickhouse-client", "--query", "SELECT 1"]
test: ["CMD", "clickhouse-client", "--user", "cbio_user", "--password", "somepassword", "--database", "cbioportal", "--query", "SELECT 1"]

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — healthcheck now includes --user, --password, and --database flags.

Comment thread docker/clickhouse/build.sh Outdated
Comment on lines +104 to +107
# Commit
echo ""
echo "Committing image as $TAG..."
docker commit ch-build-clickhouse "$TAG"

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker commit is taken from a live ClickHouse container. Databases can have in-flight writes, so committing while the server is running can capture an inconsistent state. Consider stopping ClickHouse (or at least flushing/syncing) before committing the container to make the image more reliable.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — ClickHouse is now stopped (with SYSTEM FLUSH LOGS) before docker commit.

Comment thread docker/e2e/README.md
Comment on lines +46 to +48
# Test with different data
DB_IMAGE=cbioportal/clickhouse:genie-data \
docker compose -f docker-compose.e2e.yml run test-runner

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs/examples here refer to cbioportal/clickhouse:* images, but docker-compose.e2e.yml defaults DB_IMAGE to ghcr.io/cbioportal/clickhouse-test:latest. This mismatch will confuse users trying the “Quick Start” / swapping examples—please align the README examples and the default image naming/registry.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — all references now use cbioportal/clickhouse-test:latest (Docker Hub).

Comment thread docker/e2e/README.md
Comment on lines +60 to +77
## Images

| Image | Source | Description |
|---|---|---|
| `cbioportal/frontend:latest` | cbioportal-frontend | Static web server + built React app |
| `cbioportal/cbioportal:latest` | cbioportal | Java backend (default) |
| `inodb/cbioportal-api:latest` | cbioportal-api | Go backend (alternative) |
| `cbioportal/clickhouse:test-data` | cbioportal-test | ClickHouse with 5 test studies |
| `cbioportal/e2e-runner:latest` | cbioportal-frontend | Chrome + WebDriverIO + test specs |

## Environment Variables

| Variable | Default | Description |
|---|---|---|
| `BACKEND_IMAGE` | `cbioportal/cbioportal:6.4.1` | Backend Docker image |
| `FRONTEND_IMAGE` | `cbioportal/frontend:latest` | Frontend Docker image |
| `DB_IMAGE` | `cbioportal/clickhouse:test-data` | Database Docker image |
| `RUNNER_IMAGE` | `cbioportal/e2e-runner:latest` | Test runner Docker image |

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The “Images” / “Environment Variables” tables list the default DB image as cbioportal/clickhouse:test-data, but the compose file actually defaults to ghcr.io/cbioportal/clickhouse-test:latest. Please update the tables (or the compose default) so readers don’t set the wrong image/tag.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — tables now show cbioportal/clickhouse-test:latest.

Comment on lines +33 to +36
```bash
./build.sh [tag]
# Default: cbioportal/clickhouse:test-data
```

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This README presents the published image as ghcr.io/cbioportal/clickhouse-test:latest, but the build script’s default tag is cbioportal/clickhouse:test-data. Please align the default tag (or clarify in the README which tag/registry is canonical) to avoid building one name while CI pushes another.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — build.sh default tag and README both use cbioportal/clickhouse-test:latest now.

Comment on lines +15 to +20
jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unlike the existing database image workflow, this job doesn’t gate execution to the canonical repo (e.g., if: github.repository == 'cbioportal/cbioportal-test'). Without that, forks will run the job and then fail at the push step due to missing permissions, creating noisy CI. Consider adding the same repository guard for consistency.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — added if: github.repository == 'cBioPortal/cbioportal-test' guard.

inodb and others added 3 commits March 23, 2026 22:53
Switch build workflow from GHCR to Docker Hub (cbioportal/clickhouse-test),
update all image references, and add CI workflow to detect backend image
version drift between cbioportal-test and cbioportal-docker-compose.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- build.sh: fail on readiness timeout, fix elapsed time reporting, clean
  temp dirs in trap, validate cloned scripts exist, stop ClickHouse before
  docker commit, align default tag to cbioportal/clickhouse-test:latest
- build workflow: fix branch trigger (master→main), add repo guard for forks
- docker-compose.e2e.yml: add credentials to ClickHouse healthcheck
- READMs: align image names to cbioportal/clickhouse-test:latest

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@inodb
inodb requested a review from zainasir March 31, 2026 18:39
inodb and others added 4 commits April 10, 2026 15:25
Replace the Sling-based MySQL→ClickHouse import with direct schema + seed
loading via docker-entrypoint-initdb.d, mirroring the simplified approach
from cbioportal-docker-compose#72.

- Drop MySQL container, cbioportal-core clone, Sling importer
- Load schema.sql and seed.sql.gz (~44K genes, ~850 cancer types, 50 tables)
  directly from cbioportal/add-clickhoue-database-schema-and-seed branch
- build.sh now just downloads the files and runs docker build (seconds, not
  minutes)
- Dockerfile copies schema/seed into /docker-entrypoint-initdb.d/

Also fix Caddyfile syntax in docker-compose.e2e.yml (block bodies on their
own lines, not inline).

NOTE: This image contains reference data only — no test studies. The Go
API works against this image; endpoints for studies/samples/mutations
return empty arrays. Test study import is a separate concern.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The raw SELECT 1 healthcheck returns OK as soon as ClickHouse is accepting
connections, but before docker-entrypoint-initdb.d scripts (schema.sql +
seed.sql.gz) have finished. This races with the backend start_period and
causes the Go API to fail queries against tables that don't exist yet.

Change the healthcheck to assert that the gene table has been populated
(which happens near the end of seed loading). Bump retries to 60 and add
30s start_period to give ClickHouse time to initialize.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The simplified schema-only image was missing the 5 CI test studies, so e2e
tests fail in 'before all' hooks waiting for #patientViewPageTabs.

Add test study import as a build step:
1. Build a base image with the upstream schema + seed loaded via
   docker-entrypoint-initdb.d (genes, cancer types, reference genomes)
2. Start that ClickHouse container alongside cbioportal/mysql:8.0-database-test
3. Run the Sling importer (init.sh) to sync MySQL test studies into ClickHouse,
   plus the derived-table SQL scripts from cbioportal/cbioportal:6.4.1
4. docker cp the populated /var/lib/clickhouse out of the container (volumes
   aren't captured by docker commit) and bake it into the final image via
   docker build COPY

Result: 5 studies, 918 samples, 10560 mutations, 7767 clinical records,
plus all derived tables. Total image size ~1.2GB.

Detect import completion by polling for /workdir/init-complete.txt that
init.sh touches when done — init.sh ends with `tail -f /dev/null` so we
can't just `docker run --rm` it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The cbioportal-frontend column-store proxy reads window.frontendConfig.apiRoot
and computes the host as a side effect of stripping the URL scheme. When
apiRoot is just "/" the resulting host is empty and the proxy generates
"//api/column-store/..." URLs (browser interprets "api" as a hostname,
resulting in ERR_NAME_NOT_RESOLVED).

The frontend image now reads API_ROOT/BASE_URL from env vars at startup
and substitutes them into index.html. Set API_ROOT=http://proxy/ in the
e2e compose so the column-store proxy resolves to //proxy/api/column-store/.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants