Skip to content

Commit

Permalink
[Index Management] Test LogsDb Index Template Modifications (#206548)
Browse files Browse the repository at this point in the history
Part of #203716

## Summary
This PR introduces a new test case for LogsDB in both Stateful and
Serverless:

> Verify that users can override LogsDB index settings including:
ignore_above, ignore_malformed, ignore_dynamic_beyond_limit, subobjects
and timestamp format.

For modify `subobjects` and `timestamp` format it must be done from the
mappings tab. For `ignore_above`, `ignore_malformed`,
`ignore_dynamic_beyond_limit` the configuration is done in the Settings
tab.

It also introduces a test case only for Stateful
(enableMappingsSourceFieldSection [is
disabled](https://github.com/elastic/kibana/blob/9c6de6aabced9d180bf1d68ec42708c27e5616d6/config/serverless.yml#L112)
for serverless)

> Verify that users cannot disable synthetic source for a LogsDB index.
  • Loading branch information
SoniaSanzV authored Jan 17, 2025
1 parent 2067c84 commit 75e1866
Show file tree
Hide file tree
Showing 3 changed files with 296 additions and 47 deletions.
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

0 comments on commit 75e1866

Please sign in to comment.