Files
dolt/integration-tests/bats/sql-config.bats
Maximilian Hoffman d11f5ec41b default session implements persistable interface, can save SQL variables (#2270)
* save version with defaultConfig in session -- todo remove and make PersistedSession

* add PersistedSession, and DoltSession interface to switch

* fmt

* fixup test for persistedSession

* PersistedSession progress, interfaces and enginetests

* All DsessFromSess references fixed

* delete unnuecessary lines

* Comments for dolt session

* Dolt session tests

* save bats progress

* formatting

* GMS version

* Bump GMS version

* add license header

* fix multi-db errors

* try copyright again

* make test deterministic

* higher connection timeout default

* sever config ordering

* PR fixes

* PR fixes

* config rewrite progress

* server config refactor

* PR cleanup

* delete lines

* add go tests, refactor persistent global initialization

* PR fixes

* delete more lines

* small PR cleanup

* try to fix data race

* better constructor names

* zach don't like --server flag

* edge cases around disabling replication

* missed line in merge

* Skip two tests i fixed in follow-on PR

* merge two config prs

* fix nondeterministic bats

* zach's comments

* bump bats sql-shell expect timeout

* GMS and integrator race to access system vars; need to decide whether to force integrator to initialize, or make GMS init private; leaving in GMS for now
2021-11-01 16:49:00 -07:00

113 lines
3.9 KiB
Bash

#!/usr/bin/env bats
load $BATS_TEST_DIRNAME/helper/common.bash
setup() {
mkdir $BATS_TMPDIR/dolt-repo-$$
cd $BATS_TMPDIR/dolt-repo-$$
setup_common
}
teardown() {
teardown_common
rm -rf "$BATS_TMPDIR/config-test$$"
}
@test "sql-config: query persisted variable with cli engine" {
echo '{"sqlserver.global.max_connections":"1000"}' > .dolt/config.json
run dolt sql -q "SELECT @@GLOBAL.max_connections" -r csv
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 2 ]
[[ "${lines[0]}" =~ "@@GLOBAL.max_connections" ]] || false
[[ "${lines[1]}" =~ "1000" ]] || false
}
@test "sql-config: set persist global variable with cli engine" {
dolt sql -q "SET PERSIST max_connections = 1000"
run dolt config --local --list
[ "$status" -eq 0 ]
[[ "$output" =~ "sqlserver.global.max_connections = 1000" ]] || false
}
@test "sql-config: set persist multiple global variables with cli engine" {
dolt sql -q "SET PERSIST max_connections = 1000"
dolt sql -q "SET PERSIST auto_increment_increment = 2"
run dolt config --local --list
[ "$status" -eq 0 ]
[[ "$output" =~ "sqlserver.global.auto_increment_increment = 2" ]] || false
[[ "$output" =~ "sqlserver.global.max_connections = 1000" ]] || false
}
@test "sql-config: persist only global variable with cli engine" {
dolt sql -q "SET PERSIST_ONLY max_connections = 1000"
run dolt config --local --list
[ "$status" -eq 0 ]
[[ "$output" =~ "sqlserver.global.max_connections = 1000" ]] || false
}
@test "sql-config: remove persisted variable with cli engine" {
skip "TODO parser support for RESET PERSIST"
dolt sql -q "SET PERSIST_ONLY max_connections = 1000"
dolt sql -q "RESET PERSIST max_connections"
run dolt config --local --list
[ "$status" -eq 0 ]
[[ ! "$output" =~ "sqlserver.global.max_connections = 1000" ]] || false
}
@test "sql-config: remove all persisted variables with cli engine" {
skip "TODO parser support for RESET PERSIST"
dolt sql -q "SET PERSIST_ONLY max_connections = 1000"
dolt sql -q "SET PERSIST_ONLY auto_increment_increment = 2"
dolt sql -q "RESET PERSIST"
run dolt config --local --list
[ "$status" -eq 0 ]
[[ ! "$output" =~ "sqlserver.global.max_connections = 1000" ]] || false
[[ ! "$output" =~ "sqlserver.global.auto_increment_increment = 2" ]] || false
}
@test "sql-config: persist dolt specific global variable" {
mkdir repo1
cd repo1
dolt init
dolt sql -q "SET PERSIST_ONLY repo1_head = 1000"
run dolt config --local --list
[ "$status" -eq 0 ]
[[ "$output" =~ "sqlserver.global.repo1_head = 1000" ]] || false
}
@test "sql-config: persist invalid variable name" {
run dolt sql -q "SET PERSIST unknown = 1000"
[ "$status" -eq 1 ]
[[ ! "$output" =~ "panic" ]] || false
[[ "$output" =~ "Unknown system variable 'unknown'" ]] || false
}
@test "sql-config: persist invalid variable type" {
run dolt sql -q "SET PERSIST max_connections = string"
[ "$status" -eq 1 ]
[[ ! "$output" =~ "panic" ]] || false
[[ "$output" =~ "Variable 'max_connections' can't be set to the value of 'string'" ]] || false
}
@test "sql-config: invalid persisted system variable name errors on cli sql command" {
echo '{"sqlserver.global.unknown":"1000"}' > .dolt/config.json
run dolt sql -q "SELECT @@GLOBAL.unknown" -r csv
[ "$status" -eq 1 ]
[[ ! "$output" =~ "panic" ]]
[[ "$output" =~ "Unknown system variable 'unknown'" ]] || false
}
@test "sql-config: invalid persisted system variable type errors on cli sql command" {
echo '{"sqlserver.global.max_connections":"string"}' > .dolt/config.json
run dolt sql -q "SELECT @@GLOBAL.max_connections" -r csv
[ "$status" -eq 0 ]
[[ ! "$output" =~ "panic" ]]
[[ "$output" =~ "failed to load persisted global variables: key: 'max_connections'" ]] || false
[[ "$output" =~ "invalid syntax" ]] || false
[[ "$output" =~ "151" ]]
}