Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
Install only chromium, remove docker entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
4ydan committed Aug 5, 2023
1 parent d8cc7ae commit 26d26cb
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test: test-frontend test-backend test-mdbook test-e2e ## Test everything.

.PHONY: test-e2e
test-e2e: ## End-to-End tests. Needs backend and frontend running.
cd e2e && ./entrypoint.sh
cd e2e && ./e2e.sh

.PHONY: test-frontend
test-frontend: ## Test Frontend.
Expand Down
12 changes: 7 additions & 5 deletions ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -276,18 +276,20 @@ lock("${env.NODE_NAME}-exclusive") {
checkout scm
def e2eImage = docker.build("permaplant-e2e:build", "./e2e")
try {
wait_for_pr_db()
e2eImage.inside("-e CI=1 -e E2E_URL=http://pr.permaplant.net")
e2eImage.inside("-e CI=1 -e E2E_URL=http://pr.permaplant.net") {
wait_for_pr_db()
sh "make test-e2e"
}
} catch (err) {
echo "Error occurred during the e2eImage.inside block: ${err}"
// rethrow so build fails
// groovylint-disable-next-line
throw err;
} finally {
archiveArtifacts artifacts: 'test-results/**', fingerprint: true, allowEmptyArchive: true
archiveArtifacts artifacts: 'test-reports/report.html', fingerprint: true, allowEmptyArchive: true
archiveArtifacts artifacts: 'e2e/test-results/**', fingerprint: true, allowEmptyArchive: true
archiveArtifacts artifacts: 'e2e/test-reports/report.html', fingerprint: true, allowEmptyArchive: true
cucumber failedFeaturesNumber: -1, failedScenariosNumber: -1, failedStepsNumber: -1, \
fileIncludePattern: 'test-reports/cucumber.json', pendingStepsNumber: -1, skippedStepsNumber: -1, \
fileIncludePattern: 'e2e/test-reports/cucumber.json', pendingStepsNumber: -1, skippedStepsNumber: -1, \
sortingMethod: 'ALPHABETICAL', undefinedStepsNumber: -1
deleteDir();
}
Expand Down
3 changes: 0 additions & 3 deletions e2e/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,3 @@ WORKDIR $PERMAPLANT_PATH
COPY . $PERMAPLANT_PATH

RUN ./install.sh
RUN chmod +x ./entrypoint.sh

ENTRYPOINT ["./entrypoint.sh"]
33 changes: 18 additions & 15 deletions e2e/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PermaplanT E2E tests

The Jenkins pipeline executes exactly this `Dockerfile` with `entrypoint.sh`.
The Jenkins pipeline executes exactly this [Dockerfile](Dockerfile) invoking [e2e.sh](e2e.sh).
It only skips the clean_db.py step, since its not needed in CI.
So running this setup locally should give you fast feedback.

Expand All @@ -13,8 +13,8 @@ All commands/scripts in this README are executed from this folder (/e2e).
├── pages Page object models
├── steps The actual tests
├── conftest.py Global pytest fixtures, functions.
├── test-reports pie charts, tables, runtime, etc.
├── test-results screenshots, videos, etc.
├── test-reports Pie charts, tables, runtime, etc.
├── test-results Screenshots, videos, etc.
```

## Quickstart
Expand All @@ -24,7 +24,7 @@ This will install all dependencies and run e2e tests with these [ENV](.env) vari

```sh
./install.sh
./entrypoint.sh
./e2e.sh
```

### Creating a virtual env
Expand All @@ -36,7 +36,7 @@ sudo apt install python3-venv
python3 -m venv venv
source venv/bin/activate
./install.sh
./entrypoint.sh
./e2e.sh
```

### Inside Docker
Expand All @@ -45,7 +45,7 @@ Assuming your app and database is on your localhost network.

```sh
docker build -t permaplant-e2e .
docker run --network="host" permaplant-e2e
docker run --network="host" permaplant-e2e ./e2e.sh
```

If you have a more complicated network/database setup you might need to configure all env variables and use `docker run --network`.
Expand All @@ -65,10 +65,13 @@ Feel free to open an Issue/PR if something is not working.

### Optional arguments

Most of these are set inside `.entrypoint.sh`
Most of these are already set inside [e2e.sh](e2e.sh).
Nevertheless, if you maybe want to build your own script, here are some pytest arguments.

#### Parallelization

Use as many processes as your computer has CPU cores.

```sh
python3 -m pytest -n auto
```
Expand All @@ -91,25 +94,25 @@ python3 -m pytest steps/test_login_logout.py
python3 -m pytest --video on
```

only on test failures
Only on test failures.

```sh
python3 -m pytest --video retain-on-failure
```

#### Flaky tests

If there is something suspicious going on
If there is something suspicious going on.

```sh
set -e; for i in `seq 10`;do echo "Running iteration $i"; python -m pytest -n auto; done
```

### Cleanup

Currently we need to use the python cleanup script `clean_db.py` after or before the tests.
If we dont, some tests will fail trying to create a map that already exists.
This is automatically done with `entrypoint.sh` when the ENV varaible CI is not set.
Currently we need to use [clean_db.py](clean_db.py) after/before tests to make all test maps are deleted.
If we dont delete them, some tests will fail trying to create a map that already exists.
This is automatically done inside [e2e.sh](e2e.sh)`.

## How to write tests

Expand Down Expand Up @@ -185,7 +188,7 @@ Following the [testing strategy](https://github.com/ElektraInitiative/PermaplanT

This will ensure the tests are simple and don't perform too much magic all over the place.

### Small note on pytest-xdist
### A small note on pytest-xdist

[Pytest-xdist](https://pytest-xdist.readthedocs.io/en/latest/distribution.html) is used to parallelize the tests.
This is done to reduce the pipeline time, since many tests could make this stage take a long time at the end.
Expand Down Expand Up @@ -215,7 +218,7 @@ playwright codegen http://localhost:5173/

- pytest-bdd generate features/login_logout.feature > steps/test_some_feature.py

or only missing stuff
Only missing stuff:

- pytest --generate-missing --feature features steps/

Expand All @@ -225,6 +228,6 @@ or only missing stuff

[https://playwright.dev/python/docs/intro](https://playwright.dev/python/docs/intro)

### pytest-bdd Documentation
### Pytest-bdd Documentation

[https://pypi.org/project/pytest-bdd/](https://pypi.org/project/pytest-bdd/)
File renamed without changes.
2 changes: 1 addition & 1 deletion e2e/install.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
python3 -m pip install -r requirements.txt
python3 -m playwright install --with-deps
python3 -m playwright install chromium --with-deps

0 comments on commit 26d26cb

Please sign in to comment.