Skip to content

Commit

Permalink
[8.8] [Lens][TSVB] Add TSDB field checks functional tests (#156165) (#…
Browse files Browse the repository at this point in the history
…156333)

# Backport

This will backport the following commits from `main` to `8.8`:
- [[Lens][TSVB] Add TSDB field checks functional tests
(#156165)](#156165)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Marco
Liberati","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-05-02T07:58:07Z","message":"[Lens][TSVB]
Add TSDB field checks functional tests (#156165)\n\n##
Summary\r\n\r\nFix #155830 \r\n\r\nAdd basic checks for both Lens and
TSVB editors.\r\nIn Lens more advanced tests are performed to check for
compatible and\r\nuncompatible operations for specific TSDB field
types.\r\nIn TSVB the check is only performed to verify that the editor
and\r\nvisualization doesn't crash and when unsupported the right error
message\r\nis shown.\r\n\r\n\r\n### Checklist\r\n\r\nDelete any items
that are not applicable to this PR.\r\n\r\n- [ ] Any text added follows
[EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] Any UI
touched in this PR is usable by keyboard only (learn more\r\nabout
[keyboard accessibility](https://webaim.org/techniques/keyboard/))\r\n-
[ ] Any UI touched in this PR does not create any new axe
failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[ ] If a plugin configuration key changed, check if it needs to
be\r\nallowlisted in the cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[ ] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n\r\n###
Risk Matrix\r\n\r\nDelete this section if it is not applicable to this
PR.\r\n\r\nBefore closing this PR, invite QA, stakeholders, and other
developers to\r\nidentify risks that should be tested prior to the
change/feature\r\nrelease.\r\n\r\nWhen forming the risk matrix, consider
some of the following examples\r\nand how they may potentially impact
the change:\r\n\r\n| Risk | Probability | Severity | Mitigation/Notes
|\r\n\r\n|---------------------------|-------------|----------|-------------------------|\r\n|
Multiple Spaces&mdash;unexpected behavior in non-default Kibana
Space.\r\n| Low | High | Integration tests will verify that all features
are still\r\nsupported in non-default Kibana Space and when user
switches between\r\nspaces. |\r\n| Multiple nodes&mdash;Elasticsearch
polling might have race conditions\r\nwhen multiple Kibana nodes are
polling for the same tasks. | High | Low\r\n| Tasks are idempotent, so
executing them multiple times will not result\r\nin logical error, but
will degrade performance. To test for this case we\r\nadd plenty of unit
tests around this logic and document manual testing\r\nprocedure. |\r\n|
Code should gracefully handle cases when feature X or plugin Y
are\r\ndisabled. | Medium | High | Unit tests will verify that any
feature flag\r\nor plugin combination still results in our service
operational. |\r\n| [See more potential
risk\r\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
|\r\n\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for
breaking API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"3c261237b07450ceee4877705bd8f843f0a51eca","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:TSVB","Team:Visualizations","release_note:skip","Feature:Lens","v8.8.0","v8.9.0"],"number":156165,"url":"https://github.com/elastic/kibana/pull/156165","mergeCommit":{"message":"[Lens][TSVB]
Add TSDB field checks functional tests (#156165)\n\n##
Summary\r\n\r\nFix #155830 \r\n\r\nAdd basic checks for both Lens and
TSVB editors.\r\nIn Lens more advanced tests are performed to check for
compatible and\r\nuncompatible operations for specific TSDB field
types.\r\nIn TSVB the check is only performed to verify that the editor
and\r\nvisualization doesn't crash and when unsupported the right error
message\r\nis shown.\r\n\r\n\r\n### Checklist\r\n\r\nDelete any items
that are not applicable to this PR.\r\n\r\n- [ ] Any text added follows
[EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] Any UI
touched in this PR is usable by keyboard only (learn more\r\nabout
[keyboard accessibility](https://webaim.org/techniques/keyboard/))\r\n-
[ ] Any UI touched in this PR does not create any new axe
failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[ ] If a plugin configuration key changed, check if it needs to
be\r\nallowlisted in the cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[ ] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n\r\n###
Risk Matrix\r\n\r\nDelete this section if it is not applicable to this
PR.\r\n\r\nBefore closing this PR, invite QA, stakeholders, and other
developers to\r\nidentify risks that should be tested prior to the
change/feature\r\nrelease.\r\n\r\nWhen forming the risk matrix, consider
some of the following examples\r\nand how they may potentially impact
the change:\r\n\r\n| Risk | Probability | Severity | Mitigation/Notes
|\r\n\r\n|---------------------------|-------------|----------|-------------------------|\r\n|
Multiple Spaces&mdash;unexpected behavior in non-default Kibana
Space.\r\n| Low | High | Integration tests will verify that all features
are still\r\nsupported in non-default Kibana Space and when user
switches between\r\nspaces. |\r\n| Multiple nodes&mdash;Elasticsearch
polling might have race conditions\r\nwhen multiple Kibana nodes are
polling for the same tasks. | High | Low\r\n| Tasks are idempotent, so
executing them multiple times will not result\r\nin logical error, but
will degrade performance. To test for this case we\r\nadd plenty of unit
tests around this logic and document manual testing\r\nprocedure. |\r\n|
Code should gracefully handle cases when feature X or plugin Y
are\r\ndisabled. | Medium | High | Unit tests will verify that any
feature flag\r\nor plugin combination still results in our service
operational. |\r\n| [See more potential
risk\r\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
|\r\n\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for
breaking API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"3c261237b07450ceee4877705bd8f843f0a51eca"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"8.8","label":"v8.8.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/156165","number":156165,"mergeCommit":{"message":"[Lens][TSVB]
Add TSDB field checks functional tests (#156165)\n\n##
Summary\r\n\r\nFix #155830 \r\n\r\nAdd basic checks for both Lens and
TSVB editors.\r\nIn Lens more advanced tests are performed to check for
compatible and\r\nuncompatible operations for specific TSDB field
types.\r\nIn TSVB the check is only performed to verify that the editor
and\r\nvisualization doesn't crash and when unsupported the right error
message\r\nis shown.\r\n\r\n\r\n### Checklist\r\n\r\nDelete any items
that are not applicable to this PR.\r\n\r\n- [ ] Any text added follows
[EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] Any UI
touched in this PR is usable by keyboard only (learn more\r\nabout
[keyboard accessibility](https://webaim.org/techniques/keyboard/))\r\n-
[ ] Any UI touched in this PR does not create any new axe
failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[ ] If a plugin configuration key changed, check if it needs to
be\r\nallowlisted in the cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[ ] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n\r\n###
Risk Matrix\r\n\r\nDelete this section if it is not applicable to this
PR.\r\n\r\nBefore closing this PR, invite QA, stakeholders, and other
developers to\r\nidentify risks that should be tested prior to the
change/feature\r\nrelease.\r\n\r\nWhen forming the risk matrix, consider
some of the following examples\r\nand how they may potentially impact
the change:\r\n\r\n| Risk | Probability | Severity | Mitigation/Notes
|\r\n\r\n|---------------------------|-------------|----------|-------------------------|\r\n|
Multiple Spaces&mdash;unexpected behavior in non-default Kibana
Space.\r\n| Low | High | Integration tests will verify that all features
are still\r\nsupported in non-default Kibana Space and when user
switches between\r\nspaces. |\r\n| Multiple nodes&mdash;Elasticsearch
polling might have race conditions\r\nwhen multiple Kibana nodes are
polling for the same tasks. | High | Low\r\n| Tasks are idempotent, so
executing them multiple times will not result\r\nin logical error, but
will degrade performance. To test for this case we\r\nadd plenty of unit
tests around this logic and document manual testing\r\nprocedure. |\r\n|
Code should gracefully handle cases when feature X or plugin Y
are\r\ndisabled. | Medium | High | Unit tests will verify that any
feature flag\r\nor plugin combination still results in our service
operational. |\r\n| [See more potential
risk\r\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
|\r\n\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for
breaking API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"3c261237b07450ceee4877705bd8f843f0a51eca"}}]}]
BACKPORT-->

Co-authored-by: Marco Liberati <[email protected]>
  • Loading branch information
kibanamachine and dej611 authored May 2, 2023
1 parent eaee327 commit a675560
Show file tree
Hide file tree
Showing 7 changed files with 541 additions and 112 deletions.
75 changes: 75 additions & 0 deletions test/functional/apps/visualize/group6/_tsvb_tsdb_basic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import expect from '@kbn/expect';

import { FtrProviderContext } from '../../../ftr_provider_context';

export default function ({ getPageObjects, getService }: FtrProviderContext) {
const { visualBuilder } = getPageObjects(['visualBuilder']);
const log = getService('log');
const kibanaServer = getService('kibanaServer');
const esArchiver = getService('esArchiver');
const testSubjects = getService('testSubjects');

describe('visual builder tsdb check', function describeIndexTests() {
before(async () => {
log.info(`loading sample TSDB index...`);
await esArchiver.load('test/functional/fixtures/es_archiver/kibana_sample_data_logs_tsdb');
log.info(`creating the TSDB data view...`);
await kibanaServer.importExport.load(
'test/functional/fixtures/kbn_archiver/kibana_sample_data_logs_tsdb'
);
log.info(`setting the TSDB dataView as default...`);
await kibanaServer.uiSettings.replace({
defaultIndex: '90943e30-9a47-11e8-b64d-95841ca0c247',
});
});

after(async () => {
log.info(`removing the TSDB index...`);
await esArchiver.unload('test/functional/fixtures/es_archiver/kibana_sample_data_logs_tsdb');
log.info(`removing the TSDB dataView...`);
await kibanaServer.importExport.unload(
'test/functional/fixtures/kbn_archiver/kibana_sample_data_logs_tsdb'
);
log.info(`unsetting the TSDB dataView default...`);
await kibanaServer.uiSettings.unset('defaultIndex');
});

beforeEach(async () => {
await visualBuilder.resetPage();
});

it('should render from a tsdb dataView regular fields with no issues', async () => {
await visualBuilder.selectAggType('Average');
await visualBuilder.setFieldForAggregation('bytes');
const isFieldForAggregationValid = await visualBuilder.checkFieldForAggregationValidity();
expect(isFieldForAggregationValid).to.be(true);
expect(await testSubjects.exists('visualization-error-text')).to.be(false);
});

it('should render from a tsdb dataView supported tsdb field type', async () => {
await visualBuilder.selectAggType('Average');
await visualBuilder.setFieldForAggregation('bytes_gauge');
const isFieldForAggregationValid = await visualBuilder.checkFieldForAggregationValidity();
expect(isFieldForAggregationValid).to.be(true);
expect(await testSubjects.exists('visualization-error-text')).to.be(false);
});

it('should show an error when using an unsupported tsdb field type', async () => {
await visualBuilder.selectAggType('Average');
await visualBuilder.setFieldForAggregation('bytes_counter');
// this is still returning true
const isFieldForAggregationValid = await visualBuilder.checkFieldForAggregationValidity();
expect(isFieldForAggregationValid).to.be(true);
// but an error should appear in visualization
expect(await testSubjects.exists('visualization-error-text')).to.be(true);
});
});
}
1 change: 1 addition & 0 deletions test/functional/apps/visualize/group6/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./_tag_cloud'));
loadTestFile(require.resolve('./_tsvb_markdown'));
loadTestFile(require.resolve('./_tsvb_table'));
loadTestFile(require.resolve('./_tsvb_tsdb_basic'));
loadTestFile(require.resolve('./_vega_chart'));
});
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
{
"type": "index",
"value": {
"aliases": {
},
"index": "kibana_sample_data_logstsdb",
"mappings": {
"_data_stream_timestamp": {
"enabled": true
},
"properties": {
"@timestamp": {
"type": "date"
},
"agent": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"bytes": {
"type": "long"
},
"bytes_counter": {
"time_series_metric": "counter",
"type": "long"
},
"bytes_gauge": {
"time_series_metric": "gauge",
"type": "long"
},
"clientip": {
"type": "ip"
},
"event": {
"properties": {
"dataset": {
"type": "keyword"
}
}
},
"extension": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"geo": {
"properties": {
"coordinates": {
"type": "geo_point"
},
"dest": {
"type": "keyword"
},
"src": {
"type": "keyword"
},
"srcdest": {
"type": "keyword"
}
}
},
"host": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"index": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"ip": {
"type": "ip"
},
"machine": {
"properties": {
"os": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"ram": {
"type": "long"
}
}
},
"memory": {
"type": "double"
},
"message": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"phpmemory": {
"type": "long"
},
"referer": {
"type": "keyword"
},
"request": {
"time_series_dimension": true,
"type": "keyword"
},
"response": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"tags": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"timestamp": {
"path": "@timestamp",
"type": "alias"
},
"url": {
"time_series_dimension": true,
"type": "keyword"
},
"utc_time": {
"type": "date"
}
}
},
"settings": {
"index": {
"auto_expand_replicas": "0-1",
"mode": "time_series",
"number_of_replicas": "0",
"number_of_shards": "1",
"routing_path": "request",
"time_series": {
"end_time": "2023-06-28T09:17:00.283Z",
"start_time": "2023-03-28T09:17:00.283Z"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"attributes": {
"fieldFormatMap": "{\"hour_of_day\":{}}",
"name": "Kibana Sample Data Logs (TSDB)",
"runtimeFieldMap": "{\"hour_of_day\":{\"type\":\"long\",\"script\":{\"source\":\"emit(doc['timestamp'].value.getHour());\"}}}",
"timeFieldName": "timestamp",
"title": "kibana_sample_data_logstsdb"
},
"coreMigrationVersion": "8.8.0",
"created_at": "2023-04-27T13:09:20.333Z",
"id": "90943e30-9a47-11e8-b64d-95841ca0c247",
"managed": false,
"references": [],
"sort": [
1682600960333,
64
],
"type": "index-pattern",
"typeMigrationVersion": "7.11.0",
"updated_at": "2023-04-27T13:09:20.333Z",
"version": "WzIxLDFd"
}
Loading

0 comments on commit a675560

Please sign in to comment.