Skip to content

Commit

Permalink
synthetics - fix and unskip functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dominiqueclarke committed Nov 29, 2022
1 parent c5f2072 commit 1f8cd26
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import semver from 'semver';
import uuid from 'uuid';
import { ConfigKey, HTTPFields } from '@kbn/synthetics-plugin/common/runtime_types';
import { API_URLS } from '@kbn/synthetics-plugin/common/constants';
Expand All @@ -18,8 +19,7 @@ import { comparePolicies, getTestSyntheticsPolicy } from '../uptime/rest/sample_
import { PrivateLocationTestService } from './services/private_location_test_service';

export default function ({ getService }: FtrProviderContext) {
// Failing: See https://github.com/elastic/kibana/issues/145639
describe.skip('PrivateLocationMonitor', function () {
describe('PrivateLocationMonitor', function () {
this.tags('skipCloud');
const kibanaServer = getService('kibanaServer');
const supertestAPI = getService('supertest');
Expand Down Expand Up @@ -364,11 +364,6 @@ export default function ({ getService }: FtrProviderContext) {

expect(packagePolicy.package.version).eql('0.10.3');

await supertestAPI
.post('/api/fleet/epm/packages/synthetics/0.11.2')
.set('kbn-xsrf', 'true')
.send({ force: true });

await supertestAPI.post('/api/fleet/setup').set('kbn-xsrf', 'true').send().expect(200);
const policyResponseAfterUpgrade = await supertestAPI.get(
'/api/fleet/package_policies?page=1&perPage=2000&kuery=ingest-package-policies.package.name%3A%20synthetics'
Expand All @@ -377,7 +372,7 @@ export default function ({ getService }: FtrProviderContext) {
(pkgPolicy: PackagePolicy) =>
pkgPolicy.id === monitorId + '-' + testFleetPolicyID + `-default`
);
expect(packagePolicyAfterUpgrade.package.version).eql('0.11.2');
expect(semver.gt(packagePolicyAfterUpgrade.package.version, '0.10.3')).eql(true);
} finally {
await supertestAPI
.delete(API_URLS.SYNTHETICS_MONITORS + '/' + monitorId)
Expand Down
269 changes: 134 additions & 135 deletions x-pack/test/api_integration/apis/synthetics/get_monitor_overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import { FtrProviderContext } from '../../ftr_provider_context';
import { getFixtureJson } from '../uptime/rest/helper/get_fixture_json';

export default function ({ getService }: FtrProviderContext) {
// Failing: See https://github.com/elastic/kibana/issues/146014
describe.skip('GetMonitorsOverview', function () {
describe('GetMonitorsOverview', function () {
this.tags('skipCloud');

const supertest = getService('supertest');
Expand Down Expand Up @@ -102,151 +101,151 @@ export default function ({ getService }: FtrProviderContext) {
await security.role.delete(roleName);
});

describe('returns total number of monitor combinations', () => {
it('returns the correct response', async () => {
let savedMonitors: SimpleSavedObject[] = [];
try {
const savedResponse = await Promise.all(monitors.map(saveMonitor));
savedMonitors = savedResponse;

const apiResponse = await supertest.get(
`/s/${SPACE_ID}${SYNTHETICS_API_URLS.SYNTHETICS_OVERVIEW}`
);

expect(apiResponse.body.total).eql(monitors.length * 2);
expect(apiResponse.body.allMonitorIds.sort()).eql(
savedMonitors.map((monitor) => monitor.id).sort()
);
expect(apiResponse.body.monitors.length).eql(40);
} finally {
await Promise.all(
savedMonitors.map((monitor) => {
return deleteMonitor(monitor.id);
})
);
}
});
it('returns the correct response', async () => {
let savedMonitors: SimpleSavedObject[] = [];
try {
const savedResponse = await Promise.all(monitors.map(saveMonitor));
savedMonitors = savedResponse;

const apiResponse = await supertest.get(
`/s/${SPACE_ID}${SYNTHETICS_API_URLS.SYNTHETICS_OVERVIEW}`
);

expect(apiResponse.body.total).eql(monitors.length * 2);
expect(apiResponse.body.allMonitorIds.sort()).eql(
savedMonitors.map((monitor) => monitor.id).sort()
);
expect(apiResponse.body.monitors.length).eql(40);
} finally {
await Promise.all(
savedMonitors.map((monitor) => {
return deleteMonitor(monitor.id);
})
);
}
});

it('accepts search queries', async () => {
let savedMonitors: Array<SimpleSavedObject<SyntheticsMonitor>> = [];
try {
const savedResponse = await Promise.all(monitors.map(saveMonitor));
savedMonitors = savedResponse;

const apiResponse = await supertest
.get(`/s/${SPACE_ID}${SYNTHETICS_API_URLS.SYNTHETICS_OVERVIEW}`)
.query({
query: '19',
});

expect(apiResponse.body.total).eql(2);
expect(apiResponse.body.allMonitorIds.sort()).eql(
savedMonitors
.filter((monitor) => monitor.attributes.name.includes('19'))
.map((monitor) => monitor.id)
);
expect(apiResponse.body.monitors.length).eql(2);
} finally {
await Promise.all(
savedMonitors.map((monitor) => {
return deleteMonitor(monitor.id);
})
);
}
});
it('accepts search queries', async () => {
let savedMonitors: Array<SimpleSavedObject<SyntheticsMonitor>> = [];
try {
const savedResponse = await Promise.all(monitors.map(saveMonitor));
savedMonitors = savedResponse;

const apiResponse = await supertest
.get(`/s/${SPACE_ID}${SYNTHETICS_API_URLS.SYNTHETICS_OVERVIEW}`)
.query({
query: '19',
});

expect(apiResponse.body.total).eql(2);
expect(apiResponse.body.allMonitorIds.sort()).eql(
savedMonitors
.filter((monitor) => monitor.attributes.name.includes('19'))
.map((monitor) => monitor.id)
);
expect(apiResponse.body.monitors.length).eql(2);
} finally {
await Promise.all(
savedMonitors.map((monitor) => {
return deleteMonitor(monitor.id);
})
);
}
});

describe('Overview Item', () => {
it('returns the correct response', async () => {
let savedMonitors: Array<SimpleSavedObject<SyntheticsMonitor>> = [];
const customHeartbeatId = 'example_custom_heartbeat_id';
try {
const savedResponse = await Promise.all(
[
monitors[0],
{ ...monitors[1], custom_heartbeat_id: 'example_custom_heartbeat_id' },
].map(saveMonitor)
);
savedMonitors = savedResponse;

const apiResponse = await supertest.get(
`/s/${SPACE_ID}${SYNTHETICS_API_URLS.SYNTHETICS_OVERVIEW}`
);
expect(apiResponse.body.monitors).eql([
it('returns the correct response', async () => {
let savedMonitors: Array<SimpleSavedObject<SyntheticsMonitor>> = [];
const customHeartbeatId = 'example_custom_heartbeat_id';
try {
const savedResponse = await Promise.all(
[
{ ...monitors[0], name: 'test monitor a' },
{
id: savedMonitors[0].attributes[ConfigKey.MONITOR_QUERY_ID],
configId: savedMonitors[0].id,
name: 'test-monitor-name 0',
location: {
id: 'eu-west-01',
label: 'Europe West',
geo: {
lat: 33.2343132435,
lon: 73.2342343434,
},
url: 'https://example-url.com',
isServiceManaged: true,
...monitors[1],
custom_heartbeat_id: 'example_custom_heartbeat_id',
name: 'test monitor b',
},
].map(saveMonitor)
);
savedMonitors = savedResponse;

const apiResponse = await supertest.get(
`/s/${SPACE_ID}${SYNTHETICS_API_URLS.SYNTHETICS_OVERVIEW}`
);
expect(apiResponse.body.monitors).eql([
{
id: savedMonitors[0].attributes[ConfigKey.MONITOR_QUERY_ID],
configId: savedMonitors[0].id,
name: 'test monitor a',
location: {
id: 'eu-west-01',
label: 'Europe West',
geo: {
lat: 33.2343132435,
lon: 73.2342343434,
},
isEnabled: true,
url: 'https://example-url.com',
isServiceManaged: true,
},
{
id: savedMonitors[0].attributes[ConfigKey.MONITOR_QUERY_ID],
configId: savedMonitors[0].id,
name: 'test-monitor-name 0',
location: {
id: 'eu-west-02',
label: 'Europe West',
geo: {
lat: 33.2343132435,
lon: 73.2342343434,
},
url: 'https://example-url.com',
isServiceManaged: true,
isEnabled: true,
},
{
id: savedMonitors[0].attributes[ConfigKey.MONITOR_QUERY_ID],
configId: savedMonitors[0].id,
name: 'test monitor a',
location: {
id: 'eu-west-02',
label: 'Europe West',
geo: {
lat: 33.2343132435,
lon: 73.2342343434,
},
isEnabled: true,
url: 'https://example-url.com',
isServiceManaged: true,
},
{
id: savedMonitors[1].attributes[ConfigKey.MONITOR_QUERY_ID],
configId: savedMonitors[1].id,
name: 'test-monitor-name 1',
location: {
id: 'eu-west-01',
label: 'Europe West',
geo: {
lat: 33.2343132435,
lon: 73.2342343434,
},
url: 'https://example-url.com',
isServiceManaged: true,
isEnabled: true,
},
{
id: savedMonitors[1].attributes[ConfigKey.MONITOR_QUERY_ID],
configId: savedMonitors[1].id,
name: 'test monitor b',
location: {
id: 'eu-west-01',
label: 'Europe West',
geo: {
lat: 33.2343132435,
lon: 73.2342343434,
},
isEnabled: true,
url: 'https://example-url.com',
isServiceManaged: true,
},
{
id: savedMonitors[1].attributes[ConfigKey.MONITOR_QUERY_ID],
configId: savedMonitors[1].id,
name: 'test-monitor-name 1',
location: {
id: 'eu-west-02',
label: 'Europe West',
geo: {
lat: 33.2343132435,
lon: 73.2342343434,
},
url: 'https://example-url.com',
isServiceManaged: true,
isEnabled: true,
},
{
id: savedMonitors[1].attributes[ConfigKey.MONITOR_QUERY_ID],
configId: savedMonitors[1].id,
name: 'test monitor b',
location: {
id: 'eu-west-02',
label: 'Europe West',
geo: {
lat: 33.2343132435,
lon: 73.2342343434,
},
isEnabled: true,
url: 'https://example-url.com',
isServiceManaged: true,
},
]);
expect(savedMonitors[1].attributes[ConfigKey.MONITOR_QUERY_ID]).eql(customHeartbeatId);
} finally {
await Promise.all(
savedMonitors.map((monitor) => {
return deleteMonitor(monitor.id);
})
);
}
});
isEnabled: true,
},
]);
expect(savedMonitors[1].attributes[ConfigKey.MONITOR_QUERY_ID]).eql(customHeartbeatId);
} finally {
await Promise.all(
savedMonitors.map((monitor) => {
return deleteMonitor(monitor.id);
})
);
}
});
});
}

0 comments on commit 1f8cd26

Please sign in to comment.