From 326590f42e899cc3f502893ac073215473957796 Mon Sep 17 00:00:00 2001 From: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com> Date: Fri, 9 Jul 2021 14:30:44 -0500 Subject: [PATCH] Exit test process if vault fails to initialize (#11998) --- ui/scripts/start-vault.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ui/scripts/start-vault.js b/ui/scripts/start-vault.js index 4ab40b939..2ba9a9453 100755 --- a/ui/scripts/start-vault.js +++ b/ui/scripts/start-vault.js @@ -23,7 +23,7 @@ function run(command, args = [], shareStd = true) { } var output = ''; -var unseal, root, written; +var unseal, root, written, initError; async function processLines(input, eachLine = () => {}) { const rl = readline.createInterface({ @@ -49,7 +49,6 @@ async function processLines(input, eachLine = () => {}) { ], false ); - processLines(vault.stdout, function(line) { if (written) { output = null; @@ -64,6 +63,10 @@ async function processLines(input, eachLine = () => {}) { if (rootMatch && !root) { root = rootMatch[1]; } + var errorMatch = output.match(/Error initializing core: (.*)$/m); + if (errorMatch) { + initError = errorMatch[1]; + } if (root && unseal && !written) { fs.writeFile( path.join(process.cwd(), 'tests/helpers/vault-keys.js'), @@ -74,6 +77,11 @@ async function processLines(input, eachLine = () => {}) { ); written = true; console.log('VAULT SERVER READY'); + } else if (initError) { + // If this is happening, run `export VAULT_LICENSE_PATH=/Users/username/license.hclic` + // to your valid local vault license filepath, or use OSS Vault + console.log('VAULT SERVER START FAILED'); + process.exit(1); } }); try {