Testing#
Set up storage backend#
Spider relies on a fault-tolerant storage to store metadata and data. Spider’s unit tests also require this storage backend.
Set up MySQL as storage backend#
Start a MySQL database running in background.
Create an empty database.
CREATE DATABASE <db_name>;
Set the password for
root
or create another user with password and grant access to database created in step 2.ALTER USER 'root'@'localhost' IDENTIFIED BY '<pwd>'; --- OR create a new user CREATE USER '<usr>'@'localhost' IDENTIFIED BY '<pwd>'; GRANT ALL PRIVILEGES ON <db_name>.* TO '<usr>'@'localhost';
Set the
cStorageUrl
intests/storage/StorageTestHelper.hpp
tojdbc:mariadb://localhost:3306/<db_name>?user=<usr>&password=<pwd>
.Set the
storage_url
intests/integration/client.py
tojdbc:mariadb://localhost:3306/<db_name>?user=<usr>&password=<pwd>
.
Running unit tests#
You can use the following tasks to run the set of unit tests that’s appropriate.
Task |
Description |
---|---|
|
Runs all unit tests. |
|
Runs all unit tests which don’t require a storage backend to run. |
|
Runs all unit tests which require a storage backend to run. |
If any tests show error messages for the connection function below, revisit the
setup section and verify that cStorageUrl
was set correctly.
REQUIRE( storage->connect(spider::test::cStorageUrl).success() )
GitHub unit test workflow#
The unit_tests.yaml GitHub workflow runs the unit tests on push, pull requests, and daily. Currently, it only runs unit tests that don’t require a storage backend.
Running integration tests#
You can use the following tasks to run integration tests.
Task |
Description |
---|---|
|
Runs all integration tests. |