update test data

This commit is contained in:
weiwang 2023-02-28 12:12:16 -05:00
parent 445deb9a7c
commit 94b7a29947
5 changed files with 368 additions and 365 deletions

View file

@ -22,6 +22,8 @@ export default ({ getService }: FtrProviderContext) => {
const config = getService('config');
const kibanaServerUrl = formatUrl(config.get('servers.kibana'));
const index = 'cluster-apm-filebeat-6.8.6-aws-eu-west-1-2021.12.21*';
const clickTime = 1640097150000;
const minTime = 1640077200000;
const maxTime = 1640112300000;
@ -39,80 +41,80 @@ export default ({ getService }: FtrProviderContext) => {
deviationMin,
start: minTime,
end: maxTime,
index: 'cluster-apm-filebeat-6.8.6-aws-eu-west-1-2021.12.21*',
index: index,
searchQuery: '{"bool":{"filter":[],"must":[{"match_all":{}}],"must_not":[]}}',
timeFieldName: '@timestamp',
};
const expected = {
chunksLength: 179,
actionsLength: 178,
chunksLength: 170,
actionsLength: 170,
noIndexChunksLength: 4,
noIndexActionsLength: 3,
changePointFilter: 'add_change_points',
histogramFilter: 'add_change_points_histogram',
errorFilter: 'add_error',
changePointsLength: 47,
changePointsLength: 40,
changePoints: [
{
fieldName: 'beat.hostname.keyword',
fieldValue: 'ip-172-27-97-204',
doc_count: 12631,
bg_count: 30175,
doc_count: 12000,
bg_count: 30000,
},
{
fieldName: 'beat.name.keyword',
fieldValue: 'i-0852e3f99b6c512fd',
doc_count: 12631,
bg_count: 30175,
doc_count: 12000,
bg_count: 30000,
},
{
fieldName: 'docker.container.id.keyword',
fieldValue: 'aa5a7e792e226ccc4f7bbf34dc0e999e17b4f561fd36fbf746365bad5a8112f7',
doc_count: 12629,
bg_count: 30167,
doc_count: 12000,
bg_count: 30000,
},
{
fieldName: 'docker.container.id.keyword',
fieldValue: 'dc1e531f6598b1f828fc1ccc1939cfc1fceeebd23378fab8f1ba2e8133e53b21',
doc_count: 2220,
bg_count: 4072,
doc_count: 2000,
bg_count: 4000,
},
{
fieldName: 'docker.container.image.keyword',
fieldValue: 'docker.elastic.co/cloud-assets/apm:7.13.1-0',
doc_count: 2222,
bg_count: 4126,
doc_count: 2000,
bg_count: 4000,
},
{
fieldName: 'docker.container.image.keyword',
fieldValue: 'docker.elastic.co/cloud-assets/apm:7.9.0-0',
doc_count: 1505,
bg_count: 2166,
doc_count: 1400,
bg_count: 2000,
},
{
fieldName: 'docker.container.image.keyword',
fieldValue: 'docker.elastic.co/cloud-assets/apm:7.15.2-0',
doc_count: 14777,
bg_count: 37298,
doc_count: 14000,
bg_count: 37000,
},
{
fieldName: 'docker.container.labels.co.elastic.cloud.allocator.cluster_id.keyword',
fieldValue: 'eb3713439fcd4fdfa60e355f0e57afc0',
doc_count: 12629,
bg_count: 30167,
doc_count: 12000,
bg_count: 30000,
},
{
fieldName: 'docker.container.labels.co.elastic.cloud.allocator.cluster_id.keyword',
fieldValue: 'ab8b9d3989c54817a1cb4184b2ef6b41',
doc_count: 2295,
bg_count: 3998,
doc_count: 2100,
bg_count: 3800,
},
{
fieldName: 'docker.container.labels.co.elastic.cloud.allocator.cluster_id.keyword',
fieldValue: '596808a16dec4fc39413bf34b0a70240',
doc_count: 1505,
bg_count: 2166,
doc_count: 1400,
bg_count: 2000,
},
],
histogramLength: 20,
@ -138,9 +140,9 @@ export default ({ getService }: FtrProviderContext) => {
const chunks: string[] = resp.body.toString().split('\n');
expect(chunks.length).to.eql(
expect(chunks.length).to.above(
expected.chunksLength,
`Expected 'chunks.length' to be ${expected.chunksLength}, got ${chunks.length}.`
`Expected 'chunks.length' to above ${expected.chunksLength}, got ${chunks.length}.`
);
const lastChunk = chunks.pop();
@ -152,9 +154,10 @@ export default ({ getService }: FtrProviderContext) => {
data = chunks.map((c) => JSON.parse(c));
}).not.to.throwError();
expect(data.length).to.eql(
expect(data.length).to.above(
expected.actionsLength,
`Expected 'data.length' to be ${expected.actionsLength}, got ${data.length}.`
`Expected 'data.length' to above ${expected.actionsLength}, got ${data.length}.`
);
data.forEach((d) => {
expect(typeof d.type).to.be('string');
@ -172,9 +175,9 @@ export default ({ getService }: FtrProviderContext) => {
return a.fieldName > b.fieldName ? 1 : -1;
});
expect(changePoints.length).to.eql(
expect(changePoints.length).to.above(
expected.changePointsLength,
`Expected 'changePoints.length' to be ${expected.changePointsLength}, got ${changePoints.length}.`
`Expected 'changePoints.length' to above ${expected.changePointsLength}, got ${changePoints.length}.`
);
// changePoints.forEach((cp, index) => {
// const ecp = expected.changePoints[index];
@ -248,9 +251,9 @@ export default ({ getService }: FtrProviderContext) => {
// If streaming works correctly we should receive more than one chunk.
expect(chunkCounter).to.be.greaterThan(1);
expect(data.length).to.eql(
expect(data.length).to.above(
expected.actionsLength,
`Expected 'data.length' to be ${expected.actionsLength}, got ${data.length}.`
`Expected 'data.length' to above ${expected.actionsLength}, got ${data.length}.`
);
const addChangePointsActions = data.filter((d) => d.type === expected.changePointFilter);
@ -265,9 +268,9 @@ export default ({ getService }: FtrProviderContext) => {
return a.fieldName > b.fieldName ? 1 : -1;
});
expect(changePoints.length).to.eql(
expect(changePoints.length).to.above(
expected.changePointsLength,
`Expected 'changePoints.length' to be ${expected.changePointsLength}, got ${changePoints.length}.`
`Expected 'changePoints.length' to above ${expected.changePointsLength}, got ${changePoints.length}.`
);
// Check only up to 10 changePoints even if there's more
changePoints.slice(0, 9).forEach((cp, index) => {
@ -279,13 +282,13 @@ export default ({ getService }: FtrProviderContext) => {
`Expected changePoint width 'fieldName:${cp.fieldName}'/'fieldValue:${cp.fieldValue}' to not be undefined`
);
if (ecp !== undefined) {
expect(cp.doc_count).to.eql(
expect(cp.doc_count).to.above(
ecp.doc_count,
`Expected 'doc_count' to be ${ecp.doc_count}, got ${cp.doc_count}.`
`Expected 'doc_count' to above ${ecp.doc_count}, got ${cp.doc_count}.`
);
expect(cp.bg_count).to.eql(
expect(cp.bg_count).to.above(
ecp.bg_count,
`Expected 'bg_count' to be ${ecp.bg_count}, got ${cp.bg_count}.`
`Expected 'bg_count' to above ${ecp.bg_count}, got ${cp.bg_count}.`
);
}
});

View file

@ -12,20 +12,19 @@ import { USER } from '../../../../functional/services/ml/security_common';
import { COMMON_REQUEST_HEADERS } from '../../../../functional/services/ml/common_api';
export default ({ getService }: FtrProviderContext) => {
const esArchiver = getService('esArchiver');
const esSupertest = getService('esSupertest');
const supertest = getService('supertestWithoutAuth');
const ml = getService('ml');
const testDataList = [
{
testTitleSuffix: 'with 1 field, 1 agg, no split',
const index = 'iowa*';
const testData = {
user: USER.ML_POWERUSER,
requestBody: {
aggTypes: ['sum'],
duration: { start: 1325548800000, end: 1538092800000 },
fields: ['sale_dollars'],
index: 'iowa*',
index: index,
query: { bool: { must: [{ match_all: {} }] } },
timeField: 'date',
},
@ -33,17 +32,14 @@ export default ({ getService }: FtrProviderContext) => {
responseCode: 200,
responseBody: { name: '2d', ms: 172800000 },
},
},
];
};
describe('bucket span estimator', function () {
describe('Kibana data scenario - bucket span estimator', function () {
before(async () => {
await ml.testResources.setKibanaTimeZoneToUTC();
});
describe('with default settings', function () {
for (const testData of testDataList) {
it(`estimates the bucket span ${testData.testTitleSuffix}`, async () => {
it(`estimates the bucket span`, async () => {
const { body, status } = await supertest
.post('/api/ml/validate/estimate_bucket_span')
.auth(testData.user, ml.securityCommon.getPasswordForUser(testData.user))
@ -53,7 +49,5 @@ export default ({ getService }: FtrProviderContext) => {
expect(body).to.eql(testData.expected.responseBody);
});
}
});
});
};

View file

@ -8,7 +8,6 @@
import { FtrProviderContext } from '../../../ftr_provider_context';
export default function ({ getService, loadTestFile }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const ml = getService('ml');
describe('Machine Learning', function () {

View file

@ -15,324 +15,332 @@ export default ({ getService }: FtrProviderContext) => {
const supertest = getService('supertestWithoutAuth');
const transform = getService('transform');
const testData = {
user: USER.TRANSFORM_POWERUSER,
requestBody: {
query: { bool: { must: [{ match_all: {} }] } },
fields: [
{
fieldName: 'bottle_volume_ml',
type: 'number',
},
{
fieldName: 'city',
type: 'string',
},
{
fieldName: 'date',
type: 'date',
},
],
samplerShardSize: 5000,
},
expected: {
responseCode: 200,
responseBody: [
{
data: [
{
key: 0,
doc_count: 4971,
},
{
key: 471.05263157894734,
doc_count: 17445,
},
{
key: 942.1052631578947,
doc_count: 5023,
},
{
key: 1413.157894736842,
doc_count: 7174,
},
{
key: 1884.2105263157894,
doc_count: 2,
},
{
key: 2355.2631578947367,
doc_count: 7,
},
{
key: 2826.315789473684,
doc_count: 375,
},
{
key: 3297.368421052631,
doc_count: 0,
},
{
key: 3768.4210526315787,
doc_count: 0,
},
{
key: 4239.473684210526,
doc_count: 0,
},
{
key: 4710.526315789473,
doc_count: 0,
},
{
key: 5181.578947368421,
doc_count: 0,
},
{
key: 5652.631578947368,
doc_count: 2,
},
{
key: 6123.684210526316,
doc_count: 0,
},
{
key: 6594.736842105262,
doc_count: 0,
},
{
key: 7065.78947368421,
doc_count: 0,
},
{
key: 7536.8421052631575,
doc_count: 0,
},
{
key: 8007.894736842105,
doc_count: 0,
},
{
key: 8478.947368421052,
doc_count: 0,
},
{
key: 8950,
doc_count: 1,
},
],
interval: 471.05263157894734,
stats: [50, 9000],
type: 'numeric',
id: 'bottle_volume_ml',
},
{
type: 'ordinal',
cardinality: 378,
data: [
{
key: 'des moines',
doc_count: 3471,
},
{
key: 'cedar rapids',
doc_count: 1907,
},
{
key: 'davenport',
doc_count: 1414,
},
{
key: 'sioux city',
doc_count: 1347,
},
{
key: 'council bluffs',
doc_count: 1184,
},
{
key: 'ames',
doc_count: 1147,
},
{
key: 'west des moines',
doc_count: 996,
},
{
key: 'iowa city',
doc_count: 952,
},
{
key: 'waterloo',
doc_count: 880,
},
{
key: 'mason city',
doc_count: 748,
},
{
key: 'dubuque',
doc_count: 605,
},
{
key: 'ankeny',
doc_count: 577,
},
{
key: 'cedar falls',
doc_count: 571,
},
{
key: 'muscatine',
doc_count: 515,
},
{
key: 'coralville',
doc_count: 465,
},
{
key: 'marshalltown',
doc_count: 399,
},
{
key: 'newton',
doc_count: 378,
},
{
key: 'fort dodge',
doc_count: 339,
},
{
key: 'urbandale',
doc_count: 337,
},
{
key: 'clinton',
doc_count: 313,
},
],
id: 'city',
},
{
data: [
{
key_as_string: '11/07/2011',
key: 1320692210526.3157,
doc_count: 857,
},
{
key_as_string: '03/08/2012',
key: 1331173894736.842,
doc_count: 1680,
},
{
key_as_string: '07/07/2012',
key: 1341655578947.3684,
doc_count: 1646,
},
{
key_as_string: '11/05/2012',
key: 1352137263157.8948,
doc_count: 1689,
},
{
key_as_string: '03/07/2013',
key: 1362618947368.4211,
doc_count: 1617,
},
{
key_as_string: '07/06/2013',
key: 1373100631578.9473,
doc_count: 1666,
},
{
key_as_string: '11/04/2013',
key: 1383582315789.4736,
doc_count: 1670,
},
{
key_as_string: '03/06/2014',
key: 1394064000000,
doc_count: 1585,
},
{
key_as_string: '07/05/2014',
key: 1404545684210.5264,
doc_count: 1691,
},
{
key_as_string: '11/03/2014',
key: 1415027368421.0527,
doc_count: 1760,
},
{
key_as_string: '03/04/2015',
key: 1425509052631.5789,
doc_count: 1893,
},
{
key_as_string: '07/04/2015',
key: 1435990736842.1052,
doc_count: 1830,
},
{
key_as_string: '11/02/2015',
key: 1446472421052.6316,
doc_count: 1076,
},
{
key_as_string: '03/02/2016',
key: 1456954105263.158,
doc_count: 1981,
},
{
key_as_string: '07/02/2016',
key: 1467435789473.684,
doc_count: 636,
},
{
key_as_string: '10/31/2016',
key: 1477917473684.2104,
doc_count: 6086,
},
{
key_as_string: '03/01/2017',
key: 1488399157894.7368,
doc_count: 159,
},
{
key_as_string: '07/01/2017',
key: 1498880842105.2632,
doc_count: 319,
},
{
key_as_string: '10/30/2017',
key: 1509362526315.7896,
doc_count: 2077,
},
{
key_as_string: '02/28/2018',
key: 1519844210526.3157,
doc_count: 3082,
},
],
interval: 10481684210.526316,
stats: [1325548800000, 1524700800000],
type: 'numeric',
id: 'date',
},
],
},
};
const index = 'iowa*';
describe('/api/transform/field_histograms', function () {
const testData = {
user: USER.TRANSFORM_POWERUSER,
requestBody: {
query: { bool: { must: [{ match_all: {} }] } },
"fields": [
{
"fieldName": "bottle_volume_ml",
"type": "number"
},
{
"fieldName": "city",
"type": "string"
},
{
"fieldName": "date",
"type": "date"
}
],
"samplerShardSize": 5000,
},
expected: {
responseCode: 200,
responseBody: [
{
"data": [
{
"key": 0,
"doc_count": 4971
},
{
"key": 471.05263157894734,
"doc_count": 17445
},
{
"key": 942.1052631578947,
"doc_count": 5023
},
{
"key": 1413.157894736842,
"doc_count": 7174
},
{
"key": 1884.2105263157894,
"doc_count": 2
},
{
"key": 2355.2631578947367,
"doc_count": 7
},
{
"key": 2826.315789473684,
"doc_count": 375
},
{
"key": 3297.368421052631,
"doc_count": 0
},
{
"key": 3768.4210526315787,
"doc_count": 0
},
{
"key": 4239.473684210526,
"doc_count": 0
},
{
"key": 4710.526315789473,
"doc_count": 0
},
{
"key": 5181.578947368421,
"doc_count": 0
},
{
"key": 5652.631578947368,
"doc_count": 2
},
{
"key": 6123.684210526316,
"doc_count": 0
},
{
"key": 6594.736842105262,
"doc_count": 0
},
{
"key": 7065.78947368421,
"doc_count": 0
},
{
"key": 7536.8421052631575,
"doc_count": 0
},
{
"key": 8007.894736842105,
"doc_count": 0
},
{
"key": 8478.947368421052,
"doc_count": 0
},
{
"key": 8950,
"doc_count": 1
}
],
"interval": 471.05263157894734,
"stats": [
50,
9000
],
"type": "numeric",
"id": "bottle_volume_ml"
},
{
"type": "ordinal",
"cardinality": 378,
"data": [
{
"key": "des moines",
"doc_count": 3471
},
{
"key": "cedar rapids",
"doc_count": 1907
},
{
"key": "davenport",
"doc_count": 1414
},
{
"key": "sioux city",
"doc_count": 1347
},
{
"key": "council bluffs",
"doc_count": 1184
},
{
"key": "ames",
"doc_count": 1147
},
{
"key": "west des moines",
"doc_count": 996
},
{
"key": "iowa city",
"doc_count": 952
},
{
"key": "waterloo",
"doc_count": 880
},
{
"key": "mason city",
"doc_count": 748
},
{
"key": "dubuque",
"doc_count": 605
},
{
"key": "ankeny",
"doc_count": 577
},
{
"key": "cedar falls",
"doc_count": 571
},
{
"key": "muscatine",
"doc_count": 515
},
{
"key": "coralville",
"doc_count": 465
},
{
"key": "marshalltown",
"doc_count": 399
},
{
"key": "newton",
"doc_count": 378
},
{
"key": "fort dodge",
"doc_count": 339
},
{
"key": "urbandale",
"doc_count": 337
},
{
"key": "clinton",
"doc_count": 313
}
],
"id": "city"
},
{
"data": [
{
"key_as_string": "11/07/2011",
"key": 1320692210526.3157,
"doc_count": 857
},
{
"key_as_string": "03/08/2012",
"key": 1331173894736.842,
"doc_count": 1680
},
{
"key_as_string": "07/07/2012",
"key": 1341655578947.3684,
"doc_count": 1646
},
{
"key_as_string": "11/05/2012",
"key": 1352137263157.8948,
"doc_count": 1689
},
{
"key_as_string": "03/07/2013",
"key": 1362618947368.4211,
"doc_count": 1617
},
{
"key_as_string": "07/06/2013",
"key": 1373100631578.9473,
"doc_count": 1666
},
{
"key_as_string": "11/04/2013",
"key": 1383582315789.4736,
"doc_count": 1670
},
{
"key_as_string": "03/06/2014",
"key": 1394064000000,
"doc_count": 1585
},
{
"key_as_string": "07/05/2014",
"key": 1404545684210.5264,
"doc_count": 1691
},
{
"key_as_string": "11/03/2014",
"key": 1415027368421.0527,
"doc_count": 1760
},
{
"key_as_string": "03/04/2015",
"key": 1425509052631.5789,
"doc_count": 1893
},
{
"key_as_string": "07/04/2015",
"key": 1435990736842.1052,
"doc_count": 1830
},
{
"key_as_string": "11/02/2015",
"key": 1446472421052.6316,
"doc_count": 1076
},
{
"key_as_string": "03/02/2016",
"key": 1456954105263.158,
"doc_count": 1981
},
{
"key_as_string": "07/02/2016",
"key": 1467435789473.684,
"doc_count": 636
},
{
"key_as_string": "10/31/2016",
"key": 1477917473684.2104,
"doc_count": 6086
},
{
"key_as_string": "03/01/2017",
"key": 1488399157894.7368,
"doc_count": 159
},
{
"key_as_string": "07/01/2017",
"key": 1498880842105.2632,
"doc_count": 319
},
{
"key_as_string": "10/30/2017",
"key": 1509362526315.7896,
"doc_count": 2077
},
{
"key_as_string": "02/28/2018",
"key": 1519844210526.3157,
"doc_count": 3082
}
],
"interval": 10481684210.526316,
"stats": [
1325548800000,
1524700800000
],
"type": "numeric",
"id": "date"
}
],
},
};
describe('Kibana data scenario - transform field_histograms', function () {
before(async () => {
await transform.testResources.setKibanaTimeZoneToUTC();
});
it('should return a field_histograms', async () => {
const { body, status } = await supertest
.post('/api/transform/field_histograms/iowa*')
.post(`/api/transform/field_histograms/${index}`)
.auth(
USER.TRANSFORM_POWERUSER,
transform.securityCommon.getPasswordForUser(USER.TRANSFORM_POWERUSER)

View file

@ -8,7 +8,6 @@
import { FtrProviderContext } from '../../../ftr_provider_context';
export default function ({ getService, loadTestFile }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const transform = getService('transform');
describe('transform', function () {