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

[Fleet] Throw when enabling TDSB on an incompatible datastream #148540

Closed
Closed
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 @@ -93,7 +93,7 @@ describe('experimental_datastream_features', () => {
esClient.cluster.getComponentTemplate.mockClear();
esClient.cluster.putComponentTemplate.mockClear();

esClient.cluster.getComponentTemplate.mockResolvedValueOnce({
esClient.cluster.getComponentTemplate.mockResolvedValue({
component_templates: [
{
name: 'metrics-test.test@package',
Expand Down Expand Up @@ -194,6 +194,58 @@ describe('experimental_datastream_features', () => {
})
);
});

it('should throw for tdsb option without dimension fields', async () => {
esClient.cluster.getComponentTemplate.mockResolvedValue({
component_templates: [
{
name: 'metrics-test.test@package',
component_template: {
template: {
settings: {},
mappings: {
_source: {
mode: 'stored',
},
properties: {
test: {
type: 'keyword',
},
},
},
},
},
},
],
});

const packagePolicy = getNewTestPackagePolicy({
isSyntheticSourceEnabled: false,
isTSDBEnabled: true,
});

esClient.indices.getIndexTemplate.mockResolvedValueOnce({
index_templates: [
{
name: 'metrics-test.test',
index_template: {
template: {
settings: {},
mappings: {},
},
composed_of: [],
index_patterns: '',
},
},
],
});

expect(() =>
handleExperimentalDatastreamFeatureOptIn({ soClient, esClient, packagePolicy })
).rejects.toThrowError(
/Unable to enable time-series indexing, at least one dimension field needs to be defined./
);
});
});

describe('when package policy exists (update)', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ export async function handleExperimentalDatastreamFeatureOptIn({
// Temporarily generating routing_path here until fixed in elasticsearch https://github.com/elastic/elasticsearch/issues/91592
const routingPath = builRoutingPath(mappingsProperties);

if (routingPath.length === 0) continue;
if (routingPath.length === 0) {
throw new Error(
'Unable to enable time-series indexing, at least one dimension field needs to be defined.'
);
}

const indexTemplateRes = await esClient.indices.getIndexTemplate({
name: featureMapEntry.data_stream,
Expand Down