Skip to content

Commit

Permalink
[Synthetics] preserve id field on monitor attributes (elastic#142478)
Browse files Browse the repository at this point in the history
* synthetics - preserve id field on monitor attributes

* adjust tests

* [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix'

* adjust jest tests

* adjust tests

* adjust types

* adjust tests

* adjust types

* update tests

* [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix'

Co-authored-by: kibanamachine <[email protected]>
(cherry picked from commit 61342b3)
  • Loading branch information
dominiqueclarke committed Oct 4, 2022
1 parent 042caf3 commit 62ca045
Show file tree
Hide file tree
Showing 20 changed files with 61 additions and 7 deletions.
12 changes: 9 additions & 3 deletions x-pack/plugins/synthetics/common/constants/monitor_defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export const DEFAULT_COMMON_FIELDS: CommonFields = {
[ConfigKey.NAMESPACE]: DEFAULT_NAMESPACE_STRING,
[ConfigKey.MONITOR_SOURCE_TYPE]: SourceType.UI,
[ConfigKey.JOURNEY_ID]: '',

// Deprecated, slated to be removed in a future version
[ConfigKey.ID]: '',
};

export const DEFAULT_BROWSER_ADVANCED_FIELDS: BrowserAdvancedFields = {
Expand Down Expand Up @@ -88,15 +91,17 @@ export const DEFAULT_BROWSER_SIMPLE_FIELDS: BrowserSimpleFields = {
[ConfigKey.SOURCE_ZIP_FOLDER]: '',
[ConfigKey.SOURCE_ZIP_PROXY_URL]: '',
[ConfigKey.TEXT_ASSERTION]: '',
[ConfigKey.URLS]: '',
[ConfigKey.FORM_MONITOR_TYPE]: FormMonitorType.MULTISTEP,
[ConfigKey.TIMEOUT]: null,

// Deprecated, slated to be removed in a future version
[ConfigKey.ZIP_URL_TLS_CERTIFICATE_AUTHORITIES]: undefined,
[ConfigKey.ZIP_URL_TLS_CERTIFICATE]: undefined,
[ConfigKey.ZIP_URL_TLS_KEY]: undefined,
[ConfigKey.ZIP_URL_TLS_KEY_PASSPHRASE]: undefined,
[ConfigKey.ZIP_URL_TLS_VERIFICATION_MODE]: undefined,
[ConfigKey.ZIP_URL_TLS_VERSION]: undefined,
[ConfigKey.URLS]: '',
[ConfigKey.FORM_MONITOR_TYPE]: FormMonitorType.MULTISTEP,
[ConfigKey.TIMEOUT]: null,
};

export const DEFAULT_HTTP_SIMPLE_FIELDS: HTTPSimpleFields = {
Expand Down Expand Up @@ -143,6 +148,7 @@ export const DEFAULT_TCP_SIMPLE_FIELDS: TCPSimpleFields = {
is_tls_enabled: false,
},
[ConfigKey.HOSTS]: '',
[ConfigKey.URLS]: '',
[ConfigKey.MONITOR_TYPE]: DataStream.TCP,
[ConfigKey.FORM_MONITOR_TYPE]: FormMonitorType.TCP,
[ConfigKey.PORT]: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ export enum ConfigKey {
ZIP_URL_TLS_KEY_PASSPHRASE = 'source.zip_url.ssl.key_passphrase',
ZIP_URL_TLS_VERIFICATION_MODE = 'source.zip_url.ssl.verification_mode',
ZIP_URL_TLS_VERSION = 'source.zip_url.ssl.supported_protocols',

// deprecated, slated to be removed in a future version
ID = 'id',
}

export const secretKeys = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export const commonFormatters: CommonFormatMap = {
[ConfigKey.PROJECT_ID]: null,
[ConfigKey.CUSTOM_HEARTBEAT_ID]: null,
[ConfigKey.ORIGINAL_SPACE]: null,

// Deprecated, slated to be removed in a later release
[ConfigKey.ID]: null,
};

export const arrayToJsonFormatter = (value: string[] = []) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const tcpFormatters: TCPFormatMap = {
[ConfigKey.RESPONSE_RECEIVE_CHECK]: null,
[ConfigKey.REQUEST_SEND_CHECK]: null,
[ConfigKey.PORT]: null,
[ConfigKey.URLS]: null,
...tlsFormatters,
...commonFormatters,
};
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const CommonFieldsCodec = t.intersection([
[ConfigKey.PROJECT_ID]: t.string,
[ConfigKey.ORIGINAL_SPACE]: t.string,
[ConfigKey.CUSTOM_HEARTBEAT_ID]: t.string,
[ConfigKey.ID]: t.string,
}),
]);

Expand All @@ -98,6 +99,9 @@ export const TCPSimpleFieldsCodec = t.intersection([
[ConfigKey.HOSTS]: t.string,
[ConfigKey.PORT]: t.union([t.number, t.null]),
}),
t.partial({
[ConfigKey.URLS]: t.string,
}),
CommonFieldsCodec,
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ describe('format', () => {
urls: 'sample url',
'url.port': null,
username: '',
id: '',
});
});

Expand Down Expand Up @@ -284,6 +285,7 @@ describe('format', () => {
type: 'browser',
'url.port': null,
urls: '',
id: '',
});
}
);
Expand Down Expand Up @@ -350,6 +352,7 @@ describe('format', () => {
urls: 'sample url',
'url.port': null,
username: '',
id: '',
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,7 @@ export const commonNormalizers: CommonNormalizerMap = {
[ConfigKey.PROJECT_ID]: getCommonNormalizer(ConfigKey.PROJECT_ID),
[ConfigKey.CUSTOM_HEARTBEAT_ID]: getCommonNormalizer(ConfigKey.CUSTOM_HEARTBEAT_ID),
[ConfigKey.ORIGINAL_SPACE]: getCommonNormalizer(ConfigKey.ORIGINAL_SPACE),

// Deprecated, slated to be removed in a future release
[ConfigKey.ID]: getCommonNormalizer(ConfigKey.ID),
};
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const tcpNormalizers: TCPNormalizerMap = {
[ConfigKey.PROXY_USE_LOCAL_RESOLVER]: getTCPNormalizer(ConfigKey.PROXY_USE_LOCAL_RESOLVER),
[ConfigKey.RESPONSE_RECEIVE_CHECK]: getTCPNormalizer(ConfigKey.RESPONSE_RECEIVE_CHECK),
[ConfigKey.REQUEST_SEND_CHECK]: getTCPNormalizer(ConfigKey.REQUEST_SEND_CHECK),
[ConfigKey.URLS]: getTCPNormalizer(ConfigKey.URLS),
...tlsNormalizers,
...commonNormalizers,
};
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export const commonFormatters: CommonFormatMap = {
[ConfigKey.PROJECT_ID]: null,
[ConfigKey.CUSTOM_HEARTBEAT_ID]: null,
[ConfigKey.ORIGINAL_SPACE]: null,

// Deprecated, slated to be removed in a later releae
[ConfigKey.ID]: null,
};

export const arrayFormatter = (value: string[] = []) => (value.length ? value : null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const tcpFormatters: TCPFormatMap = {
[ConfigKey.PROXY_USE_LOCAL_RESOLVER]: null,
[ConfigKey.RESPONSE_RECEIVE_CHECK]: null,
[ConfigKey.REQUEST_SEND_CHECK]: null,
[ConfigKey.URLS]: null,
...tlsFormatters,
...commonFormatters,
};
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ describe('browser normalizers', () => {
original_space: 'test-space',
custom_heartbeat_id: 'test-id-1-test-project-id-test-space',
timeout: null,
id: '',
},
unsupportedKeys: [],
errors: [],
Expand Down Expand Up @@ -213,6 +214,7 @@ describe('browser normalizers', () => {
original_space: 'test-space',
custom_heartbeat_id: 'test-id-2-test-project-id-test-space',
timeout: null,
id: '',
},
unsupportedKeys: [],
errors: [],
Expand Down Expand Up @@ -276,6 +278,7 @@ describe('browser normalizers', () => {
original_space: 'test-space',
custom_heartbeat_id: 'test-id-3-test-project-id-test-space',
timeout: null,
id: '',
},
unsupportedKeys: [],
errors: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ describe('http normalizers', () => {
urls: 'http://localhost:9200',
'url.port': null,
username: '',
id: '',
},
unsupportedKeys: ['check.response.body', 'unsupportedKey.nestedUnsupportedKey'],
},
Expand Down Expand Up @@ -235,6 +236,7 @@ describe('http normalizers', () => {
urls: 'http://localhost:9200',
'url.port': null,
username: '',
id: '',
},
unsupportedKeys: [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ describe('icmp normalizers', () => {
timeout: '60',
type: 'icmp',
wait: '30',
id: '',
},
unsupportedKeys: [],
},
Expand Down Expand Up @@ -166,6 +167,7 @@ describe('icmp normalizers', () => {
timeout: '16',
type: 'icmp',
wait: '60',
id: '',
},
unsupportedKeys: [],
},
Expand Down Expand Up @@ -218,6 +220,7 @@ describe('icmp normalizers', () => {
timeout: '16',
type: 'icmp',
wait: '1',
id: '',
},
unsupportedKeys: ['unsupportedKey.nestedUnsupportedKey'],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ describe('tcp normalizers', () => {
tags: ['service:smtp', 'org:google'],
timeout: '16',
type: 'tcp',
id: '',
urls: '',
},
unsupportedKeys: [],
},
Expand Down Expand Up @@ -194,6 +196,8 @@ describe('tcp normalizers', () => {
tags: ['tag1', 'tag2'],
timeout: '16',
type: 'tcp',
id: '',
urls: '',
},
unsupportedKeys: [],
},
Expand Down Expand Up @@ -259,6 +263,8 @@ describe('tcp normalizers', () => {
tags: ['tag1', 'tag2'],
timeout: '16',
type: 'tcp',
id: '',
urls: '',
},
unsupportedKeys: ['ports', 'unsupportedKey.nestedUnsupportedKey'],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ const payloadData = [
type: 'browser',
'url.port': null,
urls: '',
id: '',
},
{
__ui: {
Expand Down Expand Up @@ -607,6 +608,7 @@ const payloadData = [
type: 'browser',
'url.port': null,
urls: '',
id: '',
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ export default function ({ getService }: FtrProviderContext) {
type: 'browser',
'url.port': null,
urls: '',
id: '',
});
}
} finally {
Expand Down Expand Up @@ -306,6 +307,7 @@ export default function ({ getService }: FtrProviderContext) {
type: 'http',
urls: Array.isArray(monitor.urls) ? monitor.urls?.[0] : monitor.urls,
'url.port': null,
id: '',
});
}
} finally {
Expand Down Expand Up @@ -405,6 +407,8 @@ export default function ({ getService }: FtrProviderContext) {
type: 'tcp',
hosts: Array.isArray(monitor.hosts) ? monitor.hosts?.[0] : monitor.hosts,
'url.port': null,
urls: '',
id: '',
});
}
} finally {
Expand Down Expand Up @@ -506,6 +510,7 @@ export default function ({ getService }: FtrProviderContext) {
monitor.wait?.slice(-1) === 's'
? monitor.wait?.slice(0, -1)
: `${parseInt(monitor.wait?.slice(0, -1) || '1', 10) * 60}`,
id: '',
});
}
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@
"origin": "ui",
"form_monitor_type": "multistep",
"urls": "",
"url.port": null
"url.port": null,
"id": ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,6 @@
"revision": 1,
"origin": "ui",
"form_monitor_type": "http",
"journey_id": ""
"journey_id": "",
"id": ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
"name": "Test HTTP Monitor 04",
"namespace": "testnamespace",
"origin": "ui",
"form_monitor_type": "icmp"
"form_monitor_type": "icmp",
"id": ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"is_zip_url_tls_enabled": false
},
"hosts": "example-host:40",
"urls": "example-host:40",
"url.port": null,
"proxy_url": "",
"proxy_use_local_resolver": false,
Expand All @@ -32,5 +33,6 @@
"name": "Test HTTP Monitor 04",
"namespace": "testnamespace",
"origin": "ui",
"form_monitor_type": "tcp"
"form_monitor_type": "tcp",
"id": ""
}

0 comments on commit 62ca045

Please sign in to comment.