Skip to content

Commit d07c959

Browse files
authored
✅ Add e2e/integration testing (#11613)
* Split integration test out * Add e2e test * Add E2E test workflow * Fix profile for e2e tests * update to run integration and e2e test * Fix env vars * fix sonar workflow
1 parent cf60c85 commit d07c959

29 files changed

+4522
-1197
lines changed

.github/workflows/core-test.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
name: Core tests
2-
on: [push, pull_request]
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
inputs:
8+
ref:
9+
description: 'Branch or PR to test (default: main)'
10+
required: false
11+
default: 'main'
12+
13+
permissions:
14+
id-token: write # This is required for requesting the JWT
15+
contents: read # This is required for actions/checkout
16+
317
jobs:
418
build:
519
name: Setup and Test
@@ -12,6 +26,9 @@ jobs:
1226
ports:
1327
- 3306
1428
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=10
29+
env:
30+
TEST_DB_CLICKHOUSE_PASSWORD: ${{ secrets.TEST_DB_CLICKHOUSE_PASSWORD }}
31+
TEST_DB_MYSQL_PASSWORD: ${{ secrets.TEST_DB_MYSQL_PASSWORD }}
1532
steps:
1633
- name: 'Checkout cbioportal repo'
1734
uses: actions/checkout@v2
@@ -64,4 +81,8 @@ jobs:
6481
- name: 'Run integration tests separately'
6582
working-directory: ./cbioportal
6683
run: |
67-
mvn -U -Ppublic integration-test -Ddb.test.username=cbio_user -Ddb.test.password=somepassword
84+
mvn verify -Pintegration-test
85+
- name: 'Run e2e tests separately'
86+
working-directory: ./cbioportal
87+
run: |
88+
mvn verify -Pe2e-test

.github/workflows/security-integration-test.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/sonarcloud.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ jobs:
99
build:
1010
name: sonarcloud
1111
runs-on: ubuntu-latest
12+
env:
13+
TEST_DB_CLICKHOUSE_PASSWORD: ${{ secrets.TEST_DB_CLICKHOUSE_PASSWORD }}
14+
TEST_DB_MYSQL_PASSWORD: ${{ secrets.TEST_DB_MYSQL_PASSWORD }}
1215
steps:
1316
- uses: actions/checkout@v2
1417
with:
@@ -43,8 +46,11 @@ jobs:
4346
- name: 'Run integration tests'
4447
run: |
4548
mvn verify -Pintegration-test
49+
- name: 'Run e2e tests'
50+
run: |
51+
mvn verify -Pe2e-test
4652
- name: Code Coverage
4753
env:
4854
SONAR_TOKEN: de1b5cc660cd210dde840f492c371da6cc801763
4955
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50-
run: mvn sonar:sonar -Pcoverage
56+
run: mvn sonar:sonar -Pcoverage

README.md

Lines changed: 138 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,47 @@ The cBioPortal for Cancer Genomics provides visualization, analysis, and downloa
66

77
If you would like to know how to setup a private instance of the portal and/or get set up for developing, see the [documentation](https://docs.cbioportal.org). For details on contributing code changes via pull requests, see our [Contributing document](CONTRIBUTING.md).
88

9-
If you are interested in coordinating the development of new features, please contact [email protected] or reach out on https://slack.cbioportal.org.
9+
If you are interested in coordinating the development of new features, please contact <[email protected]> or reach out on <https://slack.cbioportal.org>.
1010

1111
## 📘 Documentation
12+
1213
See [https://docs.cbioportal.org](https://docs.cbioportal.org)
1314

1415
## 🤝 License
16+
1517
See [LICENSE](./LICENSE)
1618

1719
## 💻 Run Backend
20+
1821
cBioPortal consists of several components, please read the [Architecture docs](https://docs.cbioportal.org/architecture-overview/) to figure out what repo would be relevant to edit. If you e.g. only want to make frontend changes, one can directly edit [the frontend repo](https://github.com/cbioportal/cbioportal-frontend) instead. Read the instructions in that repo for more info on how to do frontend development. This repo only contains the backend part. Before editing the backend, it's good to read the [backend code organization](docs/development/Backend-Code-Organization.md).
1922

2023
### Local Development
2124

2225
This section provides a summary. For Quick Start instructions, or for more additional information, please see [Deploy with Docker](https://docs.cbioportal.org/deployment/docker/)
2326

2427
#### What MySQL database to use
25-
We recommend to set up a MySQL database automatically using [Docker Compose](https://github.com/cBioPortal/cbioportal-docker-compose). It's useful to know how to do this as it allows you to import any dataset of your choice. For debugging production issues, we also have a database available with all the data on https://cbioportal.org that one can connect to directly. Please reach out on slack to get the credentials.
28+
29+
We recommend to set up a MySQL database automatically using [Docker Compose](https://github.com/cBioPortal/cbioportal-docker-compose). It's useful to know how to do this as it allows you to import any dataset of your choice. For debugging production issues, we also have a database available with all the data on <https://cbioportal.org> that one can connect to directly. Please reach out on slack to get the credentials.
2630

2731
#### Deploy your development image inside Docker Compose
28-
The easiest option is to deploy your development image directly into the [docker-compose](https://github.com/cBioPortal/cbioportal-docker-compose/blob/5da068f0eb9b4f42db52ab5e91321b26a1826d7a/docker-compose.yml#L6) file.
32+
33+
The easiest option is to deploy your development image directly into the [docker-compose](https://github.com/cBioPortal/cbioportal-docker-compose/blob/5da068f0eb9b4f42db52ab5e91321b26a1826d7a/docker-compose.yml#L6) file.
2934

3035
1. From the cbioportal repo, build the image:
36+
3137
```
3238
docker build -t cbioportal/cbioportal:my-dev-cbioportal-image -f docker/web-and-data/Dockerfile .
3339
```
40+
3441
2. From the cbioportal-docker-compose repo, change the [env file](https://github.com/cBioPortal/cbioportal-docker-compose/blob/master/.env) to use your image (e.g. **cbioportal/cbioportal:my-dev-cbioportal-image**).
3542

3643
3. Run the containers.
44+
3745
```
3846
docker compose up
3947
```
4048

41-
4. The app will be visible at http://localhost:8080.
49+
4. The app will be visible at <http://localhost:8080>.
4250

4351
For more information, please see [Deploy with Docker](https://docs.cbioportal.org/deployment/docker/#building-cbioportal).
4452

@@ -49,6 +57,7 @@ If you want to instead run the cBioPortal web app from the command line please f
4957
```
5058
docker compose -f docker-compose.yml -f dev/open-ports.yml up
5159
```
60+
5261
This should open the ports. Now we are ready to run the cBioPortal web app locally. You can compile the backend code with:
5362

5463
```
@@ -70,7 +79,7 @@ java -Xms2g -Xmx4g \
7079
org.cbioportal.PortalApplication
7180
```
7281

73-
The app should now show up at http://localhost:8080.
82+
The app should now show up at <http://localhost:8080>.
7483

7584
### Dev Database
7685

@@ -98,35 +107,150 @@ You can then use a JAVA IDE to connect to that port. E.g. in [VSCode](https://co
98107
}
99108
```
100109

110+
## ✅ Testing Overview
111+
112+
This project uses a layered testing strategy that separates **unit**, **integration**, and **end-to-end (E2E)** tests for better clarity and control.
113+
114+
---
115+
116+
### 🧪 Test Layers
117+
118+
| Layer | Purpose | Runs by Default? | Tools Used |
119+
|--------------|-----------------------------------------------------------|------------------|-----------------------------|
120+
| **Unit** | Test isolated logic (e.g. services, utils) | ✅ Yes | JUnit, Mockito |
121+
| **Integration** | Test Spring components (e.g. JPA, Repositories) using real databases | 🚫 No | Spring Boot, Failsafe |
122+
| **E2E** | Test full HTTP endpoints via real HTTP calls | 🚫 No | Spring Boot, TestRestTemplate, MockMvc |
123+
124+
---
125+
126+
### 📁 Directory Structure
127+
128+
```
129+
src/test/java/ → Unit tests (default)
130+
src/integration/java/ → Integration tests (DB, Spring context)
131+
src/e2e/java/ → E2E tests (REST API over HTTP)
132+
```
133+
134+
---
135+
136+
## 🔧 Configuration via Environment Variables
137+
138+
All integration and E2E tests are **configured via environment variables** for test DBs. This avoids hardcoding credentials and allows flexible use in local dev or CI.
139+
140+
### ✅ Supported Environment Variables
141+
142+
| Variable | Description | Applies To |
143+
|----------------------------------|--------------------------------------|---------------------|
144+
| `TEST_DB_MYSQL_URL` | JDBC URL for test MySQL | Integration |
145+
| `TEST_DB_MYSQL_USERNAME` | MySQL username | Integration |
146+
| `TEST_DB_MYSQL_PASSWORD` | MySQL password (🔒 required) | Integration |
147+
| `TEST_DB_MYSQL_DRIVER` | Optional, defaults to MySQL driver | Integration |
148+
| `TEST_DB_CLICKHOUSE_URL` | JDBC URL for test ClickHouse | Integration & E2E |
149+
| `TEST_DB_CLICKHOUSE_USERNAME` | ClickHouse username | Integration & E2E |
150+
| `TEST_DB_CLICKHOUSE_PASSWORD` | ClickHouse password (🔒 required) | Integration & E2E |
151+
| `TEST_DB_CLICKHOUSE_DRIVER` | Optional, defaults to ClickHouse driver | Integration & E2E |
152+
153+
> If a variable is marked as required and not set, tests will fail with a helpful error.
154+
155+
---
156+
157+
### 🧪 Running Tests
158+
159+
#### ✅ Run Unit Tests (default)
160+
161+
```bash
162+
mvn test
163+
```
164+
165+
---
166+
167+
#### ✅ Run Integration Tests
168+
169+
```bash
170+
# Set required env vars
171+
export TEST_DB_MYSQL_PASSWORD=...
172+
export TEST_DB_CLICKHOUSE_PASSWORD=...
173+
174+
mvn verify -Pintegration-tests
175+
```
176+
177+
---
178+
179+
#### ✅ Run E2E Tests
180+
181+
```bash
182+
# Set required env vars
183+
export TEST_DB_MYSQL_PASSWORD=...
184+
export TEST_DB_CLICKHOUSE_PASSWORD=...
185+
186+
mvn verify -Pe2e-tests
187+
```
188+
189+
---
190+
191+
#### 🔍 Test Class Inheritance
192+
193+
All E2E tests should extend:
194+
195+
```java
196+
public abstract class AbstractE2ETest { ... }
197+
```
198+
199+
All integration tests (if needed) may use:
200+
201+
```java
202+
public abstract class AbstractClickhouseIntegrationTest { ... }
203+
```
204+
205+
These base classes:
206+
207+
- Load the Spring context
208+
- Register dynamic properties from environment variables using `@DynamicPropertySource`
209+
- Share default behavior across test suites
210+
211+
---
212+
213+
### 📦 Maven Profile Summary
214+
215+
| Profile | Purpose | Command |
216+
|-------------------|-----------------------|----------------------------------|
217+
| *(default)* | Unit tests only | `mvn test` |
218+
| `integration-tests` | Integration tests | `mvn verify -Pintegration-tests` |
219+
| `e2e-tests` | E2E tests | `mvn verify -Pe2e-tests` |
220+
221+
---
222+
101223
## 🌳 Branch Information
102224

103225
| | main branch | upcoming release branch | later release candidate branch |
104226
| --- | --- | --- | --- |
105227
| Branch name | [`master`](https://github.com/cBioPortal/cbioportal/tree/master) | -- | [`rc`](https://github.com/cBioPortal/cbioportal/tree/rc) |
106228
| Description | All bug fixes and features not requiring database migrations go here. This code is either already in production or will be released this week | Next release that requires database migrations. Thorough manual product review often takes place for this branch before release | Later releases with features that require database migrations. This is useful to allow merging in new features without affecting the upcoming release. Could be seen as a development branch, but note that only high quality pull requests are merged. That is the feature should be pretty much ready for release after merge. |
107-
| Live instance | https://www.cbioportal.org / https://master.cbioportal.org | -- | https://rc.cbioportal.org |
108-
| Live instance version | https://www.cbioportal.org/api/info / https://master.cbioportal.org/api/info | -- | https://rc.cbioportal.org/api/info |
229+
| Live instance | <https://www.cbioportal.org> / <https://master.cbioportal.org> | -- | <https://rc.cbioportal.org> |
230+
| Live instance version | <https://www.cbioportal.org/api/info> / <https://master.cbioportal.org/api/info> | -- | <https://rc.cbioportal.org/api/info> |
109231
| Docker Image | cbioportal/cbioportal:master | --| cbioportal/cbioportal:rc |
110232
| Kubernetes Config | [production](https://github.com/knowledgesystems/knowledgesystems-k8s-deployment/blob/master/cbioportal/cbioportal_spring_boot.yaml) / [master](https://github.com/knowledgesystems/knowledgesystems-k8s-deployment/blob/master/cbioportal/cbioportal_backend_master.yaml) | -- | [rc](https://github.com/knowledgesystems/knowledgesystems-k8s-deployment/blob/master/cbioportal/cbioportal_backend_rc.yaml) |
111233
| Status | [![master build status](https://github.com/cbioportal/cbioportal/workflows/Core%20tests/badge.svg)](https://github.com/cBioPortal/cbioportal/actions/workflows/core-test.yml?query=branch%3Amaster) [![master build status](https://github.com/cbioportal/cbioportal/workflows/Integration%20tests/badge.svg)](https://github.com/cBioPortal/cbioportal/actions/workflows/integration-test.yml?query=branch%3Amaster) [![master build status](https://github.com/cbioportal/cbioportal/workflows/Docker%20Image%20CI/badge.svg)](https://github.com/cBioPortal/cbioportal/actions/workflows/dockerimage.yml?query=branch%3Amaster) [![master build status](https://github.com/cbioportal/cbioportal/workflows/Python%20validator/badge.svg)](https://github.com/cBioPortal/cbioportal/actions/workflows/validate-data.yml?query=branch%3Amaster) [![CircleCI](https://circleci.com/gh/cBioPortal/cbioportal/tree/master.svg?style=svg)](https://app.circleci.com/pipelines/github/cBioPortal/cbioportal?branch=master&filter=all) | -- | -- |
112234

113235
## 🚀 Releases
236+
114237
Release Notes on GitHub:
115238

116-
https://github.com/cBioPortal/cbioportal/releases
239+
<https://github.com/cBioPortal/cbioportal/releases>
117240

118241
See also the cBioPortal News section for user focused release information:
119242

120-
https://www.cbioportal.org/news
243+
<https://www.cbioportal.org/news>
121244

122245
Docker Images are available for each tag and branch:
123246

124-
https://hub.docker.com/repository/docker/cbioportal/cbioportal/tags
247+
<https://hub.docker.com/repository/docker/cbioportal/cbioportal/tags>
125248

126249
## 👉 Other Repos
250+
127251
Read the [Architecture docs](https://docs.cbioportal.org/2.1-deployment/architecture-overview) to see how these relate:
128252

129-
- https://github.com/cBioPortal/cbioportal-frontend
130-
- https://github.com/cbioportal/session-service
131-
- https://github.com/cBioPortal/datahub/
132-
- https://github.com/cBioPortal/cbioportal-core
253+
- <https://github.com/cBioPortal/cbioportal-frontend>
254+
- <https://github.com/cbioportal/session-service>
255+
- <https://github.com/cBioPortal/datahub/>
256+
- <https://github.com/cBioPortal/cbioportal-core>

0 commit comments

Comments
 (0)