Exit test process if vault fails to initialize (#11998)

This commit is contained in:
Chelsea Shaw 2021-07-09 14:30:44 -05:00 committed by GitHub
parent a3ac49aa05
commit 326590f42e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -23,7 +23,7 @@ function run(command, args = [], shareStd = true) {
} }
var output = ''; var output = '';
var unseal, root, written; var unseal, root, written, initError;
async function processLines(input, eachLine = () => {}) { async function processLines(input, eachLine = () => {}) {
const rl = readline.createInterface({ const rl = readline.createInterface({
@ -49,7 +49,6 @@ async function processLines(input, eachLine = () => {}) {
], ],
false false
); );
processLines(vault.stdout, function(line) { processLines(vault.stdout, function(line) {
if (written) { if (written) {
output = null; output = null;
@ -64,6 +63,10 @@ async function processLines(input, eachLine = () => {}) {
if (rootMatch && !root) { if (rootMatch && !root) {
root = rootMatch[1]; root = rootMatch[1];
} }
var errorMatch = output.match(/Error initializing core: (.*)$/m);
if (errorMatch) {
initError = errorMatch[1];
}
if (root && unseal && !written) { if (root && unseal && !written) {
fs.writeFile( fs.writeFile(
path.join(process.cwd(), 'tests/helpers/vault-keys.js'), path.join(process.cwd(), 'tests/helpers/vault-keys.js'),
@ -74,6 +77,11 @@ async function processLines(input, eachLine = () => {}) {
); );
written = true; written = true;
console.log('VAULT SERVER READY'); 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 { try {