-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[plugins] Ensures X-Pack is available during plugin install (#19426)
For the default distribution, we were not including X-Pack during plugin installation. This broke plugin installation which relied on X-Pack interfaces. Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
- Loading branch information
1 parent
194aba1
commit b57aed8
Showing
8 changed files
with
119 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import execa from 'execa'; | ||
import stripAnsi from 'strip-ansi'; | ||
import sinon from 'sinon'; | ||
|
||
import { watchStdioForLine } from '../watch_stdio_for_line'; | ||
|
||
describe('src/utils/watch_stdio_for_line', function () { | ||
const sandbox = sinon.sandbox.create(); | ||
afterEach(() => sandbox.reset()); | ||
|
||
const onLogLine = sandbox.stub(); | ||
const logFn = line => onLogLine(stripAnsi(line)); | ||
|
||
it('calls logFn with log lines', async () => { | ||
const proc = execa(process.execPath, ['-e', 'console.log("hi")']); | ||
|
||
await watchStdioForLine(proc, logFn); | ||
|
||
// log output of the process | ||
sinon.assert.calledWithExactly(onLogLine, sinon.match(/hi/)); | ||
}); | ||
|
||
it('send the proc SIGKILL if it logs a line matching exitAfter regexp', async function () { | ||
// fixture proc will exit after 10 seconds if sigint not received, but the test won't fail | ||
// unless we see the log line `SIGINT not received`, so we let the test take up to 30 seconds | ||
// for potentially huge delays here and there | ||
this.timeout(30000); | ||
|
||
const proc = execa(process.execPath, [require.resolve('./fixtures/log_on_sigint')]); | ||
|
||
await watchStdioForLine(proc, logFn, /listening for SIGINT/); | ||
|
||
sinon.assert.calledWithExactly(onLogLine, sinon.match(/listening for SIGINT/)); | ||
sinon.assert.neverCalledWith(onLogLine, sinon.match(/SIGINT not received/)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Transform } from 'stream'; | ||
|
||
import { | ||
createPromiseFromStreams, | ||
createSplitStream, | ||
createMapStream, | ||
} from './streams'; | ||
|
||
// creates a stream that skips empty lines unless they are followed by | ||
// another line, preventing the empty lines produced by splitStream | ||
function skipLastEmptyLineStream() { | ||
let skippedEmptyLine = false; | ||
return new Transform({ | ||
objectMode: true, | ||
transform(line, enc, cb) { | ||
if (skippedEmptyLine) { | ||
this.push(''); | ||
skippedEmptyLine = false; | ||
} | ||
|
||
if (line === '') { | ||
skippedEmptyLine = true; | ||
return cb(); | ||
} else { | ||
return cb(null, line); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
export async function watchStdioForLine(proc, logFn, exitAfter) { | ||
function onLogLine(line) { | ||
logFn(line); | ||
|
||
if (exitAfter && exitAfter.test(line)) { | ||
proc.kill('SIGINT'); | ||
} | ||
} | ||
|
||
await Promise.all([ | ||
proc.catch(error => { | ||
// ignore the error thrown by execa if it's because we killed with SIGINT | ||
if (error.signal !== 'SIGINT') { | ||
throw error; | ||
} | ||
}), | ||
createPromiseFromStreams([ | ||
proc.stdout, | ||
createSplitStream('\n'), | ||
skipLastEmptyLineStream(), | ||
createMapStream(onLogLine), | ||
]), | ||
createPromiseFromStreams([ | ||
proc.stderr, | ||
createSplitStream('\n'), | ||
skipLastEmptyLineStream(), | ||
createMapStream(onLogLine), | ||
]), | ||
]); | ||
} |