From 00bf27ba291f0951bde45a19290d497dddecd6c8 Mon Sep 17 00:00:00 2001 From: Nick Tobey Date: Wed, 29 Nov 2023 12:43:33 -0800 Subject: [PATCH] Add initial performance regression tests. --- integration-tests/bats/performance.bats | 157 ++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 integration-tests/bats/performance.bats diff --git a/integration-tests/bats/performance.bats b/integration-tests/bats/performance.bats new file mode 100644 index 00000000000..6a3c6331cd7 --- /dev/null +++ b/integration-tests/bats/performance.bats @@ -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 +} \ No newline at end of file