mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Removes event-stream package (#26205)
* Removes event-stream package (and sub-deps) + implements a similar API to what we were using * Removing array_streams in favor of existing utils * Fixing lockfile * Allow report-errors to propogate through (don't catch) * [cli/reloacConfig/test] update test to use promises * avoid mixing async and Promise.then more than necessary
This commit is contained in:
parent
e09f6906ae
commit
837a054466
4 changed files with 65 additions and 102 deletions
|
@ -329,7 +329,6 @@
|
|||
"eslint-plugin-prefer-object-spread": "^1.2.1",
|
||||
"eslint-plugin-prettier": "^2.6.2",
|
||||
"eslint-plugin-react": "^7.11.1",
|
||||
"event-stream": "3.3.2",
|
||||
"expect.js": "0.3.1",
|
||||
"faker": "1.1.0",
|
||||
"fetch-mock": "^5.13.1",
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
import { spawn } from 'child_process';
|
||||
import { writeFileSync } from 'fs';
|
||||
import { relative, resolve } from 'path';
|
||||
|
||||
import { safeDump } from 'js-yaml';
|
||||
import es from 'event-stream';
|
||||
import { createMapStream, createSplitStream, createPromiseFromStreams } from '../../../utils/streams';
|
||||
import { getConfigFromFiles } from '../../../core/server/config/read_config';
|
||||
|
||||
const testConfigFile = follow('__fixtures__/reload_logging_config/kibana.test.yml');
|
||||
|
@ -66,65 +67,67 @@ describe('Server logging configuration', function () {
|
|||
// nothing to do for Windows
|
||||
});
|
||||
} else {
|
||||
it('should be reloadable via SIGHUP process signaling', function (done) {
|
||||
it('should be reloadable via SIGHUP process signaling', async function () {
|
||||
expect.assertions(3);
|
||||
|
||||
child = spawn('node', [kibanaPath, '--config', testConfigFile]);
|
||||
|
||||
child.on('error', err => {
|
||||
done(new Error(`error in child process while attempting to reload config. ${err.stack || err.message || err}`));
|
||||
child = spawn(process.execPath, [kibanaPath, '--config', testConfigFile], {
|
||||
stdio: 'pipe'
|
||||
});
|
||||
|
||||
let sawJson = false;
|
||||
let sawNonjson = false;
|
||||
|
||||
child.on('exit', _code => {
|
||||
const code = _code === null ? 0 : _code;
|
||||
const [exitCode] = await Promise.all([
|
||||
Promise.race([
|
||||
new Promise(r => child.once('exit', r))
|
||||
.then(code => code === null ? 0 : code),
|
||||
|
||||
expect(code).toEqual(0);
|
||||
expect(sawJson).toEqual(true);
|
||||
expect(sawNonjson).toEqual(true);
|
||||
done();
|
||||
});
|
||||
new Promise(r => child.once('error', r))
|
||||
.then(err => {
|
||||
throw new Error(`error in child process while attempting to reload config. ${err.stack || err.message || err}`);
|
||||
})
|
||||
]),
|
||||
|
||||
child.stdout
|
||||
.pipe(es.split())
|
||||
.pipe(es.mapSync(line => {
|
||||
if (!line) {
|
||||
// skip empty lines
|
||||
return;
|
||||
}
|
||||
|
||||
if (isJson) {
|
||||
const data = JSON.parse(line);
|
||||
sawJson = true;
|
||||
|
||||
if (data.tags.includes('listening')) {
|
||||
switchToPlainTextLog();
|
||||
createPromiseFromStreams([
|
||||
child.stdout,
|
||||
createSplitStream('\n'),
|
||||
createMapStream(async (line) => {
|
||||
if (!line) {
|
||||
// skip empty lines
|
||||
return;
|
||||
}
|
||||
} else if (line.startsWith('{')) {
|
||||
// We have told Kibana to stop logging json, but it hasn't completed
|
||||
// the switch yet, so we ignore before switching over.
|
||||
} else {
|
||||
// Kibana has successfully stopped logging json, so kill the server.
|
||||
|
||||
sawNonjson = true;
|
||||
if (isJson) {
|
||||
const data = JSON.parse(line);
|
||||
sawJson = true;
|
||||
|
||||
child.kill();
|
||||
child = undefined;
|
||||
}
|
||||
}));
|
||||
if (data.tags.includes('listening')) {
|
||||
isJson = false;
|
||||
setLoggingJson(false);
|
||||
|
||||
function switchToPlainTextLog() {
|
||||
isJson = false;
|
||||
setLoggingJson(false);
|
||||
// Reload logging config. We give it a little bit of time to just make
|
||||
// sure the process sighup handler is registered.
|
||||
await new Promise(r => setTimeout(r, 100));
|
||||
child.kill('SIGHUP');
|
||||
}
|
||||
} else if (line.startsWith('{')) {
|
||||
// We have told Kibana to stop logging json, but it hasn't completed
|
||||
// the switch yet, so we ignore before switching over.
|
||||
} else {
|
||||
// Kibana has successfully stopped logging json, so kill the server.
|
||||
|
||||
// Reload logging config. We give it a little bit of time to just make
|
||||
// sure the process sighup handler is registered.
|
||||
setTimeout(() => {
|
||||
child.kill('SIGHUP');
|
||||
}, 100);
|
||||
}
|
||||
sawNonjson = true;
|
||||
|
||||
child.kill();
|
||||
child = undefined;
|
||||
}
|
||||
})
|
||||
])
|
||||
]);
|
||||
|
||||
expect(exitCode).toEqual(0);
|
||||
expect(sawJson).toEqual(true);
|
||||
expect(sawNonjson).toEqual(true);
|
||||
}, 60000);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
import xml2js from 'xml2js';
|
||||
import vfs from 'vinyl-fs';
|
||||
import es from 'event-stream';
|
||||
import { createMapStream } from '../../utils/streams';
|
||||
import { getGithubClient, markdownMetadata, paginate } from '../github_utils';
|
||||
import { find } from 'lodash';
|
||||
import stripAnsi from 'strip-ansi';
|
||||
|
@ -32,16 +32,19 @@ const BUILD_URL = process.env.BUILD_URL;
|
|||
/**
|
||||
* Parses junit XML files into JSON
|
||||
*/
|
||||
const mapXml = es.map((file, cb) => {
|
||||
const mapXml = createMapStream((file) => new Promise((resolve, reject) => {
|
||||
xml2js.parseString(file.contents.toString(), (err, result) => {
|
||||
cb(null, result);
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
/**
|
||||
* Filters all testsuites to find failed testcases
|
||||
*/
|
||||
const filterFailures = es.map((testSuite, cb) => {
|
||||
const filterFailures = createMapStream((testSuite) => {
|
||||
// Grab the failures. Reporters may report multiple testsuites in a single file.
|
||||
const testFiles = testSuite.testsuites
|
||||
? testSuite.testsuites.testsuite
|
||||
|
@ -64,16 +67,16 @@ const filterFailures = es.map((testSuite, cb) => {
|
|||
|
||||
console.log(`Found ${failures.length} test failures`);
|
||||
|
||||
cb(null, failures);
|
||||
return failures;
|
||||
});
|
||||
|
||||
/**
|
||||
* Creates and updates github issues for the given testcase failures.
|
||||
*/
|
||||
const updateGithubIssues = (githubClient, issues) => {
|
||||
return es.map(async (failureCases, cb) => {
|
||||
return createMapStream(async (failureCases) => {
|
||||
|
||||
const issueOps = failureCases.map(async (failureCase) => {
|
||||
await Promise.all(failureCases.map(async (failureCase) => {
|
||||
const existingIssue = find(issues, (issue) => {
|
||||
return markdownMetadata.get(issue.body, 'test.class') === failureCase.classname &&
|
||||
markdownMetadata.get(issue.body, 'test.name') === failureCase.name;
|
||||
|
@ -121,12 +124,9 @@ const updateGithubIssues = (githubClient, issues) => {
|
|||
|
||||
console.log(`Created issue ${newIssue.data.html_url}`);
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
Promise
|
||||
.all(issueOps)
|
||||
.then(() => cb(null, failureCases))
|
||||
.catch(e => cb(e));
|
||||
return failureCases;
|
||||
});
|
||||
};
|
||||
|
||||
|
|
45
yarn.lock
45
yarn.lock
|
@ -7092,7 +7092,7 @@ duplexer3@^0.1.4:
|
|||
resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2"
|
||||
integrity sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=
|
||||
|
||||
duplexer@^0.1.1, duplexer@~0.1.1:
|
||||
duplexer@^0.1.1:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1"
|
||||
integrity sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=
|
||||
|
@ -7958,19 +7958,6 @@ event-emitter@~0.3.5:
|
|||
d "1"
|
||||
es5-ext "~0.10.14"
|
||||
|
||||
event-stream@3.3.2:
|
||||
version "3.3.2"
|
||||
resolved "http://registry.npmjs.org/event-stream/-/event-stream-3.3.2.tgz#3cc310feb1f28d2f62b2a085d736a9ef566378b8"
|
||||
integrity sha1-PMMQ/rHyjS9isqCF1zap71ZjeLg=
|
||||
dependencies:
|
||||
duplexer "~0.1.1"
|
||||
from "~0"
|
||||
map-stream "~0.1.0"
|
||||
pause-stream "0.0.11"
|
||||
split "0.3"
|
||||
stream-combiner "~0.0.4"
|
||||
through "~2.3.1"
|
||||
|
||||
eventemitter2@~0.4.13:
|
||||
version "0.4.14"
|
||||
resolved "https://registry.yarnpkg.com/eventemitter2/-/eventemitter2-0.4.14.tgz#8f61b75cde012b2e9eb284d4545583b5643b61ab"
|
||||
|
@ -8950,7 +8937,7 @@ from2@^2.1.0, from2@^2.1.1:
|
|||
inherits "^2.0.1"
|
||||
readable-stream "^2.0.0"
|
||||
|
||||
from@^0.1.3, from@~0:
|
||||
from@^0.1.3:
|
||||
version "0.1.7"
|
||||
resolved "https://registry.yarnpkg.com/from/-/from-0.1.7.tgz#83c60afc58b9c56997007ed1a768b3ab303a44fe"
|
||||
integrity sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=
|
||||
|
@ -13866,11 +13853,6 @@ map-obj@^2.0.0:
|
|||
resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-2.0.0.tgz#a65cd29087a92598b8791257a523e021222ac1f9"
|
||||
integrity sha1-plzSkIepJZi4eRJXpSPgISIqwfk=
|
||||
|
||||
map-stream@~0.1.0:
|
||||
version "0.1.0"
|
||||
resolved "https://registry.yarnpkg.com/map-stream/-/map-stream-0.1.0.tgz#e56aa94c4c8055a16404a0674b78f215f7c8e194"
|
||||
integrity sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=
|
||||
|
||||
map-visit@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/map-visit/-/map-visit-1.0.0.tgz#ecdca8f13144e660f1b5bd41f12f3479d98dfb8f"
|
||||
|
@ -15908,13 +15890,6 @@ path-type@^2.0.0:
|
|||
dependencies:
|
||||
pify "^2.0.0"
|
||||
|
||||
pause-stream@0.0.11:
|
||||
version "0.0.11"
|
||||
resolved "https://registry.yarnpkg.com/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445"
|
||||
integrity sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=
|
||||
dependencies:
|
||||
through "~2.3"
|
||||
|
||||
pbkdf2@^3.0.3:
|
||||
version "3.0.14"
|
||||
resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.0.14.tgz#a35e13c64799b06ce15320f459c230e68e73bade"
|
||||
|
@ -19603,13 +19578,6 @@ split-string@^3.0.1, split-string@^3.0.2:
|
|||
dependencies:
|
||||
extend-shallow "^3.0.0"
|
||||
|
||||
split@0.3:
|
||||
version "0.3.3"
|
||||
resolved "https://registry.yarnpkg.com/split/-/split-0.3.3.tgz#cd0eea5e63a211dfff7eb0f091c4133e2d0dd28f"
|
||||
integrity sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8=
|
||||
dependencies:
|
||||
through "2"
|
||||
|
||||
sprintf-js@^1.0.3:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.1.1.tgz#36be78320afe5801f6cea3ee78b6e5aab940ea0c"
|
||||
|
@ -19736,13 +19704,6 @@ stream-browserify@^2.0.1:
|
|||
inherits "~2.0.1"
|
||||
readable-stream "^2.0.2"
|
||||
|
||||
stream-combiner@~0.0.4:
|
||||
version "0.0.4"
|
||||
resolved "https://registry.yarnpkg.com/stream-combiner/-/stream-combiner-0.0.4.tgz#4d5e433c185261dde623ca3f44c586bcf5c4ad14"
|
||||
integrity sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ=
|
||||
dependencies:
|
||||
duplexer "~0.1.1"
|
||||
|
||||
stream-consume@~0.1.0:
|
||||
version "0.1.0"
|
||||
resolved "https://registry.yarnpkg.com/stream-consume/-/stream-consume-0.1.0.tgz#a41ead1a6d6081ceb79f65b061901b6d8f3d1d0f"
|
||||
|
@ -20444,7 +20405,7 @@ through2@~0.4.1:
|
|||
readable-stream "~1.0.17"
|
||||
xtend "~2.1.1"
|
||||
|
||||
through@2, "through@>=2.2.7 <3", through@^2.3.4, through@^2.3.6, through@^2.3.8, through@~2.3, through@~2.3.1, through@~2.3.4, through@~2.3.6:
|
||||
"through@>=2.2.7 <3", through@^2.3.4, through@^2.3.6, through@^2.3.8, through@~2.3.4, through@~2.3.6:
|
||||
version "2.3.8"
|
||||
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
|
||||
integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue