Skip to content

Commit

Permalink
[8.6] [Synthetics] fix failing Private location tests (elastic#146484) (
Browse files Browse the repository at this point in the history
elastic#146913)

# Backport

This will backport the following commits from `main` to `8.6`:
- [[Synthetics] fix failing Private location tests
(elastic#146484)](elastic#146484)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Dominique
Clarke","email":"[email protected]"},"sourceCommit":{"committedDate":"2022-12-02T18:28:49Z","message":"[Synthetics]
fix failing Private location tests (elastic#146484)\n\n##
Summary\r\n\r\nResolves
https://github.com/elastic/kibana/issues/145639\r\n\r\nUses semver to
test whether or not Synthetics policies is able to be\r\nauto upgraded
through the Fleet auto upgrade flow, rather than relying\r\non a
specific version.\r\n\r\nCo-authored-by: Kibana Machine
<[email protected]>","sha":"f9b906e39850ea208f3a0758c46b4fec132e9538","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["test","Team:uptime","release_note:skip","v8.6.0","v8.7.0"],"number":146484,"url":"https://github.com/elastic/kibana/pull/146484","mergeCommit":{"message":"[Synthetics]
fix failing Private location tests (elastic#146484)\n\n##
Summary\r\n\r\nResolves
https://github.com/elastic/kibana/issues/145639\r\n\r\nUses semver to
test whether or not Synthetics policies is able to be\r\nauto upgraded
through the Fleet auto upgrade flow, rather than relying\r\non a
specific version.\r\n\r\nCo-authored-by: Kibana Machine
<[email protected]>","sha":"f9b906e39850ea208f3a0758c46b4fec132e9538"}},"sourceBranch":"main","suggestedTargetBranches":["8.6"],"targetPullRequestStates":[{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/146484","number":146484,"mergeCommit":{"message":"[Synthetics]
fix failing Private location tests (elastic#146484)\n\n##
Summary\r\n\r\nResolves
https://github.com/elastic/kibana/issues/145639\r\n\r\nUses semver to
test whether or not Synthetics policies is able to be\r\nauto upgraded
through the Fleet auto upgrade flow, rather than relying\r\non a
specific version.\r\n\r\nCo-authored-by: Kibana Machine
<[email protected]>","sha":"f9b906e39850ea208f3a0758c46b4fec132e9538"}}]}]
BACKPORT-->
  • Loading branch information
dominiqueclarke authored Dec 2, 2022
1 parent 502fed4 commit a924f45
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 139 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 Down Expand Up @@ -363,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.3')
.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 @@ -376,7 +372,7 @@ export default function ({ getService }: FtrProviderContext) {
(pkgPolicy: PackagePolicy) =>
pkgPolicy.id === monitorId + '-' + testFleetPolicyID + `-default`
);
expect(packagePolicyAfterUpgrade.package.version).eql('0.11.3');
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);
})
);
}
});
});
}

0 comments on commit a924f45

Please sign in to comment.