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

[Dataset Quality] Fix failing test on mki qa #196122

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b34b9f1
Fix refresh table breaking for summary
achyutjhunjhunwala Jun 21, 2024
d1fdaeb
Add timeout to find
achyutjhunjhunwala Jun 21, 2024
ac496c4
Merge branch 'elastic:main' into main
achyutjhunjhunwala Jun 21, 2024
12cad21
Merge branch 'elastic:main' into main
achyutjhunjhunwala Jun 21, 2024
db7d63b
Revert "Add timeout to find"
achyutjhunjhunwala Jun 21, 2024
c3a2774
Revert "Fix refresh table breaking for summary"
achyutjhunjhunwala Jun 21, 2024
9ba8128
Merge branch 'elastic:main' into main
achyutjhunjhunwala Jun 24, 2024
425cdb4
Merge branch 'elastic:main' into main
achyutjhunjhunwala Jun 25, 2024
a5ccc32
Merge branch 'elastic:main' into main
achyutjhunjhunwala Jun 26, 2024
1ab7806
Merge branch 'elastic:main' into main
achyutjhunjhunwala Jul 1, 2024
abad280
Merge branch 'elastic:main' into main
achyutjhunjhunwala Jul 3, 2024
14a3620
Merge branch 'elastic:main' into main
achyutjhunjhunwala Jul 5, 2024
0dd0eb1
Merge branch 'elastic:main' into main
achyutjhunjhunwala Jul 9, 2024
2dd64cc
Merge branch 'elastic:main' into main
achyutjhunjhunwala Jul 22, 2024
3833283
Merge branch 'elastic:main' into main
achyutjhunjhunwala Jul 23, 2024
a1a1ce1
Merge branch 'elastic:main' into main
achyutjhunjhunwala Jul 25, 2024
6278a51
Merge branch 'elastic:main' into main
achyutjhunjhunwala Aug 9, 2024
14161a3
Merge branch 'elastic:main' into main
achyutjhunjhunwala Aug 13, 2024
2df6d10
Merge branch 'elastic:main' into main
achyutjhunjhunwala Aug 13, 2024
99d8084
Merge branch 'elastic:main' into main
achyutjhunjhunwala Aug 13, 2024
28e789c
Merge branch 'elastic:main' into main
achyutjhunjhunwala Aug 14, 2024
59fc802
Merge branch 'elastic:main' into main
achyutjhunjhunwala Aug 27, 2024
dec1cae
Merge branch 'elastic:main' into main
achyutjhunjhunwala Aug 27, 2024
33c0c60
Merge branch 'elastic:main' into main
achyutjhunjhunwala Sep 4, 2024
6f5c1c6
Merge branch 'elastic:main' into main
achyutjhunjhunwala Sep 5, 2024
fbf7d08
Merge branch 'elastic:main' into main
achyutjhunjhunwala Sep 6, 2024
55d1cff
Merge branch 'elastic:main' into main
achyutjhunjhunwala Sep 17, 2024
73ae28d
Merge branch 'elastic:main' into main
achyutjhunjhunwala Sep 26, 2024
b475502
Merge branch 'elastic:main' into main
achyutjhunjhunwala Oct 3, 2024
53e9a19
Merge branch 'elastic:main' into main
achyutjhunjhunwala Oct 7, 2024
ddb587a
Merge branch 'elastic:main' into main
achyutjhunjhunwala Oct 9, 2024
a3cb5cc
Merge branch 'elastic:main' into main
achyutjhunjhunwala Oct 14, 2024
60ebd22
Fix mapping issue with logs db on mki
achyutjhunjhunwala Oct 14, 2024
07412cc
Fix mapping issue with logs db on mki for FTR tests
achyutjhunjhunwala Oct 14, 2024
b35cc0b
Fix mapping issue with logs db on mki for FTR tests for stateful
achyutjhunjhunwala Oct 14, 2024
74d6a6b
Merge branch 'main' into fix-failing-test-on-mki-qa
achyutjhunjhunwala Oct 14, 2024
68889cb
Remove skip on MKI tag
achyutjhunjhunwala Oct 14, 2024
42b8347
Merge branch 'main' into fix-failing-test-on-mki-qa
achyutjhunjhunwala Oct 14, 2024
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 @@ -48,6 +48,33 @@ export class LogsSynthtraceEsClient extends SynthtraceEsClient<LogDocument> {
}
}

async createComponentTemplate(name: string, mappings: MappingTypeMapping) {
const isTemplateExisting = await this.client.cluster.existsComponentTemplate({ name });

if (isTemplateExisting) return this.logger.info(`Component template already exists: ${name}`);

try {
await this.client.cluster.putComponentTemplate({
name,
template: {
mappings,
},
});
this.logger.info(`Component template successfully created: ${name}`);
} catch (err) {
this.logger.error(`Component template creation failed: ${name} - ${err.message}`);
}
Comment on lines +56 to +66
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to continue with test run when component template does not exist/failed to create?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well The only use case, where they will fail to create, would be either a Network issue or User roles and right issue. In that case, the test would fail.

Copy link
Member

@dmlemeshko dmlemeshko Oct 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is required by test to exist, I suggest throwing an error instead of just logging it. Thoughts?

}

async deleteComponentTemplate(name: string) {
try {
await this.client.cluster.deleteComponentTemplate({ name });
this.logger.info(`Component template successfully deleted: ${name}`);
} catch (err) {
this.logger.error(`Component template deletion failed: ${name} - ${err.message}`);
}
dmlemeshko marked this conversation as resolved.
Show resolved Hide resolved
}

async createIndex(index: string, mappings?: MappingTypeMapping) {
try {
const isIndexExisting = await this.client.indices.exists({ index });
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
* 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 { MappingTypeMapping } from '@elastic/elasticsearch/lib/api/types';

export const logsSynthMappings = (dataset: string): MappingTypeMapping => ({
properties: {
'@timestamp': {
type: 'date',
ignore_malformed: false,
},
data_stream: {
properties: {
dataset: {
type: 'constant_keyword',
value: dataset,
},
namespace: {
type: 'constant_keyword',
value: 'default',
},
type: {
type: 'constant_keyword',
value: 'logs',
},
},
},
event: {
properties: {
dataset: {
type: 'keyword',
ignore_above: 1024,
},
},
},
host: {
properties: {
name: {
type: 'keyword',
fields: {
text: {
type: 'match_only_text',
},
},
},
},
},
input: {
properties: {
type: {
type: 'keyword',
ignore_above: 1024,
},
},
},
log: {
properties: {
file: {
properties: {
path: {
type: 'keyword',
fields: {
text: {
type: 'match_only_text',
},
},
},
},
},
},
},
message: {
type: 'match_only_text',
},
network: {
properties: {
bytes: {
type: 'long',
},
},
},
service: {
properties: {
name: {
type: 'keyword',
fields: {
text: {
type: 'match_only_text',
},
},
},
},
},
test_field: {
type: 'keyword',
ignore_above: 1024,
},
tls: {
properties: {
established: {
type: 'boolean',
},
},
},
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { log, timerange } from '@kbn/apm-synthtrace-client';
import { SupertestWithRoleScopeType } from '../../../services';
import { DeploymentAgnosticFtrProviderContext } from '../../../ftr_provider_context';
import { createBackingIndexNameWithoutVersion, setDataStreamSettings } from './es_utils';
import { logsSynthMappings } from './custom_mappings/custom_synth_mappings';

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?';
Expand All @@ -27,6 +28,8 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
const hostName = 'synth-host';
const dataStreamName = `${type}-${dataset}-${namespace}`;

const customComponentTemplateName = 'logs-synth@mappings';

async function callApiAs({
roleScopedSupertestWithCookieCredentials,
apiParams: { dataStream, degradedField, lastBackingIndex },
Expand All @@ -46,8 +49,6 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
}

describe('Degraded field analyze', function () {
// see details: https://github.com/elastic/kibana/issues/195466
this.tags(['failsOnMKI']);
let supertestAdminWithCookieCredentials: SupertestWithRoleScopeType;

before(async () => {
Expand All @@ -62,6 +63,29 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {

describe('gets limit analysis for a given datastream and degraded field', () => {
before(async () => {
await synthtrace.createComponentTemplate(
customComponentTemplateName,
logsSynthMappings(dataset)
);
await esClient.indices.putIndexTemplate({
name: dataStreamName,
_meta: {
managed: false,
description: 'custom synth template created by synthtrace tool.',
},
priority: 500,
index_patterns: [dataStreamName],
composed_of: [
customComponentTemplateName,
'logs@mappings',
'logs@settings',
'ecs@mappings',
],
allow_auto_create: true,
data_stream: {
hidden: false,
},
});
await synthtrace.index([
timerange(start, end)
.interval('1m')
Expand Down Expand Up @@ -153,6 +177,8 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {

after(async () => {
await synthtrace.clean();
await esClient.indices.deleteIndexTemplate({ name: dataStreamName });
await synthtrace.deleteComponentTemplate(customComponentTemplateName);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
* 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 { MappingTypeMapping } from '@elastic/elasticsearch/lib/api/types';

export const logsSynthMappings = (dataset: string): MappingTypeMapping => ({
properties: {
'@timestamp': {
type: 'date',
ignore_malformed: false,
},
data_stream: {
properties: {
dataset: {
type: 'constant_keyword',
value: 'degraded.dataset.rca',
},
namespace: {
type: 'constant_keyword',
value: 'default',
},
type: {
type: 'constant_keyword',
value: 'logs',
},
},
},
event: {
properties: {
dataset: {
type: 'keyword',
ignore_above: 1024,
},
},
},
host: {
properties: {
name: {
type: 'keyword',
fields: {
text: {
type: 'match_only_text',
},
},
},
},
},
input: {
properties: {
type: {
type: 'keyword',
ignore_above: 1024,
},
},
},
log: {
properties: {
level: {
type: 'keyword',
ignore_above: 1024,
},
},
},
message: {
type: 'match_only_text',
},
network: {
properties: {
bytes: {
type: 'long',
},
},
},
service: {
properties: {
name: {
type: 'keyword',
fields: {
text: {
type: 'match_only_text',
},
},
},
},
},
test_field: {
type: 'keyword',
ignore_above: 1024,
},
tls: {
properties: {
established: {
type: 'boolean',
},
},
},
trace: {
properties: {
id: {
type: 'keyword',
ignore_above: 1024,
},
},
},
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import { generateShortId, log, timerange } from '@kbn/apm-synthtrace-client';
import { DatasetQualityFtrProviderContext } from './config';
import {
createDegradedFieldsRecord,
datasetNames,
defaultNamespace,
getInitialTestLogs,
ANOTHER_1024_CHARS,
MORE_THAN_1024_CHARS,
} from './data';
import { logsSynthMappings } from './custom_mappings/custom_synth_mappings';

export default function ({ getService, getPageObjects }: DatasetQualityFtrProviderContext) {
const PageObjects = getPageObjects([
Expand All @@ -27,15 +27,17 @@ export default function ({ getService, getPageObjects }: DatasetQualityFtrProvid
]);
const testSubjects = getService('testSubjects');
const synthtrace = getService('logSynthtraceEsClient');
const esClient = getService('es');
const retry = getService('retry');
const to = new Date().toISOString();
const degradedDatasetName = datasetNames[2];
const degradedDatasetName = 'synth.degraded';
const degradedDataStreamName = `logs-${degradedDatasetName}-${defaultNamespace}`;

const degradedDatasetWithLimitsName = 'degraded.dataset.rca';
const degradedDatasetWithLimitsName = 'synth.degraded.rca';
const degradedDatasetWithLimitDataStreamName = `logs-${degradedDatasetWithLimitsName}-${defaultNamespace}`;
const serviceName = 'test_service';
const count = 5;
const customComponentTemplateName = 'logs-synth@mappings';

describe('Degraded fields flyout', () => {
before(async () => {
Expand Down Expand Up @@ -114,6 +116,32 @@ export default function ({ getService, getPageObjects }: DatasetQualityFtrProvid

describe('testing root cause for ignored fields', () => {
before(async () => {
// Create custom component template
await synthtrace.createComponentTemplate(
customComponentTemplateName,
logsSynthMappings(degradedDatasetWithLimitsName)
);

// Create custom index template
await esClient.indices.putIndexTemplate({
name: degradedDatasetWithLimitDataStreamName,
_meta: {
managed: false,
description: 'custom synth template created by synthtrace tool.',
},
priority: 500,
index_patterns: [degradedDatasetWithLimitDataStreamName],
composed_of: [
customComponentTemplateName,
'logs@mappings',
'logs@settings',
'ecs@mappings',
],
allow_auto_create: true,
data_stream: {
hidden: false,
},
});
// Ingest Degraded Logs with 25 fields
await synthtrace.index([
timerange(moment(to).subtract(count, 'minute'), moment(to))
Expand Down Expand Up @@ -413,6 +441,10 @@ export default function ({ getService, getPageObjects }: DatasetQualityFtrProvid

after(async () => {
await synthtrace.clean();
await esClient.indices.deleteIndexTemplate({
name: degradedDatasetWithLimitDataStreamName,
});
await synthtrace.deleteComponentTemplate(customComponentTemplateName);
});
});
});
Expand Down
Loading