mirror of
https://github.com/dolthub/dolt.git
synced 2026-05-08 02:36:27 -05:00
Merge remote-tracking branch 'origin/main' into steph/clone-branch
This commit is contained in:
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -0,0 +1 @@
|
||||
5:__DOLT__:4t8rtld9ul7l137jac93phj1o6qinq6o:8ep2ilbq0lb461mqibkqp80nd0skdend:00000000000000000000000000000000:vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv:3722
|
||||
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"head": "refs/heads/full",
|
||||
"remotes": {},
|
||||
"backups": {},
|
||||
"branches": {}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
#!/usr/bin/env bats
|
||||
load $BATS_TEST_DIRNAME/helper/common.bash
|
||||
|
||||
# This BATS test attempts to detect performance regressions when using standard workflows on large datasets.
|
||||
# Please note that this is a rough approach that is not designed to detect all performance issues, merely an extra
|
||||
# safeguard against bugs that cause large (order-of-magnitude+) regressions.
|
||||
|
||||
# BATS_TEST_TIMEOUT is measured in seconds and is chosen to be high enough that all tests in this suite pass
|
||||
# when running on GitHub's CI, but low enough that an order-of magnitude regression will cause them to fail.
|
||||
BATS_TEST_TIMEOUT=50
|
||||
|
||||
# This function was used to create the dolt repo used for this test. It is not run during testing.
|
||||
create_repo() {
|
||||
dolt init
|
||||
dolt checkout -b full
|
||||
|
||||
dolt sql -q 'create table t (pk int primary key, c0 text default "1", c3 text default "2", c4 text default "3", c5 text default "4", c6 text default "5", c7 text default "6");'
|
||||
dolt commit -Am "new table t"
|
||||
|
||||
echo "insert into t(pk) values" > import.sql
|
||||
for i in {1..100000}
|
||||
do
|
||||
echo " ($i)," >> import.sql
|
||||
done
|
||||
echo " (104857);" >> import.sql
|
||||
|
||||
dolt sql < import.sql
|
||||
|
||||
dolt add .
|
||||
dolt commit -m "Add all rows"
|
||||
}
|
||||
|
||||
setup() {
|
||||
cp -r $BATS_TEST_DIRNAME/performance-repo/ $BATS_TMPDIR/dolt-repo-$$
|
||||
cd $BATS_TMPDIR/dolt-repo-$$
|
||||
}
|
||||
|
||||
@test "performance: merge with no schema change and no conflict" {
|
||||
dolt checkout full
|
||||
dolt checkout -b mod2
|
||||
dolt reset --soft HEAD^
|
||||
|
||||
dolt sql -q "delete from t where pk % 2 = 0"
|
||||
|
||||
dolt add .
|
||||
dolt commit -m "Add mod2 rows"
|
||||
|
||||
dolt checkout full
|
||||
dolt checkout -b mod3
|
||||
dolt reset --soft HEAD^
|
||||
|
||||
dolt sql -q "delete from t where pk % 3 = 0"
|
||||
|
||||
dolt add .
|
||||
dolt commit -m "Add mod3 rows"
|
||||
|
||||
run dolt merge mod2
|
||||
log_status_eq 0
|
||||
}
|
||||
|
||||
@test "performance: merge with no schema change and conflict" {
|
||||
dolt checkout full
|
||||
dolt checkout -b mod2
|
||||
dolt reset --soft HEAD^
|
||||
|
||||
dolt sql -q "delete from t where pk % 2 = 0"
|
||||
|
||||
dolt add .
|
||||
dolt commit -m "Add mod2 rows"
|
||||
|
||||
dolt checkout full
|
||||
dolt checkout -b mod3
|
||||
dolt reset --soft HEAD^
|
||||
|
||||
dolt sql -q "delete from t where pk % 3 = 0"
|
||||
dolt sql -q 'update t set c0 = "conflict" where pk = 91'
|
||||
|
||||
dolt add .
|
||||
dolt commit -m "Add mod3 rows"
|
||||
|
||||
run dolt merge mod2
|
||||
log_status_eq 1
|
||||
[[ "$output" =~ "Merge conflict in t" ]] || false
|
||||
|
||||
dolt conflicts resolve --ours t
|
||||
BATS_TEST_TIMEOUT=1
|
||||
}
|
||||
|
||||
|
||||
@test "performance: merge with schema change and no conflict" {
|
||||
dolt checkout full
|
||||
dolt checkout -b mod2
|
||||
dolt reset --soft HEAD^
|
||||
|
||||
dolt sql -q "delete from t where pk % 2 = 0"
|
||||
|
||||
dolt add .
|
||||
dolt commit -m "Add mod2 rows"
|
||||
|
||||
dolt sql -q "alter table t add column c1 int default 1"
|
||||
dolt add .
|
||||
dolt commit -m "Add column c1"
|
||||
|
||||
dolt checkout full
|
||||
dolt checkout -b mod3
|
||||
dolt reset --soft HEAD^
|
||||
|
||||
dolt sql -q "delete from t where pk % 3 = 0"
|
||||
|
||||
dolt add .
|
||||
dolt commit -m "Add mod3 rows"
|
||||
|
||||
dolt sql -q "alter table t add column c2 int default 2"
|
||||
dolt add .
|
||||
dolt commit -m "Add column c2"
|
||||
|
||||
run dolt merge mod2
|
||||
log_status_eq 0
|
||||
}
|
||||
|
||||
@test "performance: merge with schema change and conflict" {
|
||||
dolt checkout full
|
||||
dolt checkout -b mod2
|
||||
dolt reset --soft HEAD^
|
||||
|
||||
dolt sql -q "delete from t where pk % 2 = 0"
|
||||
|
||||
dolt add .
|
||||
dolt commit -m "Add mod2 rows"
|
||||
|
||||
dolt sql -q "alter table t add column c1 int default 1"
|
||||
dolt add .
|
||||
dolt commit -m "Add column c1"
|
||||
|
||||
dolt checkout full
|
||||
dolt checkout -b mod3
|
||||
dolt reset --soft HEAD^
|
||||
|
||||
dolt sql -q "delete from t where pk % 3 = 0"
|
||||
dolt sql -q 'update t set c0 = "conflict" where pk = 91'
|
||||
|
||||
dolt add .
|
||||
dolt commit -m "Add mod3 rows"
|
||||
|
||||
dolt sql -q "alter table t add column c2 int default 2"
|
||||
dolt add .
|
||||
dolt commit -m "Add column c2"
|
||||
|
||||
run dolt merge mod2
|
||||
log_status_eq 1
|
||||
|
||||
dolt conflicts resolve --ours t
|
||||
}
|
||||
Regular → Executable
+234
-20
@@ -6,40 +6,27 @@ teardown() {
|
||||
teardown_common
|
||||
}
|
||||
|
||||
# Asserts that when DOLT_DISABLE_REFLOG is set, the dolt_reflog() table
|
||||
# function returns an empty result set with no error.
|
||||
# Asserts that when DOLT_DISABLE_REFLOG is set, dolt reflog returns nothing with no error.
|
||||
@test "reflog: disabled with DOLT_DISABLE_REFLOG" {
|
||||
export DOLT_DISABLE_REFLOG=true
|
||||
setup_common
|
||||
setup_common # need to set env vars before setup_common for remote tests
|
||||
|
||||
dolt sql -q "create table t (i int primary key, j int);"
|
||||
dolt sql -q "insert into t values (1, 1), (2, 2), (3, 3)";
|
||||
dolt commit -Am "initial commit"
|
||||
dolt commit --allow-empty -m "test commit 1"
|
||||
|
||||
run dolt sql -q "select * from dolt_reflog();"
|
||||
run dolt reflog
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${#lines[@]}" -eq 0 ]
|
||||
}
|
||||
|
||||
# Sanity check for the most basic case of querying the Dolt reflog
|
||||
@test "reflog: enabled by default" {
|
||||
setup_common
|
||||
dolt sql -q "create table t (i int primary key, j int);"
|
||||
dolt sql -q "insert into t values (1, 1), (2, 2), (3, 3)";
|
||||
dolt commit -Am "initial commit"
|
||||
|
||||
run dolt sql -q "select * from dolt_reflog();"
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${#lines[@]}" -eq 6 ]
|
||||
[[ "$output" =~ "initial commit" ]] || false
|
||||
[[ "$output" =~ "Initialize data repository" ]] || false
|
||||
}
|
||||
|
||||
# Asserts that when DOLT_REFLOG_RECORD_LIMIT has been set, the reflog only contains the
|
||||
# most recent entries and is limited by the env var's value.
|
||||
@test "reflog: set DOLT_REFLOG_RECORD_LIMIT" {
|
||||
export DOLT_REFLOG_RECORD_LIMIT=2
|
||||
setup_common
|
||||
setup_common # need to set env vars before setup_common for remote tests
|
||||
|
||||
dolt sql -q "create table t (i int primary key, j int);"
|
||||
dolt sql -q "insert into t values (1, 1), (2, 2), (3, 3)";
|
||||
dolt commit -Am "initial commit"
|
||||
@@ -47,10 +34,237 @@ teardown() {
|
||||
dolt commit --allow-empty -m "test commit 2"
|
||||
|
||||
# Only the most recent two ref changes should appear in the log
|
||||
run dolt sql -q "select * from dolt_reflog();"
|
||||
run dolt reflog
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" =~ "test commit 1" ]] || false
|
||||
[[ "$output" =~ "test commit 2" ]] || false
|
||||
[[ ! "$output" =~ "initial commit" ]] || false
|
||||
[[ ! "$output" =~ "Initialize data repository" ]] || false
|
||||
}
|
||||
|
||||
@test "reflog: simple reflog" {
|
||||
setup_common
|
||||
|
||||
dolt sql -q "create table t (i int primary key, j int);"
|
||||
dolt sql -q "insert into t values (1, 1), (2, 2), (3, 3)";
|
||||
dolt commit -Am "initial commit"
|
||||
|
||||
run dolt reflog
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${#lines[@]}" -eq 2 ]
|
||||
out=$(echo "$output" | sed -E 's/\x1b\[[0-9;]*m//g') # remove special characters for color
|
||||
[[ "$out" =~ "(HEAD -> main) initial commit" ]] || false
|
||||
[[ "$out" =~ "Initialize data repository" ]] || false
|
||||
}
|
||||
|
||||
@test "reflog: reflog with ref given" {
|
||||
setup_common
|
||||
|
||||
dolt sql <<SQL
|
||||
create table t1(pk int primary key);
|
||||
call dolt_commit('-Am', 'creating table t1');
|
||||
|
||||
insert into t1 values(1);
|
||||
call dolt_commit('-Am', 'inserting row 1');
|
||||
call dolt_tag('tag1');
|
||||
|
||||
call dolt_checkout('-b', 'branch1');
|
||||
insert into t1 values(2);
|
||||
call dolt_commit('-Am', 'inserting row 2');
|
||||
|
||||
insert into t1 values(3);
|
||||
call dolt_commit('-Am', 'inserting row 3');
|
||||
call dolt_tag('-d', 'tag1');
|
||||
call dolt_tag('tag1');
|
||||
SQL
|
||||
|
||||
run dolt reflog refs/heads/main
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${#lines[@]}" -eq 3 ]
|
||||
out=$(echo "$output" | sed -E 's/\x1b\[[0-9;]*m//g') # remove special characters for color
|
||||
[[ "$out" =~ "(HEAD -> main) inserting row 1" ]] || false
|
||||
[[ "$out" =~ "creating table t1" ]] || false
|
||||
[[ "$out" =~ "Initialize data repository" ]] || false
|
||||
|
||||
# ref is case-insensitive
|
||||
run dolt reflog rEFs/heAdS/MAIN
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${#lines[@]}" -eq 3 ]
|
||||
out=$(echo "$output" | sed -E 's/\x1b\[[0-9;]*m//g') # remove special characters for color
|
||||
[[ "$out" =~ "(HEAD -> main) inserting row 1" ]] || false
|
||||
[[ "$out" =~ "creating table t1" ]] || false
|
||||
[[ "$out" =~ "Initialize data repository" ]] || false
|
||||
|
||||
run dolt reflog main
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${#lines[@]}" -eq 3 ]
|
||||
out=$(echo "$output" | sed -E 's/\x1b\[[0-9;]*m//g') # remove special characters for color
|
||||
[[ "$out" =~ "(HEAD -> main) inserting row 1" ]] || false
|
||||
[[ "$out" =~ "creating table t1" ]] || false
|
||||
[[ "$out" =~ "Initialize data repository" ]] || false
|
||||
|
||||
# ref is case-insensitive
|
||||
run dolt reflog MaIn
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${#lines[@]}" -eq 3 ]
|
||||
out=$(echo "$output" | sed -E 's/\x1b\[[0-9;]*m//g') # remove special characters for color
|
||||
[[ "$out" =~ "(HEAD -> main) inserting row 1" ]] || false
|
||||
[[ "$out" =~ "creating table t1" ]] || false
|
||||
[[ "$out" =~ "Initialize data repository" ]] || false
|
||||
|
||||
run dolt reflog refs/heads/branch1
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${#lines[@]}" -eq 3 ]
|
||||
out=$(echo "$output" | sed -E 's/\x1b\[[0-9;]*m//g') # remove special characters for color
|
||||
[[ "$out" =~ "(branch1) inserting row 3" ]] || false
|
||||
[[ "$out" =~ "inserting row 2" ]] || false
|
||||
[[ "$out" =~ "inserting row 1" ]] || false
|
||||
|
||||
run dolt reflog branch1
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${#lines[@]}" -eq 3 ]
|
||||
out=$(echo "$output" | sed -E 's/\x1b\[[0-9;]*m//g') # remove special characters for color
|
||||
[[ "$out" =~ "(branch1) inserting row 3" ]] || false
|
||||
[[ "$out" =~ "inserting row 2" ]] || false
|
||||
[[ "$out" =~ "inserting row 1" ]] || false
|
||||
|
||||
run dolt reflog refs/tags/tag1
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${#lines[@]}" -eq 2 ]
|
||||
out=$(echo "$output" | sed -E 's/\x1b\[[0-9;]*m//g') # remove special characters for color
|
||||
[[ "$out" =~ "(tag: tag1) inserting row 3" ]] || false
|
||||
[[ "$out" =~ "inserting row 1" ]] || false
|
||||
|
||||
# ref is case-insensitive
|
||||
run dolt reflog Refs/tAGs/TaG1
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${#lines[@]}" -eq 2 ]
|
||||
out=$(echo "$output" | sed -E 's/\x1b\[[0-9;]*m//g') # remove special characters for color
|
||||
[[ "$out" =~ "(tag: tag1) inserting row 3" ]] || false
|
||||
[[ "$out" =~ "inserting row 1" ]] || false
|
||||
|
||||
run dolt reflog tag1
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${#lines[@]}" -eq 2 ]
|
||||
out=$(echo "$output" | sed -E 's/\x1b\[[0-9;]*m//g') # remove special characters for color
|
||||
[[ "$out" =~ "(tag: tag1) inserting row 3" ]] || false
|
||||
[[ "$out" =~ "inserting row 1" ]] || false
|
||||
|
||||
# ref is case-insensitive
|
||||
run dolt reflog TAg1
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${#lines[@]}" -eq 2 ]
|
||||
out=$(echo "$output" | sed -E 's/\x1b\[[0-9;]*m//g') # remove special characters for color
|
||||
[[ "$out" =~ "(tag: tag1) inserting row 3" ]] || false
|
||||
[[ "$out" =~ "inserting row 1" ]] || false
|
||||
|
||||
dolt branch -D branch1
|
||||
|
||||
run dolt reflog branch1
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${#lines[@]}" -eq 3 ]
|
||||
out=$(echo "$output" | sed -E 's/\x1b\[[0-9;]*m//g') # remove special characters for color
|
||||
[[ "$out" =~ "(branch1) inserting row 3" ]] || false
|
||||
[[ "$out" =~ "inserting row 2" ]] || false
|
||||
[[ "$out" =~ "inserting row 1" ]] || false
|
||||
|
||||
dolt tag -d tag1
|
||||
run dolt reflog tag1
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${#lines[@]}" -eq 2 ]
|
||||
out=$(echo "$output" | sed -E 's/\x1b\[[0-9;]*m//g') # remove special characters for color
|
||||
[[ "$out" =~ "(tag: tag1) inserting row 3" ]] || false
|
||||
[[ "$out" =~ "inserting row 1" ]] || false
|
||||
}
|
||||
|
||||
@test "reflog: garbage collection with no newgen data" {
|
||||
setup_common
|
||||
|
||||
run dolt reflog
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${#lines[@]}" -eq 1 ]
|
||||
out=$(echo "$output" | sed -E 's/\x1b\[[0-9;]*m//g') # remove special characters for color
|
||||
[[ "$out" =~ "(HEAD -> main) Initialize data repository" ]] || false
|
||||
|
||||
dolt gc
|
||||
|
||||
run dolt reflog
|
||||
[ "$status" -eq 0 ]
|
||||
if [ "$SQL_ENGINE" = "remote-engine" ]; then
|
||||
[ "${#lines[@]}" -eq 1 ]
|
||||
[[ "$output" =~ "Initialize data repository" ]] || false
|
||||
else
|
||||
[ "${#lines[@]}" -eq 0 ]
|
||||
fi
|
||||
}
|
||||
|
||||
@test "reflog: garbage collection with newgen data" {
|
||||
setup_common
|
||||
|
||||
dolt sql <<SQL
|
||||
create table t1(pk int primary key);
|
||||
call dolt_commit('-Am', 'creating table t1');
|
||||
insert into t1 values(1);
|
||||
call dolt_commit('-Am', 'inserting row 1');
|
||||
call dolt_tag('tag1');
|
||||
insert into t1 values(2);
|
||||
call dolt_commit('-Am', 'inserting row 2');
|
||||
SQL
|
||||
|
||||
run dolt reflog main
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${#lines[@]}" -eq 4 ]
|
||||
out=$(echo "$output" | sed -E 's/\x1b\[[0-9;]*m//g') # remove special characters for color
|
||||
[[ "$out" =~ "(HEAD -> main) inserting row 2" ]] || false
|
||||
[[ "$out" =~ "inserting row 1" ]] || false
|
||||
[[ "$out" =~ "creating table t1" ]] || false
|
||||
[[ "$out" =~ "Initialize data repository" ]] || false
|
||||
|
||||
dolt gc
|
||||
|
||||
run dolt reflog main
|
||||
[ "$status" -eq 0 ]
|
||||
if [ "$SQL_ENGINE" = "remote-engine" ]; then
|
||||
[ "${#lines[@]}" -eq 1 ]
|
||||
[[ "$output" =~ "inserting row 2" ]] || false
|
||||
else
|
||||
[ "${#lines[@]}" -eq 0 ]
|
||||
fi
|
||||
}
|
||||
|
||||
@test "reflog: too many arguments given" {
|
||||
setup_common
|
||||
|
||||
run dolt reflog foo bar
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" =~ "error: reflog has too many positional arguments" ]] || false
|
||||
}
|
||||
|
||||
@test "reflog: unknown ref returns nothing" {
|
||||
setup_common
|
||||
|
||||
dolt sql -q "create table t (i int primary key, j int);"
|
||||
dolt sql -q "insert into t values (1, 1), (2, 2), (3, 3)";
|
||||
dolt commit -Am "initial commit"
|
||||
|
||||
run dolt reflog foo
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${#lines[@]}" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "reflog: 'HEAD -> ' decoration only appears on HEAD entries" {
|
||||
setup_common
|
||||
|
||||
dolt sql -q "create table t (i int primary key, j int);"
|
||||
dolt sql -q "insert into t values (1, 1), (2, 2), (3, 3)";
|
||||
dolt commit -Am "initial commit"
|
||||
|
||||
run dolt reflog
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${#lines[@]}" -eq 2 ]
|
||||
line1=$(echo "${lines[0]}" | sed -E 's/\x1b\[[0-9;]*m//g') # remove special characters for color
|
||||
line2=$(echo "${lines[1]}" | sed -E 's/\x1b\[[0-9;]*m//g') # remove special characters for color
|
||||
[[ "$line1" =~ "(HEAD -> main) initial commit" ]] || false
|
||||
[[ "$line2" =~ "Initialize data repository" ]] || false
|
||||
[[ ! "$line2" =~ "HEAD" ]] || false
|
||||
}
|
||||
|
||||
@@ -1270,3 +1270,71 @@ SQL
|
||||
|
||||
[[ "$localOutput" == "$remoteOutput" ]] || false
|
||||
}
|
||||
|
||||
@test "sql-local-remote: verify dolt reflog behavior" {
|
||||
cd altDB
|
||||
dolt sql -q "create table t (i int primary key, j int);"
|
||||
dolt sql -q "insert into t values (1, 1), (2, 2), (3, 3)";
|
||||
dolt commit -Am "initial commit"
|
||||
|
||||
run dolt --verbose-engine-setup reflog
|
||||
[ $status -eq 0 ]
|
||||
[[ "$output" =~ "starting local mode" ]] || false
|
||||
[[ "$output" =~ "initial commit" ]] || false
|
||||
run dolt reflog
|
||||
localOutput=$output
|
||||
|
||||
start_sql_server altDB
|
||||
run dolt --verbose-engine-setup reflog
|
||||
[ $status -eq 0 ]
|
||||
[[ "$output" =~ "starting remote mode" ]] || false
|
||||
[[ "$output" =~ "initial commit" ]] || false
|
||||
run dolt reflog
|
||||
remoteOutput=$output
|
||||
|
||||
[[ "$localOutput" == "$remoteOutput" ]] || false
|
||||
}
|
||||
|
||||
@test "sql-local-remote: verify dolt gc behavior" {
|
||||
cd altDB
|
||||
dolt sql <<SQL
|
||||
CREATE TABLE test (pk int PRIMARY KEY);
|
||||
INSERT INTO test VALUES
|
||||
(1),(2),(3),(4),(5);
|
||||
SQL
|
||||
run dolt sql -q 'select count(*) from test' -r csv
|
||||
[ "$status" -eq "0" ]
|
||||
[[ "$output" =~ "5" ]] || false
|
||||
|
||||
run dolt --verbose-engine-setup gc
|
||||
[ $status -eq 0 ]
|
||||
[[ "$output" =~ "starting local mode" ]] || false
|
||||
|
||||
run dolt sql -q 'select count(*) from test' -r csv
|
||||
[ "$status" -eq "0" ]
|
||||
[[ "$output" =~ "5" ]] || false
|
||||
|
||||
start_sql_server altDB
|
||||
dolt sql <<SQL
|
||||
CREATE TABLE test2 (pk int PRIMARY KEY);
|
||||
INSERT INTO test2 VALUES
|
||||
(1),(2),(3),(4),(5);
|
||||
SQL
|
||||
run dolt sql -q 'select count(*) from test' -r csv
|
||||
[ "$status" -eq "0" ]
|
||||
[[ "$output" =~ "5" ]] || false
|
||||
run dolt sql -q 'select count(*) from test2' -r csv
|
||||
[ "$status" -eq "0" ]
|
||||
[[ "$output" =~ "5" ]] || false
|
||||
|
||||
run dolt --verbose-engine-setup gc
|
||||
[ $status -eq 0 ]
|
||||
[[ "$output" =~ "starting remote mode" ]] || false
|
||||
|
||||
run dolt sql -q 'select count(*) from test' -r csv
|
||||
[ "$status" -eq "0" ]
|
||||
[[ "$output" =~ "5" ]] || false
|
||||
run dolt sql -q 'select count(*) from test2' -r csv
|
||||
[ "$status" -eq "0" ]
|
||||
[[ "$output" =~ "5" ]] || false
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bats
|
||||
load $BATS_TEST_DIRNAME/helper/common.bash
|
||||
|
||||
teardown() {
|
||||
assert_feature_version
|
||||
teardown_common
|
||||
}
|
||||
|
||||
# Asserts that when DOLT_DISABLE_REFLOG is set, the dolt_reflog() table
|
||||
# function returns an empty result set with no error.
|
||||
@test "sql-reflog: disabled with DOLT_DISABLE_REFLOG" {
|
||||
export DOLT_DISABLE_REFLOG=true
|
||||
setup_common # need to set env vars before setup_common for remote tests
|
||||
|
||||
dolt sql -q "create table t (i int primary key, j int);"
|
||||
dolt sql -q "insert into t values (1, 1), (2, 2), (3, 3)";
|
||||
dolt commit -Am "initial commit"
|
||||
dolt commit --allow-empty -m "test commit 1"
|
||||
|
||||
run dolt sql -q "select * from dolt_reflog();"
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${#lines[@]}" -eq 0 ]
|
||||
}
|
||||
|
||||
# Sanity check for the most basic case of querying the Dolt reflog
|
||||
@test "sql-reflog: enabled by default" {
|
||||
setup_common
|
||||
|
||||
dolt sql -q "create table t (i int primary key, j int);"
|
||||
dolt sql -q "insert into t values (1, 1), (2, 2), (3, 3)";
|
||||
dolt commit -Am "initial commit"
|
||||
|
||||
run dolt sql -q "select * from dolt_reflog();"
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${#lines[@]}" -eq 6 ]
|
||||
[[ "$output" =~ "initial commit" ]] || false
|
||||
[[ "$output" =~ "Initialize data repository" ]] || false
|
||||
}
|
||||
|
||||
# Asserts that when DOLT_REFLOG_RECORD_LIMIT has been set, the reflog only contains the
|
||||
# most recent entries and is limited by the env var's value.
|
||||
@test "sql-reflog: set DOLT_REFLOG_RECORD_LIMIT" {
|
||||
export DOLT_REFLOG_RECORD_LIMIT=2
|
||||
setup_common # need to set env vars before setup_common for remote tests
|
||||
|
||||
dolt sql -q "create table t (i int primary key, j int);"
|
||||
dolt sql -q "insert into t values (1, 1), (2, 2), (3, 3)";
|
||||
dolt commit -Am "initial commit"
|
||||
dolt commit --allow-empty -m "test commit 1"
|
||||
dolt commit --allow-empty -m "test commit 2"
|
||||
|
||||
# Only the most recent two ref changes should appear in the log
|
||||
run dolt sql -q "select * from dolt_reflog();"
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" =~ "test commit 1" ]] || false
|
||||
[[ "$output" =~ "test commit 2" ]] || false
|
||||
[[ ! "$output" =~ "initial commit" ]] || false
|
||||
[[ ! "$output" =~ "Initialize data repository" ]] || false
|
||||
}
|
||||
Reference in New Issue
Block a user