-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add upgrade rule smoke tests (#136048)
* Add upgrade rule smoke tests * Add version check Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
74691b6
commit d862f6f
Showing
5 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
export default function ({ loadTestFile }: FtrProviderContext) { | ||
describe('upgrade', function () { | ||
loadTestFile(require.resolve('./rules_smoke_tests')); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
import semver from 'semver'; | ||
import { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
export default function ({ getPageObjects, getService }: FtrProviderContext) { | ||
const pageObjects = getPageObjects(['common', 'header']); | ||
const rulesHelper = getService('rulesHelper'); | ||
const log = getService('log'); | ||
const testSubjects = getService('testSubjects'); | ||
|
||
describe('upgrade rules smoke tests', function describeIndexTests() { | ||
before(async function () { | ||
log.debug(process.env.ORIGINAL_VERSION!); | ||
if (semver.lt(process.env.ORIGINAL_VERSION!, '7.13.0-SNAPSHOT')) { | ||
log.debug('Skipping! These tests are valid only for 7.13+ versions'); | ||
this.skip(); | ||
} | ||
}); | ||
const spaces = [ | ||
{ space: 'default', basePath: '' }, | ||
{ space: 'automation', basePath: 's/automation' }, | ||
]; | ||
|
||
spaces.forEach(({ space, basePath }) => { | ||
describe('space: ' + space, () => { | ||
before(async () => { | ||
await pageObjects.common.navigateToUrl( | ||
'management', | ||
'insightsAndAlerting/triggersActions/rules', | ||
{ | ||
ensureCurrentUrl: false, | ||
shouldLoginIfPrompted: true, | ||
shouldUseHashForSubUrl: false, | ||
basePath, | ||
} | ||
); | ||
await pageObjects.header.waitUntilLoadingHasFinished(); | ||
await testSubjects.click('rulesTab'); | ||
}); | ||
it('shows created rule with no errors', async () => { | ||
const createdRuleName = 'Upgrade Rule'; | ||
await testSubjects.click('rulesTab'); | ||
await rulesHelper.searchRules('"' + createdRuleName + '"'); | ||
const workAround = process.env.TEST_RULE_WORKAROUND ? true : false; | ||
if (workAround) { | ||
await rulesHelper.disableEnableRule(); | ||
} | ||
const searchResults = await rulesHelper.getRulesList(); | ||
expect(searchResults.length).to.equal(1); | ||
expect(searchResults[0].name).to.contain(createdRuleName); | ||
expect(searchResults[0].interval).to.equal('1 min'); | ||
expect(searchResults[0].status).to.equal('Enabled'); | ||
expect(searchResults[0].lastResponse).to.equal('Ok'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
import { FtrProviderContext } from '../ftr_provider_context'; | ||
import { | ||
CustomCheerio, | ||
CustomCheerioStatic, | ||
} from '../../../../test/functional/services/lib/web_element_wrapper/custom_cheerio_api'; | ||
|
||
export function RulesHelper({ getPageObjects, getService }: FtrProviderContext) { | ||
const find = getService('find'); | ||
const browser = getService('browser'); | ||
const retry = getService('retry'); | ||
const testSubjects = getService('testSubjects'); | ||
const pageObjects = getPageObjects(['common', 'header']); | ||
const ENTER_KEY = '\uE007'; | ||
|
||
function getRowItemData(row: CustomCheerio, $: CustomCheerioStatic) { | ||
return { | ||
name: $(row).findTestSubject('rulesTableCell-name').find('.euiTableCellContent').text(), | ||
duration: $(row) | ||
.findTestSubject('rulesTableCell-duration') | ||
.find('.euiTableCellContent') | ||
.text(), | ||
interval: $(row) | ||
.findTestSubject('rulesTableCell-interval') | ||
.find('.euiTableCellContent') | ||
.text(), | ||
tags: $(row) | ||
.findTestSubject('rulesTableCell-tagsPopover') | ||
.find('.euiTableCellContent') | ||
.text(), | ||
lastResponse: $(row) | ||
.findTestSubject('rulesTableCell-lastResponse') | ||
.find('.euiTableCellContent') | ||
.text(), | ||
status: $(row).findTestSubject('rulesTableCell-status').find('.euiTableCellContent').text(), | ||
}; | ||
} | ||
|
||
return { | ||
async searchRules(searchText: string) { | ||
const searchBox = await testSubjects.find('ruleSearchField'); | ||
await searchBox.click(); | ||
await searchBox.clearValue(); | ||
await searchBox.type(searchText); | ||
await searchBox.pressKeys(ENTER_KEY); | ||
await find.byCssSelector( | ||
'.euiBasicTable[data-test-subj="rulesList"]:not(.euiBasicTable-loading)' | ||
); | ||
}, | ||
async getRulesList() { | ||
const table = await find.byCssSelector('[data-test-subj="rulesList"] table'); | ||
const $ = await table.parseDomContent(); | ||
return $.findTestSubjects('rule-row') | ||
.toArray() | ||
.map((row) => { | ||
return getRowItemData(row, $); | ||
}); | ||
}, | ||
|
||
async isStatus(status: string): Promise<boolean> { | ||
const actionsDropdown = await testSubjects.find('statusDropdown'); | ||
const currentStatus = await actionsDropdown.getVisibleText(); | ||
if (currentStatus === status) { | ||
return true; | ||
} | ||
return false; | ||
}, | ||
|
||
async changeStatus(status: string) { | ||
if (await this.isStatus(status)) { | ||
return; | ||
} | ||
const actionsDropdown = await testSubjects.find('statusDropdown'); | ||
await actionsDropdown.click(); | ||
const actionsMenuElem = await testSubjects.find('ruleStatusMenu'); | ||
const actionsMenuItemElem = await actionsMenuElem.findByTestSubject( | ||
'statusDropdown' + status + 'Item' | ||
); | ||
await actionsMenuItemElem.click(); | ||
await actionsDropdown.findByClassName('euiLoadingSpinner euiLoadingSpinner--small'); | ||
await retry.try(async () => { | ||
await this.getRulesList(); | ||
expect(await this.isStatus(status)).to.eql(true); | ||
}); | ||
}, | ||
|
||
async disableEnableRule() { | ||
await this.changeStatus('Disabled'); | ||
await this.changeStatus('Enabled'); | ||
const searchResults = await this.getRulesList(); | ||
expect(searchResults[0].lastResponse).to.equal('Pending'); | ||
await browser.refresh(); | ||
await pageObjects.header.waitUntilLoadingHasFinished(); | ||
}, | ||
}; | ||
} | ||
|
||
export const services = { | ||
rulesHelper: RulesHelper, | ||
}; |