Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(NA): move missing monitoring plugin tests out of __tests__ folder #88016

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/

import expect from '@kbn/expect';
import { handleResponse } from '../get_index_summary';
import { handleResponse } from './get_index_summary';

describe('get_index_summary handleResponse', () => {
// TODO: tests were not running and are not up to date
describe.skip('get_index_summary handleResponse', () => {
it('default undefined fields in result for empty response', () => {
const shardStats = {};
const indexUuid = null;
Expand All @@ -16,7 +16,7 @@ describe('get_index_summary handleResponse', () => {
const response = {};

const result = handleFn(response);
expect(result).to.be.eql({
expect(result).toBe({
dataSize: {
primaries: undefined,
total: undefined,
Expand Down Expand Up @@ -58,7 +58,7 @@ describe('get_index_summary handleResponse', () => {
},
});

expect(result).to.be.eql({
expect(result).toBe({
documents: 250,
dataSize: {
primaries: 122500,
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('get_index_summary handleResponse', () => {
},
});

expect(result).to.be.eql({
expect(result).toBe({
documents: 250,
dataSize: {
primaries: 122500,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { handleResponse } from '../get_indices';
import expect from '@kbn/expect';
import { handleResponse } from './get_indices';

describe('Get Elasticsearch Indices', () => {
it('handle an empty response', () => {
const result = handleResponse();
expect(result).to.eql([]);
expect(result).toEqual([]);
});

it('should handle a simple response', () => {
Expand All @@ -26,7 +25,7 @@ describe('Get Elasticsearch Indices', () => {
},
};
const result = handleResponse(resp, 0, 0);
expect(result).to.eql([
expect(result).toEqual([
{
name: 'My Cool Test Index',
doc_count: undefined,
Expand Down Expand Up @@ -102,7 +101,7 @@ describe('Get Elasticsearch Indices', () => {
},
};
const result = handleResponse(resp, 0, 604800);
expect(result).to.eql([
expect(result).toEqual([
{
name: 'avocado-tweets-2017.08.08',
doc_count: 381,
Expand Down Expand Up @@ -218,7 +217,7 @@ describe('Get Elasticsearch Indices', () => {
};

const result = handleResponse(resp, 0, 604800, shardStats);
expect(result).to.eql([
expect(result).toEqual([
{
name: 'avocado-tweets-2017.08.08',
doc_count: 381,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,34 @@
*/

import { set } from '@elastic/safer-lodash-set';
import expect from '@kbn/expect';
import { calculateNodeType } from '../calculate_node_type.js';
import { calculateNodeType } from './calculate_node_type.js';

const masterNodeId = 'def456';

describe('Calculating Node Type from Attributes', () => {
it('Calculates default', () => {
const node = {};
const result = calculateNodeType(node, masterNodeId);
expect(result).to.be.eql('node');
expect(result).toBe('node');
});
it('Calculates master_only', () => {
const node = set({}, 'attributes', { master: 'true', data: 'false' });
const result = calculateNodeType(node, masterNodeId);
expect(result).to.be.eql('master_only');
expect(result).toBe('master_only');
});
it('Calculates data', () => {
const node = set({}, 'attributes', { master: 'false', data: 'true' });
const result = calculateNodeType(node, masterNodeId);
expect(result).to.be.eql('data');
expect(result).toBe('data');
});
it('Calculates client', () => {
const node = set({}, 'attributes', { master: 'false', data: 'false' });
const result = calculateNodeType(node, masterNodeId);
expect(result).to.be.eql('client');
expect(result).toBe('client');
});
it('Calculates master', () => {
const node = { node_ids: ['abc123', 'def456'] };
const result = calculateNodeType(node, masterNodeId);
expect(result).to.be.eql('master');
expect(result).toBe('master');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/

import expect from '@kbn/expect';
import { handleResponse } from '../get_node_summary';
import { handleResponse } from './get_node_summary';

describe('Elasticsearch Node Summary get_node_summary handleResponse', () => {
// TODO: tests were not running and are not up to date
describe.skip('Elasticsearch Node Summary get_node_summary handleResponse', () => {
it('should return undefined fields in result for empty response', () => {
const clusterState = {};
const shardStats = {};
Expand All @@ -17,7 +17,7 @@ describe('Elasticsearch Node Summary get_node_summary handleResponse', () => {
const response = {};

const result = handleFn(response);
expect(result).to.be.eql({
expect(result).toBe({
attributes: {},
resolver: null,
name: null,
Expand Down Expand Up @@ -48,7 +48,7 @@ describe('Elasticsearch Node Summary get_node_summary handleResponse', () => {
const response = {};

const result = handleFn(response);
expect(result).to.be.eql({
expect(result).toBe({
attributes: {},
resolver: 'fooNode',
name: 'fooNode',
Expand Down Expand Up @@ -126,7 +126,7 @@ describe('Elasticsearch Node Summary get_node_summary handleResponse', () => {
};

const result = handleFn(response);
expect(result).to.be.eql({
expect(result).toBe({
attributes: {},
resolver: 'fooNode-Uuid',
name: 'fooNode-Name',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import expect from '@kbn/expect';
import { getNodeTypeClassLabel } from '../get_node_type_class_label';
import { getNodeTypeClassLabel } from './get_node_type_class_label';

describe('Node Type and Label', () => {
describe('when master node', () => {
Expand All @@ -14,25 +13,25 @@ describe('Node Type and Label', () => {
master: true,
};
const { nodeType, nodeTypeLabel, nodeTypeClass } = getNodeTypeClassLabel(node);
expect(nodeType).to.be('master');
expect(nodeTypeLabel).to.be('Master Node');
expect(nodeTypeClass).to.be('starFilled');
expect(nodeType).toBe('master');
expect(nodeTypeLabel).toBe('Master Node');
expect(nodeTypeClass).toBe('starFilled');
});
it('type is indicated by string', () => {
const node = {};
const type = 'master';
const { nodeType, nodeTypeLabel, nodeTypeClass } = getNodeTypeClassLabel(node, type);
expect(nodeType).to.be('master');
expect(nodeTypeLabel).to.be('Master Node');
expect(nodeTypeClass).to.be('starFilled');
expect(nodeType).toBe('master');
expect(nodeTypeLabel).toBe('Master Node');
expect(nodeTypeClass).toBe('starFilled');
});
});
it('when type is generic node', () => {
const node = {};
const type = 'node';
const { nodeType, nodeTypeLabel, nodeTypeClass } = getNodeTypeClassLabel(node, type);
expect(nodeType).to.be('node');
expect(nodeTypeLabel).to.be('Node');
expect(nodeTypeClass).to.be('storage');
expect(nodeType).toBe('node');
expect(nodeTypeLabel).toBe('Node');
expect(nodeTypeClass).toBe('storage');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { getMetricAggs } from '../get_metric_aggs';
import { getMetricAggs } from './get_metric_aggs';

describe('get metric aggs', () => {
it('should create aggregations for "basic" metrics', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { getNodeIds } from '../get_node_ids';
import { getNodeIds } from './get_node_ids';

describe('getNodeIds', () => {
it('should return a list of ids and uuids', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { getPaginatedNodes } from '../get_paginated_nodes';
import { getPaginatedNodes } from './get_paginated_nodes';

jest.mock('../get_node_ids', () => ({
jest.mock('./get_node_ids', () => ({
getNodeIds: () => [
{
name: 'one',
Expand All @@ -18,7 +18,7 @@ jest.mock('../get_node_ids', () => ({
],
}));

jest.mock('../../../../details/get_metrics', () => ({
jest.mock('../../../details/get_metrics', () => ({
getMetrics: () => {
return {
foo: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import clusterDataFixture from './fixtures/cluster_data';
import { handleResponse } from '../handle_response';
import clusterDataFixture from './__fixtures__/cluster_data';
import { handleResponse } from './handle_response';

const { nodeStats, clusterStats, shardStats, timeOptions } = clusterDataFixture;
const pageOfNodes = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { mapNodesInfo } from '../map_nodes_info';
import { mapNodesInfo } from './map_nodes_info';

describe('map nodes info', () => {
it('should summarize the info', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { mapNodesMetrics } from '../map_nodes_metrics';
import { mapNodesMetrics } from './map_nodes_metrics';

describe('map nodes metrics', () => {
it('should summarize the info', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { nodeTypeClass, nodeTypeLabel } from '../lookups';
import expect from '@kbn/expect';
import { nodeTypeClass, nodeTypeLabel } from './lookups';
import _ from 'lodash';

describe('Node Types Lookups', () => {
// TODO: tests were not running and are not up to date
describe.skip('Node Types Lookups', () => {
it('Has matching classes and labels', () => {
const classKeys = Object.keys(nodeTypeClass);
const labelKeys = Object.keys(nodeTypeLabel);
const typeKeys = ['client', 'data', 'invalid', 'master', 'master_only', 'node'];
classKeys.sort();
labelKeys.sort();
expect(classKeys).to.be.eql(typeKeys);
expect(labelKeys).to.be.eql(typeKeys);
expect(classKeys).toBe(typeKeys);
expect(labelKeys).toBe(typeKeys);
});

it('Has usable values', () => {
_.each(nodeTypeClass, (value) => {
expect(value).to.be.a('string');
expect(value).toBeInstanceOf(String);
});
_.each(nodeTypeLabel, (value) => {
expect(value).to.be.a('string');
expect(value).toBeInstanceOf(String);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
*/

import { cloneDeep } from 'lodash';
import expect from '@kbn/expect';
import { handleResponse } from '../get_shard_stats';
import { shardStatsFixture, clusterFixture } from './fixtures';
import { handleResponse } from './get_shard_stats';
import { shardStatsFixture, clusterFixture } from './__fixtures__';

let resp;
let cluster;
Expand All @@ -25,7 +24,7 @@ describe('getShardStats handler', () => {

it('returns a default if response is empty', () => {
const result = handleResponse({}, includeNodes, includeNodes, {});
expect(result).to.eql({
expect(result).toEqual({
indicesTotals: undefined,
indices: undefined,
nodes: undefined,
Expand All @@ -35,7 +34,7 @@ describe('getShardStats handler', () => {
describe('calculates indicesTotals', () => {
it('for green cluster status - no unassigned', () => {
const result = handleResponse(resp, includeNodes, includeNodes, cluster);
expect(result).to.eql({
expect(result).toEqual({
indicesTotals: {
primary: 26,
replica: 26,
Expand Down Expand Up @@ -84,7 +83,7 @@ describe('getShardStats handler', () => {
},
];
const result = handleResponse(resp, includeNodes, includeNodes, cluster);
expect(result).to.eql({
expect(result).toEqual({
indicesTotals: {
primary: 26,
replica: 21,
Expand Down Expand Up @@ -118,7 +117,7 @@ describe('getShardStats handler', () => {
},
];
const result = handleResponse(resp, includeNodes, includeNodes, cluster);
expect(result).to.eql({
expect(result).toEqual({
indicesTotals: {
primary: 26,
replica: 21,
Expand All @@ -136,7 +135,7 @@ describe('getShardStats handler', () => {
it('returns nodes info and indicesTotals calculation', () => {
includeNodes = true;
const result = handleResponse(resp, includeNodes, includeIndices, cluster);
expect(result).to.eql({
expect(result).toEqual({
indicesTotals: { primary: 26, replica: 26, unassigned: { primary: 0, replica: 0 } },
indices: undefined,
nodes: {
Expand All @@ -161,7 +160,7 @@ describe('getShardStats handler', () => {
it('returns indices info and indicesTotals calculation', () => {
includeIndices = true;
const result = handleResponse(resp, includeNodes, includeIndices, cluster);
expect(result).to.eql({
expect(result).toEqual({
indicesTotals: { primary: 26, replica: 26, unassigned: { primary: 0, replica: 0 } },
indices: {
'.ml-anomalies-shared': {
Expand Down
Loading