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
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export const esPackageResponse = () => {
return {
monitoredClusters: {
clusters: {
standalone: {},
},
execution: {
timedOut: false,
errors: [],
},
},
metricbeatErrors: {
execution: {
errors: [],
timedOut: false,
},
products: {},
},
packageErrors: {
execution: {
errors: [],
timedOut: false,
},
products: {
elasticsearch: {
'elasticsearch.stack_monitoring.node_stats': [
{
lastSeen: '2023-01-13T15:11:40.458Z',
message:
'error making http request: Get "http://localhost:9200/_nodes/_local/stats": dial tcp [::1]:9200: connect: cannot assign requested address',
},
{
lastSeen: '2023-01-13T15:11:30.458Z',
message:
'error making http request: Get "http://localhost:9200/_nodes/_local/stats": dial tcp 127.0.0.1:9200: connect: connection refused',
},
],
},
},
},
};
};
32 changes: 31 additions & 1 deletion x-pack/test/api_integration/apis/monitoring/_health/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import { getLifecycleMethods } from '../data_stream';

import emptyResponse from './fixtures/response_empty.json';
import { esBeatsResponse } from './fixtures/response_es_beats';
import { esPackageResponse } from './fixtures/response_es_package';

const ELASTICSEARCH_PACKAGE_ARCHIVE =
'x-pack/test/api_integration/apis/monitoring/es_archives/_health/elasticsearch_package_error';
const METRICBEAT_ARCHIVE =
'x-pack/test/api_integration/apis/monitoring/es_archives/_health/metricbeat_8';
export default function ({ getService }) {
Expand All @@ -36,7 +39,7 @@ export default function ({ getService }) {
});
});

describe('with data', () => {
describe('with metricbeat data', () => {
const archives = [
'x-pack/test/api_integration/apis/monitoring/es_archives/_health/monitoring_es_8',
'x-pack/test/api_integration/apis/monitoring/es_archives/_health/monitoring_beats_8',
Expand Down Expand Up @@ -82,5 +85,32 @@ export default function ({ getService }) {
});
});
});

describe('with integration package data', () => {
const timeRange = {
min: '2023-01-10T14:46:10.461Z',
max: '2023-01-15T22:30:00.000Z',
};
const archives = [ELASTICSEARCH_PACKAGE_ARCHIVE];
const { setup, tearDown } = getLifecycleMethods(getService);

before('load archive', () => {
return setup(archives);
});

after('unload archive', () => {
return tearDown([ELASTICSEARCH_PACKAGE_ARCHIVE]);
});

it('returns the state of the monitoring documents', async () => {
const { body } = await supertest
.get(`/api/monitoring/v1/_health?min=${timeRange.min}&max=${timeRange.max}`)
.set('kbn-xsrf', 'xxx')
.expect(200);

delete body.settings;
expect(body).to.eql(esPackageResponse());
});
});
});
}
Binary file not shown.
Loading