From 90d1886d54ae79a2ba67d53b506773c5185a959f Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Mon, 13 Jan 2025 08:56:34 +0000 Subject: [PATCH 01/17] backend: allow configuring S3_REGION See: https://github.com/getodk/central/pull/870 --- lib/bin/s3-create-bucket.js | 6 +++--- lib/external/s3.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/bin/s3-create-bucket.js b/lib/bin/s3-create-bucket.js index 84f16c449..aa63c92fd 100644 --- a/lib/bin/s3-create-bucket.js +++ b/lib/bin/s3-create-bucket.js @@ -9,7 +9,7 @@ const Minio = require('minio'); -const { server, bucketName, accessKey, secretKey } = require('config').get('default.external.s3blobStore'); +const { server, region, bucketName, accessKey, secretKey } = require('config').get('default.external.s3blobStore'); const minioClient = (() => { const url = new URL(server); @@ -29,8 +29,8 @@ minioClient.bucketExists(bucketName) return; } - log('Creating bucket:', bucketName); - return minioClient.makeBucket(bucketName) + log('Creating bucket:', bucketName, 'in', region ?? 'default region'); + return minioClient.makeBucket(bucketName, region) .then(() => log('Bucket created OK.')); }) .catch(err => { diff --git a/lib/external/s3.js b/lib/external/s3.js index ee77ba240..a51d9b165 100644 --- a/lib/external/s3.js +++ b/lib/external/s3.js @@ -12,7 +12,7 @@ const disabled = { enabled: false }; const init = (config) => { if (!config) return disabled; - const { server, accessKey, secretKey, bucketName, requestTimeout, objectPrefix } = config; + const { server, accessKey, secretKey, bucketName, region, requestTimeout, objectPrefix } = config; if (!(server && accessKey && secretKey && bucketName)) return disabled; const http = require('node:http'); @@ -83,7 +83,7 @@ const init = (config) => { return req; }; - const clientConfig = { endPoint, port, useSSL, accessKey, secretKey, transport: { request } }; + const clientConfig = { endPoint, port, useSSL, accessKey, secretKey, region, transport: { request } }; return new Minio.Client(clientConfig); })(); From 95002349ccf8051da44fb039a0b2741dd260b43f Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Mon, 13 Jan 2025 09:00:26 +0000 Subject: [PATCH 02/17] add region when creating bucket --- lib/bin/s3-create-bucket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bin/s3-create-bucket.js b/lib/bin/s3-create-bucket.js index aa63c92fd..284e416fd 100644 --- a/lib/bin/s3-create-bucket.js +++ b/lib/bin/s3-create-bucket.js @@ -17,7 +17,7 @@ const minioClient = (() => { const endPoint = (url.hostname + url.pathname).replace(/\/$/, ''); const port = parseInt(url.port, 10); - return new Minio.Client({ endPoint, port, useSSL, accessKey, secretKey }); + return new Minio.Client({ endPoint, port, useSSL, accessKey, secretKey, region }); })(); const log = (...args) => console.log(__filename, ...args); From fac48ac9f772654dee8db27b7273ff21bae4916f Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Mon, 13 Jan 2025 09:06:11 +0000 Subject: [PATCH 03/17] makeBucket() with/without region --- lib/bin/s3-create-bucket.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/bin/s3-create-bucket.js b/lib/bin/s3-create-bucket.js index 284e416fd..f54c9ef96 100644 --- a/lib/bin/s3-create-bucket.js +++ b/lib/bin/s3-create-bucket.js @@ -30,9 +30,10 @@ minioClient.bucketExists(bucketName) } log('Creating bucket:', bucketName, 'in', region ?? 'default region'); - return minioClient.makeBucket(bucketName, region) - .then(() => log('Bucket created OK.')); + if (region) return minioClient.makeBucket(bucketName, region); + else return minioClient.makeBucket(bucketName); // eslint-disable-line no-multi-spaces }) + .then(() => log('Bucket created OK.')) .catch(err => { log('ERROR CREATING MINIO BUCKET:', err); process.exit(1); From 8b3774bdcdbeb9bc8f9fbb8b99696dd20d5acd84 Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Mon, 13 Jan 2025 09:15:00 +0000 Subject: [PATCH 04/17] shift NODE_CONFIG_ENV passing --- test/e2e/s3/run-tests.sh | 2 +- test/e2e/s3/test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/s3/run-tests.sh b/test/e2e/s3/run-tests.sh index 54e5a1778..56dbecbca 100755 --- a/test/e2e/s3/run-tests.sh +++ b/test/e2e/s3/run-tests.sh @@ -61,7 +61,7 @@ timeout 30 bash -c "while ! curl -s -o /dev/null $serverUrl; do sleep 1; done" log 'Backend started!' cd test/e2e/s3 -npx mocha test.js +NODE_CONFIG_ENV=s3-dev npx mocha test.js if ! curl -s -o /dev/null "$serverUrl"; then log '!!! Backend died.' diff --git a/test/e2e/s3/test.js b/test/e2e/s3/test.js index b94c2e75c..f1a45c3bd 100644 --- a/test/e2e/s3/test.js +++ b/test/e2e/s3/test.js @@ -403,7 +403,7 @@ function cli(cmd) { cmd = `exec node lib/bin/s3 ${cmd}`; // eslint-disable-line no-param-reassign log.debug('cli()', 'calling:', cmd); - const env = { ..._.pick(process.env, 'PATH'), NODE_CONFIG_ENV:'s3-dev' }; + const env = _.pick(process.env, 'PATH', 'NODE_CONFIG_ENV'); const promise = new Promise((resolve, reject) => { const child = exec(cmd, { env, cwd:'../../..' }, (err, stdout, stderr) => { From 08917b855f215ca80281a2d280a4db665d617ba4 Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Mon, 13 Jan 2025 09:15:35 +0000 Subject: [PATCH 05/17] don't re-specify env --- test/e2e/s3/test.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/e2e/s3/test.js b/test/e2e/s3/test.js index f1a45c3bd..e756d0b84 100644 --- a/test/e2e/s3/test.js +++ b/test/e2e/s3/test.js @@ -403,10 +403,9 @@ function cli(cmd) { cmd = `exec node lib/bin/s3 ${cmd}`; // eslint-disable-line no-param-reassign log.debug('cli()', 'calling:', cmd); - const env = _.pick(process.env, 'PATH', 'NODE_CONFIG_ENV'); const promise = new Promise((resolve, reject) => { - const child = exec(cmd, { env, cwd:'../../..' }, (err, stdout, stderr) => { + const child = exec(cmd, { cwd:'../../..' }, (err, stdout, stderr) => { if (err) { err.stdout = stdout; // eslint-disable-line no-param-reassign err.stderr = stderr; // eslint-disable-line no-param-reassign From ef05e966cd47bc7276f0d150cbe8bed7cf4bcbd2 Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Mon, 13 Jan 2025 10:23:38 +0000 Subject: [PATCH 06/17] add server ports --- config/s3-dev-blank-region.json | 17 ++++++++++++ config/s3-dev-with-region.json | 17 ++++++++++++ test/e2e/s3/run-tests.sh | 46 +++++++++++++++++++++++---------- test/e2e/s3/test.js | 2 +- 4 files changed, 67 insertions(+), 15 deletions(-) create mode 100644 config/s3-dev-blank-region.json create mode 100644 config/s3-dev-with-region.json diff --git a/config/s3-dev-blank-region.json b/config/s3-dev-blank-region.json new file mode 100644 index 000000000..f1c977624 --- /dev/null +++ b/config/s3-dev-blank-region.json @@ -0,0 +1,17 @@ +{ + "default": { + "server": { + "port": 8384 + }, + "external": { + "s3blobStore": { + "region": "", + "server": "http://localhost:9000", + "accessKey": "odk-central-dev", + "secretKey": "topSecret123", + "bucketName": "odk-central-bucket", + "requestTimeout": 60000 + } + } + } +} diff --git a/config/s3-dev-with-region.json b/config/s3-dev-with-region.json new file mode 100644 index 000000000..4a92f3dce --- /dev/null +++ b/config/s3-dev-with-region.json @@ -0,0 +1,17 @@ +{ + "default": { + "server": { + "port": 8385 + }, + "external": { + "s3blobStore": { + "region": "eu-west-1", + "server": "http://localhost:9000", + "accessKey": "odk-central-dev", + "secretKey": "topSecret123", + "bucketName": "odk-central-bucket", + "requestTimeout": 60000 + } + } + } +} diff --git a/test/e2e/s3/run-tests.sh b/test/e2e/s3/run-tests.sh index 56dbecbca..79f6bb320 100755 --- a/test/e2e/s3/run-tests.sh +++ b/test/e2e/s3/run-tests.sh @@ -52,20 +52,38 @@ EOF read -rp '' fi -NODE_CONFIG_ENV=s3-dev node lib/bin/s3-create-bucket.js -NODE_CONFIG_ENV=s3-dev make run & -serverPid=$! - -log 'Waiting for backend to start...' -timeout 30 bash -c "while ! curl -s -o /dev/null $serverUrl; do sleep 1; done" -log 'Backend started!' - -cd test/e2e/s3 -NODE_CONFIG_ENV=s3-dev npx mocha test.js +run_suite() { + suite="$1" + configEnv="$2" + + case "$suite" in + smoke) testOptions="--fgrep @smoke-test" ;; + all) testOptions="" ;; + *) log "Unrecongised test suite: $suite"; exit 1 ;; + esac + + NODE_CONFIG_ENV="$configEnv" node lib/bin/s3-create-bucket.js + NODE_CONFIG_ENV="$configEnv" make run & + serverPid=$! + + log 'Waiting for backend to start...' + timeout 30 bash -c "while ! curl -s -o /dev/null $serverUrl; do sleep 1; done" + log 'Backend started!' + + cd test/e2e/s3 + NODE_CONFIG_ENV="$configEnv" npx mocha "$testOptions" test.js + + if ! curl -s -o /dev/null "$serverUrl"; then + log '!!! Backend died.' + exit 1 + fi + + kill "$serverPid" + wait "$serverPid" +} -if ! curl -s -o /dev/null "$serverUrl"; then - log '!!! Backend died.' - exit 1 -fi +run_suite smoke s3-dev-with-region +run_suite smoke s3-dev-blank-region +run_suite all s3-dev log "Tests completed OK." diff --git a/test/e2e/s3/test.js b/test/e2e/s3/test.js index e756d0b84..287f49ecb 100644 --- a/test/e2e/s3/test.js +++ b/test/e2e/s3/test.js @@ -85,7 +85,7 @@ describe('s3 support', () => { await assertNoneRedirect(actualAttachments); } - it('should shift submission attachments to s3', async function() { + it('should shift submission attachments to s3 @smoke-test', async function() { this.timeout(TIMEOUT); // given From f08a4c8affb2f4c3e68968fe9993d7ff723479e4 Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Mon, 13 Jan 2025 10:23:53 +0000 Subject: [PATCH 07/17] proper arrays --- test/e2e/s3/run-tests.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/e2e/s3/run-tests.sh b/test/e2e/s3/run-tests.sh index 79f6bb320..51868a5aa 100755 --- a/test/e2e/s3/run-tests.sh +++ b/test/e2e/s3/run-tests.sh @@ -56,9 +56,11 @@ run_suite() { suite="$1" configEnv="$2" + log "Running suite '$suite' with config '$configEnv'..." + case "$suite" in - smoke) testOptions="--fgrep @smoke-test" ;; - all) testOptions="" ;; + smoke) testOptions=(--fgrep @smoke-test) ;; + all) testOptions=() ;; *) log "Unrecongised test suite: $suite"; exit 1 ;; esac @@ -71,7 +73,8 @@ run_suite() { log 'Backend started!' cd test/e2e/s3 - NODE_CONFIG_ENV="$configEnv" npx mocha "$testOptions" test.js + NODE_CONFIG_ENV="$configEnv" npx mocha "${testOptions[@]}" test.js + cd - if ! curl -s -o /dev/null "$serverUrl"; then log '!!! Backend died.' From 6ae89ce751edfcc48fcfb4879d13e2ca30fefb38 Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Mon, 13 Jan 2025 10:54:22 +0000 Subject: [PATCH 08/17] add @smoke-test --- test/e2e/s3/run-tests.sh | 25 ++++++++++------ test/e2e/s3/test-forms/0.xml | 56 ++++++++++++++++++++++++++++++++++++ test/e2e/s3/test.js | 28 +++++++++++++++--- 3 files changed, 97 insertions(+), 12 deletions(-) create mode 100644 test/e2e/s3/test-forms/0.xml diff --git a/test/e2e/s3/run-tests.sh b/test/e2e/s3/run-tests.sh index 51868a5aa..d075653a1 100755 --- a/test/e2e/s3/run-tests.sh +++ b/test/e2e/s3/run-tests.sh @@ -1,7 +1,6 @@ #!/bin/bash -eu set -o pipefail -serverUrl="http://localhost:8383" userEmail="x@example.com" userPassword="secret1234" @@ -17,11 +16,6 @@ cleanup() { } trap cleanup EXIT SIGINT SIGTERM SIGHUP -if curl -s -o /dev/null $serverUrl; then - log "!!! Error: server already running at: $serverUrl" - exit 1 -fi - make base if [[ "${CI-}" = '' ]]; then @@ -65,6 +59,14 @@ run_suite() { esac NODE_CONFIG_ENV="$configEnv" node lib/bin/s3-create-bucket.js + + serverPort="$(NODE_CONFIG_ENV="$configEnv" node -e 'console.log(require("config").default.server.port)')" + serverUrl="http://localhost:$serverPort" + if curl -s -o /dev/null $serverUrl; then + log "!!! Error: server already running at: $serverUrl" + exit 1 + fi + NODE_CONFIG_ENV="$configEnv" make run & serverPid=$! @@ -73,7 +75,7 @@ run_suite() { log 'Backend started!' cd test/e2e/s3 - NODE_CONFIG_ENV="$configEnv" npx mocha "${testOptions[@]}" test.js + NODE_CONFIG_ENV="$configEnv" NODE_CONFIG_DIR=../../../config npx mocha "${testOptions[@]}" test.js cd - if ! curl -s -o /dev/null "$serverUrl"; then @@ -81,8 +83,15 @@ run_suite() { exit 1 fi + # TODO may not be necessary + NODE_CONFIG_ENV="$configEnv" node lib/bin/s3.js upload-pending + + # TODO may not be necessary kill "$serverPid" - wait "$serverPid" + wait "$serverPid" || true # already finished? or the command isn't working? + sleep 10 # TODO work out a better way of doing this! + + log "Suite '$suite' with config '$configEnv' completed OK." } run_suite smoke s3-dev-with-region diff --git a/test/e2e/s3/test-forms/0.xml b/test/e2e/s3/test-forms/0.xml new file mode 100644 index 000000000..03f62859e --- /dev/null +++ b/test/e2e/s3/test-forms/0.xml @@ -0,0 +1,56 @@ + + + + Blob Test 0 + + + + + Big Bin 1 + jr://images/big-1.bin + + + + + + + + + + + + + + + + + image-big-1-bin + a + + + + + + + + + + + + + + image type with draw appearance + + + + file type with no appearance <br/> WARNING: any kind of file could be uploaded including files that contain viruses or other malware. Be sure to take proper precautions when downloading files from server. + + + diff --git a/test/e2e/s3/test.js b/test/e2e/s3/test.js index 287f49ecb..045f85a8b 100644 --- a/test/e2e/s3/test.js +++ b/test/e2e/s3/test.js @@ -17,12 +17,13 @@ const fs = require('node:fs'); const { randomBytes } = require('node:crypto'); const _ = require('lodash'); const should = require('should'); +const tmp = require('tmp'); const SUITE_NAME = 'test/e2e/s3'; const log = require('../util/logger')(SUITE_NAME); const { apiClient, mimetypeFor, Redirect } = require('../util/api'); -const serverUrl = 'http://localhost:8383'; +const serverUrl = `http://localhost:${require('config').default.server.port}`; const userEmail = 'x@example.com'; const userPassword = 'secret1234'; @@ -65,7 +66,7 @@ describe('s3 support', () => { bigFileSizeMb = 100, } = opts; // eslint-disable-line object-curly-newline - attDir = `./test-forms/${testNumber}-attachments`; + attDir = opts.attDir || `./test-forms/${testNumber}-attachments`; // given fs.mkdirSync(attDir, { recursive:true }); @@ -85,7 +86,25 @@ describe('s3 support', () => { await assertNoneRedirect(actualAttachments); } - it('should shift submission attachments to s3 @smoke-test', async function() { + it('should shift submission attachment to s3 @smoke-test', async function() { + this.timeout(TIMEOUT); + + // given + // randomise attDir to ensure re-runs do not use the same generated files + await setup(0, { bigFiles: 1, bigFileSizeMb: 0.01, attDir: tmp.dirSync().name }); + await assertNewStatuses({ pending: 1 }); + + // when + await cli('upload-pending'); + + // then + await assertNewStatuses({ uploaded: 1 }); + // and + await assertAllRedirect(actualAttachments); + await assertAllDownloadsMatchOriginal(actualAttachments); + }); + + it('should shift submission attachments to s3', async function() { this.timeout(TIMEOUT); // given @@ -403,9 +422,10 @@ function cli(cmd) { cmd = `exec node lib/bin/s3 ${cmd}`; // eslint-disable-line no-param-reassign log.debug('cli()', 'calling:', cmd); + const env = _.omit(process.env, 'NODE_CONFIG_DIR'); const promise = new Promise((resolve, reject) => { - const child = exec(cmd, { cwd:'../../..' }, (err, stdout, stderr) => { + const child = exec(cmd, { env, cwd:'../../..' }, (err, stdout, stderr) => { if (err) { err.stdout = stdout; // eslint-disable-line no-param-reassign err.stderr = stderr; // eslint-disable-line no-param-reassign From 453ebbe3c8250c7d3ea4f93bd140ff1489844246 Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Mon, 13 Jan 2025 11:01:42 +0000 Subject: [PATCH 09/17] remove extra cleanup stage --- test/e2e/s3/run-tests.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/e2e/s3/run-tests.sh b/test/e2e/s3/run-tests.sh index d075653a1..271455535 100755 --- a/test/e2e/s3/run-tests.sh +++ b/test/e2e/s3/run-tests.sh @@ -86,11 +86,6 @@ run_suite() { # TODO may not be necessary NODE_CONFIG_ENV="$configEnv" node lib/bin/s3.js upload-pending - # TODO may not be necessary - kill "$serverPid" - wait "$serverPid" || true # already finished? or the command isn't working? - sleep 10 # TODO work out a better way of doing this! - log "Suite '$suite' with config '$configEnv' completed OK." } From 4b482138d8fba72f61f152f7f9fa8584edc3ebbc Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Mon, 13 Jan 2025 11:02:44 +0000 Subject: [PATCH 10/17] remove more unnecessary cleanup --- test/e2e/s3/run-tests.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/e2e/s3/run-tests.sh b/test/e2e/s3/run-tests.sh index 271455535..7ad768317 100755 --- a/test/e2e/s3/run-tests.sh +++ b/test/e2e/s3/run-tests.sh @@ -83,9 +83,6 @@ run_suite() { exit 1 fi - # TODO may not be necessary - NODE_CONFIG_ENV="$configEnv" node lib/bin/s3.js upload-pending - log "Suite '$suite' with config '$configEnv' completed OK." } From fa466aad77d4632a9de364c522d99655ad8eee02 Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Mon, 13 Jan 2025 13:28:24 +0000 Subject: [PATCH 11/17] neater error --- test/e2e/s3/run-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/s3/run-tests.sh b/test/e2e/s3/run-tests.sh index 7ad768317..b2c936485 100755 --- a/test/e2e/s3/run-tests.sh +++ b/test/e2e/s3/run-tests.sh @@ -55,7 +55,7 @@ run_suite() { case "$suite" in smoke) testOptions=(--fgrep @smoke-test) ;; all) testOptions=() ;; - *) log "Unrecongised test suite: $suite"; exit 1 ;; + *) log "!!! Error: unrecongised test suite: $suite"; exit 1 ;; esac NODE_CONFIG_ENV="$configEnv" node lib/bin/s3-create-bucket.js From be81716b630cc6dba56241fe3c69ad8a0205a014 Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Mon, 13 Jan 2025 13:28:30 +0000 Subject: [PATCH 12/17] try to break the region --- test/e2e/s3/run-tests.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/e2e/s3/run-tests.sh b/test/e2e/s3/run-tests.sh index b2c936485..cfd5bc5dd 100755 --- a/test/e2e/s3/run-tests.sh +++ b/test/e2e/s3/run-tests.sh @@ -86,8 +86,14 @@ run_suite() { log "Suite '$suite' with config '$configEnv' completed OK." } -run_suite smoke s3-dev-with-region -run_suite smoke s3-dev-blank-region -run_suite all s3-dev +# TODO consider if this will be simpler with explicit config declaration here, e.g. NODE_CONFIG="{...}" +# TODO consider if this will be simpler with explicit mocha options declared here, e.g. (--fgrep @smoke-test) +NODE_CONFIG='{ "default":{ "server":{ "port":8384 } "external":{ "s3blobStore":{ "region":"" } } } }' \ +run_suite smoke + +NODE_CONFIG='{ "default":{ "server":{ "port":8385 } "external":{ "s3blobStore":{ "region":"ijijij3ofij4ofjoi4jf534ijfo534ijf34oijfo43ijf4o3ijfo43ijfo34ijfoi34jfo43ijfo43ijo34ifjo34ifj what" } } } }' \ +run_suite smoke + +run_suite all log "Tests completed OK." From c9a8200f4a16c0dfbb8e3c43322604038c843be4 Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Mon, 13 Jan 2025 13:37:05 +0000 Subject: [PATCH 13/17] fx --- test/e2e/s3/run-tests.sh | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/test/e2e/s3/run-tests.sh b/test/e2e/s3/run-tests.sh index cfd5bc5dd..0926ef6f9 100755 --- a/test/e2e/s3/run-tests.sh +++ b/test/e2e/s3/run-tests.sh @@ -48,9 +48,8 @@ fi run_suite() { suite="$1" - configEnv="$2" - log "Running suite '$suite' with config '$configEnv'..." + log "Running suite '$suite' ..." case "$suite" in smoke) testOptions=(--fgrep @smoke-test) ;; @@ -58,24 +57,23 @@ run_suite() { *) log "!!! Error: unrecongised test suite: $suite"; exit 1 ;; esac - NODE_CONFIG_ENV="$configEnv" node lib/bin/s3-create-bucket.js + NODE_CONFIG_ENV="s3-dev" node lib/bin/s3-create-bucket.js - serverPort="$(NODE_CONFIG_ENV="$configEnv" node -e 'console.log(require("config").default.server.port)')" + serverPort="$(NODE_CONFIG_ENV="s3-dev" node -e 'console.log(require("config").default.server.port)')" serverUrl="http://localhost:$serverPort" - if curl -s -o /dev/null $serverUrl; then + if curl -s -o /dev/null "$serverUrl"; then log "!!! Error: server already running at: $serverUrl" exit 1 fi - NODE_CONFIG_ENV="$configEnv" make run & - serverPid=$! + NODE_CONFIG_ENV="s3-dev" make run & log 'Waiting for backend to start...' timeout 30 bash -c "while ! curl -s -o /dev/null $serverUrl; do sleep 1; done" log 'Backend started!' cd test/e2e/s3 - NODE_CONFIG_ENV="$configEnv" NODE_CONFIG_DIR=../../../config npx mocha "${testOptions[@]}" test.js + NODE_CONFIG_ENV="s3-dev" NODE_CONFIG_DIR=../../../config npx mocha "${testOptions[@]}" test.js cd - if ! curl -s -o /dev/null "$serverUrl"; then @@ -83,7 +81,7 @@ run_suite() { exit 1 fi - log "Suite '$suite' with config '$configEnv' completed OK." + log "Suite '$suite' completed OK." } # TODO consider if this will be simpler with explicit config declaration here, e.g. NODE_CONFIG="{...}" From d23c9a5777e2eb7165e936e1878073c01f808454 Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Mon, 13 Jan 2025 13:45:21 +0000 Subject: [PATCH 14/17] fix JSON --- test/e2e/s3/run-tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/s3/run-tests.sh b/test/e2e/s3/run-tests.sh index 0926ef6f9..639269ee8 100755 --- a/test/e2e/s3/run-tests.sh +++ b/test/e2e/s3/run-tests.sh @@ -86,10 +86,10 @@ run_suite() { # TODO consider if this will be simpler with explicit config declaration here, e.g. NODE_CONFIG="{...}" # TODO consider if this will be simpler with explicit mocha options declared here, e.g. (--fgrep @smoke-test) -NODE_CONFIG='{ "default":{ "server":{ "port":8384 } "external":{ "s3blobStore":{ "region":"" } } } }' \ +NODE_CONFIG='{ "default":{ "server":{ "port":8384 }, "external":{ "s3blobStore":{ "region":"" } } } }' \ run_suite smoke -NODE_CONFIG='{ "default":{ "server":{ "port":8385 } "external":{ "s3blobStore":{ "region":"ijijij3ofij4ofjoi4jf534ijfo534ijf34oijfo43ijf4o3ijfo43ijfo34ijfoi34jfo43ijfo43ijo34ifjo34ifj what" } } } }' \ +NODE_CONFIG='{ "default":{ "server":{ "port":8385 }, "external":{ "s3blobStore":{ "region":"ijijij3ofij4ofjoi4jf534ijfo534ijf34oijfo43ijf4o3ijfo43ijfo34ijfoi34jfo43ijfo43ijo34ifjo34ifj what" } } } }' \ run_suite smoke run_suite all From 962755d3114e81f0d41979c5d5efbcac7c451dde Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Mon, 13 Jan 2025 13:59:35 +0000 Subject: [PATCH 15/17] resolve TODOs; improve logging --- test/e2e/s3/run-tests.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/e2e/s3/run-tests.sh b/test/e2e/s3/run-tests.sh index 639269ee8..4a1568d79 100755 --- a/test/e2e/s3/run-tests.sh +++ b/test/e2e/s3/run-tests.sh @@ -84,14 +84,12 @@ run_suite() { log "Suite '$suite' completed OK." } -# TODO consider if this will be simpler with explicit config declaration here, e.g. NODE_CONFIG="{...}" -# TODO consider if this will be simpler with explicit mocha options declared here, e.g. (--fgrep @smoke-test) NODE_CONFIG='{ "default":{ "server":{ "port":8384 }, "external":{ "s3blobStore":{ "region":"" } } } }' \ run_suite smoke -NODE_CONFIG='{ "default":{ "server":{ "port":8385 }, "external":{ "s3blobStore":{ "region":"ijijij3ofij4ofjoi4jf534ijfo534ijf34oijfo43ijf4o3ijfo43ijfo34ijfoi34jfo43ijfo43ijo34ifjo34ifj what" } } } }' \ +NODE_CONFIG='{ "default":{ "server":{ "port":8385 }, "external":{ "s3blobStore":{ "region":"eu-nornoreast-3000" } } } }' \ run_suite smoke run_suite all -log "Tests completed OK." +log "All tests completed OK." From fa4c533222615744bc2c6dcdbaa8d1197fb7b5ed Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Mon, 13 Jan 2025 13:59:57 +0000 Subject: [PATCH 16/17] remove new configs --- config/s3-dev-blank-region.json | 17 ----------------- config/s3-dev-with-region.json | 17 ----------------- 2 files changed, 34 deletions(-) delete mode 100644 config/s3-dev-blank-region.json delete mode 100644 config/s3-dev-with-region.json diff --git a/config/s3-dev-blank-region.json b/config/s3-dev-blank-region.json deleted file mode 100644 index f1c977624..000000000 --- a/config/s3-dev-blank-region.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "default": { - "server": { - "port": 8384 - }, - "external": { - "s3blobStore": { - "region": "", - "server": "http://localhost:9000", - "accessKey": "odk-central-dev", - "secretKey": "topSecret123", - "bucketName": "odk-central-bucket", - "requestTimeout": 60000 - } - } - } -} diff --git a/config/s3-dev-with-region.json b/config/s3-dev-with-region.json deleted file mode 100644 index 4a92f3dce..000000000 --- a/config/s3-dev-with-region.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "default": { - "server": { - "port": 8385 - }, - "external": { - "s3blobStore": { - "region": "eu-west-1", - "server": "http://localhost:9000", - "accessKey": "odk-central-dev", - "secretKey": "topSecret123", - "bucketName": "odk-central-bucket", - "requestTimeout": 60000 - } - } - } -} From ee5a3955b4264e935a0563b2a20df5dec9b66088 Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Mon, 13 Jan 2025 14:00:29 +0000 Subject: [PATCH 17/17] use a more normal region --- test/e2e/s3/run-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/s3/run-tests.sh b/test/e2e/s3/run-tests.sh index 4a1568d79..ea7795703 100755 --- a/test/e2e/s3/run-tests.sh +++ b/test/e2e/s3/run-tests.sh @@ -87,7 +87,7 @@ run_suite() { NODE_CONFIG='{ "default":{ "server":{ "port":8384 }, "external":{ "s3blobStore":{ "region":"" } } } }' \ run_suite smoke -NODE_CONFIG='{ "default":{ "server":{ "port":8385 }, "external":{ "s3blobStore":{ "region":"eu-nornoreast-3000" } } } }' \ +NODE_CONFIG='{ "default":{ "server":{ "port":8385 }, "external":{ "s3blobStore":{ "region":"eu-east-1" } } } }' \ run_suite smoke run_suite all