Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,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",
Expand Down
105 changes: 54 additions & 51 deletions src/cli/serve/integration_tests/reload_logging_config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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;

expect(code).toEqual(0);
expect(sawJson).toEqual(true);
expect(sawNonjson).toEqual(true);
done();
});

child.stdout
.pipe(es.split())
.pipe(es.mapSync(line => {
if (!line) {
// skip empty lines
return;
}

if (isJson) {
const data = JSON.parse(line);
sawJson = true;
const [exitCode] = await Promise.all([
Promise.race([
new Promise(r => child.once('exit', r))
.then(code => code === null ? 0 : code),

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}`);
})
]),

createPromiseFromStreams([
child.stdout,
createSplitStream('\n'),
createMapStream(async (line) => {
if (!line) {
// skip empty lines
return;
}

if (data.tags.includes('listening')) {
switchToPlainTextLog();
if (isJson) {
const data = JSON.parse(line);
sawJson = true;

if (data.tags.includes('listening')) {
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.

sawNonjson = true;

child.kill();
child = undefined;
}
} 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;

child.kill();
child = undefined;
}
}));

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.
setTimeout(() => {
child.kill('SIGHUP');
}, 100);
}
})
])
]);

expect(exitCode).toEqual(0);
expect(sawJson).toEqual(true);
expect(sawNonjson).toEqual(true);
}, 60000);
}
});
26 changes: 13 additions & 13 deletions src/dev/failed_tests/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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;
});
};

Expand Down
45 changes: 3 additions & 42 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7063,7 +7063,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=
Expand Down Expand Up @@ -7929,19 +7929,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"
Expand Down Expand Up @@ -8921,7 +8908,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=
Expand Down Expand Up @@ -13829,11 +13816,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"
Expand Down Expand Up @@ -15871,13 +15853,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"
Expand Down Expand Up @@ -19559,13 +19534,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"
Expand Down Expand Up @@ -19692,13 +19660,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"
Expand Down Expand Up @@ -20395,7 +20356,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=
Expand Down