[Lens] Add functional test for epoch millis (#119773)

This commit is contained in:
Joe Reuter 2021-12-07 17:47:53 +01:00 committed by GitHub
parent 51729646e9
commit eba077c22d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 640 additions and 1 deletions

View file

@ -0,0 +1,61 @@
/*
* 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 expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const PageObjects = getPageObjects(['visualize', 'lens', 'common', 'header']);
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
describe('epoch millis', () => {
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/lens/epoch_millis');
await kibanaServer.importExport.load(
'x-pack/test/functional/fixtures/kbn_archiver/lens/epoch_millis.json'
);
});
after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/lens/epoch_millis');
await kibanaServer.importExport.unload(
'x-pack/test/functional/fixtures/kbn_archiver/lens/epoch_millis.json'
);
});
it('should show field list', async () => {
await PageObjects.visualize.navigateToNewVisualization();
await PageObjects.visualize.clickVisType('lens');
await PageObjects.lens.switchDataPanelIndexPattern('epoch-millis');
await PageObjects.lens.goToTimeRange();
await PageObjects.lens.switchToVisualization('lnsDatatable');
const fieldList = await PageObjects.lens.findAllFields();
expect(fieldList).to.contain('@timestamp');
// not defined for document in time range, only out of time range
expect(fieldList).not.to.contain('agent.raw');
});
it('should able to configure a regular metric', async () => {
await PageObjects.lens.configureDimension({
dimension: 'lnsDatatable_metrics > lns-empty-dimension',
operation: 'count',
field: 'Records',
});
await PageObjects.lens.waitForVisualization();
expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('1');
});
it('should able to configure a shifted metric', async () => {
await PageObjects.lens.openDimensionEditor('lnsDatatable_metrics > lns-dimensionTrigger');
await PageObjects.lens.enableTimeShift();
await PageObjects.lens.setTimeShift('3d');
await PageObjects.lens.waitForVisualization();
expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('2');
});
});
}

View file

@ -55,6 +55,7 @@ export default function ({ getService, loadTestFile, getPageObjects }: FtrProvid
loadTestFile(require.resolve('./table'));
loadTestFile(require.resolve('./runtime_fields'));
loadTestFile(require.resolve('./dashboard'));
loadTestFile(require.resolve('./epoch_millis'));
});
describe('', function () {

View file

@ -0,0 +1,187 @@
{
"type": "doc",
"value": {
"id": "AU_x4-TaGFA8no6QjiSJ",
"index": "epoch-millis",
"source": {
"@message": "212.113.62.183 - - [2015-09-21T06:09:20.045Z] \"GET /uploads/dafydd-williams.jpg HTTP/1.1\" 200 3182 \"-\" \"Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1\"",
"@tags": [
"success",
"info"
],
"@timestamp": 1442664000000,
"bytes": 3182,
"clientip": "212.113.62.183",
"extension": "jpg",
"geo": {
"coordinates": {
"lat": 34.57528944,
"lon": -117.1861792
},
"dest": "US",
"src": "BI",
"srcdest": "BI:US"
},
"headings": [
"<h3>stephen-thorne</h5>",
"http://nytimes.com/success/sandra-magnus"
],
"host": "media-for-the-masses.theacademyofperformingartsandscience.org",
"index": "logstash-2015.09.21",
"ip": "212.113.62.183",
"links": [
"gherman-titov@nytimes.com",
"http://facebook.com/security/mercury-redstone-3",
"www.facebook.com"
],
"machine": {
"os": "ios",
"ram": 17179869184,
"ram_range": {
"gte": 17179869184,
"lt": 17179869199
}
},
"referer": "http://twitter.com/error/takuya-onishi",
"relatedContent": [
{
"article:modified_time": "2014-11-26T18:18:09-08:00",
"article:published_time": "2008-02-06T16:56:48-08:00",
"article:section": "News",
"og:description": "If you followed the election fine print - those ballot measures having nothing to do with Hillary Clinton, Barack Obama, John McCain or Mitt Romney, you...",
"og:site_name": "LA Weekly",
"og:title": "Fabian, maybe it&#039;s the friends you keep",
"og:type": "article",
"og:url": "http://www.laweekly.com/news/fabian-maybe-its-the-friends-you-keep-2399081",
"twitter:card": "summary",
"twitter:description": "If you followed the election fine print - those ballot measures having nothing to do with Hillary Clinton, Barack Obama, John McCain or Mitt Romney, you...",
"twitter:site": "@laweekly",
"twitter:title": "Fabian, maybe it&#039;s the friends you keep",
"url": "http://www.laweekly.com/news/fabian-maybe-its-the-friends-you-keep-2399081"
}
],
"request": "/uploads/dafydd-williams.jpg",
"response": "200",
"spaces": "this is a thing with lots of spaces wwwwoooooo",
"type": "apache",
"url": "https://media-for-the-masses.theacademyofperformingartsandscience.org/uploads/dafydd-williams.jpg",
"utc_time": "2015-09-21T06:09:20.045Z",
"xss": "<script>console.log(\"xss\")</script>"
}
}
}
{
"type": "doc",
"value": {
"id": "AU_x4-TaGFA8no6QjiSL",
"index": "epoch-millis",
"source": {
"@message": "156.252.112.76 - - [2015-09-21T21:13:02.070Z] \"GET /uploads/aleksandr-samokutyayev.jpg HTTP/1.1\" 200 6176 \"-\" \"Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24\"",
"@tags": [
"success",
"info"
],
"@timestamp": 1442518400000,
"agent": "Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1",
"bytes": 6176,
"clientip": "156.252.112.76",
"extension": "jpg",
"geo": {
"coordinates": {
"lat": 41.55239139,
"lon": -112.0622625
},
"dest": "CA",
"src": "IR",
"srcdest": "IR:CA"
},
"headings": [
"<h3>oleg-atkov</h5>",
"http://twitter.com/warning/curt-michel"
],
"host": "media-for-the-masses.theacademyofperformingartsandscience.org",
"index": "logstash-2015.09.21",
"ip": "156.252.112.76",
"links": [
"pavel-belyayev@twitter.com",
"http://www.slate.com/info/gregory-linteris",
"www.facebook.com"
],
"machine": {
"ram": 21474836480,
"ram_range": {
"gte": 21474836480,
"lt": 21474836499
}
},
"referer": "http://twitter.com/error/duane-graveline",
"relatedContent": [
{
"article:modified_time": "2014-11-25T20:21:15-08:00",
"article:published_time": "2007-02-10T21:02:00-08:00",
"article:section": "Arts",
"og:description": "FRIDAY, 7:30 p.m. Viper Room There was a lively and fashionable crowd at the Viper Room Friday night for MSO PR&#039;s soiree celebrating the launch of their...",
"og:image": "http://images1.laweekly.com/imager/erasure-and-smashing-pumpkins-news/u/original/2440535/mitch.jpg",
"og:image:height": "225",
"og:image:width": "300",
"og:site_name": "LA Weekly",
"og:title": "Erasure and Smashing Pumpkins News",
"og:type": "article",
"og:url": "http://www.laweekly.com/arts/erasure-and-smashing-pumpkins-news-2372898",
"twitter:card": "summary",
"twitter:description": "FRIDAY, 7:30 p.m. Viper Room There was a lively and fashionable crowd at the Viper Room Friday night for MSO PR&#039;s soiree celebrating the launch of their...",
"twitter:image": "http://images1.laweekly.com/imager/erasure-and-smashing-pumpkins-news/u/original/2440535/mitch.jpg",
"twitter:site": "@laweekly",
"twitter:title": "Erasure and Smashing Pumpkins News",
"url": "http://www.laweekly.com/arts/erasure-and-smashing-pumpkins-news-2372898"
},
{
"article:modified_time": "2014-11-25T19:36:57-08:00",
"article:published_time": "2006-11-29T00:11:37-08:00",
"article:section": "Arts",
"og:description": "So, I was bored one evening (tonight, as it happens) and as we do in the digital age I decided to google my name and find out what other Steffies exist ...",
"og:image": "http://images1.laweekly.com/imager/i-amdoll-parts/u/original/2442334/1186talksteffie.jpg",
"og:image:height": "264",
"og:image:width": "281",
"og:site_name": "LA Weekly",
"og:title": "I Am...Doll Parts",
"og:type": "article",
"og:url": "http://www.laweekly.com/arts/i-amdoll-parts-2373466",
"twitter:card": "summary",
"twitter:description": "So, I was bored one evening (tonight, as it happens) and as we do in the digital age I decided to google my name and find out what other Steffies exist ...",
"twitter:image": "http://images1.laweekly.com/imager/i-amdoll-parts/u/original/2442334/1186talksteffie.jpg",
"twitter:site": "@laweekly",
"twitter:title": "I Am...Doll Parts",
"url": "http://www.laweekly.com/arts/i-amdoll-parts-2373466"
},
{
"article:modified_time": "2014-11-25T18:07:09-08:00",
"article:published_time": "2008-02-07T17:55:05-08:00",
"article:section": "Arts",
"og:description": "Grammy week... Fashion week (in NYC)...the writers strike... Britney... There so much to do and watch and bitch, uh write, about.... Our new year&#039;s reso...",
"og:image": "http://images1.laweekly.com/imager/shit-list/u/original/2443852/tees.jpg",
"og:image:height": "253",
"og:image:width": "179",
"og:site_name": "LA Weekly",
"og:title": "Shit List",
"og:type": "article",
"og:url": "http://www.laweekly.com/arts/shit-list-2373962",
"twitter:card": "summary",
"twitter:description": "Grammy week... Fashion week (in NYC)...the writers strike... Britney... There so much to do and watch and bitch, uh write, about.... Our new year&#039;s reso...",
"twitter:image": "http://images1.laweekly.com/imager/shit-list/u/original/2443852/tees.jpg",
"twitter:site": "@laweekly",
"twitter:title": "Shit List",
"url": "http://www.laweekly.com/arts/shit-list-2373962"
}
],
"request": "/uploads/aleksandr-samokutyayev.jpg",
"response": "200",
"spaces": "this is a thing with lots of spaces wwwwoooooo",
"type": "apache",
"url": "https://media-for-the-masses.theacademyofperformingartsandscience.org/uploads/aleksandr-samokutyayev.jpg",
"utc_time": "2015-09-21T21:13:02.070Z",
"xss": "<script>console.log(\"xss\")</script>"
}
}
}

View file

@ -0,0 +1,374 @@
{
"type": "index",
"value": {
"index": "epoch-millis",
"mappings": {
"dynamic_templates": [
{
"string_fields": {
"mapping": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"match": "*",
"match_mapping_type": "string"
}
}
],
"runtime": {
"runtime_number": {
"type": "long",
"script" : { "source" : "emit(doc['bytes'].value)" }
}
},
"properties": {
"@message": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"@tags": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"@timestamp": {
"type": "date",
"format": "epoch_millis"
},
"agent": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"bytes": {
"type": "long"
},
"clientip": {
"type": "ip"
},
"extension": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"geo": {
"properties": {
"coordinates": {
"type": "geo_point"
},
"dest": {
"type": "keyword"
},
"src": {
"type": "keyword"
},
"srcdest": {
"type": "keyword"
}
}
},
"headings": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"host": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"id": {
"type": "integer"
},
"index": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"ip": {
"type": "ip"
},
"links": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"machine": {
"properties": {
"os": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"ram": {
"type": "long"
},
"ram_range": {
"type": "long_range"
}
}
},
"memory": {
"type": "double"
},
"meta": {
"properties": {
"char": {
"type": "keyword"
},
"related": {
"type": "text"
},
"user": {
"properties": {
"firstname": {
"type": "text"
},
"lastname": {
"type": "integer"
}
}
}
}
},
"phpmemory": {
"type": "long"
},
"referer": {
"type": "keyword"
},
"relatedContent": {
"properties": {
"article:modified_time": {
"type": "date"
},
"article:published_time": {
"type": "date"
},
"article:section": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"article:tag": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"og:description": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"og:image": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"og:image:height": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"og:image:width": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"og:site_name": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"og:title": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"og:type": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"og:url": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"twitter:card": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"twitter:description": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"twitter:image": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"twitter:site": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"twitter:title": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"url": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
}
}
},
"request": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"response": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"spaces": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"type": {
"type": "keyword"
},
"url": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
},
"utc_time": {
"type": "date"
},
"xss": {
"fields": {
"raw": {
"type": "keyword"
}
},
"type": "text"
}
}
},
"settings": {
"index": {
"analysis": {
"analyzer": {
"url": {
"max_token_length": "1000",
"tokenizer": "uax_url_email",
"type": "standard"
}
}
},
"number_of_replicas": "0",
"number_of_shards": "1"
}
}
}
}

View file

@ -0,0 +1,15 @@
{
"attributes": {
"timeFieldName": "@timestamp",
"title": "epoch-millis"
},
"coreMigrationVersion": "8.0.0",
"id": "epoch-millis",
"migrationVersion": {
"index-pattern": "7.11.0"
},
"references": [],
"type": "index-pattern",
"updated_at": "2018-12-21T00:43:07.096Z",
"version": "WzEzLDJd"
}

View file

@ -39,7 +39,8 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
},
async findAllFields() {
return await testSubjects.findAll('lnsFieldListPanelField');
const fields = await testSubjects.findAll('lnsFieldListPanelField');
return await Promise.all(fields.map((field) => field.getVisibleText()));
},
async isLensPageOrFail() {