Skip to content

Commit

Permalink
Add initial performance regression tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicktobey committed Nov 29, 2023
1 parent 3115ab7 commit 00bf27b
Showing 1 changed file with 157 additions and 0 deletions.
157 changes: 157 additions & 0 deletions integration-tests/bats/performance.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
#!/usr/bin/env bats
load $BATS_TEST_DIRNAME/helper/common.bash

setup_file() {
BATS_TEST_TIMEOUT=200
run rm -rf $BATS_TMPDIR/dolt-repo-perf
setup_common

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"

cd ..
mv $BATS_TMPDIR/dolt-repo-$$/ $BATS_TMPDIR/dolt-repo-perf
}

setup() {
cd $BATS_TMPDIR/dolt-repo-perf
dolt reset --hard HEAD
dolt checkout full
# Remove all branches except for the currently checked out branch.
dolt branch | cut -w -f 2 | run xargs -L 1 dolt branch -D
}

@test "performance: merge with no schema change and no conflict" {
pwd
ls -al
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" {
pwd
ls -al
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
}

0 comments on commit 00bf27b

Please sign in to comment.