Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor localdb tests #5078

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,104 @@ jobs:
name: 'Check code style with Prettier'
command: cd /tmp/repo/ && yarn run prettierCheckCircleCI

pull_cbioportal_test_codebase:
machine:
image: ubuntu-2204:2024.08.1
resource_class: medium
working_directory: /tmp/repo
steps:
- run:
name: Checkout cbioportal/cbioportal-test
environment:
TEST_REPO_URL: https://github.com/cbioportal/cbioportal-test
command: |
git clone ${TEST_REPO_URL}
- persist_to_workspace:
root: /tmp/repo
paths: cbioportal-test

checkout_pr:
machine:
image: ubuntu-2204:2024.08.1
resource_class: medium
working_directory: /tmp/repo
steps:
- checkout:
path: /tmp/repo/cbioportal-frontend
- persist_to_workspace:
root: /tmp/repo
paths: cbioportal-frontend

build_frontend:
<<: *defaults
working_directory: /tmp/repo
environment:
BRANCH_ENV: master
steps:
- attach_workspace:
at: /tmp/repo
- run:
name: Build frontend application
command: |
cd cbioportal-frontend
yarn install --frozen-lockfile
yarn run buildAll
- run:
name: Build frontend tests
command: |
cd cbioportal-frontend/end-to-end-test
yarn --ignore-engines
- persist_to_workspace:
root: /tmp/repo
paths:
- cbioportal-frontend

e2e_localdb_tests:
machine:
image: ubuntu-2204:2024.08.1
resource_class: large
working_directory: /tmp/repo
environment:
BACKEND_PORT: 8080
FRONTEND_PORT: 3000
NODE_VERSION: 15.2.1
YARN_VERSION: 1.22.5
DOCKER_IMAGE_MYSQL: cbioportal/cbioportal-dev:database
steps:
- attach_workspace:
at: /tmp/repo
- run:
name: Start backend server
command: |
cd cbioportal-test
./scripts/docker-compose.sh --portal_type='web-and-data' --docker_args='-d'
- run:
name: Wait for backend server at localhost
command: |
cd cbioportal-test
./utils/check-connection.sh --url=localhost:${BACKEND_PORT} --max_retries=50
- run:
name: Start frontend server
command: |
cd cbioportal-frontend
openssl \
req -newkey rsa:2048 -new -nodes -x509 -days 1 -keyout key.pem -out cert.pem -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=localhost" && \
nohup ./node_modules/http-server/bin/http-server --cors dist/ -p ${FRONTEND_PORT} > /dev/null 2>&1 &
- run:
name: Wait for frontend server at localhost
command: |
cd cbioportal-test
./utils/check-connection.sh --url=localhost:${FRONTEND_PORT}
- run:
name: Run e2e localdb tests
command: |
cd cbioportal-frontend
nvm install ${NODE_VERSION}
nvm use ${NODE_VERSION}
npm install -g yarn@${YARN_VERSION}
yarn run e2e:local


workflows:
install_and_test:
jobs:
Expand Down Expand Up @@ -407,6 +505,19 @@ workflows:
- check_incorrect_import_statements:
requires:
- install

e2e_localdb_tests:
jobs:
- pull_cbioportal_test_codebase
- checkout_pr
- build_frontend:
requires:
- checkout_pr
- e2e_localdb_tests:
requires:
- pull_cbioportal_test_codebase
- build_frontend

nightly:
triggers:
- schedule:
Expand Down
39 changes: 3 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ A custom frontend can be tested against any backend in the web browser using a l
## Run of `localdb` e2e-tests
To enable e2e-tests on for features that depend on data that are not included in studies served by the public cBioPortal instance, cbioportal-frontend provides the `e2e local database` (refered to as _e2e-localdb_ or _local e2e_ in this text) facility that allows developers to load custom studies in any backend version used for e2e-tests. CircleCI runs the `e2e-localdb` tests as a separate job.

Files for the local database e2e-tests are located in the `./end-to-end-test/local` directory of cbioportal-frontend. The directory structure of `./end-to-end-test/local` is comparable to that of the `./end-to-end-test/remote` directory used for e2e-tests against remote public cBioPortal instances.
The script that can be used to run e2e-localdb tests is located at [./scripts/e2e-localdb.sh](./scripts/e2e-localdb.sh).

### Running `localdb` e2e-tests for development

Expand All @@ -195,45 +195,12 @@ Files for the local database e2e-tests are located in the `./end-to-end-test/loc

3. You need to have a global version of Maven installed.

In a terminal, start the frontend dev server
In a terminal, call script from root directory.

```
export BRANCH_ENV=custom
yarn install --frozen-lockfile // only necessary first time
yarn buildDLL:dev // only necessary first tiem
yarn start
./scripts/e2e-localdb.sh
```

3. Install dev dependencies:
```bash
cd end-to-end-test
yarn
```
5. In a second terminal at project root, spinup the backend (api) instance:

```
// if you are running for first time, you will need to build the docker containers.
// Answer yes when it prompts you to do so. This will take at least 20 minutes depending
// on your system speed.
// Once you have done this, you can answer no on subsequent attempts

yarn run e2e:spinup
```

6. When backend instance is operational, you can run tests. Upon executing
the command below, a browser should open and you should see your tests execute.

```
//grep accepts fragments of file name,
//but you MUST using trailing *
//you need only match the file name, not path

yarn run e2e:local --grep=some.spec*

```



### Running e2e-localdb tests _CircleCI_ or _CircleCI+PR_ context
E2e-tests on _CircleCI_ and _CircleCI+PR_ context are triggered via _hooks_ configured on GitHub. Configuration of hooks falls beyond the scope of this manual.

Expand Down
Loading
Loading