Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Andy/write feature version #1328

Merged
merged 27 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
44d1514
deduped dangling commit functions in doltdb
andy-wm-arthur Dec 16, 2020
52d71ac
injecting feature version on commit
andy-wm-arthur Dec 16, 2020
bead12d
added more versions to compatibility testing
andy-wm-arthur Dec 16, 2020
c6be5ef
update compat versions
andy-wm-arthur Dec 19, 2020
41e0711
support more versions
andy-wm-arthur Dec 20, 2020
efd7d2f
reverting feature version injection on commit
andy-wm-arthur Feb 5, 2021
bf081d6
write feature version on TableEditSession.flush()
andy-wm-arthur Feb 7, 2021
b7402bb
added feature_version.md
andy-wm-arthur Feb 7, 2021
acc3525
setup whitebox integration tests for feature version
andy-wm-arthur Feb 8, 2021
8b79803
feature version integration tests
andy-wm-arthur Feb 8, 2021
db025df
refactored checkout to retain feature version data
andy-wm-arthur Feb 9, 2021
ebdba47
moved FeatureVersion validation into doltdb.newRootValue
andy-wm-arthur Feb 9, 2021
866d5e6
more tests, set feature version on merge and stage
andy-wm-arthur Feb 9, 2021
0ab5ae1
comment doc for RootValue.SetFeatureVersion()
andy-wm-arthur Feb 9, 2021
bbd371e
test fixes
andy-wm-arthur Feb 9, 2021
5f0c962
removed RootValue.SetFeatureVersion(), set FeatureVersion on every Do…
andy-wm-arthur Feb 12, 2021
ccbf872
write correct RootVal hash on clone
andy-wm-arthur Feb 12, 2021
8fcb16f
added --feature-version flag to CLI
andy-wm-arthur Feb 12, 2021
84b7596
added bats for feature version
andy-wm-arthur Feb 13, 2021
2d5f2ee
reduce scope of assert_feature_version
andy-wm-arthur Feb 13, 2021
9e40cc4
refactored RootValueUnreadable to not swallow errors
andy-wm-arthur Feb 15, 2021
2056725
assert FeatureVersion in BATS teardown
andy-wm-arthur Feb 15, 2021
bcd4154
go vet fixes
andy-wm-arthur Feb 15, 2021
51df4bb
remove assert_feature_version from sql-multi-db.bats
andy-wm-arthur Feb 17, 2021
6922b69
more feature version bats
andy-wm-arthur Feb 17, 2021
577a684
merge master to resolve conflicts
andy-wm-arthur Feb 17, 2021
dd833bd
Update go/cmd/dolt/commands/version.go
andy-wm-arthur Feb 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions bats/1pk5col-ints.bats
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ SQL
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
1 change: 1 addition & 0 deletions bats/1pk5col-strings.bats
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ SQL
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
1 change: 1 addition & 0 deletions bats/1pksupportedtypes.bats
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ SQL
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
1 change: 1 addition & 0 deletions bats/2pk5cols-ints.bats
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ SQL
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
1 change: 1 addition & 0 deletions bats/arg-parsing.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ setup() {
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
1 change: 1 addition & 0 deletions bats/auto_increment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ SQL
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
1 change: 1 addition & 0 deletions bats/blame.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ setup() {
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
1 change: 1 addition & 0 deletions bats/case-sensitivity.bats
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ DELIM
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
1 change: 1 addition & 0 deletions bats/column_tags.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ setup() {
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
1 change: 1 addition & 0 deletions bats/commit_tags.bats
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ SQL
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
5 changes: 4 additions & 1 deletion bats/compatibility/test_files/dolt_versions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ v0.16.0
v0.17.0
v0.18.0
v0.19.0
v0.20.0
v0.20.0
v0.21.0
v0.22.0
v0.22.7
1 change: 1 addition & 0 deletions bats/cp-and-mv.bats
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ SQL
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
1 change: 1 addition & 0 deletions bats/create-views.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ setup() {
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
1 change: 1 addition & 0 deletions bats/diff.bats
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ SQL
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
1 change: 1 addition & 0 deletions bats/docs.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ setup() {
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
1 change: 1 addition & 0 deletions bats/empty-repo.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ setup() {
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
1 change: 1 addition & 0 deletions bats/export-tables.bats
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ SQL
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
128 changes: 128 additions & 0 deletions bats/feature-version.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#!/usr/bin/env bats
load $BATS_TEST_DIRNAME/helper/common.bash

setup() {
setup_common
}

teardown() {
teardown_common
}

# client FeatureVersion must be >= repo FeatureVersion to read
# read with maximum FeatureVersion for assersions
MAX=1000

OLD=10
NEW=20

@test "set feature version with CLI flag" {
dolt --feature-version 19 sql -q "CREATE TABLE test (pk int PRIMARY KEY)"
run dolt --feature-version $MAX version --feature
[[ "$output" =~ "feature version: 19" ]] || false
}

@test "new client writes to table, locking out old client" {
run dolt --feature-version $OLD sql <<SQL
CREATE TABLE test (pk int PRIMARY KEY);
INSERT INTO test VALUES (10),(11),(12);
SQL
[ "$status" -eq 0 ]
run dolt --feature-version $NEW sql -q "INSERT INTO test VALUES (20),(21),(22);"
[ "$status" -eq 0 ]

# old client can't read or write
run dolt --feature-version $OLD sql -q "SELECT * FROM test"
[ "$status" -ne 0 ]
[[ ! "$output" =~ "panic" ]] || false
run dolt --feature-version $OLD sql -q "INSERT INTO test VALUES (13);"
[ "$status" -ne 0 ]
[[ ! "$output" =~ "panic" ]] || false

run dolt --feature-version $MAX version --feature
[ "$status" -eq 0 ]
[[ "$output" =~ "feature version: $NEW" ]] || false
}

setup_remote_tests() {
# remote repo from top-level test directory
rm -rf .dolt/

# create a new repo and a remote
mkdir remote first_repo
pushd first_repo
dolt --feature-version $OLD init
dolt --feature-version $OLD remote add origin file://../remote/

# add some data and push
dolt --feature-version $OLD sql <<SQL
CREATE TABLE test (pk int PRIMARY KEY);
INSERT INTO test VALUES (10),(11),(12);
SQL
dolt --feature-version $OLD add .
dolt --feature-version $OLD commit -m "test table"
dolt --feature-version $OLD push origin master
popd

# clone repo
dolt --feature-version $OLD clone file://remote clone_repo
}

@test "pulling newer FeatureVersion locks out old client" {
setup_remote_tests

pushd first_repo
dolt --feature-version $NEW sql -q "INSERT INTO test VALUES (20);"
dolt --feature-version $NEW commit -am "added row with new FeatureVersion on master"
dolt --feature-version $NEW push origin master
popd

pushd clone_repo
run dolt --feature-version $NEW sql -q "SELECT count(*) FROM test;" -r csv
[ "$status" -eq 0 ]
[[ "${lines[1]}" =~ "3" ]] || false
run dolt --feature-version $MAX version --feature
[ "$status" -eq 0 ]
[[ "$output" =~ "feature version: $OLD" ]] || false

# pull fails with old FeatureVersion
run dolt --feature-version $OLD pull
[ "$status" -ne 0 ]

# pull succeeds with old FeatureVersion
run dolt --feature-version $NEW pull
[ "$status" -eq 0 ]

run dolt --feature-version $NEW sql -q "SELECT count(*) FROM test;" -r csv
[ "$status" -eq 0 ]
[[ "${lines[1]}" =~ "4" ]] || false
run dolt --feature-version $MAX version --feature
[ "$status" -eq 0 ]
[[ "$output" =~ "feature version: $NEW" ]] || false
}

@test "older client maintains access to feature branch" {
setup_remote_tests

pushd clone_repo
dolt --feature-version $OLD checkout -b other
dolt --feature-version $OLD sql -q "INSERT INTO test VALUES (13);"
dolt --feature-version $OLD commit -am "made some changes on branch other"
popd

pushd first_repo
dolt --feature-version $NEW sql -q "INSERT INTO test VALUES (20);"
dolt --feature-version $NEW commit -am "added row with new FeatureVersion on master"
dolt --feature-version $NEW push origin master
popd

pushd clone_repo
dolt --feature-version $OLD fetch
dolt --feature-version $OLD checkout master
run dolt --feature-version $OLD pull
[ "$status" -ne 0 ]
[[ "$output" =~ "visit https://github.com/dolthub/dolt/releases/latest/" ]] || false
dolt --feature-version $OLD sql -q "SELECT * FROM test"
dolt --feature-version $OLD checkout other
popd
}
1 change: 1 addition & 0 deletions bats/filter-branch.bats
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ SQL
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
1 change: 1 addition & 0 deletions bats/foreign-keys.bats
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ SQL
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
5 changes: 5 additions & 0 deletions bats/helper/common.bash
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ setup_no_dolt_init() {
cd "dolt-repo-$$"
}

assert_feature_version() {
run dolt version --feature
[[ "$output" =~ "feature version: 0" ]] || exit 1
}

setup_common() {
setup_no_dolt_init
dolt init
Expand Down
1 change: 1 addition & 0 deletions bats/import-create-tables.bats
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ SQL
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
1 change: 1 addition & 0 deletions bats/import-replace-tables.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ setup() {
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
1 change: 1 addition & 0 deletions bats/import-update-tables.bats
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ SQL
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
1 change: 1 addition & 0 deletions bats/index-on-writes.bats
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ setup() {
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
1 change: 1 addition & 0 deletions bats/index.bats
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ SQL
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
1 change: 1 addition & 0 deletions bats/keyless.bats
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ SQL
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
2 changes: 2 additions & 0 deletions bats/localbs-remotes.bats
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ setup() {
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down Expand Up @@ -160,4 +161,5 @@ SQL
run dolt clone localbs://../remotedir test-repo
[ "$status" -eq 1 ]
[ ! -d test-repo ]
cd ..
}
1 change: 1 addition & 0 deletions bats/log.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ setup() {
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
1 change: 1 addition & 0 deletions bats/merge.bats
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ SQL
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
1 change: 1 addition & 0 deletions bats/multiple-tables.bats
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ SQL
}

teardown() {
assert_feature_version
teardown_common
}

Expand Down
2 changes: 2 additions & 0 deletions bats/no-repo.bats
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ setup() {
}

teardown() {
cd ../
teardown_common
rm -rf $BATS_TMPDIR/no-dolt-dir-$$
}
Expand Down Expand Up @@ -250,6 +251,7 @@ NOT_VALID_REPO_ERROR="The current directory is not a valid dolt repository."
[ -f .dolt/repo_state.json ]
[ ! -f README.md ]
[ ! -f LICENSE.md ]
cd ../
rm -rf $BATS_TMPDIR/dolt-repo-$$-new
}

Expand Down