Skip to content

Commit

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

Fix #155830 

Add basic checks for both Lens and TSVB editors.
In Lens more advanced tests are performed to check for compatible and
uncompatible operations for specific TSDB field types.
In TSVB the check is only performed to verify that the editor and
visualization doesn't crash and when unsupported the right error message
is shown.


### Checklist

Delete any items that are not applicable to this PR.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to
identify risks that should be tested prior to the change/feature
release.

When forming the risk matrix, consider some of the following examples
and how they may potentially impact the change:

| Risk | Probability | Severity | Mitigation/Notes |

|---------------------------|-------------|----------|-------------------------|
| Multiple Spaces—unexpected behavior in non-default Kibana Space.
| Low | High | Integration tests will verify that all features are still
supported in non-default Kibana Space and when user switches between
spaces. |
| Multiple nodes—Elasticsearch polling might have race conditions
when multiple Kibana nodes are polling for the same tasks. | High | Low
| Tasks are idempotent, so executing them multiple times will not result
in logical error, but will degrade performance. To test for this case we
add plenty of unit tests around this logic and document manual testing
procedure. |
| Code should gracefully handle cases when feature X or plugin Y are
disabled. | Medium | High | Unit tests will verify that any feature flag
or plugin combination still results in our service operational. |
| [See more potential risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
  • Loading branch information
dej611 authored May 2, 2023
1 parent a3f5a34 commit 3c26123
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 3c26123

Please sign in to comment.