Skip to content

Commit

Permalink
setup/teardown to support datastreams
Browse files Browse the repository at this point in the history
  • Loading branch information
klacabane committed Dec 21, 2021
1 parent 15eb061 commit 0d69c42
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions x-pack/test/functional/apps/monitoring/_get_lifecycle_methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,24 @@
export const getLifecycleMethods = (getService, getPageObjects) => {
const esArchiver = getService('esArchiver');
const security = getService('security');
const client = getService('es');
const PageObjects = getPageObjects(['monitoring', 'timePicker', 'security', 'common']);
let _archive;

const deleteDataStream = async (index) => {
await client.transport.request(
{
method: 'DELETE',
path: `_data_stream/${index}`,
},
{
ignore: [404],
}
);
};

return {
async setup(archive, { from, to, useSuperUser = false }) {
async setup(archive, { from, to, useSuperUser = false, useCreate = false }) {
_archive = archive;
if (!useSuperUser) {
await security.testUser.setRoles(['monitoring_user', 'kibana_admin', 'test_monitoring']);
Expand All @@ -24,7 +37,7 @@ export const getLifecycleMethods = (getService, getPageObjects) => {
// provide extra height for the page and avoid clusters sending telemetry during tests
await browser.setWindowSize(1600, 1000);

await esArchiver.load(archive);
await esArchiver.load(archive, { useCreate });
await kibanaServer.uiSettings.replace({});

await PageObjects.common.navigateToApp('monitoring');
Expand All @@ -37,6 +50,7 @@ export const getLifecycleMethods = (getService, getPageObjects) => {
},

async tearDown() {
await deleteDataStream('.monitoring-*-8-*');
await security.testUser.restoreDefaults();
return esArchiver.unload(_archive);
},
Expand Down

0 comments on commit 0d69c42

Please sign in to comment.