Skip to content

Commit

Permalink
chore(NA): move monitoring out of __tests__ folder (#87556)
Browse files Browse the repository at this point in the history
* chore(NA): move server and common from monitoring out of the __tests__ folder

* chore(NA): move monitoring public out of __tests__ folder

* chore(NA): add missing skip on test

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
mistic and kibanamachine authored Jan 7, 2021
1 parent 9a17446 commit 9d4ef37
Show file tree
Hide file tree
Showing 119 changed files with 1,064 additions and 1,136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import expect from '@kbn/expect';
import moment from 'moment';
import { formatTimestampToDuration } from '../format_timestamp_to_duration';
import { CALCULATE_DURATION_SINCE, CALCULATE_DURATION_UNTIL } from '../constants';
import { formatTimestampToDuration } from './format_timestamp_to_duration';
import { CALCULATE_DURATION_SINCE, CALCULATE_DURATION_UNTIL } from './constants';

const testTime = moment('2010-05-01'); // pick a date where adding/subtracting 2 months formats roundly to '2 months 0 days'
const getTestTime = () => moment(testTime); // clones the obj so it's not mutated with .adds and .subtracts
Expand All @@ -22,23 +21,23 @@ describe('formatTimestampToDuration', () => {
const fiftyNineSeconds = getTestTime().subtract(59, 'seconds');
expect(
formatTimestampToDuration(fiftyNineSeconds, CALCULATE_DURATION_SINCE, getTestTime())
).to.be('59 seconds');
).toBe('59 seconds');

const fiveMins = getTestTime().subtract(5, 'minutes').subtract(30, 'seconds');
expect(formatTimestampToDuration(fiveMins, CALCULATE_DURATION_SINCE, getTestTime())).to.be(
expect(formatTimestampToDuration(fiveMins, CALCULATE_DURATION_SINCE, getTestTime())).toBe(
'6 mins'
);

const sixHours = getTestTime().subtract(6, 'hours').subtract(30, 'minutes');
expect(formatTimestampToDuration(sixHours, CALCULATE_DURATION_SINCE, getTestTime())).to.be(
expect(formatTimestampToDuration(sixHours, CALCULATE_DURATION_SINCE, getTestTime())).toBe(
'6 hrs 30 mins'
);

const sevenDays = getTestTime()
.subtract(7, 'days')
.subtract(6, 'hours')
.subtract(18, 'minutes');
expect(formatTimestampToDuration(sevenDays, CALCULATE_DURATION_SINCE, getTestTime())).to.be(
expect(formatTimestampToDuration(sevenDays, CALCULATE_DURATION_SINCE, getTestTime())).toBe(
'7 days 6 hrs 18 mins'
);

Expand All @@ -47,22 +46,22 @@ describe('formatTimestampToDuration', () => {
.subtract(7, 'days')
.subtract(6, 'hours')
.subtract(18, 'minutes');
expect(formatTimestampToDuration(eightWeeks, CALCULATE_DURATION_SINCE, getTestTime())).to.be(
expect(formatTimestampToDuration(eightWeeks, CALCULATE_DURATION_SINCE, getTestTime())).toBe(
'2 months 2 days'
);

const oneHour = getTestTime().subtract(1, 'hour'); // should trim 0 min
expect(formatTimestampToDuration(oneHour, CALCULATE_DURATION_SINCE, getTestTime())).to.be(
expect(formatTimestampToDuration(oneHour, CALCULATE_DURATION_SINCE, getTestTime())).toBe(
'1 hr'
);

const oneDay = getTestTime().subtract(1, 'day'); // should trim 0 hrs
expect(formatTimestampToDuration(oneDay, CALCULATE_DURATION_SINCE, getTestTime())).to.be(
expect(formatTimestampToDuration(oneDay, CALCULATE_DURATION_SINCE, getTestTime())).toBe(
'1 day'
);

const twoMonths = getTestTime().subtract(2, 'month'); // should trim 0 days
expect(formatTimestampToDuration(twoMonths, CALCULATE_DURATION_SINCE, getTestTime())).to.be(
expect(formatTimestampToDuration(twoMonths, CALCULATE_DURATION_SINCE, getTestTime())).toBe(
'2 months'
);
});
Expand All @@ -74,20 +73,20 @@ describe('formatTimestampToDuration', () => {
const fiftyNineSeconds = getTestTime().add(59, 'seconds');
expect(
formatTimestampToDuration(fiftyNineSeconds, CALCULATE_DURATION_UNTIL, getTestTime())
).to.be('59 seconds');
).toBe('59 seconds');

const fiveMins = getTestTime().add(10, 'minutes');
expect(formatTimestampToDuration(fiveMins, CALCULATE_DURATION_UNTIL, getTestTime())).to.be(
expect(formatTimestampToDuration(fiveMins, CALCULATE_DURATION_UNTIL, getTestTime())).toBe(
'10 mins'
);

const sixHours = getTestTime().add(6, 'hours').add(30, 'minutes');
expect(formatTimestampToDuration(sixHours, CALCULATE_DURATION_UNTIL, getTestTime())).to.be(
expect(formatTimestampToDuration(sixHours, CALCULATE_DURATION_UNTIL, getTestTime())).toBe(
'6 hrs 30 mins'
);

const sevenDays = getTestTime().add(7, 'days').add(6, 'hours').add(18, 'minutes');
expect(formatTimestampToDuration(sevenDays, CALCULATE_DURATION_UNTIL, getTestTime())).to.be(
expect(formatTimestampToDuration(sevenDays, CALCULATE_DURATION_UNTIL, getTestTime())).toBe(
'7 days 6 hrs 18 mins'
);

Expand All @@ -96,22 +95,22 @@ describe('formatTimestampToDuration', () => {
.add(7, 'days')
.add(6, 'hours')
.add(18, 'minutes');
expect(formatTimestampToDuration(eightWeeks, CALCULATE_DURATION_UNTIL, getTestTime())).to.be(
expect(formatTimestampToDuration(eightWeeks, CALCULATE_DURATION_UNTIL, getTestTime())).toBe(
'2 months 2 days'
);

const oneHour = getTestTime().add(1, 'hour'); // should trim 0 min
expect(formatTimestampToDuration(oneHour, CALCULATE_DURATION_UNTIL, getTestTime())).to.be(
expect(formatTimestampToDuration(oneHour, CALCULATE_DURATION_UNTIL, getTestTime())).toBe(
'1 hr'
);

const oneDay = getTestTime().add(1, 'day'); // should trim 0 hrs
expect(formatTimestampToDuration(oneDay, CALCULATE_DURATION_UNTIL, getTestTime())).to.be(
expect(formatTimestampToDuration(oneDay, CALCULATE_DURATION_UNTIL, getTestTime())).toBe(
'1 day'
);

const twoMonths = getTestTime().add(2, 'month'); // should trim 0 days
expect(formatTimestampToDuration(twoMonths, CALCULATE_DURATION_UNTIL, getTestTime())).to.be(
expect(formatTimestampToDuration(twoMonths, CALCULATE_DURATION_UNTIL, getTestTime())).toBe(
'2 months'
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import React from 'react';
import { renderWithIntl } from '@kbn/test/jest';
import { BytesUsage, BytesPercentageUsage } from '../helpers';
import { BytesUsage, BytesPercentageUsage } from './helpers';

describe('Bytes Usage', () => {
it('should format correctly with used and max bytes', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import React from 'react';
import { renderWithIntl } from '@kbn/test/jest';
import { MetricCell } from '../cells';
import { MetricCell } from './cells';

describe('Node Listing Metric Cell', () => {
it('should format a percentage metric', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/

import expect from '@kbn/expect';
import { IfStatement } from '../if_statement';
import { PluginVertex } from '../../graph/plugin_vertex';
import { IfElement } from '../../list/if_element';
import { PluginElement } from '../../list/plugin_element';
import { IfStatement } from './if_statement';
import { PluginVertex } from '../graph/plugin_vertex';
import { IfElement } from '../list/if_element';
import { PluginElement } from '../list/plugin_element';

describe('IfStatement class', () => {
let ifVertex;
Expand Down Expand Up @@ -57,16 +56,16 @@ describe('IfStatement class', () => {
it('creates a IfStatement from vertex props', () => {
const ifStatement = IfStatement.fromPipelineGraphVertex(ifVertex, pipelineStage);

expect(ifStatement.id).to.be('0aef421');
expect(ifStatement.hasExplicitId).to.be(false);
expect(ifStatement.stats).to.eql({});
expect(ifStatement.meta).to.be(meta);
expect(ifStatement.condition).to.be('[is_rt] == "RT"');
expect(ifStatement.trueStatements).to.be.an(Array);
expect(ifStatement.trueStatements.length).to.be(1);
expect(ifStatement.elseStatements).to.be.an(Array);
expect(ifStatement.elseStatements.length).to.be(0);
expect(ifStatement.vertex).to.eql(ifVertex);
expect(ifStatement.id).toBe('0aef421');
expect(ifStatement.hasExplicitId).toBe(false);
expect(ifStatement.stats).toEqual({});
expect(ifStatement.meta).toBe(meta);
expect(ifStatement.condition).toBe('[is_rt] == "RT"');
expect(ifStatement.trueStatements).toBeInstanceOf(Array);
expect(ifStatement.trueStatements.length).toBe(1);
expect(ifStatement.elseStatements).toBeInstanceOf(Array);
expect(ifStatement.elseStatements.length).toBe(0);
expect(ifStatement.vertex).toEqual(ifVertex);
});
});

Expand Down Expand Up @@ -99,16 +98,16 @@ describe('IfStatement class', () => {
it('creates a IfStatement from vertex props', () => {
const ifStatement = IfStatement.fromPipelineGraphVertex(ifVertex, pipelineStage);

expect(ifStatement.id).to.be('0aef421');
expect(ifStatement.hasExplicitId).to.be(false);
expect(ifStatement.stats).to.eql({});
expect(ifStatement.meta).to.be(meta);
expect(ifStatement.condition).to.be('[is_rt] == "RT"');
expect(ifStatement.trueStatements).to.be.an(Array);
expect(ifStatement.trueStatements.length).to.be(1);
expect(ifStatement.elseStatements).to.be.an(Array);
expect(ifStatement.elseStatements.length).to.be(1);
expect(ifStatement.vertex).to.eql(ifVertex);
expect(ifStatement.id).toBe('0aef421');
expect(ifStatement.hasExplicitId).toBe(false);
expect(ifStatement.stats).toEqual({});
expect(ifStatement.meta).toBe(meta);
expect(ifStatement.condition).toBe('[is_rt] == "RT"');
expect(ifStatement.trueStatements).toBeInstanceOf(Array);
expect(ifStatement.trueStatements.length).toBe(1);
expect(ifStatement.elseStatements).toBeInstanceOf(Array);
expect(ifStatement.elseStatements.length).toBe(1);
expect(ifStatement.vertex).toEqual(ifVertex);
});
});

Expand Down Expand Up @@ -142,16 +141,16 @@ describe('IfStatement class', () => {
it('creates a IfStatement from vertex props', () => {
const ifStatement = IfStatement.fromPipelineGraphVertex(ifVertex, pipelineStage);

expect(ifStatement.id).to.be('0aef421');
expect(ifStatement.hasExplicitId).to.be(false);
expect(ifStatement.stats).to.eql({});
expect(ifStatement.meta).to.be(meta);
expect(ifStatement.condition).to.be('[is_rt] == "RT"');
expect(ifStatement.trueStatements).to.be.an(Array);
expect(ifStatement.trueStatements.length).to.be(2);
expect(ifStatement.elseStatements).to.be.an(Array);
expect(ifStatement.elseStatements.length).to.be(0);
expect(ifStatement.vertex).to.eql(ifVertex);
expect(ifStatement.id).toBe('0aef421');
expect(ifStatement.hasExplicitId).toBe(false);
expect(ifStatement.stats).toEqual({});
expect(ifStatement.meta).toBe(meta);
expect(ifStatement.condition).toBe('[is_rt] == "RT"');
expect(ifStatement.trueStatements).toBeInstanceOf(Array);
expect(ifStatement.trueStatements.length).toBe(2);
expect(ifStatement.elseStatements).toBeInstanceOf(Array);
expect(ifStatement.elseStatements.length).toBe(0);
expect(ifStatement.vertex).toEqual(ifVertex);
});
});

Expand Down Expand Up @@ -193,16 +192,16 @@ describe('IfStatement class', () => {
it('creates a IfStatement from vertex props', () => {
const ifStatement = IfStatement.fromPipelineGraphVertex(ifVertex, pipelineStage);

expect(ifStatement.id).to.be('0aef421');
expect(ifStatement.hasExplicitId).to.be(false);
expect(ifStatement.stats).to.eql({});
expect(ifStatement.meta).to.be(meta);
expect(ifStatement.condition).to.be('[is_rt] == "RT"');
expect(ifStatement.trueStatements).to.be.an(Array);
expect(ifStatement.trueStatements.length).to.be(1);
expect(ifStatement.elseStatements).to.be.an(Array);
expect(ifStatement.elseStatements.length).to.be(2);
expect(ifStatement.vertex).to.eql(ifVertex);
expect(ifStatement.id).toBe('0aef421');
expect(ifStatement.hasExplicitId).toBe(false);
expect(ifStatement.stats).toEqual({});
expect(ifStatement.meta).toBe(meta);
expect(ifStatement.condition).toBe('[is_rt] == "RT"');
expect(ifStatement.trueStatements).toBeInstanceOf(Array);
expect(ifStatement.trueStatements.length).toBe(1);
expect(ifStatement.elseStatements).toBeInstanceOf(Array);
expect(ifStatement.elseStatements.length).toBe(2);
expect(ifStatement.vertex).toEqual(ifVertex);
});
});

Expand All @@ -220,14 +219,14 @@ describe('IfStatement class', () => {

const result = ifStatement.toList(0, 'output');

expect(result).to.be.an(Array);
expect(result.length).to.be(2);
expect(result[0]).to.be.an(IfElement);
expect(result[0].id).to.be('0aef421');
expect(result[1]).to.be.an(PluginElement);
expect(result).toBeInstanceOf(Array);
expect(result.length).toBe(2);
expect(result[0]).toBeInstanceOf(IfElement);
expect(result[0].id).toBe('0aef421');
expect(result[1]).toBeInstanceOf(PluginElement);
const plugin = result[1];
expect(plugin).to.be.an(PluginElement);
expect(plugin.id).to.be('es_output');
expect(plugin).toBeInstanceOf(PluginElement);
expect(plugin.id).toBe('es_output');
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@
* you may not use this file except in compliance with the Elastic License.
*/

import expect from '@kbn/expect';
import { makeStatement } from '../make_statement';
import { PluginVertex } from '../../graph/plugin_vertex';
import { IfVertex } from '../../graph/if_vertex';
import { QueueVertex } from '../../graph/queue_vertex';
import { PluginStatement } from '../plugin_statement';
import { IfStatement } from '../if_statement';
import { Queue } from '../queue';
import { makeStatement } from './make_statement';
import { PluginVertex } from '../graph/plugin_vertex';
import { IfVertex } from '../graph/if_vertex';
import { QueueVertex } from '../graph/queue_vertex';
import { PluginStatement } from './plugin_statement';
import { IfStatement } from './if_statement';
import { Queue } from './queue';

describe('makeStatement', () => {
it('can make a PluginStatement from a PluginVertex', () => {
const pluginVertex = new PluginVertex({}, { json: { id: 'my_grok' } });
const actual = makeStatement(pluginVertex, 'output');
expect(actual).to.be.a(PluginStatement);
expect(actual).toBeInstanceOf(PluginStatement);
});

it('can make an IfStatement from an IfVertex', () => {
Expand All @@ -37,17 +36,19 @@ describe('makeStatement', () => {
{ json: { id: 'abcdef0' } }
);
const actual = makeStatement(ifVertex, 'output');
expect(actual).to.be.a(IfStatement);
expect(actual).toBeInstanceOf(IfStatement);
});

it('can make a Queue from a QueueVertex', () => {
const queueVertex = new QueueVertex({}, { json: { id: '__QUEUE__' } });
const actual = makeStatement(queueVertex);
expect(actual).to.be.a(Queue);
expect(actual).toBeInstanceOf(Queue);
});

it('throws an error for an unknown type of vertex', () => {
const unknownVertex = {};
expect(makeStatement).withArgs(unknownVertex, 'output').to.throwError();
expect(() => {
makeStatement(unknownVertex, 'output');
}).toThrow();
});
});
Loading

0 comments on commit 9d4ef37

Please sign in to comment.