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 @@ -349,7 +349,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
116 changes: 58 additions & 58 deletions src/cli/serve/integration_tests/reload_logging_config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,20 @@ import mkdirp from 'mkdirp';
import rimraf from 'rimraf';

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');
const kibanaPath = follow('../../../../scripts/kibana.js');

const second = 1000;
const minute = second * 60;

const tempDir = path.join(os.tmpdir(), 'kbn-reload-test');


function follow(file) {
return path.relative(process.cwd(), path.resolve(__dirname, file));
}

const second = 1000;
const minute = second * 60;
const tempDir = path.join(os.tmpdir(), 'kbn-reload-test');

function setLoggingJson(enabled) {
const conf = getConfigFromFiles([testConfigFile]);
conf.logging = conf.logging || {};
Expand Down Expand Up @@ -80,66 +78,68 @@ 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;

if (data.tags.includes('listening')) {
switchToPlainTextLog();
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;
}
} 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);
}
}, minute);
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;
}
})
])
]);

expect(exitCode).toEqual(0);
expect(sawJson).toEqual(true);
expect(sawNonjson).toEqual(true);
}, 60000);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional nit: there should a minute, but I don't want you to wait another CI run, so I'm fine with backporting this as is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coolio, going to merge this!

}

it.skip('should recreate file handler on SIGHUP', function (done) {
Expand Down
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 @@ -7136,7 +7136,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 @@ -7909,19 +7909,6 @@ etag@~1.8.1:
resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887"
integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=

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 @@ -8899,7 +8886,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 @@ -13782,11 +13769,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 @@ -15794,13 +15776,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 @@ -19191,13 +19166,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 @@ -19329,13 +19297,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 @@ -20033,7 +19994,7 @@ through2@~0.4.1:
readable-stream "~1.0.17"
xtend "~2.1.1"

through@2, 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.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