The integration tests run a full Springtail instance and perform end-to-end testing of the ingest and query components by executing SQL and then verify correctness. The integration tests should be run from theDocumentation Index
Fetch the complete documentation index at: https://docs.springtail.io/llms.txt
Use this file to discover all available pages before exploring further.
python/testing directory via:
Integration test framework
Overview
Our SQL test runner operates using individual test files which each represent a single test case. These test cases can then be bundled together into test sets, which share a single global setup and cleanup phase.Running the tests
Tests are run usingtest_runner.py which is located in python/testing. It requires a YAML configuration file with the following parameters:
test_folder- The path to the folder containing the test set directories.
system_json_path- The path to the Springtail system configuration JSON file.
build_dir- The path to the Springtail build directory.
tmp_config_dir- This a temporary directory for where to put an overlay generated system json file
overlay_config- A dictionary of overlays. The key represents the overlay name and a matching overlay file should be present in
overlays/<key>.json. For each overlay key we specify other parameters used by an overlay and interpreted by the testing framework
- A dictionary of overlays. The key represents the overlay name and a matching overlay file should be present in
configs- In this section we specify what we want to run for each configuration. Each configuration contains a list of overlay and of the corresponding test sets that we want to run for this overlay. The
defaultconfiguration is used if no command line parameters are passed in.
- In this section we specify what we want to run for each configuration. Each configuration contains a list of overlay and of the corresponding test sets that we want to run for this overlay. The
Test Case
A test case is defined by a single file which has the following structure:Sections
There are 2 required sections and 2 optional sections of every test case.Metadata (optional)
Themetadata section defines variables for the overall test case.
autocommit- Specifies if the sql commands are each individual transactions or not. If not, you can use
BEGINandCOMMITsql commands to perform a transaction within the test. Either way, aCOMMITis automatically issued at the end of the “test” section by the test runner. - The default value is
trueto maintain the behavior of the current tests.
- Specifies if the sql commands are each individual transactions or not. If not, you can use
default_txn- Specifies the name of the default transaction to use in sequential sections. This is only useful in very specific situations where you are using a mix of sequential and parallel sub-sections and want to ensure that the sequential sections use a specific transaction from the parallel sub-section without having to specify it with each sequential sub-section header.
- The default value is
default.
sync_timeout- Specifies the maximum time in seconds spent waiting for a sync to Springtail to complete. This impacts both the
syncdirective and the implicit sync that occurs after thetestsection is run. It may make sense to increase this if the test is performing actions that could take a long time to sync (e.g., loading a large amount of data or forcing a re-sync on a large table). - The default value is
3seconds.
- Specifies the maximum time in seconds spent waiting for a sync to Springtail to complete. This impacts both the
query_timeout- Specifies the maximum time to wait for a query to complete. If this timeout is exceeded by any query to the Springtail replica database then the test is considered failed.
- The default value is
5seconds.
poll_interval- Specifies the time between checks for the
syncoperation in seconds. Can be specified as a float for sub-second timing. - The default value is
0.001seconds.
- Specifies the time between checks for the
require_overlays- Specifies the list of overlays that are required to be able to run this test case
Test (required)
Thetest section defines the actual sql commands to run for this test case. There are also a number of directives available to better control the behaviors of the test.
load_csv- Specifies a CSV file and a table into which the CSV file will be loaded. Please ensure that the table exists before this directive is called since it will not create it. The CSV file is assumed to be in the same directory with the test case and it must contain headers which match the column names in the table it is being loaded into.
- If your CSV file is large, please place a gzip compressed version of it in the public S3 bucket at
s3://public-share.springtail.io/test_files— e.g.,s3://public-share.springtail.io/test_files/mushroom_overload.csv.gz. The CSV files of that directory are synchronized locally before tests are run, allowing you to create a symlink to the appropriate CSV file from your test set’s directory.
sleep- Specifies that a given transaction should pause sending SQL statements for a given number of seconds. This is most useful when trying to enforce timings between different transactions in a parallel sub-section.
sync- Blocks execution until the previous SQL statements have been applied to the Springtail replica. This is almost never required since their is an implicit
syncrun at the end of every test section to ensure data is fully synced before running the verify section.
- Blocks execution until the previous SQL statements have been applied to the Springtail replica. This is almost never required since their is an implicit
txn- Specifies that the following SQL statements should be executed within a single transaction with the provided logical name. These logical transactions are executed on separate database connections, meaning you can interleave SQL statements between transactions to ensure correctness in more complex situations.
- By default SQL statements are part of the default transaction if none has been specified.
parallel- Specifies that the following statements are part of a parallel execution. In this sub-section, separate transactions (as defined by
txndirectives) are executed in parallel. If you do not specify a transaction, then the statements are executed in the default transaction.
- Specifies that the following statements are part of a parallel execution. In this sub-section, separate transactions (as defined by
sequential- Specifies that the following statements should be executed sequentially. This means that each statement will be run only when the previous has completed, even when switching between logical transactions.
recovery_point- Uses this instruction to get current XID and stores it as XID to recover to once
force_recoveryis triggered.
- Uses this instruction to get current XID and stores it as XID to recover to once
force_recovery- Brings down the system, reverts the committed XID to an earlier XID retrieved at
recovery_point, and then brings the system back up to force it to recover data from the WAL.
- Brings down the system, reverts the committed XID to an earlier XID retrieved at
restart- Forces the system to do full restart without resetting the database.
swtich_db- Changes the current transaction to use specified database. If there is no
txninstruction preceding this statement, then database switch is applied to the default transaction, otherwise it is applied to the transaction specified bytxninstruction that is precedingswitch_dbinstruction. This forces all the further instructions or SQL statements to apply only to this database.
- Changes the current transaction to use specified database. If there is no
streaming- Enables streaming
Verify (required)
Theverify section defines sql commands that are run against both the primary and the Springtail replica and then have their results compared to ensure that the test has run successfully. These can consist of SELECT statements or the following directives:
schema_check- Compares the table schemas between the primary and Springtail to ensure that they match. Also checks all active indexes (primary and secondary)
table_exists- Verifies that the specified table exists or does not exist on both primary and replica.
index_exists- Verifies that the specified index exists or does not exist on both primary and replica.
swtich_db- Changes the current transaction to use specified database.This forces all the further instructions or SQL statements to apply only to this database.
Cleanup (optional)
Thecleanup section defines sql commands that are run against the primary after the verification step to revert any changes you don’t want visible to the next test in the test set. This section allows the following directives:
swtich_db- Changes the current transaction to use specified database.This forces all the further instructions or SQL statements to apply only to this database.
Test Set
A test set is composed of a set of test cases along with a global configuration. The test case is specified using a directory, the test cases are files within that directory that end with the.sql extension. The global configuration is a special file named __config.sql which uses a similar, but slightly different and simplified format from the test cases.
Global configuration
The global configuration also has an optionalmetadata section which can contain the following instructions:
autocommit- Specifies if the sql commands are each individual transactions or not. If not, you can use
BEGINandCOMMITsql commands to perform a transaction within the test. Either way, aCOMMITis automatically issued at the end of the “test” section by the test runner. - The default value is
trueto maintain the behavior of the current tests.
- Specifies if the sql commands are each individual transactions or not. If not, you can use
live_startup- Specifies that the test set should run a background thread with the given sleep interval. This background thread will periodically issue an update to
background_controltable.
- Specifies that the test set should run a background thread with the given sleep interval. This background thread will periodically issue an update to
require_overlays- Specifies the list of overlays that are required to be able to run this test set
setup section of the global configuration specifies any SQL commands that should be run prior to Springtail starting. This allows us to test the initial sync of the primary database, as well as centralize the creation of any shared tables required by the individual test cases. It can have one initial instruction:
add_db- Add given database at the setup time. From that point on, this database will be available for
switch_dbinstruction and data preload before the system starts.
- Add given database at the setup time. From that point on, this database will be available for
cleanup section of the global configuration specifies any SQL commands that should be run after Springtail is shutdown. Ideally this would revert the database to it’s state prior to the test set running so that another test set can be run.
Running a test set
A test set execution is composed of the following steps:- Setup
- Runs the
setupfrom the global configuration to prepare the primary database for the test cases.
- Runs the
- Start Springtail
- Brings up the Springtail replica from scratch, also causing the initial sync of the primary database.
- Execute test cases
- Runs each test case in the test set. The test cases are run based on the lexicographical order of their file names.
- Shutdown Springtail
- Brings down the Springtail replica.
- Cleanup
- Runs the
cleanupfrom the global configuration to prepare for the next test set.
- Runs the