-
Notifications
You must be signed in to change notification settings - Fork 9
feat(test): Add MariaDB docker tasks; Add storage-related tests in GitHub workflows. #267
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
Changes from all commits
915dc91
6300ca0
5e5f7a0
32e4462
cd34070
50d0288
a622008
aa7e551
37e68cb
dee2ecb
6a28b85
38dee77
0705901
c115833
62d9add
82f882e
0f72824
5e871bc
0173937
909de43
ef02ec8
ecac810
55f7300
89c8b6b
9b3fa91
f03981e
4ca400c
b21e361
d0b32cc
0678ea1
26b8cc6
e25e09b
068f454
7d21f3c
1ae488e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| name: "unit-tests" | ||
| name: "tests" | ||
|
|
||
| on: | ||
| pull_request: | ||
|
|
@@ -17,7 +17,7 @@ concurrency: | |
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| non-storage-unit-tests: | ||
| tests: | ||
| strategy: | ||
| matrix: | ||
| os: ["ubuntu-22.04", "ubuntu-24.04"] | ||
|
|
@@ -49,12 +49,14 @@ jobs: | |
| task --version | ||
| uv --version | ||
|
|
||
| - name: "Install project dependencies " | ||
| - name: "Install project dependencies" | ||
| timeout-minutes: 10 | ||
| env: | ||
| SPIDER_DEPS_MAX_PARALLELISM_PER_TASK: "1" | ||
| run: "task deps:lib_install" | ||
|
|
||
| - run: "task test:cpp-non-storage-unit-tests" | ||
| - run: "task test:cpp-unit-tests" | ||
|
|
||
| - run: "task test:spider-py-non-storage-unit-tests" | ||
| - run: "task test:spider-py-unit-tests" | ||
|
|
||
| - run: "task test:cpp-integration" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Group unit tests before integration tests. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,24 +5,29 @@ vars: | |
| G_TEST_VENV_DIR: "{{.G_BUILD_DIR}}/test-venv" | ||
| G_TEST_VENV_CHECKSUM_FILE: "{{.G_BUILD_DIR}}/test#venv.md5" | ||
|
|
||
| # MariaDB testing config | ||
| G_MARIADB_DATABASE: "spider-db" | ||
| G_MARIADB_USERNAME: "spider-user" | ||
| G_MARIADB_PASSWORD: "spider-password" | ||
|
|
||
| tasks: | ||
| cpp-non-storage-unit-tests: | ||
| deps: | ||
| - "build-unit-test" | ||
|
Comment on lines
-9
to
-11
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove |
||
| cpp-unit-tests: | ||
| cmds: | ||
| - "{{.G_UNIT_TEST_BINARY}} \"~[storage]\"" | ||
| - task: "mariadb-storage-task-executor" | ||
| vars: | ||
| STORAGE_TASK: "spider-wolf-unit-tests-executor" | ||
|
|
||
| cpp-storage-unit-tests: | ||
| deps: | ||
| - "build-unit-test" | ||
| cpp-integration: | ||
| cmds: | ||
| - "{{.G_UNIT_TEST_BINARY}} \"[storage]\"" | ||
| - task: "mariadb-storage-task-executor" | ||
| vars: | ||
| STORAGE_TASK: "spider-wolf-integration-tests-executor" | ||
|
|
||
| cpp-unit-tests: | ||
| deps: | ||
| - "build-unit-test" | ||
| spider-py-unit-tests: | ||
| cmds: | ||
| - "{{.G_UNIT_TEST_BINARY}}" | ||
| - task: "mariadb-storage-task-executor" | ||
| vars: | ||
| STORAGE_TASK: "spider-py-unit-tests-executor" | ||
|
|
||
| build-unit-test: | ||
| internal: true | ||
|
|
@@ -31,23 +36,6 @@ tasks: | |
| vars: | ||
| TARGETS: ["spider_task_executor", "unitTest", "worker_test"] | ||
|
|
||
| cpp-integration: | ||
| dir: "{{.G_BUILD_SPIDER_DIR}}" | ||
| deps: | ||
| - "venv" | ||
| - task: ":build:cpp-target" | ||
| vars: | ||
| TARGETS: [ | ||
| "spider_task_executor", | ||
| "worker_test", | ||
| "client_test", | ||
| "spider_worker", | ||
| "spider_scheduler", | ||
| "integrationTest"] | ||
| cmd: |- | ||
| . ../test-venv/bin/activate | ||
| ../test-venv/bin/pytest tests/integration | ||
|
|
||
| venv: | ||
| internal: true | ||
| vars: | ||
|
|
@@ -77,26 +65,95 @@ tasks: | |
| CHECKSUM_FILE: "{{.CHECKSUM_FILE}}" | ||
| INCLUDE_PATTERNS: ["{{.OUTPUT_DIR}}"] | ||
|
|
||
| spider-py-unit-tests: | ||
| dir: "{{.G_SRC_PYTHON_DIR}}" | ||
| env: | ||
| # Don't create __pycache__ directories in the source tree. | ||
| PYTHONDONTWRITEBYTECODE: "1" | ||
| # A generic wrapper that runs the given task with a MariaDB storage backend. | ||
| # | ||
| # @param {string} STORAGE_TASK The task to execute. The task must accept no parameters other than | ||
| # `SPIDER_STORAGE_URL`, which is set to the MariaDB instance URL. | ||
|
Comment on lines
+68
to
+71
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't forget to add docstrings for unit tests that contains variables. |
||
| mariadb-storage-task-executor: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a wrapper for storage task exeuction so we don't need to repeat the save set up everywhere. |
||
| internal: true | ||
| vars: | ||
| MARIADB_CONTAINER_NAME: | ||
| # Normalize UUID casing: macOS generates uppercase while Linux generates lowercase. | ||
| sh: "uuidgen | tr '[:upper:]' '[:lower:]' | sed 's/^/spider-mariadb-/'" | ||
| MARIADB_PORT: | ||
| sh: "tools/scripts/get_free_port.py" | ||
LinZhihao-723 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| requires: | ||
| vars: ["STORAGE_TASK"] | ||
| dir: "{{.ROOT_DIR}}" | ||
| cmds: | ||
| - "uv run pytest" | ||
| - |- | ||
| tools/scripts/mariadb/start.py \ | ||
| --name "{{.MARIADB_CONTAINER_NAME}}" \ | ||
| --port "{{.MARIADB_PORT}}" \ | ||
| --database "{{.G_MARIADB_DATABASE}}" \ | ||
| --username "{{.G_MARIADB_USERNAME}}" \ | ||
| --password "{{.G_MARIADB_PASSWORD}}" | ||
| - defer: |- | ||
| {{.ROOT_DIR}}/tools/scripts/mariadb/stop.py \ | ||
| --name "{{.MARIADB_CONTAINER_NAME}}" | ||
| - |- | ||
| tools/scripts/mariadb/wolf/init_db.py \ | ||
| --port "{{.MARIADB_PORT}}" \ | ||
| --database "{{.G_MARIADB_DATABASE}}" \ | ||
| --username "{{.G_MARIADB_USERNAME}}" \ | ||
| --password "{{.G_MARIADB_PASSWORD}}" | ||
| - task: "{{.STORAGE_TASK}}" | ||
| vars: | ||
| SPIDER_STORAGE_URL: | ||
| "jdbc:mariadb://127.0.0.1:{{.MARIADB_PORT}}/{{.G_MARIADB_DATABASE}}?\ | ||
| user={{.G_MARIADB_USERNAME}}&password={{.G_MARIADB_PASSWORD}}" | ||
|
|
||
LinZhihao-723 marked this conversation as resolved.
Show resolved
Hide resolved
LinZhihao-723 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| spider-py-non-storage-unit-tests: | ||
| dir: "{{.G_SRC_PYTHON_DIR}}" | ||
| # Internal task that runs all spider-py's unit tests. | ||
| # | ||
| # @param {string} SPIDER_STORAGE_URL An URL pointing to the MariaDB instance. | ||
| spider-py-unit-tests-executor: | ||
| internal: true | ||
| env: | ||
| # Don't create __pycache__ directories in the source tree. | ||
| PYTHONDONTWRITEBYTECODE: "1" | ||
| cmds: | ||
| - "uv run pytest -m \"not storage\"" | ||
|
|
||
| spider-py-storage-unit-tests: | ||
| SPIDER_STORAGE_URL: "{{.SPIDER_STORAGE_URL}}" | ||
| requires: | ||
| vars: ["SPIDER_STORAGE_URL"] | ||
| dir: "{{.G_SRC_PYTHON_DIR}}" | ||
| cmd: "uv run pytest" | ||
|
|
||
| # Internal task that runs all Spider Wolf's unit tests. | ||
| # | ||
| # @param {string} SPIDER_STORAGE_URL An URL pointing to the MariaDB instance. | ||
| spider-wolf-unit-tests-executor: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should document the versioning. But since this is an internal task, I'm gonna refer to wolf directly. |
||
| internal: true | ||
| env: | ||
| # Don't create __pycache__ directories in the source tree. | ||
| PYTHONDONTWRITEBYTECODE: "1" | ||
| SPIDER_STORAGE_URL: "{{.SPIDER_STORAGE_URL}}" | ||
| requires: | ||
| vars: ["SPIDER_STORAGE_URL"] | ||
| dir: "{{.ROOT_DIR}}" | ||
| deps: | ||
| - "build-unit-test" | ||
| cmd: "{{.G_UNIT_TEST_BINARY}}" | ||
|
|
||
| # Internal task that runs all Spider Wolf's integration tests. | ||
| # | ||
| # @param {string} SPIDER_STORAGE_URL An URL pointing to the MariaDB instance. | ||
| spider-wolf-integration-tests-executor: | ||
| internal: true | ||
| env: | ||
| SPIDER_STORAGE_URL: "{{.SPIDER_STORAGE_URL}}" | ||
| requires: | ||
| vars: ["SPIDER_STORAGE_URL"] | ||
| dir: "{{.G_BUILD_SPIDER_DIR}}" | ||
| deps: | ||
| - "venv" | ||
| - task: ":build:cpp-target" | ||
| vars: | ||
| TARGETS: [ | ||
| "spider_task_executor", | ||
| "worker_test", | ||
| "client_test", | ||
| "spider_worker", | ||
| "spider_scheduler", | ||
| "integrationTest" | ||
| ] | ||
| cmds: | ||
| - "uv run pytest -m \"storage\"" | ||
| - |- | ||
| . {{.G_TEST_VENV_DIR}}/bin/activate | ||
| {{.G_TEST_VENV_DIR}}/bin/pytest tests/integration | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove space.