Skip to content

Commit

Permalink
Add more FTRs
Browse files Browse the repository at this point in the history
  • Loading branch information
ElenaStoeva committed Dec 19, 2024
1 parent 06012ca commit 429e891
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,42 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const security = getService('security');
const testSubjects = getService('testSubjects');

const TEST_DS_NAME = 'test-ds-1';
const TEST_DS_NAME_1 = 'test-ds-1';
const TEST_DS_NAME_2 = 'test-ds-2';
const TEST_DATA_STREAM_NAMES = [TEST_DS_NAME_1, TEST_DS_NAME_2];

describe('Data streams tab', function () {
before(async () => {
await log.debug('Creating required data stream');
try {
await es.indices.putIndexTemplate({
name: `${TEST_DS_NAME}_index_template`,
index_patterns: [TEST_DS_NAME],
data_stream: {},
_meta: {
description: `Template for ${TEST_DS_NAME} testing index`,
},
template: {
settings: { mode: undefined },
mappings: {
properties: {
'@timestamp': {
type: 'date',
for (const dataStreamName of TEST_DATA_STREAM_NAMES) {
await es.indices.putIndexTemplate({
name: `${dataStreamName}_index_template`,
index_patterns: [dataStreamName],
data_stream: {},
_meta: {
description: `Template for ${dataStreamName} testing index`,
},
template: {
settings: { mode: undefined },
mappings: {
properties: {
'@timestamp': {
type: 'date',
},
},
},
lifecycle: {
// @ts-expect-error @elastic/elasticsearch enabled prop is not typed yet
enabled: true,
},
},
lifecycle: {
// @ts-expect-error @elastic/elasticsearch enabled prop is not typed yet
enabled: true,
},
},
});
});

await es.indices.createDataStream({
name: TEST_DS_NAME,
});
await es.indices.createDataStream({
name: dataStreamName,
});
}
} catch (e) {
log.debug('[Setup error] Error creating test data stream');
throw e;
Expand All @@ -66,10 +70,12 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await log.debug('Cleaning up created data stream');

try {
await es.indices.deleteDataStream({ name: TEST_DS_NAME });
await es.indices.deleteIndexTemplate({
name: `${TEST_DS_NAME}_index_template`,
});
for (const dataStreamName of TEST_DATA_STREAM_NAMES) {
await es.indices.deleteDataStream({ name: dataStreamName });
await es.indices.deleteIndexTemplate({
name: `${dataStreamName}_index_template`,
});
}
} catch (e) {
log.debug('[Teardown error] Error deleting test data stream');
throw e;
Expand All @@ -78,10 +84,10 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {

it('shows the details flyout when clicking on a data stream', async () => {
// Open details flyout
await pageObjects.indexManagement.clickDataStreamNameLink(TEST_DS_NAME);
await pageObjects.indexManagement.clickDataStreamNameLink(TEST_DS_NAME_1);
// Verify url is stateful
const url = await browser.getCurrentUrl();
expect(url).to.contain(`/data_streams/${TEST_DS_NAME}`);
expect(url).to.contain(`/data_streams/${TEST_DS_NAME_1}`);
// Assert that flyout is opened
expect(await testSubjects.exists('dataStreamDetailPanel')).to.be(true);
// Close flyout
Expand All @@ -91,7 +97,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
describe('shows the correct index mode in the details flyout', function () {
it('standard index mode', async () => {
// Open details flyout of existing data stream - it has standard index mode
await pageObjects.indexManagement.clickDataStreamNameLink(TEST_DS_NAME);
await pageObjects.indexManagement.clickDataStreamNameLink(TEST_DS_NAME_1);
// Check that index mode detail exists and its label is "Standard"
expect(await testSubjects.exists('indexModeDetail')).to.be(true);
expect(await testSubjects.getVisibleText('indexModeDetail')).to.be('Standard');
Expand Down Expand Up @@ -129,44 +135,94 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
});
});

it('allows to update data retention', async () => {
// Open details flyout
await pageObjects.indexManagement.clickDataStreamNameLink(TEST_DS_NAME);
// Open the edit retention dialog
await testSubjects.click('manageDataStreamButton');
await testSubjects.click('editDataRetentionButton');

// Disable infinite retention
await testSubjects.click('infiniteRetentionPeriod > input');
// Set the retention to 7 hours
await testSubjects.setValue('dataRetentionValue', '7');
await testSubjects.click('show-filters-button');
await testSubjects.click('filter-option-h');

// Submit the form
await testSubjects.click('saveButton');

// Expect to see a success toast
const successToast = await toasts.getElementByIndex(1);
expect(await successToast.getVisibleText()).to.contain('Data retention updated');
});
describe('data retention modal', function () {
describe('from details panel', function () {
it('allows to update data retention', async () => {
// Open details flyout
await pageObjects.indexManagement.clickDataStreamNameLink(TEST_DS_NAME_1);
// Open the edit retention dialog
await testSubjects.click('manageDataStreamButton');
await testSubjects.click('editDataRetentionButton');

// Disable infinite retention
await testSubjects.click('infiniteRetentionPeriod > input');
// Set the retention to 7 hours
await testSubjects.setValue('dataRetentionValue', '7');
await testSubjects.click('show-filters-button');
await testSubjects.click('filter-option-h');

// Submit the form
await testSubjects.click('saveButton');

// Expect to see a success toast
const successToast = await toasts.getElementByIndex(1);
expect(await successToast.getVisibleText()).to.contain('Data retention updated');
// Clear up toasts for next test
await toasts.dismissAll();
});

it('allows to disable data retention', async () => {
// Open details flyout
await pageObjects.indexManagement.clickDataStreamNameLink(TEST_DS_NAME);
// Open the edit retention dialog
await testSubjects.click('manageDataStreamButton');
await testSubjects.click('editDataRetentionButton');
it('allows to disable data retention', async () => {
// Open details flyout
await pageObjects.indexManagement.clickDataStreamNameLink(TEST_DS_NAME_1);
// Open the edit retention dialog
await testSubjects.click('manageDataStreamButton');
await testSubjects.click('editDataRetentionButton');

// Disable infinite retention
await testSubjects.click('dataRetentionEnabledField > input');
// Disable infinite retention
await testSubjects.click('dataRetentionEnabledField > input');

// Submit the form
await testSubjects.click('saveButton');
// Submit the form
await testSubjects.click('saveButton');

// Expect to see a success toast
const successToast = await toasts.getElementByIndex(1);
expect(await successToast.getVisibleText()).to.contain('Data retention disabled');
// Expect to see a success toast
const successToast = await toasts.getElementByIndex(1);
expect(await successToast.getVisibleText()).to.contain('Data retention disabled');
// Clear up toasts for next test
await toasts.dismissAll();
});
});

describe('bulk edit modal', function () {
it('allows to update data retention', async () => {
// Select and manage mutliple data streams
await pageObjects.indexManagement.clickBulkEditDataRetention(TEST_DATA_STREAM_NAMES);

// Set the retention to 7 hours
await testSubjects.setValue('dataRetentionValue', '7');
await testSubjects.click('show-filters-button');
await testSubjects.click('filter-option-h');

// Submit the form
await testSubjects.click('saveButton');

// Expect to see a success toast
const successToast = await toasts.getElementByIndex(1);
expect(await successToast.getVisibleText()).to.contain(
'Data retention has been updated for 2 data streams.'
);
// Clear up toasts for next test
await toasts.dismissAll();
});

it('allows to disable data retention', async () => {
// Select and manage mutliple data streams
await pageObjects.indexManagement.clickBulkEditDataRetention(TEST_DATA_STREAM_NAMES);

// Disable infinite retention
await testSubjects.click('dataRetentionEnabledField > input');

// Submit the form
await testSubjects.click('saveButton');

// Expect to see a success toast
const successToast = await toasts.getElementByIndex(1);
expect(await successToast.getVisibleText()).to.contain(
'Data retention has been updated for 2 data streams.'
);
// Clear up toasts for next test
await toasts.dismissAll();
});
});
});
});
};
11 changes: 11 additions & 0 deletions x-pack/test/functional/page_objects/index_management_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ export function IndexManagementPageProvider({ getService }: FtrProviderContext)
await policyDetailsLinks[indexOfRow].click();
},

async clickBulkEditDataRetention(dataStreamNames: string[]): Promise<void> {
for (const dsName of dataStreamNames) {
const checkbox = await testSubjects.find(`checkboxSelectRow-${dsName}`);
if (!(await checkbox.isSelected())) {
await checkbox.click();
}
}
await testSubjects.click('dataStreamActionsPopoverButton');
await testSubjects.click('bulkEditDataRetentionButton');
},

async clickDataStreamNameLink(name: string): Promise<void> {
await find.clickByLinkText(name);
},
Expand Down

0 comments on commit 429e891

Please sign in to comment.