[Synthetics] Fix flaky test (#162642)

This commit is contained in:
Shahzad 2023-07-28 09:53:12 +02:00 committed by GitHub
parent 8543e8366b
commit 633a466336
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 9 deletions

View file

@ -522,7 +522,7 @@ export default function ({ getService }: FtrProviderContext) {
pkgPolicy.id === monitorId + '-' + testFleetPolicyID + `-default`
);
expect(packagePolicy.package.version).eql('1.0.1');
expect(packagePolicy.package.version).eql('1.0.3');
await supertestAPI.post('/api/fleet/setup').set('kbn-xsrf', 'true').send().expect(200);
const policyResponseAfterUpgrade = await supertestAPI.get(
@ -532,7 +532,7 @@ export default function ({ getService }: FtrProviderContext) {
(pkgPolicy: PackagePolicy) =>
pkgPolicy.id === monitorId + '-' + testFleetPolicyID + `-default`
);
expect(semver.gte(packagePolicyAfterUpgrade.package.version, '1.0.1')).eql(true);
expect(semver.gte(packagePolicyAfterUpgrade.package.version, '1.0.3')).eql(true);
} finally {
await supertestAPI
.delete(SYNTHETICS_API_URLS.SYNTHETICS_MONITORS + '/' + monitorId)

View file

@ -29,7 +29,7 @@ export const getTestSyntheticsPolicy = (props: PolicyProps): PackagePolicy => {
version: 'WzE2MjYsMV0=',
name: 'test-monitor-name-Test private location 0-default',
namespace: namespace ?? 'testnamespace',
package: { name: 'synthetics', title: 'Elastic Synthetics', version: '1.0.1' },
package: { name: 'synthetics', title: 'Elastic Synthetics', version: '1.0.3' },
enabled: true,
policy_id: '5347cd10-0368-11ed-8df7-a7424c6f5167',
inputs: [
@ -72,6 +72,7 @@ export const getTestSyntheticsPolicy = (props: PolicyProps): PackagePolicy => {
origin: { type: 'text' },
'monitor.project.id': { type: 'text' },
'monitor.project.name': { type: 'text' },
'monitor.id': { type: 'text' },
ipv4: { type: 'bool', value: true },
ipv6: { type: 'bool', value: true },
mode: { type: 'text' },
@ -109,6 +110,8 @@ export const getTestSyntheticsPolicy = (props: PolicyProps): PackagePolicy => {
origin: { type: 'text' },
'monitor.project.id': { type: 'text' },
'monitor.project.name': { type: 'text' },
'monitor.id': { type: 'text' },
test_run_id: { type: 'text' },
ipv4: { type: 'bool', value: true },
ipv6: { type: 'bool', value: true },
mode: { type: 'text' },
@ -175,9 +178,11 @@ export const getHttpInput = ({
id: { type: 'text' },
config_id: { type: 'text' },
run_once: { value: false, type: 'bool' },
test_run_id: { type: 'text' },
origin: { type: 'text' },
'monitor.project.id': { type: 'text' },
'monitor.project.name': { type: 'text' },
'monitor.id': { type: 'text' },
ipv4: { type: 'bool', value: true },
ipv6: { type: 'bool', value: true },
mode: { type: 'text' },
@ -238,9 +243,11 @@ export const getHttpInput = ({
id: { value: JSON.stringify(id), type: 'text' },
config_id: { value: id, type: 'text' },
run_once: { value: false, type: 'bool' },
test_run_id: { type: 'text' },
origin: { value: projectId ? 'project' : 'ui', type: 'text' },
'monitor.project.id': { type: 'text', value: projectId ?? null },
'monitor.project.name': { type: 'text', value: projectId ?? null },
'monitor.id': { type: 'text' },
ipv4: { type: 'bool', value: true },
ipv6: { type: 'bool', value: true },
mode: { type: 'text', value: 'any' },
@ -423,9 +430,11 @@ export const getBrowserInput = ({ id, params, isBrowser, projectId }: PolicyProp
id: { value: id, type: 'text' },
config_id: { value: id, type: 'text' },
run_once: { value: false, type: 'bool' },
test_run_id: { type: 'text' },
origin: { value: 'ui', type: 'text' },
'monitor.project.id': { value: projectId ?? null, type: 'text' },
'monitor.project.name': { value: projectId ?? null, type: 'text' },
'monitor.id': { type: 'text' },
}
: {
__ui: { type: 'yaml' },
@ -462,9 +471,11 @@ export const getBrowserInput = ({ id, params, isBrowser, projectId }: PolicyProp
id: { type: 'text' },
config_id: { type: 'text' },
run_once: { value: false, type: 'bool' },
test_run_id: { type: 'text' },
origin: { type: 'text' },
'monitor.project.id': { type: 'text' },
'monitor.project.name': { type: 'text' },
'monitor.id': { type: 'text' },
};
return {

View file

@ -37,7 +37,7 @@ export const getTestProjectSyntheticsPolicyLightweight = (
version: 'WzEzMDksMV0=',
name: `4b6abc6c-118b-4d93-a489-1135500d09f1-${projectId}-default-Test private location 0`,
namespace: 'default',
package: { name: 'synthetics', title: 'Elastic Synthetics', version: '1.0.1' },
package: { name: 'synthetics', title: 'Elastic Synthetics', version: '1.0.3' },
enabled: true,
policy_id: '46034710-0ba6-11ed-ba04-5f123b9faa8b',
inputs: [
@ -130,6 +130,7 @@ export const getTestProjectSyntheticsPolicyLightweight = (
type: 'text',
value: 'any',
},
test_run_id: { type: 'text' },
'monitor.project.id': {
type: 'text',
value: JSON.stringify(projectId),
@ -138,6 +139,9 @@ export const getTestProjectSyntheticsPolicyLightweight = (
type: 'text',
value: JSON.stringify(projectId),
},
'monitor.id': {
type: 'text',
},
name: {
type: 'text',
value: JSON.stringify(name),
@ -317,9 +321,11 @@ export const getTestProjectSyntheticsPolicyLightweight = (
id: { type: 'text' },
config_id: { type: 'text' },
run_once: { value: false, type: 'bool' },
test_run_id: { type: 'text' },
origin: { type: 'text' },
'monitor.project.id': { type: 'text' },
'monitor.project.name': { type: 'text' },
'monitor.id': { type: 'text' },
ipv4: { type: 'bool', value: true },
ipv6: { type: 'bool', value: true },
mode: { type: 'text' },
@ -355,9 +361,11 @@ export const getTestProjectSyntheticsPolicyLightweight = (
id: { type: 'text' },
config_id: { type: 'text' },
run_once: { value: false, type: 'bool' },
test_run_id: { type: 'text' },
origin: { type: 'text' },
'monitor.project.id': { type: 'text' },
'monitor.project.name': { type: 'text' },
'monitor.id': { type: 'text' },
ipv4: { type: 'bool', value: true },
ipv6: { type: 'bool', value: true },
mode: { type: 'text' },
@ -427,9 +435,11 @@ export const getTestProjectSyntheticsPolicyLightweight = (
id: { type: 'text' },
config_id: { type: 'text' },
run_once: { value: false, type: 'bool' },
test_run_id: { type: 'text' },
origin: { type: 'text' },
'monitor.project.id': { type: 'text' },
'monitor.project.name': { type: 'text' },
'monitor.id': { type: 'text' },
...inputs,
},
id: `synthetics/browser-browser-4b6abc6c-118b-4d93-a489-1135500d09f1-${projectId}-default-d70a46e0-22ea-11ed-8c6b-09a2d21dfbc3`,
@ -532,7 +542,7 @@ export const getTestProjectSyntheticsPolicy = (
version: 'WzEzMDksMV0=',
name: `4b6abc6c-118b-4d93-a489-1135500d09f1-${projectId}-default-Test private location 0`,
namespace: 'default',
package: { name: 'synthetics', title: 'Elastic Synthetics', version: '1.0.1' },
package: { name: 'synthetics', title: 'Elastic Synthetics', version: '1.0.3' },
enabled: true,
policy_id: '46034710-0ba6-11ed-ba04-5f123b9faa8b',
inputs: [
@ -584,9 +594,11 @@ export const getTestProjectSyntheticsPolicy = (
id: { type: 'text' },
config_id: { type: 'text' },
run_once: { value: false, type: 'bool' },
test_run_id: { type: 'text' },
origin: { type: 'text' },
'monitor.project.id': { type: 'text' },
'monitor.project.name': { type: 'text' },
'monitor.id': { type: 'text' },
ipv4: { type: 'bool', value: true },
ipv6: { type: 'bool', value: true },
mode: { type: 'text' },
@ -630,9 +642,11 @@ export const getTestProjectSyntheticsPolicy = (
id: { type: 'text' },
config_id: { type: 'text' },
run_once: { value: false, type: 'bool' },
test_run_id: { type: 'text' },
origin: { type: 'text' },
'monitor.project.id': { type: 'text' },
'monitor.project.name': { type: 'text' },
'monitor.id': { type: 'text' },
ipv4: { type: 'bool', value: true },
ipv6: { type: 'bool', value: true },
mode: { type: 'text' },
@ -667,9 +681,11 @@ export const getTestProjectSyntheticsPolicy = (
id: { type: 'text' },
config_id: { type: 'text' },
run_once: { value: false, type: 'bool' },
test_run_id: { type: 'text' },
origin: { type: 'text' },
'monitor.project.id': { type: 'text' },
'monitor.project.name': { type: 'text' },
'monitor.id': { type: 'text' },
ipv4: { type: 'bool', value: true },
ipv6: { type: 'bool', value: true },
mode: { type: 'text' },
@ -746,9 +762,11 @@ export const getTestProjectSyntheticsPolicy = (
id: { value: id, type: 'text' },
config_id: { value: configId, type: 'text' },
run_once: { value: false, type: 'bool' },
test_run_id: { type: 'text' },
origin: { value: 'project', type: 'text' },
'monitor.project.id': { value: JSON.stringify(projectId), type: 'text' },
'monitor.project.name': { value: JSON.stringify(projectId), type: 'text' },
'monitor.id': { type: 'text' },
...inputs,
},
id: `synthetics/browser-browser-4b6abc6c-118b-4d93-a489-1135500d09f1-${projectId}-default-d70a46e0-22ea-11ed-8c6b-09a2d21dfbc3`,

View file

@ -22,12 +22,12 @@ export class PrivateLocationTestService {
async installSyntheticsPackage() {
await this.supertest.post('/api/fleet/setup').set('kbn-xsrf', 'true').send().expect(200);
const response = await this.supertest
.get('/api/fleet/epm/packages/synthetics/1.0.1')
.get('/api/fleet/epm/packages/synthetics/1.0.3')
.set('kbn-xsrf', 'true')
.expect(200);
if (response.body.item.status !== 'installed') {
await this.supertest
.post('/api/fleet/epm/packages/synthetics/1.0.1')
.post('/api/fleet/epm/packages/synthetics/1.0.3')
.set('kbn-xsrf', 'true')
.send({ force: true })
.expect(200);

View file

@ -21,8 +21,7 @@ import { PrivateLocationTestService } from './services/private_location_test_ser
import { comparePolicies, getTestSyntheticsPolicy } from './sample_data/test_policy';
export default function ({ getService }: FtrProviderContext) {
// Failing: See https://github.com/elastic/kibana/issues/162594
describe.skip('SyncGlobalParams', function () {
describe('SyncGlobalParams', function () {
this.tags('skipCloud');
const supertestAPI = getService('supertest');
const kServer = getService('kibanaServer');