Skip to content

Commit

Permalink
Exit test process if vault fails to initialize (hashicorp#11998)
Browse files Browse the repository at this point in the history
  • Loading branch information
hashishaw authored and jartek committed Sep 11, 2021
1 parent 6c89955 commit 0f12fc0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ui/scripts/start-vault.js
Expand Up @@ -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({
Expand All @@ -49,7 +49,6 @@ async function processLines(input, eachLine = () => {}) {
],
false
);

processLines(vault.stdout, function(line) {
if (written) {
output = null;
Expand All @@ -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'),
Expand All @@ -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 {
Expand Down

0 comments on commit 0f12fc0

Please sign in to comment.