Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] [Index Management] Test LogsDb Index Template Modifications (#206548) #207019

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ export const StepReview: React.FunctionComponent<Props> = React.memo(
defaultMessage: 'Request',
}),
content: <RequestTab />,
'data-test-subj': 'stepReviewRequestTab',
},
];

Expand All @@ -397,6 +398,7 @@ export const StepReview: React.FunctionComponent<Props> = React.memo(
defaultMessage: 'Preview',
}),
content: <PreviewTab template={template} />,
'data-test-subj': 'stepReviewPreviewTab',
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const testSubjects = getService('testSubjects');
const es = getService('es');

const INDEX_TEMPLATE_NAME = `test-index-template-name`;
const INDEX_TEMPLATE_NAME = 'index-template-test-name';

describe('Index template tab', function () {
before(async () => {
Expand All @@ -25,8 +25,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
// Navigate to the templates tab
await pageObjects.indexManagement.changeTabs('templatesTab');
await pageObjects.header.waitUntilLoadingHasFinished();
// Click create template button
await testSubjects.click('createTemplateButton');
});

afterEach(async () => {
Expand All @@ -36,48 +34,192 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await testSubjects.click('reloadButton');
});

it('can create an index template with data retention', async () => {
// Complete required fields from step 1
await testSubjects.setValue('nameField', INDEX_TEMPLATE_NAME);
await testSubjects.setValue('indexPatternsField', 'test-1');
// Enable data retention
await testSubjects.click('dataRetentionToggle > input');
// Set the retention to 7 hours
await testSubjects.setValue('valueDataRetentionField', '7');
await testSubjects.click('show-filters-button');
await testSubjects.click('filter-option-h');
// Navigate to the last step of the wizard
await testSubjects.click('formWizardStep-5');
await pageObjects.header.waitUntilLoadingHasFinished();
describe('index template creation', () => {
beforeEach(async () => {
// Click create template button
await testSubjects.click('createTemplateButton');
// Complete required fields from step 1
await testSubjects.setValue('nameField', INDEX_TEMPLATE_NAME);
await testSubjects.setValue('indexPatternsField', 'test-1');
});

afterEach(async () => {
// Click Create template
await pageObjects.indexManagement.clickNextButton();
// Close detail tab
await testSubjects.click('closeDetailsButton');
});

it('can create an index template with data retention', async () => {
// Enable data retention
await testSubjects.click('dataRetentionToggle > input');
// Set the retention to 7 hours
await testSubjects.setValue('valueDataRetentionField', '7');
await testSubjects.click('show-filters-button');
await testSubjects.click('filter-option-h');
// Navigate to the last step of the wizard
await testSubjects.click('formWizardStep-5');
await pageObjects.header.waitUntilLoadingHasFinished();

expect(await testSubjects.getVisibleText('lifecycleValue')).to.be('7 hours');
});

expect(await testSubjects.getVisibleText('lifecycleValue')).to.be('7 hours');
it('can create an index template with logsdb index mode', async () => {
// Modify index mode
await testSubjects.click('indexModeField');
await testSubjects.click('index_mode_logsdb');

// Click Create template
await pageObjects.indexManagement.clickNextButton();
// Close detail tab
await testSubjects.click('closeDetailsButton');
// Navigate to the last step of the wizard
await testSubjects.click('formWizardStep-5');
await pageObjects.header.waitUntilLoadingHasFinished();

expect(await testSubjects.exists('indexModeTitle')).to.be(true);
expect(await testSubjects.getVisibleText('indexModeValue')).to.be('LogsDB');
});
});

it('can create an index template with logsdb index mode', async () => {
await testSubjects.click('createTemplateButton');
// Fill out required fields
await testSubjects.setValue('nameField', INDEX_TEMPLATE_NAME);
await testSubjects.setValue('indexPatternsField', 'logsdb-test-index-pattern');
describe('index template modification', () => {
beforeEach(async () => {
await es.indices.putIndexTemplate({
name: INDEX_TEMPLATE_NAME,
index_patterns: ['logsdb-test-index-pattern'],
data_stream: {},
template: {
settings: {
index: {
mode: 'logsdb',
},
},
},
});

await testSubjects.click('indexModeField');
await testSubjects.click('index_mode_logsdb');
await testSubjects.click('reloadButton');
await pageObjects.indexManagement.clickIndexTemplateNameLink(INDEX_TEMPLATE_NAME);
await testSubjects.click('manageTemplateButton');
await testSubjects.click('editIndexTemplateButton');
await pageObjects.header.waitUntilLoadingHasFinished();
});

// Navigate to the last step of the wizard
await testSubjects.click('formWizardStep-5');
await pageObjects.header.waitUntilLoadingHasFinished();
afterEach(async () => {
if (await testSubjects.exists('closeDetailsButton')) {
// Close Flyout to return to templates tab
await testSubjects.click('closeDetailsButton');
} else {
// Comeback to templates tab
await pageObjects.common.navigateToApp('indexManagement');
await pageObjects.indexManagement.changeTabs('templatesTab');
}
});

it('can modify ignore_above, ignore_malformed, ignore_dynamic_beyond_limit, subobjects and timestamp format in an index template with logsdb index mode', async () => {
// Navigate to Index Settings
await testSubjects.click('formWizardStep-2');
await pageObjects.header.waitUntilLoadingHasFinished();

// Modify Index settings
await testSubjects.setValue(
'kibanaCodeEditor',
JSON.stringify({
index: {
mapping: {
ignore_above: '20',
total_fields: {
ignore_dynamic_beyond_limit: 'true',
},
ignore_malformed: 'true',
},
},
}),
{
clearWithKeyboard: true,
}
);

expect(await testSubjects.exists('indexModeTitle')).to.be(true);
expect(await testSubjects.getVisibleText('indexModeValue')).to.be('LogsDB');
// Navigate to Mappings
await testSubjects.click('formWizardStep-3');
await pageObjects.header.waitUntilLoadingHasFinished();
const mappingTabs = await testSubjects.findAll('formTab');
await mappingTabs[3].click();

// Click Create template
await pageObjects.indexManagement.clickNextButton();
// Close detail tab
await testSubjects.click('closeDetailsButton');
// Modify timestamp format
await testSubjects.click('comboBoxClearButton');
await testSubjects.setValue('comboBoxInput', 'basic_date');
await testSubjects.pressEnter('comboBoxInput');

// Modify subobjects
await testSubjects.click('subobjectsToggle');

// Navigate to the last step of the wizard
await testSubjects.click('formWizardStep-5');
await pageObjects.header.waitUntilLoadingHasFinished();

// Click Create template
await pageObjects.indexManagement.clickNextButton();
await pageObjects.header.waitUntilLoadingHasFinished();

const flyoutTabs = await testSubjects.findAll('tab');

// Verify Index Settings
await flyoutTabs[1].click();
await pageObjects.header.waitUntilLoadingHasFinished();
expect(await testSubjects.exists('settingsTabContent')).to.be(true);
const settingsTabContent = await testSubjects.getVisibleText('settingsTabContent');
expect(JSON.parse(settingsTabContent)).to.eql({
index: {
mode: 'logsdb',
mapping: {
ignore_above: '20',
total_fields: {
ignore_dynamic_beyond_limit: 'true',
},
ignore_malformed: 'true',
},
},
});

// Verify Mappings
await flyoutTabs[2].click();
await pageObjects.header.waitUntilLoadingHasFinished();
expect(await testSubjects.exists('mappingsTabContent')).to.be(true);
const mappingsTabContent = await testSubjects.getVisibleText('mappingsTabContent');
expect(JSON.parse(mappingsTabContent)).to.eql({
dynamic_date_formats: ['basic_date'],
_source: {
mode: 'synthetic',
},
subobjects: false,
});
});
describe('syntethic source', () => {
it('can not disable syntethic source in an index template with logsdb index mode', async () => {
// Navigate to Mappings
await testSubjects.click('formWizardStep-3');
await pageObjects.header.waitUntilLoadingHasFinished();
const mappingTabs = await testSubjects.findAll('formTab');
await mappingTabs[3].click();

// Modify source
await testSubjects.click('sourceValueField');
await testSubjects.click('disabledSourceFieldOption');

// Navigate to the last step of the wizard
await testSubjects.click('formWizardStep-5');
await pageObjects.header.waitUntilLoadingHasFinished();

// Click Create template
await pageObjects.indexManagement.clickNextButton();
await pageObjects.header.waitUntilLoadingHasFinished();

expect(await testSubjects.exists('saveTemplateError')).to.be(true);

await testSubjects.click('stepReviewPreviewTab');
await pageObjects.header.waitUntilLoadingHasFinished();
expect(await testSubjects.exists('simulateTemplatePreview')).to.be(true);
expect(await testSubjects.getVisibleText('simulateTemplatePreview')).to.contain(
'_source can not be disabled in index using [logsdb] index mode'
);
});
});
});
});
};
Loading
Loading