Skip to content

Commit

Permalink
Merge pull request #7389 from dolthub/aaron/remotesrv-bats-no-running…
Browse files Browse the repository at this point in the history
…-in-parent-dir-fix

[no-release-notes] integration-tests/bats: Ensure we do not run `dolt` from a parent directory of the remotesrv dir.
  • Loading branch information
reltuk authored Jan 22, 2024
2 parents 15bd713 + 48be2c4 commit 777ae43
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions integration-tests/bats/remotesrv.bats
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ stop_remotesrv() {

@test "remotesrv: can read from remotesrv in repo-mode" {
mkdir remote
mkdir cloned
cd remote
dolt init
dolt sql -q 'create table vals (i int);'
Expand All @@ -36,7 +37,7 @@ stop_remotesrv() {
remotesrv --http-port 1234 --repo-mode &
remotesrv_pid=$!

cd ../
cd ../cloned
dolt clone http://localhost:50051/test-org/test-repo repo1
cd repo1
run dolt ls
Expand All @@ -45,21 +46,22 @@ stop_remotesrv() {
[[ "$output" =~ "5" ]] || false

stop_remotesrv
cd ../remote
cd ../../remote
dolt sql -q 'insert into vals (i) values (6), (7), (8), (9), (10);'
dolt commit -am 'add some vals'

remotesrv --http-port 1234 --repo-mode &
remotesrv_pid=$!

cd ../repo1
cd ../cloned/repo1
dolt pull
run dolt sql -q 'select count(*) from vals;'
[[ "$output" =~ "10" ]] || false
}

@test "remotesrv: can write to remotesrv in repo-mode" {
mkdir remote
mkdir cloned
cd remote
dolt init
dolt sql -q 'create table vals (i int);'
Expand All @@ -69,15 +71,15 @@ stop_remotesrv() {
remotesrv --http-port 1234 --repo-mode &
remotesrv_pid=$!

cd ../
cd ../cloned
dolt clone http://localhost:50051/test-org/test-repo repo1
cd repo1
dolt sql -q 'insert into vals values (1), (2), (3), (4), (5);'
dolt commit -am 'insert some values'
dolt push origin main:main

stop_remotesrv
cd ../remote
cd ../../remote
# Have to reset the working set, which was not updated by the push...
dolt reset --hard
run dolt sql -q 'select count(*) from vals;'
Expand All @@ -86,6 +88,7 @@ stop_remotesrv() {

@test "remotesrv: can write to remotesrv when repo has a dirty working set" {
mkdir remote
mkdir cloned
cd remote
dolt init
dolt sql -q 'create table vals (i int);'
Expand All @@ -96,15 +99,15 @@ stop_remotesrv() {
remotesrv --http-port 1234 --repo-mode &
remotesrv_pid=$!

cd ../
cd ../cloned
dolt clone http://localhost:50051/test-org/test-repo repo1
cd repo1
dolt sql -q 'insert into vals values (9778), (12433);'
dolt commit -am 'insert two unique values'
dolt push origin main:main

stop_remotesrv
cd ../remote
cd ../../remote

# HEAD has the pushed value.
run dolt show
Expand All @@ -124,6 +127,7 @@ stop_remotesrv() {

@test "remotesrv: read only server rejects writes" {
mkdir remote
mkdir cloned
cd remote
dolt init
dolt sql -q 'create table vals (i int);'
Expand All @@ -133,7 +137,7 @@ stop_remotesrv() {
remotesrv --http-port 1234 --repo-mode -read-only &
remotesrv_pid=$!

cd ../
cd ../cloned
dolt clone http://localhost:50051/test-org/test-repo repo1
cd repo1
dolt sql -q 'insert into vals values (1), (2), (3), (4), (5);'
Expand All @@ -144,6 +148,7 @@ stop_remotesrv() {

@test "remotesrv: can run grpc and http on same port" {
mkdir remote
mkdir cloned
cd remote
dolt init
dolt sql -q 'create table vals (i int);'
Expand All @@ -153,6 +158,6 @@ stop_remotesrv() {
remotesrv --grpc-port 1234 --http-port 1234 --repo-mode &
remotesrv_pid=$!

cd ../
cd ../cloned
dolt clone http://localhost:1234/test-org/test-repo repo1
}

0 comments on commit 777ae43

Please sign in to comment.