Skip to content

Commit

Permalink
Merge branch 'code-coverage-on-ci' of github.com:dmlemeshko/kibana in…
Browse files Browse the repository at this point in the history
…to code-coverage-on-ci
  • Loading branch information
dmlemeshko committed Oct 23, 2019
2 parents 5b18300 + e02d68c commit b97516b
Show file tree
Hide file tree
Showing 42 changed files with 538 additions and 732 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@
"@elastic/eslint-config-kibana": "0.15.0",
"@elastic/eslint-plugin-eui": "0.0.2",
"@elastic/github-checks-reporter": "0.0.20b3",
"@elastic/makelogs": "^4.5.0",
"@elastic/makelogs": "^5.0.0",
"@kbn/dev-utils": "1.0.0",
"@kbn/es": "1.0.0",
"@kbn/eslint-import-resolver-kibana": "2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions test/functional/apps/discover/_discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.discover.brushHistogram();

const newDurationHours = await PageObjects.timePicker.getTimeDurationInHours();
expect(Math.round(newDurationHours)).to.be(108);
expect(Math.round(newDurationHours)).to.be(25);
const rowData = await PageObjects.discover.getDocTableField(1);
expect(rowData).to.have.string('Sep 22, 2015 @ 23:50:13.253');
expect(Date.parse(rowData)).to.be.within(Date.parse('Sep 20, 2015 @ 22:00:00.000'), Date.parse('Sep 20, 2015 @ 23:30:00.000'));
});

it('should show correct initial chart interval of Auto', async function () {
Expand Down
4 changes: 0 additions & 4 deletions x-pack/legacy/plugins/TEST_PLAN.md

This file was deleted.

7 changes: 7 additions & 0 deletions x-pack/legacy/plugins/apm/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ yarn prettier "./x-pack/legacy/plugins/apm/**/*.{tsx,ts,js}" --write
yarn eslint ./x-pack/legacy/plugins/apm --fix
```

### Useful Github Pull Request commands

The following commands can be executed by writing them as comments on a pull request:

- `@elasticmachine merge upstream`: Will merge the upstream (eg. master or 7.x) into the branch. This is useful if a bug has been fixed upstream and the fix is necessary to pass CI checks
- `retest` Re-run the tests. This is useful if a flaky test caused the build to fail

### Visual Studio Code

When using [Visual Studio Code](https://code.visualstudio.com/) with APM it's best to set up a [multi-root workspace](https://code.visualstudio.com/docs/editor/multi-root-workspaces) and add the `x-pack/legacy/plugins/apm` directory, the `x-pack` directory, and the root of the Kibana repository to the workspace. This makes it so you can navigate and search within APM and use the wider workspace roots when you need to widen your search.
Expand Down
6 changes: 3 additions & 3 deletions x-pack/legacy/plugins/canvas/common/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ export const DATATABLE_COLUMN_TYPES = ['string', 'number', 'null', 'boolean', 'd
export const LAUNCHED_FULLSCREEN = 'workpad-full-screen-launch';
export const LAUNCHED_FULLSCREEN_AUTOPLAY = 'workpad-full-screen-launch-with-autoplay';
export const API_ROUTE_SHAREABLE_BASE = '/public/canvas';
export const API_ROUTE_SHAREABLE_ZIP = `${API_ROUTE_SHAREABLE_BASE}/zip`;
export const API_ROUTE_SHAREABLE_RUNTIME = `${API_ROUTE_SHAREABLE_BASE}/runtime`;
export const API_ROUTE_SHAREABLE_RUNTIME_DOWNLOAD = `${API_ROUTE_SHAREABLE_BASE}/${SHAREABLE_RUNTIME_NAME}.js`;
export const API_ROUTE_SHAREABLE_ZIP = '/public/canvas/zip';
export const API_ROUTE_SHAREABLE_RUNTIME = '/public/canvas/runtime';
export const API_ROUTE_SHAREABLE_RUNTIME_DOWNLOAD = `/public/canvas/${SHAREABLE_RUNTIME_NAME}.js`;
10 changes: 5 additions & 5 deletions x-pack/legacy/plugins/canvas/scripts/shareable_runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ const execa = require('execa');
const asyncPipeline = promisify(pipeline);

const {
SHAREABLE_RUNTIME_SRC: RUNTIME_SRC,
SHAREABLE_RUNTIME_SRC,
KIBANA_ROOT,
STATS_OUTPUT,
SHAREABLE_RUNTIME_FILE: RUNTIME_FILE,
SHAREABLE_RUNTIME_FILE,
} = require('../shareable_runtime/constants');

run(
Expand All @@ -36,11 +36,11 @@ run(
...options,
});

const webpackConfig = path.resolve(RUNTIME_SRC, 'webpack.config.js');
const webpackConfig = path.resolve(SHAREABLE_RUNTIME_SRC, 'webpack.config.js');

const clean = () => {
log.info('Deleting previous build.');
del.sync([RUNTIME_FILE], { force: true });
del.sync([SHAREABLE_RUNTIME_FILE], { force: true });
};

if (flags.clean) {
Expand All @@ -66,7 +66,7 @@ run(
'--display-entrypoints',
'false',
'--content-base',
RUNTIME_SRC,
SHAREABLE_RUNTIME_SRC,
],
options
);
Expand Down
15 changes: 14 additions & 1 deletion x-pack/legacy/plugins/canvas/server/routes/shareables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
SHAREABLE_RUNTIME_FILE,
SHAREABLE_RUNTIME_NAME,
SHAREABLE_RUNTIME_SRC,
SHAREABLE_RUNTIME_OUTPUT,
} from '../../shareable_runtime/constants';

import { CoreSetup } from '../shim';
Expand All @@ -25,15 +26,27 @@ export function shareableWorkpads(route: CoreSetup['http']['route']) {
route({
method: 'GET',
path: API_ROUTE_SHAREABLE_RUNTIME,
options: {
files: {
relativeTo: SHAREABLE_RUNTIME_OUTPUT,
},
},
handler: {
file: SHAREABLE_RUNTIME_FILE,
file: {
path: SHAREABLE_RUNTIME_FILE,
},
},
});

// download runtime
route({
method: 'GET',
path: API_ROUTE_SHAREABLE_RUNTIME_DOWNLOAD,
options: {
files: {
relativeTo: SHAREABLE_RUNTIME_OUTPUT,
},
},
handler(_request, handler) {
// @ts-ignore No type for inert Hapi handler
const file = handler.file(SHAREABLE_RUNTIME_FILE);
Expand Down
27 changes: 14 additions & 13 deletions x-pack/legacy/plugins/canvas/shareable_runtime/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,24 @@ const path = require('path');

const LIBRARY_NAME = 'KbnCanvas';
const SHAREABLE_RUNTIME_NAME = 'kbn_canvas';
const SHAREABLE_RUNTIME_CSS_NAME = 'kbn_canvas_css';
const KIBANA_ROOT = path.resolve(__dirname, '../../../../..');
const SHAREABLE_RUNTIME_SRC = path.resolve(
KIBANA_ROOT,
'x-pack/legacy/plugins/canvas/shareable_runtime'
);
const SHAREABLE_RUNTIME_OUTPUT = path.resolve(SHAREABLE_RUNTIME_SRC, 'build');
const SHAREABLE_RUNTIME_FILE = path.resolve(
SHAREABLE_RUNTIME_OUTPUT,
SHAREABLE_RUNTIME_NAME + '.js'
);
const STATS_OUTPUT = path.resolve(SHAREABLE_RUNTIME_OUTPUT, 'webpack_stats.json');

const KIBANA_ROOT_PATH = '../../../../..';
const CANVAS_ROOT_PATH = 'x-pack/legacy/plugins/canvas';
const SHAREABLE_RUNTIME_PATH = 'shareable_runtime';
const SHAREABLE_RUNTIME_OUTPUT_PATH = 'shareable_runtime/build';
const SHAREABLE_RUNTIME_FILE_PATH = 'shareable_runtime/build/kbn_canvas.js';
const STATS_OUTPUT_PATH = 'shareable_runtime/build/webpack_stats.json';

const KIBANA_ROOT = path.resolve(__dirname, KIBANA_ROOT_PATH);
const CANVAS_ROOT = path.resolve(KIBANA_ROOT, CANVAS_ROOT_PATH);
const SHAREABLE_RUNTIME_SRC = path.resolve(CANVAS_ROOT, SHAREABLE_RUNTIME_PATH);
const SHAREABLE_RUNTIME_OUTPUT = path.resolve(CANVAS_ROOT, SHAREABLE_RUNTIME_OUTPUT_PATH);
const SHAREABLE_RUNTIME_FILE = path.resolve(CANVAS_ROOT, SHAREABLE_RUNTIME_FILE_PATH);
const STATS_OUTPUT = path.resolve(CANVAS_ROOT, STATS_OUTPUT_PATH);

module.exports = {
KIBANA_ROOT,
LIBRARY_NAME,
SHAREABLE_RUNTIME_CSS_NAME,
SHAREABLE_RUNTIME_FILE,
SHAREABLE_RUNTIME_NAME,
SHAREABLE_RUNTIME_OUTPUT,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/ml/common/util/job_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ export function validateModelMemoryLimitUnits(job) {

if (typeof job.analysis_limits !== 'undefined' && typeof job.analysis_limits.model_memory_limit !== 'undefined') {
const mml = job.analysis_limits.model_memory_limit.toUpperCase();
const mmlSplit = mml.match(/\d+(\w+)/);
const mmlSplit = mml.match(/\d+(\w+)$/);
const unit = (mmlSplit && mmlSplit.length === 2) ? mmlSplit[1] : null;

if (ALLOWED_DATA_UNITS.indexOf(unit) === -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export function cloneJob(jobId) {
mlJobService.tempJobCloningObjects.end = end;
}
} else {
// otherwise use the currentJob
// otherwise use the tempJobCloningObjects
mlJobService.tempJobCloningObjects.job = job;
}
window.location.href = '#/jobs/new_job';
Expand Down Expand Up @@ -284,13 +284,13 @@ export function filterJobs(jobs, clauses) {
return filteredJobs;
}

// check to see if a job has been stored in mlJobService.currentJob
// check to see if a job has been stored in mlJobService.tempJobCloningObjects
// if it has, return an object with the minimum properties needed for the
// start datafeed modal.
export function checkForAutoStartDatafeed() {
const job = mlJobService.currentJob;
const job = mlJobService.tempJobCloningObjects.job;
if (job !== undefined) {
mlJobService.currentJob = undefined;
mlJobService.tempJobCloningObjects.job = undefined;
const hasDatafeed = (typeof job.datafeed_config === 'object' && Object.keys(job.datafeed_config).length > 0);
const datafeedId = hasDatafeed ? job.datafeed_config.datafeed_id : '';
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { IndexPattern } from 'ui/index_patterns';

import { JobCreator } from './job_creator';
import { Field, Aggregation, SplitField } from '../../../../../common/types/fields';
import { Job, Datafeed, Detector } from './configs';
import { Job, Datafeed, Detector, CustomRule } from './configs';
import { createBasicDetector } from './util/default_configs';
import { JOB_TYPE } from './util/constants';
import { getRichDetectors } from './util/general';
Expand All @@ -24,14 +24,14 @@ export interface RichDetector {
partitionField: SplitField;
excludeFrequent: string | null;
description: string | null;
customRules: CustomRule[] | null;
}

export class AdvancedJobCreator extends JobCreator {
protected _type: JOB_TYPE = JOB_TYPE.ADVANCED;
private _richDetectors: RichDetector[] = [];
private _queryString: string;

// TODO - remove constructor if it isn't needed
constructor(indexPattern: IndexPattern, savedSearch: SavedSearch, query: object) {
super(indexPattern, savedSearch, query);

Expand All @@ -47,14 +47,18 @@ export class AdvancedJobCreator extends JobCreator {
excludeFrequent: string | null,
description: string | null
) {
// addDetector doesn't support adding new custom rules.
// this will be added in the future once it's supported in the UI
const customRules = null;
const { detector, richDetector } = this._createDetector(
agg,
field,
byField,
overField,
partitionField,
excludeFrequent,
description
description,
customRules
);

this._addDetector(detector, agg, field);
Expand All @@ -71,14 +75,18 @@ export class AdvancedJobCreator extends JobCreator {
description: string | null,
index: number
) {
const customRules =
this._detectors[index] !== undefined ? this._detectors[index].custom_rules || null : null;

const { detector, richDetector } = this._createDetector(
agg,
field,
byField,
overField,
partitionField,
excludeFrequent,
description
description,
customRules
);

this._editDetector(detector, agg, field, index);
Expand All @@ -95,7 +103,8 @@ export class AdvancedJobCreator extends JobCreator {
overField: SplitField,
partitionField: SplitField,
excludeFrequent: string | null,
description: string | null
description: string | null,
customRules: CustomRule[] | null
): { detector: Detector; richDetector: RichDetector } {
const detector: Detector = createBasicDetector(agg, field);

Expand All @@ -114,6 +123,9 @@ export class AdvancedJobCreator extends JobCreator {
if (description !== null) {
detector.detector_description = description;
}
if (customRules !== null) {
detector.custom_rules = customRules;
}

const richDetector: RichDetector = {
agg,
Expand All @@ -123,6 +135,7 @@ export class AdvancedJobCreator extends JobCreator {
partitionField,
excludeFrequent,
description,
customRules,
};

return { detector, richDetector };
Expand Down Expand Up @@ -168,6 +181,9 @@ export class AdvancedJobCreator extends JobCreator {
this._overrideConfigs(job, datafeed);
const detectors = getRichDetectors(job, datafeed, true);

// keep track of the custom rules for each detector
const customRules = this._detectors.map(d => d.custom_rules);

this.removeAllDetectors();
this._richDetectors.length = 0;

Expand All @@ -185,5 +201,12 @@ export class AdvancedJobCreator extends JobCreator {
);
}
});

// re-apply custom rules
customRules.forEach((cr, i) => {
if (cr !== undefined) {
this._detectors[i].custom_rules = cr;
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,33 +146,29 @@ export function isSparseDataJob(job: Job, datafeed: Datafeed): boolean {
function stashCombinedJob(
jobCreator: JobCreatorType,
skipTimeRangeStep: boolean = false,
advanced: boolean = false,
includeTimeRange: boolean = false
) {
const combinedJob = {
...jobCreator.jobConfig,
datafeed_config: jobCreator.datafeedConfig,
};
if (advanced === true) {
mlJobService.currentJob = combinedJob;
} else {
mlJobService.tempJobCloningObjects.job = combinedJob;

// skip over the time picker step of the wizard
mlJobService.tempJobCloningObjects.skipTimeRangeStep = skipTimeRangeStep;
mlJobService.tempJobCloningObjects.job = combinedJob;

if (includeTimeRange === true) {
// auto select the start and end dates of the time picker
mlJobService.tempJobCloningObjects.start = jobCreator.start;
mlJobService.tempJobCloningObjects.end = jobCreator.end;
}
// skip over the time picker step of the wizard
mlJobService.tempJobCloningObjects.skipTimeRangeStep = skipTimeRangeStep;

if (includeTimeRange === true) {
// auto select the start and end dates of the time picker
mlJobService.tempJobCloningObjects.start = jobCreator.start;
mlJobService.tempJobCloningObjects.end = jobCreator.end;
}
}

export function convertToMultiMetricJob(jobCreator: JobCreatorType) {
jobCreator.createdBy = CREATED_BY_LABEL.MULTI_METRIC;
jobCreator.modelPlot = false;
stashCombinedJob(jobCreator, true, false, true);
stashCombinedJob(jobCreator, true, true);

window.location.href = window.location.href.replace(
JOB_TYPE.SINGLE_METRIC,
Expand All @@ -182,7 +178,7 @@ export function convertToMultiMetricJob(jobCreator: JobCreatorType) {

export function convertToAdvancedJob(jobCreator: JobCreatorType) {
jobCreator.createdBy = null;
stashCombinedJob(jobCreator, true, false, false);
stashCombinedJob(jobCreator, true, true);

let jobType = JOB_TYPE.SINGLE_METRIC;
if (isMultiMetricJobCreator(jobCreator)) {
Expand All @@ -196,13 +192,13 @@ export function convertToAdvancedJob(jobCreator: JobCreatorType) {

export function resetJob(jobCreator: JobCreatorType) {
jobCreator.jobId = '';
stashCombinedJob(jobCreator, true, false, true);
stashCombinedJob(jobCreator, true, true);

window.location.href = '#/jobs/new_job';
}

export function advancedStartDatafeed(jobCreator: JobCreatorType) {
stashCombinedJob(jobCreator, false, true, false);
stashCombinedJob(jobCreator, false, false);
window.location.href = '#/jobs';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export const AdvancedDetectorModal: FC<Props> = ({
partitionField,
excludeFrequent: excludeFrequentOption.label !== '' ? excludeFrequentOption.label : null,
description: descriptionOption !== '' ? descriptionOption : null,
customRules: null,
};
setDetector(dtr);
setDescriptionPlaceholder(dtr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const emptyRichDetector: RichDetector = {
partitionField: null,
excludeFrequent: null,
description: null,
customRules: null,
};

export const AdvancedDetectors: FC<Props> = ({ setIsValid }) => {
Expand Down
Loading

0 comments on commit b97516b

Please sign in to comment.