mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
# Backport This will backport the following commits from `main` to `8.18`: - [[Dataset Quality] Fix brittle test which was failing in the midnight job (#216260)](https://github.com/elastic/kibana/pull/216260) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Achyut Jhunjhunwala","email":"achyut.jhunjhunwala@elastic.co"},"sourceCommit":{"committedDate":"2025-03-28T15:13:05Z","message":"[Dataset Quality] Fix brittle test which was failing in the midnight job (#216260)\n\nThis PR fixes a bug where the test would run at midnight and due to the\nodd timing, the index which gets created is asserted for a different\ndate than expected.\n\nWith this fix, we don't check the complete index name now by replacing\nthe date assertion part with startWith and endsWith assertions.","sha":"0f0ee3a0b8be0182e136f4bb75765d469917ee3b","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","backport:prev-major","Feature:Dataset Health","v9.1.0","Team:Obs UX Logs"],"title":"[Dataset Quality] Fix brittle test which was failing in the midnight job","number":216260,"url":"https://github.com/elastic/kibana/pull/216260","mergeCommit":{"message":"[Dataset Quality] Fix brittle test which was failing in the midnight job (#216260)\n\nThis PR fixes a bug where the test would run at midnight and due to the\nodd timing, the index which gets created is asserted for a different\ndate than expected.\n\nWith this fix, we don't check the complete index name now by replacing\nthe date assertion part with startWith and endsWith assertions.","sha":"0f0ee3a0b8be0182e136f4bb75765d469917ee3b"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/216260","number":216260,"mergeCommit":{"message":"[Dataset Quality] Fix brittle test which was failing in the midnight job (#216260)\n\nThis PR fixes a bug where the test would run at midnight and due to the\nodd timing, the index which gets created is asserted for a different\ndate than expected.\n\nWith this fix, we don't check the complete index name now by replacing\nthe date assertion part with startWith and endsWith assertions.","sha":"0f0ee3a0b8be0182e136f4bb75765d469917ee3b"}}]}] BACKPORT--> Co-authored-by: Achyut Jhunjhunwala <achyut.jhunjhunwala@elastic.co>
This commit is contained in:
parent
24c65a5dcc
commit
15b5519963
3 changed files with 8 additions and 73 deletions
|
@ -11,7 +11,7 @@ import expect from '@kbn/expect';
|
|||
import { DegradedField } from '@kbn/dataset-quality-plugin/common/api_types';
|
||||
import { DeploymentAgnosticFtrProviderContext } from '../../../ftr_provider_context';
|
||||
import { SupertestWithRoleScopeType } from '../../../services';
|
||||
import { rolloverDataStream, createBackingIndexNameWithoutVersion } from './utils';
|
||||
import { rolloverDataStream } from './utils';
|
||||
|
||||
const MORE_THAN_1024_CHARS =
|
||||
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?';
|
||||
|
@ -178,20 +178,15 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
|
|||
(dFields: DegradedField) => dFields.name === 'trace.id'
|
||||
)?.indexFieldWasLastPresentIn;
|
||||
|
||||
expect(logLevelLastBackingIndex).to.be(
|
||||
`${createBackingIndexNameWithoutVersion({
|
||||
type,
|
||||
dataset: degradedFieldDataset,
|
||||
namespace,
|
||||
})}-000002`
|
||||
const logLevelRegex = new RegExp(
|
||||
`^\\.ds-${type}-${degradedFieldDataset}-${namespace}.*-000002$`
|
||||
);
|
||||
expect(traceIdLastBackingIndex).to.be(
|
||||
`${createBackingIndexNameWithoutVersion({
|
||||
type,
|
||||
dataset: degradedFieldDataset,
|
||||
namespace,
|
||||
})}-000001`
|
||||
expect(logLevelLastBackingIndex?.match(logLevelRegex)).to.not.be(null);
|
||||
|
||||
const traceIdRegex = new RegExp(
|
||||
`^\\.ds-${type}-${degradedFieldDataset}-${namespace}.*-000001$`
|
||||
);
|
||||
expect(traceIdLastBackingIndex?.match(traceIdRegex)).to.not.be(null);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { Client } from '@elastic/elasticsearch';
|
||||
import { IndicesIndexSettings } from '@elastic/elasticsearch/lib/api/types';
|
||||
|
||||
export async function rolloverDataStream(es: Client, name: string) {
|
||||
return es.indices.rollover({ alias: name });
|
||||
}
|
||||
|
||||
export async function getDataStreamSettingsOfEarliestIndex(es: Client, name: string) {
|
||||
const matchingIndexesObj = await es.indices.getSettings({ index: name });
|
||||
|
||||
const matchingIndexes = Object.keys(matchingIndexesObj ?? {});
|
||||
matchingIndexes.sort((a, b) => {
|
||||
return (
|
||||
Number(matchingIndexesObj[a].settings?.index?.creation_date) -
|
||||
Number(matchingIndexesObj[b].settings?.index?.creation_date)
|
||||
);
|
||||
});
|
||||
|
||||
return matchingIndexesObj[matchingIndexes[0]].settings;
|
||||
}
|
||||
|
||||
function getCurrentDateFormatted() {
|
||||
const date = new Date();
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
|
||||
return `${year}.${month}.${day}`;
|
||||
}
|
||||
|
||||
export function createBackingIndexNameWithoutVersion({
|
||||
type,
|
||||
dataset,
|
||||
namespace = 'default',
|
||||
}: {
|
||||
type: string;
|
||||
dataset: string;
|
||||
namespace: string;
|
||||
}) {
|
||||
return `.ds-${type}-${dataset}-${namespace}-${getCurrentDateFormatted()}`;
|
||||
}
|
||||
|
||||
export async function setDataStreamSettings(
|
||||
esClient: Client,
|
||||
name: string,
|
||||
settings: IndicesIndexSettings
|
||||
) {
|
||||
return esClient.indices.putSettings({
|
||||
index: name,
|
||||
settings,
|
||||
});
|
||||
}
|
|
@ -6,4 +6,3 @@
|
|||
*/
|
||||
|
||||
export { expectToReject } from './expect_to_reject';
|
||||
export * from './data_stream';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue