mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Synthetics] allow retest on failure to be turned off (#189013)
## Summary Resolves https://github.com/elastic/kibana/issues/188804 Allows retest on failure to be configured in the monitor creation UI. https://www.loom.com/share/2302ccfd150b4668a61966be165478f8 ### Testing 1. Create a monitor and toggle retest on failure off. 2. Navigate to edit that monitor. Ensure the setting remains off. ### Release note Fixes a bug where retest on failure was not able to be turned off when creating a monitor in the Synthetics app. Retest on failure can now be turned off.
This commit is contained in:
parent
13b0749d09
commit
14f370b613
4 changed files with 83 additions and 2 deletions
|
@ -232,7 +232,7 @@ export class AddEditMonitorAPI {
|
|||
...DEFAULT_FIELDS[monitorType],
|
||||
...monitor,
|
||||
[ConfigKey.SCHEDULE]: getMonitorSchedule(schedule ?? defaultFields[ConfigKey.SCHEDULE]),
|
||||
[ConfigKey.MAX_ATTEMPTS]: getMaxAttempts(retestOnFailure),
|
||||
[ConfigKey.MAX_ATTEMPTS]: getMaxAttempts(retestOnFailure, monitor[ConfigKey.MAX_ATTEMPTS]),
|
||||
[ConfigKey.LOCATIONS]: locationsVal,
|
||||
} as MonitorFields;
|
||||
}
|
||||
|
|
|
@ -124,8 +124,11 @@ const getAlertConfig = (monitor: ProjectMonitor) => {
|
|||
|
||||
const ONLY_ONE_ATTEMPT = 1;
|
||||
|
||||
export const getMaxAttempts = (retestOnFailure?: boolean) => {
|
||||
export const getMaxAttempts = (retestOnFailure?: boolean, maxAttempts?: number) => {
|
||||
const defaultFields = DEFAULT_COMMON_FIELDS;
|
||||
if (!retestOnFailure && maxAttempts) {
|
||||
return maxAttempts;
|
||||
}
|
||||
if (retestOnFailure) {
|
||||
return defaultFields[ConfigKey.MAX_ATTEMPTS];
|
||||
} else if (retestOnFailure === false) {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
import expect from '@kbn/expect';
|
||||
import epct from 'expect';
|
||||
import moment from 'moment/moment';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { omit, omitBy } from 'lodash';
|
||||
|
@ -141,6 +142,36 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
);
|
||||
});
|
||||
|
||||
it('can disable retries', async () => {
|
||||
const maxAttempts = 1;
|
||||
const newMonitor = {
|
||||
max_attempts: maxAttempts,
|
||||
urls: 'https://elastic.co',
|
||||
name: `Sample name ${uuidv4()}`,
|
||||
type: 'http',
|
||||
locations: [localLoc],
|
||||
};
|
||||
|
||||
const { body: apiResponse } = await addMonitorAPI(newMonitor);
|
||||
|
||||
epct(apiResponse).toEqual(epct.objectContaining({ max_attempts: maxAttempts }));
|
||||
});
|
||||
|
||||
it('can enable retries', async () => {
|
||||
const maxAttempts = 2;
|
||||
const newMonitor = {
|
||||
max_attempts: maxAttempts,
|
||||
urls: 'https://elastic.co',
|
||||
name: `Sample name ${uuidv4()}`,
|
||||
type: 'http',
|
||||
locations: [localLoc],
|
||||
};
|
||||
|
||||
const { body: apiResponse } = await addMonitorAPI(newMonitor);
|
||||
|
||||
epct(apiResponse).toEqual(epct.objectContaining({ max_attempts: maxAttempts }));
|
||||
});
|
||||
|
||||
it('cannot create a invalid monitor without a monitor type', async () => {
|
||||
// Delete a required property to make payload invalid
|
||||
const newMonitor = {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
import expect from '@kbn/expect';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { omitBy } from 'lodash';
|
||||
|
||||
import { DEFAULT_FIELDS } from '@kbn/synthetics-plugin/common/constants/monitor_defaults';
|
||||
|
@ -135,6 +136,52 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('can enable retries', async () => {
|
||||
const name = `test name ${uuidv4()}`;
|
||||
const monitor = {
|
||||
type: 'http',
|
||||
locations: ['dev'],
|
||||
url: 'https://www.google.com',
|
||||
name,
|
||||
retest_on_failure: true,
|
||||
};
|
||||
const { body: result } = await addMonitorAPI(monitor);
|
||||
|
||||
expect(result).eql(
|
||||
omitMonitorKeys({
|
||||
...defaultFields,
|
||||
...monitor,
|
||||
locations: [localLoc],
|
||||
name,
|
||||
max_attempts: 2,
|
||||
retest_on_failure: undefined, // this key is not part of the SO and should not be defined
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('can disable retries', async () => {
|
||||
const name = `test name ${uuidv4()}`;
|
||||
const monitor = {
|
||||
type: 'http',
|
||||
locations: ['dev'],
|
||||
url: 'https://www.google.com',
|
||||
name,
|
||||
retest_on_failure: false,
|
||||
};
|
||||
const { body: result } = await addMonitorAPI(monitor);
|
||||
|
||||
expect(result).eql(
|
||||
omitMonitorKeys({
|
||||
...defaultFields,
|
||||
...monitor,
|
||||
locations: [localLoc],
|
||||
name,
|
||||
max_attempts: 1,
|
||||
retest_on_failure: undefined, // this key is not part of the SO and should not be defined
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('TCP Monitor', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue