Skip to content

Commit

Permalink
[Discover] Fix Elasticsearch query rule for "KQL or Lucene" query wit…
Browse files Browse the repository at this point in the history
…hout filters (elastic#151632)

Closes elastic#151609 

For testing:
- Go to Rule Management page
- Create a new Rule with "Elasticsearch query" type in "KQL or Lucene"
format
- Save and check the status after the rule finishes the creating process
=> It should say "Succeeded"
  • Loading branch information
jughosta authored Feb 21, 2023
1 parent 144df81 commit 17ab3a3
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ async function generateLink(
}

function updateFilterReferences(filters: Filter[], fromDataView: string, toDataView: string) {
return filters.map((filter) => {
return (filters || []).map((filter) => {
if (filter.meta.index === fromDataView) {
return {
...filter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const filterBar = getService('filterBar');
const find = getService('find');
const toasts = getService('toasts');
const kibanaServer = getService('kibanaServer');

const SOURCE_DATA_VIEW = 'search-source-alert';
const OUTPUT_DATA_VIEW = 'search-source-alert-output';
Expand Down Expand Up @@ -330,6 +331,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await deleteDataView(outputDataViewId);
await deleteConnector(connectorId);
await security.testUser.restoreDefaults();
await kibanaServer.savedObjects.cleanStandardList();
});

it('should create an alert when there is no data view', async () => {
Expand Down Expand Up @@ -535,5 +537,60 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await checkInitialRuleParamsState(SOURCE_DATA_VIEW);
await checkInitialDataViewState(SOURCE_DATA_VIEW);
});

it('should check that there are no errors detected after an alert is created', async () => {
const newAlert = 'New Alert for checking its status';
await createDataView('search-source*');

await PageObjects.common.navigateToApp('management');
await PageObjects.header.waitUntilLoadingHasFinished();

await testSubjects.click('triggersActions');
await PageObjects.header.waitUntilLoadingHasFinished();

await testSubjects.click('createRuleButton');
await PageObjects.header.waitUntilLoadingHasFinished();

await retry.waitFor('rule name value is correct', async () => {
await testSubjects.setValue('ruleNameInput', newAlert);
const ruleName = await testSubjects.getAttribute('ruleNameInput', 'value');
return ruleName === newAlert;
});

await testSubjects.click('.es-query-SelectOption');
await PageObjects.header.waitUntilLoadingHasFinished();
await testSubjects.click('queryFormType_searchSource');
await PageObjects.header.waitUntilLoadingHasFinished();

await testSubjects.click('selectDataViewExpression');
await testSubjects.click('indexPattern-switcher--input');
if (await testSubjects.exists('clearSearchButton')) {
await testSubjects.click('clearSearchButton');
}
const dataViewsElem = await testSubjects.find('euiSelectableList');
const sourceDataViewOption = await dataViewsElem.findByCssSelector(
`[title="search-source*"]`
);
await sourceDataViewOption.click();

await testSubjects.click('saveRuleButton');

await retry.waitFor('confirmation modal', async () => {
return await testSubjects.exists('confirmModalConfirmButton');
});

await testSubjects.click('confirmModalConfirmButton');

await PageObjects.header.waitUntilLoadingHasFinished();

await openAlertRuleInManagement(newAlert);

await retry.waitFor('success status', async () => {
await browser.refresh();
await PageObjects.header.waitUntilLoadingHasFinished();

return await testSubjects.exists('ruleStatus-ok');
});
});
});
}

0 comments on commit 17ab3a3

Please sign in to comment.