Skip to content

Commit 0a9ffdc

Browse files
authored
[#2767] Fixed 'VORTEX_DB_DIR' and 'VORTEX_DB_FILE' ignored for indexed DB fetches. (#2770)
1 parent e5e4938 commit 0a9ffdc

9 files changed

Lines changed: 109 additions & 13 deletions

‎.vortex/tooling/src/vortex-fetch-db‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ VORTEX_FETCH_DB_PROCEED="${!_v:-1}"
3535
# Database dump file name.
3636
_v="VORTEX_FETCH_DB${_db_index}_FILE"
3737
_vs="VORTEX_DB${_db_index}_FILE"
38-
VORTEX_FETCH_DB_FILE="${!_v:-${!_vs:-db.sql}}"
38+
VORTEX_FETCH_DB_FILE="${!_v:-${!_vs:-${VORTEX_DB_FILE:-db.sql}}}"
3939

4040
# Directory with database dump file.
4141
_v="VORTEX_FETCH_DB${_db_index}_DIR"
4242
_vs="VORTEX_DB${_db_index}_DIR"
43-
VORTEX_FETCH_DB_DIR="${!_v:-${!_vs:-./.data}}"
43+
VORTEX_FETCH_DB_DIR="${!_v:-${!_vs:-${VORTEX_DB_DIR:-./.data}}}"
4444

4545
# ------------------------------------------------------------------------------
4646

‎.vortex/tooling/src/vortex-fetch-db-acquia‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ VORTEX_FETCH_DB_ACQUIA_DB_NAME="${!_v:-}"
5353
_v="VORTEX_FETCH_DB${_db_index}_ACQUIA_DB_DIR"
5454
_vs="VORTEX_FETCH_DB${_db_index}_DIR"
5555
_vss="VORTEX_DB${_db_index}_DIR"
56-
VORTEX_FETCH_DB_ACQUIA_DB_DIR="${!_v:-${!_vs:-${!_vss:-./.data}}}"
56+
VORTEX_FETCH_DB_ACQUIA_DB_DIR="${!_v:-${!_vs:-${!_vss:-${VORTEX_DB_DIR:-./.data}}}}"
5757

5858
# Database dump file name.
5959
_v="VORTEX_FETCH_DB${_db_index}_ACQUIA_DB_FILE"
6060
_vs="VORTEX_FETCH_DB${_db_index}_FILE"
6161
_vss="VORTEX_DB${_db_index}_FILE"
62-
VORTEX_FETCH_DB_ACQUIA_DB_FILE="${!_v:-${!_vs:-${!_vss:-db.sql}}}"
62+
VORTEX_FETCH_DB_ACQUIA_DB_FILE="${!_v:-${!_vs:-${!_vss:-${VORTEX_DB_FILE:-db.sql}}}}"
6363

6464
# Flag to fetch a fresh copy of the database by triggering a new backup.
6565
_v="VORTEX_FETCH_DB${_db_index}_FRESH"

‎.vortex/tooling/src/vortex-fetch-db-container-registry‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ VORTEX_FETCH_DB_CONTAINER_REGISTRY_PASS="${!_v:-${VORTEX_CONTAINER_REGISTRY_PASS
3838
_v="VORTEX_FETCH_DB${_db_index}_CONTAINER_REGISTRY_DB_DIR"
3939
_vs="VORTEX_FETCH_DB${_db_index}_DIR"
4040
_vss="VORTEX_DB${_db_index}_DIR"
41-
VORTEX_FETCH_DB_CONTAINER_REGISTRY_DB_DIR="${!_v:-${!_vs:-${!_vss:-./.data}}}"
41+
VORTEX_FETCH_DB_CONTAINER_REGISTRY_DB_DIR="${!_v:-${!_vs:-${!_vss:-${VORTEX_DB_DIR:-./.data}}}}"
4242

4343
# The base container image used as a fallback when the archive does not exist.
4444
_v="VORTEX_FETCH_DB${_db_index}_CONTAINER_REGISTRY_IMAGE_BASE"

‎.vortex/tooling/src/vortex-fetch-db-ftp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ VORTEX_FETCH_DB_FTP_FILE="${!_v:-}"
3939
_v="VORTEX_FETCH_DB${_db_index}_FTP_DB_DIR"
4040
_vs="VORTEX_FETCH_DB${_db_index}_DIR"
4141
_vss="VORTEX_DB${_db_index}_DIR"
42-
VORTEX_FETCH_DB_FTP_DB_DIR="${!_v:-${!_vs:-${!_vss:-./.data}}}"
42+
VORTEX_FETCH_DB_FTP_DB_DIR="${!_v:-${!_vs:-${!_vss:-${VORTEX_DB_DIR:-./.data}}}}"
4343

4444
# Database dump file name.
4545
_v="VORTEX_FETCH_DB${_db_index}_FTP_DB_FILE"
4646
_vs="VORTEX_FETCH_DB${_db_index}_FILE"
4747
_vss="VORTEX_DB${_db_index}_FILE"
48-
VORTEX_FETCH_DB_FTP_DB_FILE="${!_v:-${!_vs:-${!_vss:-db.sql}}}"
48+
VORTEX_FETCH_DB_FTP_DB_FILE="${!_v:-${!_vs:-${!_vss:-${VORTEX_DB_FILE:-db.sql}}}}"
4949

5050
#-------------------------------------------------------------------------------
5151

‎.vortex/tooling/src/vortex-fetch-db-lagoon‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ VORTEX_FETCH_DB_LAGOON_SSH_USER="${!_v:-${VORTEX_FETCH_DB_LAGOON_PROJECT}-${VORT
7676
_v="VORTEX_FETCH_DB${_db_index}_LAGOON_DB_DIR"
7777
_vs="VORTEX_FETCH_DB${_db_index}_DIR"
7878
_vss="VORTEX_DB${_db_index}_DIR"
79-
VORTEX_FETCH_DB_LAGOON_DB_DIR="${!_v:-${!_vs:-${!_vss:-./.data}}}"
79+
VORTEX_FETCH_DB_LAGOON_DB_DIR="${!_v:-${!_vs:-${!_vss:-${VORTEX_DB_DIR:-./.data}}}}"
8080

8181
# Database dump file name on the host.
8282
_v="VORTEX_FETCH_DB${_db_index}_LAGOON_DB_FILE"
8383
_vs="VORTEX_FETCH_DB${_db_index}_FILE"
8484
_vss="VORTEX_DB${_db_index}_FILE"
85-
VORTEX_FETCH_DB_LAGOON_DB_FILE="${!_v:-${!_vs:-${!_vss:-db.sql}}}"
85+
VORTEX_FETCH_DB_LAGOON_DB_FILE="${!_v:-${!_vs:-${!_vss:-${VORTEX_DB_FILE:-db.sql}}}}"
8686

8787
# Name of the webroot directory with Drupal codebase.
8888
WEBROOT="${WEBROOT:-web}"

‎.vortex/tooling/src/vortex-fetch-db-s3‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ VORTEX_FETCH_DB_S3_PREFIX="${!_v:-${S3_PREFIX:-}}"
4141
_v="VORTEX_FETCH_DB${_db_index}_S3_DB_DIR"
4242
_vs="VORTEX_FETCH_DB${_db_index}_DIR"
4343
_vss="VORTEX_DB${_db_index}_DIR"
44-
VORTEX_FETCH_DB_S3_DB_DIR="${!_v:-${!_vs:-${!_vss:-./.data}}}"
44+
VORTEX_FETCH_DB_S3_DB_DIR="${!_v:-${!_vs:-${!_vss:-${VORTEX_DB_DIR:-./.data}}}}"
4545

4646
# Database dump file name.
4747
_v="VORTEX_FETCH_DB${_db_index}_S3_DB_FILE"
4848
_vs="VORTEX_FETCH_DB${_db_index}_FILE"
4949
_vss="VORTEX_DB${_db_index}_FILE"
50-
VORTEX_FETCH_DB_S3_DB_FILE="${!_v:-${!_vs:-${!_vss:-db.sql}}}"
50+
VORTEX_FETCH_DB_S3_DB_FILE="${!_v:-${!_vs:-${!_vss:-${VORTEX_DB_FILE:-db.sql}}}}"
5151

5252
# ------------------------------------------------------------------------------
5353

‎.vortex/tooling/src/vortex-fetch-db-url‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ VORTEX_FETCH_DB_URL="${!_v:-}"
2424
_v="VORTEX_FETCH_DB${_db_index}_URL_DB_DIR"
2525
_vs="VORTEX_FETCH_DB${_db_index}_DIR"
2626
_vss="VORTEX_DB${_db_index}_DIR"
27-
VORTEX_FETCH_DB_URL_DB_DIR="${!_v:-${!_vs:-${!_vss:-./.data}}}"
27+
VORTEX_FETCH_DB_URL_DB_DIR="${!_v:-${!_vs:-${!_vss:-${VORTEX_DB_DIR:-./.data}}}}"
2828

2929
# Database dump file name.
3030
_v="VORTEX_FETCH_DB${_db_index}_URL_DB_FILE"
3131
_vs="VORTEX_FETCH_DB${_db_index}_FILE"
3232
_vss="VORTEX_DB${_db_index}_FILE"
33-
VORTEX_FETCH_DB_URL_DB_FILE="${!_v:-${!_vs:-${!_vss:-db.sql}}}"
33+
VORTEX_FETCH_DB_URL_DB_FILE="${!_v:-${!_vs:-${!_vss:-${VORTEX_DB_FILE:-db.sql}}}}"
3434

3535
# Password for unzipping password-protected zip files.
3636
_v="VORTEX_FETCH_DB${_db_index}_UNZIP_PASSWORD"

‎.vortex/tooling/tests/unit/fetch-db-url.bats‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,46 @@ load ../_helper.bash
2525
popd >/dev/null
2626
}
2727

28+
@test "fetch-db-url: Resolve indexed dir from plain VORTEX_DB_DIR fallback" {
29+
pushd "${LOCAL_REPO_DIR}" >/dev/null || exit 1
30+
31+
mock_curl=$(mock_command "curl")
32+
mock_set_side_effect "${mock_curl}" "mkdir -p custom_data && touch custom_data/db2.sql" 1
33+
34+
# The migration DB (index 2) has no per-index directory in the fixture, so the
35+
# non-indexed VORTEX_DB_DIR base must be used for the fetch target directory.
36+
export VORTEX_DB_INDEX="2"
37+
export VORTEX_FETCH_DB2_URL="http://example.com/db.sql"
38+
export VORTEX_DB_DIR="custom_data"
39+
40+
run .vortex/tooling/src/vortex-fetch-db-url
41+
assert_success
42+
# curl writes into custom_data, resolved via the plain VORTEX_DB_DIR fallback.
43+
assert_contains "custom_data/" "$(mock_get_call_args "${mock_curl}" 1)"
44+
45+
popd >/dev/null
46+
}
47+
48+
@test "fetch-db-url: Resolve indexed file name from plain VORTEX_DB_FILE fallback" {
49+
pushd "${LOCAL_REPO_DIR}" >/dev/null || exit 1
50+
51+
mock_curl=$(mock_command "curl")
52+
mock_set_side_effect "${mock_curl}" "mkdir -p .data && touch .data/custom.sql" 1
53+
54+
# An index with no per-index file override must fall back to the non-indexed
55+
# VORTEX_DB_FILE for the fetch target file name.
56+
export VORTEX_DB_INDEX="3"
57+
export VORTEX_FETCH_DB3_URL="http://example.com/db.sql"
58+
export VORTEX_DB_FILE="custom.sql"
59+
60+
run .vortex/tooling/src/vortex-fetch-db-url
61+
assert_success
62+
# curl writes custom.sql, resolved via the plain VORTEX_DB_FILE fallback.
63+
assert_contains "/custom.sql" "$(mock_get_call_args "${mock_curl}" 1)"
64+
65+
popd >/dev/null
66+
}
67+
2868
@test "fetch-db-url: Fetch zip file without password" {
2969
pushd "${LOCAL_REPO_DIR}" >/dev/null || exit 1
3070

‎.vortex/tooling/tests/unit/fetch-db.bats‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,62 @@ EOF
184184
popd >/dev/null
185185
}
186186

187+
@test "fetch-db: Resolve indexed dir from plain VORTEX_DB_DIR fallback" {
188+
pushd "${LOCAL_REPO_DIR}" >/dev/null || exit 1
189+
190+
# The migration DB (index 2) has a per-index file name (db2.sql) but no
191+
# per-index directory, so the non-indexed VORTEX_DB_DIR must act as the base
192+
# directory. An existing dump placed there should be discovered.
193+
mkdir -p custom_data
194+
touch custom_data/db2.sql
195+
196+
mock_ls=$(mock_command "ls")
197+
mock_set_output "${mock_ls}" "total 0" 1
198+
199+
export VORTEX_DB_INDEX="2"
200+
export VORTEX_FETCH_DB2_SOURCE="url"
201+
export VORTEX_FETCH_DB2_PROCEED="1"
202+
# Set the per-index file name explicitly so the fixture name matches the
203+
# resolved dump file rather than relying on the fixture .env default.
204+
export VORTEX_FETCH_DB2_FILE="db2.sql"
205+
export VORTEX_DB_DIR="custom_data"
206+
207+
run .vortex/tooling/src/vortex-fetch-db
208+
assert_success
209+
# The router resolved the indexed dump directory to custom_data via the
210+
# plain VORTEX_DB_DIR fallback and found the existing dump there.
211+
assert_output_contains "Found existing database dump file(s)."
212+
assert_output_contains "Using existing database dump file(s)."
213+
214+
popd >/dev/null
215+
}
216+
217+
@test "fetch-db: Resolve indexed file name from plain VORTEX_DB_FILE fallback" {
218+
pushd "${LOCAL_REPO_DIR}" >/dev/null || exit 1
219+
220+
# An index with no per-index file override (unlike index 2, which the fixture
221+
# sets to db2.sql) must fall back to the non-indexed VORTEX_DB_FILE for the
222+
# dump file name. An existing dump with that name should be discovered.
223+
mkdir -p .data
224+
touch .data/custom.sql
225+
226+
mock_ls=$(mock_command "ls")
227+
mock_set_output "${mock_ls}" "total 0" 1
228+
229+
export VORTEX_DB_INDEX="3"
230+
export VORTEX_FETCH_DB3_SOURCE="url"
231+
export VORTEX_FETCH_DB3_PROCEED="1"
232+
export VORTEX_DB_FILE="custom.sql"
233+
234+
run .vortex/tooling/src/vortex-fetch-db
235+
assert_success
236+
# The router resolved the indexed dump file name to custom.sql via the
237+
# plain VORTEX_DB_FILE fallback and found the existing dump.
238+
assert_output_contains "Found existing database dump file(s)."
239+
240+
popd >/dev/null
241+
}
242+
187243
@test "fetch-db: Existing database file handling" {
188244
pushd "${LOCAL_REPO_DIR}" >/dev/null || exit 1
189245

0 commit comments

Comments
 (0)