-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add tests for data storage (#21)
Add unit test for data storage and doc for set up storage backend.
- Loading branch information
1 parent
6e1c7f1
commit 9d6e5fa
Showing
20 changed files
with
648 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# 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 | ||
|
||
1. Start a MySQL database running in background. | ||
2. Create an empty database. | ||
```sql | ||
CREATE DATABASE <db_name>; | ||
``` | ||
3. Set the password for `root` or create another user with password and grant access to database | ||
created in step 2. | ||
```sql | ||
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'; | ||
``` | ||
4. Set the `cStorageUrl` in `tests/storage/StorageTestHelper.hpp` to | ||
`jdbc:mariadb://localhost:3306/<db_name>?user=<usr>&password=<pwd>`. | ||
|
||
## Build and run unit tests | ||
|
||
To build and run the unit tests, run the following commands in project root directory. | ||
|
||
```shell | ||
cmake -S . -B build | ||
cmake --build build --target unitTest --parallel | ||
./build/tests/unitTest | ||
``` | ||
|
||
If the tests show error messages for connection functions below, | ||
revisit [Setup storage backend](#setup-storage-backend) section and double check if `cStorageUrl` is | ||
set correctly. | ||
|
||
```c++ | ||
REQUIRE( storage->connect(spider::test::cStorageUrl).success() ) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.