Projects STRLCPY dolt Files
🤬
..
helper Loading last commit info...
.gitignore
1pk5col-ints.bats
1pk5col-strings.bats
1pksupportedtypes.bats
2pk5cols-ints.bats
README.md
arg-parsing.bats
auto_increment.bats
backup.bats
bats.sql
blame-system-view.bats
blame.bats
branch-control.bats
branch.bats
case-sensitivity.bats
checkout.bats
cherry-pick.bats
column_tags.bats
commit.bats
commit_tags.bats
common.bash.bats
config-home.bats
config.bats
conflict-cat.bats
conflict-detection-2.bats
conflict-detection.bats
constraint-violations.bats
cp-and-mv.bats
create-views.bats
creds.bats
db-revision-specifiers.bats
default-values.bats
deleted-branches.bats
diff.bats
docs.bats
doltpy.bats
drop-create.bats
dump-docs.bats
dump.bats
empty-repo.bats
export-tables.bats
feature-version.bats
filter-branch.bats
foreign-keys-invert-pk.bats
foreign-keys.bats
garbage_collection.bats
import-create-tables.bats
import-mysqldump.bats
import-replace-tables.bats
import-update-tables.bats
index-on-writes-2.bats
index-on-writes.bats
index.bats
init.bats
json-diff.bats
json-new-fmt.bats
json.bats
keyless-foreign-keys.bats
keyless.bats
large-update.bats
log.bats
log.expect
merge-base.bats
merge.bats
migrate.bats
migration-integration.bats
multidb.bats
multiple-tables.bats
mysql.db
no-repo.bats
primary-key-changes.bats
privs.json
query-catalog.bats
regression-tests.bats
remotes-aws.bats
remotes-file-system.bats
remotes-localbs.bats
remotes-sql-server.bats
remotes.bats
remotesrv.bats
rename-tables.bats
replace.bats
replication-multidb.bats
replication.bats
reset.bats
revert.bats
schema-changes.bats
schema-export.bats
schema-import.bats
send-metrics.bats
sql-add.bats
sql-backup.bats
sql-batch.bats
sql-branch.bats
sql-charsets-collations.bats
sql-check-constraints.bats
sql-checkout.bats
sql-clean.bats
sql-client-no-privs-no-mysql.expect
sql-client.bats
sql-commit.bats
sql-config.bats
sql-conflicts-resolve.bats
sql-conflicts.bats
sql-create-database.bats
sql-create-tables.bats
sql-delimiter.expect
sql-diff.bats
sql-fetch.bats
sql-load-data.bats
sql-merge.bats
sql-multi-db.bats
sql-privs.bats
sql-pull.bats
sql-push.bats
sql-reserved-column-name.bats
sql-reset.bats
sql-server-mysql.expect
sql-server-remotesrv.bats
sql-server.bats
sql-shell.bats
sql-shell.expect
sql-show.bats
sql-spatial-types.bats
sql-status.bats
sql-tags.bats
sql-unique-error.expect
sql-use.expect
sql-vertical-format.expect
sql-works-after-failing-query.expect
sql.bats
status.bats
system-tables.bats
tableplus.bats
triggers.bats
types.bats
validation.bats
verify-constraints.bats
window.bats
README.md

BATS - Bash Automated Testing System

BATS is used to integration test dolt. Our BATS tests started as a humble suite of integration tests. Over two years of development the suite has grown to over 1,000 tests. When we find a customer facing bug in the dolt command line or SQL implementation, we cover it with a BATS test. These tests are run on every dolt PR on Mac, Windows, and Linux using GitHub Actions.

These tests are also useful documentation. If you are wondering how a certain command or feature works in practice, using grep to find the appropriate BATS test can give you some simple examples of happy path and error case behavior.

The naming conventions for the test files have evolved over time. Generally, the files are named after the feature the file intends to test. However, some of the early tests are named after the schema of the table they implement ie. 1pk5col-ints.bats. These files were implemented to reuse setup and teardown logic. This scheme was quickly abandoned but the legacy remains.

If you find a bug in dolt, we would love a skipped bats test PR in addition to a GitHub issue.

Running for yourself

  1. Install bats.
npm install -g bats
  1. Install dolt and noms
cd go/cmd/dolt && go install . && cd -
cd go/store/cmd/noms && go install . && cd -
  1. Make sure you have python3 installed.

This came with my Mac Developer Tools and was on my PATH.

  1. pip install mysql-connector-python and pip install pyarrow

I also needed this specific version on the python mysql.connector. pip install mysql.connector mostly worked but caused some SSL errors.

pip3 install mysql-connector-python
pip install pyarrow
  1. Install parquet and its dependencies

I used Homebrew on Mac to install parquet. You also need to install hadoop and set PARQUET_RUNTIME_JAR to get bats to work. Here's what I ended up running.

brew install parquet-cli
brew install hadoop
export PARQUET_RUNTIME_JAR=/opt/homebrew/opt/parquet-cli/libexec/parquet-cli-1.12.3-runtime.jar
  1. Go to the directory with the bats tests and run:
bats . 

This will run all the tests. Specify a particular .bats file to run only those tests.

Here Docs

BATS tests in Dolt make extensive use of Here Docs. Common patterns include piping SQL scripts to dolt sql:

    dolt sql <<SQL
CREATE TABLE my_table (pk int PRIMARY KEY);
SQL

And creating data files for import:

    cat <<DELIM > data.csv
pk,c1,c2
1,1,1
2,2,2
DELIM
    dolt table import -c -pk=pk my_table data.csv

Skipped BATS

Various tests are skipped as TODOs and/or as documentation of known bugs. Eg:

@test "..." {
    ...
    skip "this test is currently failing because..."
}

Skipped BATS can still be partially useful for testing as they execute normally up to skip statement.

More Information

We published a blog entry on BATS with more information and some useful tips and tricks.

Please wait...
Page is in error, reload to recover