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

[Synthetics] fix failing Private location tests #146484

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,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
266 changes: 133 additions & 133 deletions x-pack/test/api_integration/apis/synthetics/get_monitor_overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,151 +102,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);
})
);
}
});
});
}