From 0ee67ddfac0f9cfca239bff41ad8a4295b57aae5 Mon Sep 17 00:00:00 2001 From: Johnson Sun Date: Sun, 4 Aug 2024 14:17:28 +0800 Subject: [PATCH] ci: Isolate end-to-end-test --- README.md | 8 ++++---- tests/{ => end-to-end-test}/Dockerfile | 0 tests/{ => end-to-end-test}/compose.yml | 9 ++++----- tests/{ => end-to-end-test}/requirements.txt | 0 tests/{ => end-to-end-test}/test_default.py | 2 +- tests/{ => end-to-end-test}/test_interactive.py | 0 tests/{ => end-to-end-test}/test_navigation.py | 2 +- tests/scripts/docker-compose.sh | 8 ++++---- tests/scripts/docker-utils/exec-selenium.sh | 4 ++-- tests/scripts/docker-utils/test-connection.sh | 2 +- tests/{ => testcases}/testcases.yaml | 0 11 files changed, 17 insertions(+), 18 deletions(-) rename tests/{ => end-to-end-test}/Dockerfile (100%) rename tests/{ => end-to-end-test}/compose.yml (93%) rename tests/{ => end-to-end-test}/requirements.txt (100%) rename tests/{ => end-to-end-test}/test_default.py (98%) rename tests/{ => end-to-end-test}/test_interactive.py (100%) rename tests/{ => end-to-end-test}/test_navigation.py (99%) rename tests/{ => testcases}/testcases.yaml (100%) diff --git a/README.md b/README.md index f2ae33b..6f7b221 100644 --- a/README.md +++ b/README.md @@ -158,7 +158,7 @@ The automated tests currently include the following: - **Default tests**: Test the default title name of arXiv abstract/PDF pages. - **Navigation tests**: Test the arxiv-utils button can switch between arXiv abstract/PDF pages, and the title is modified. -The testcases along with their description is stored in [tests/testcases.yaml](tests/testcases.yaml). +The testcases along with their description is stored in [tests/testcases/testcases.yaml](tests/testcases/testcases.yaml). Other functions should still be tested manually: @@ -195,11 +195,11 @@ docker compose up -d Then run the tests: ```sh -docker exec -t tests-selenium-tests-1 \ - python "/app/tests/test_navigation.py" +docker exec -t end-to-end-test-selenium-tests-1 \ + python "/app/tests/end-to-end-test/test_navigation.py" ``` -When adding new test cases, it is often convenient to comment out existing test cases in [tests/testcases.yaml](tests/testcases.yaml); When testing specific browsers, you can modify the `for browser in [...]` part in [tests/test_navigation.py](tests/test_navigation.py) to only run tests for the desired browser. +When adding new test cases, it is often convenient to comment out existing test cases in [tests/testcases/testcases.yaml](tests/testcases/testcases.yaml); When testing specific browsers, you can modify the `for browser in [...]` part in [tests/test_navigation.py](tests/test_navigation.py) to only run tests for the desired browser. > If the test logs stuck at launching the webdriver, you may need to restart the containers. diff --git a/tests/Dockerfile b/tests/end-to-end-test/Dockerfile similarity index 100% rename from tests/Dockerfile rename to tests/end-to-end-test/Dockerfile diff --git a/tests/compose.yml b/tests/end-to-end-test/compose.yml similarity index 93% rename from tests/compose.yml rename to tests/end-to-end-test/compose.yml index 221ea87..3342d17 100644 --- a/tests/compose.yml +++ b/tests/end-to-end-test/compose.yml @@ -2,7 +2,6 @@ # To execute this docker-compose yml file use `docker-compose -f docker-compose-v3.yml up` # Add the `-d` flag at the end for detached execution # To stop the execution, hit Ctrl+C, and then `docker-compose -f docker-compose-v3.yml down` -version: "3" services: chrome-node: image: selenium/node-chrome:4.8.3-20230404 @@ -15,7 +14,7 @@ services: - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 # - VNC_NO_PASSWORD=1 volumes: - - "..:/app:ro" # Source code + - "../..:/app:ro" # Source code - "data:/data" # For testing downloads ports: - "6900:5900" # VNC port, default password: secret @@ -32,7 +31,7 @@ services: - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 # - VNC_NO_PASSWORD=1 volumes: - - "..:/app:ro" # Source code + - "../..:/app:ro" # Source code - "data:/data" # For testing downloads ports: - "6901:5900" # VNC port, default password: secret @@ -49,7 +48,7 @@ services: - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 # - VNC_NO_PASSWORD=1 volumes: - - "..:/app:ro" # Source code + - "../..:/app:ro" # Source code - "data:/data" # For testing downloads ports: - "6902:5900" # VNC port, default password: secret @@ -66,7 +65,7 @@ services: selenium-tests: build: . volumes: - - "..:/app:ro" # Source code + - "../..:/app:ro" # Source code - "data:/data" # For testing downloads # Attach to the container with: # docker exec -it tests_selenium-tests_1 bash diff --git a/tests/requirements.txt b/tests/end-to-end-test/requirements.txt similarity index 100% rename from tests/requirements.txt rename to tests/end-to-end-test/requirements.txt diff --git a/tests/test_default.py b/tests/end-to-end-test/test_default.py similarity index 98% rename from tests/test_default.py rename to tests/end-to-end-test/test_default.py index bb8c0ea..91dd792 100644 --- a/tests/test_default.py +++ b/tests/end-to-end-test/test_default.py @@ -7,7 +7,7 @@ from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait -testcases_path = "/app/tests/testcases.yaml" +testcases_path = "/app/tests/testcases/testcases.yaml" with open(testcases_path, "r") as f: testcases = yaml.safe_load(f) diff --git a/tests/test_interactive.py b/tests/end-to-end-test/test_interactive.py similarity index 100% rename from tests/test_interactive.py rename to tests/end-to-end-test/test_interactive.py diff --git a/tests/test_navigation.py b/tests/end-to-end-test/test_navigation.py similarity index 99% rename from tests/test_navigation.py rename to tests/end-to-end-test/test_navigation.py index 694800f..1c6de38 100644 --- a/tests/test_navigation.py +++ b/tests/end-to-end-test/test_navigation.py @@ -11,7 +11,7 @@ from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait -testcases_path = "/app/tests/testcases.yaml" +testcases_path = "/app/tests/testcases/testcases.yaml" with open(testcases_path, "r") as f: testcases = yaml.safe_load(f) diff --git a/tests/scripts/docker-compose.sh b/tests/scripts/docker-compose.sh index d2d7b10..67758ca 100755 --- a/tests/scripts/docker-compose.sh +++ b/tests/scripts/docker-compose.sh @@ -3,11 +3,11 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" if [[ "$1" == "up" ]]; then - docker compose -f $DIR/../compose.yml up --build "${@:2}" + docker compose -f $DIR/../end-to-end-test/compose.yml up --build "${@:2}" elif [[ "$1" == "pull" ]]; then - docker compose -f $DIR/../compose.yml pull + docker compose -f $DIR/../end-to-end-test/compose.yml pull elif [[ "$1" == "down" ]]; then - docker compose -f $DIR/../compose.yml down + docker compose -f $DIR/../end-to-end-test/compose.yml down elif [[ "$1" == "shutdown" ]]; then - docker compose -f $DIR/../compose.yml down -v --remove-orphans + docker compose -f $DIR/../end-to-end-test/compose.yml down -v --remove-orphans fi diff --git a/tests/scripts/docker-utils/exec-selenium.sh b/tests/scripts/docker-utils/exec-selenium.sh index 2c8f2f1..6c1c462 100755 --- a/tests/scripts/docker-utils/exec-selenium.sh +++ b/tests/scripts/docker-utils/exec-selenium.sh @@ -1,4 +1,4 @@ #!/bin/bash -e -docker exec -t tests-selenium-tests-1 \ - python "/app/tests/$@" +docker exec -t end-to-end-test-selenium-tests-1 \ + python "/app/tests/end-to-end-test/$@" diff --git a/tests/scripts/docker-utils/test-connection.sh b/tests/scripts/docker-utils/test-connection.sh index a8421fb..67bce4b 100755 --- a/tests/scripts/docker-utils/test-connection.sh +++ b/tests/scripts/docker-utils/test-connection.sh @@ -1,3 +1,3 @@ #!/bin/bash -e -docker run --rm --network tests_default curlimages/curl:latest -s --retry 20 --retry-delay 1 --retry-connrefused $1 +docker run --rm --network end-to-end-test_default curlimages/curl:latest -s --retry 20 --retry-delay 1 --retry-connrefused $1 diff --git a/tests/testcases.yaml b/tests/testcases/testcases.yaml similarity index 100% rename from tests/testcases.yaml rename to tests/testcases/testcases.yaml