From 7534074a75f108a362b962da6e524dedd229e317 Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Thu, 4 Nov 2021 12:36:10 -0700 Subject: [PATCH] test organization --- .../reporting_and_security/usage.ts | 46 +++++++++---------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/x-pack/test/reporting_api_integration/reporting_and_security/usage.ts b/x-pack/test/reporting_api_integration/reporting_and_security/usage.ts index 976cbed75c27f..4f17d753faf0e 100644 --- a/x-pack/test/reporting_api_integration/reporting_and_security/usage.ts +++ b/x-pack/test/reporting_api_integration/reporting_and_security/usage.ts @@ -10,6 +10,11 @@ import { FtrProviderContext } from '../ftr_provider_context'; import * as GenerationUrls from '../services/generation_urls'; import { ReportingUsageStats } from '../services/usage'; +const JOB_PARAMS_CSV_DEFAULT_SPACE = + `columns:!(order_date,category,customer_full_name,taxful_total_price,currency),objectType:search,searchSource:(fields:!((field:'*',include_unmapped:true))` + + `,filter:!((meta:(field:order_date,index:aac3e500-f2c7-11ea-8250-fb138aa491e7,params:()),query:(range:(order_date:(format:strict_date_optional_time,gte:'2019-06-02T12:28:40.866Z'` + + `,lte:'2019-07-18T20:59:57.136Z'))))),index:aac3e500-f2c7-11ea-8250-fb138aa491e7,parent:(filter:!(),highlightAll:!t,index:aac3e500-f2c7-11ea-8250-fb138aa491e7` + + `,query:(language:kuery,query:''),version:!t),sort:!((order_date:desc)),trackTotalHits:!t)`; const OSS_KIBANA_ARCHIVE_PATH = 'test/functional/fixtures/es_archiver/dashboard/current/kibana'; const OSS_DATA_ARCHIVE_PATH = 'test/functional/fixtures/es_archiver/dashboard/current/data'; @@ -20,30 +25,14 @@ interface UsageStats { // eslint-disable-next-line import/no-default-export export default function ({ getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); - const kibanaServer = getService('kibanaServer'); const reportingAPI = getService('reportingAPI'); const retry = getService('retry'); const usageAPI = getService('usageAPI'); describe('Usage', () => { - before(async () => { - await esArchiver.load(OSS_KIBANA_ARCHIVE_PATH); - await esArchiver.load(OSS_DATA_ARCHIVE_PATH); - - await kibanaServer.uiSettings.update({ - defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', - }); - await reportingAPI.deleteAllReports(); - }); - - after(async () => { - await esArchiver.unload(OSS_KIBANA_ARCHIVE_PATH); - await esArchiver.unload(OSS_DATA_ARCHIVE_PATH); - }); - - afterEach(async () => { - await reportingAPI.deleteAllReports(); - }); + const deleteAllReports = () => reportingAPI.deleteAllReports(); + beforeEach(deleteAllReports); + after(deleteAllReports); describe('initial state', () => { let usage: UsageStats; @@ -123,16 +112,23 @@ export default function ({ getService }: FtrProviderContext) { }); describe('from new jobs posted', () => { + before(async () => { + await esArchiver.load(OSS_KIBANA_ARCHIVE_PATH); + await esArchiver.load(OSS_DATA_ARCHIVE_PATH); + await reportingAPI.initEcommerce(); + }); + + after(async () => { + await esArchiver.unload(OSS_KIBANA_ARCHIVE_PATH); + await esArchiver.unload(OSS_DATA_ARCHIVE_PATH); + await reportingAPI.teardownEcommerce(); + }); + it('should handle csv_searchsource', async () => { - const JOB_PARAMS_CSV_DEFAULT_SPACE = - `columns:!(order_date,category,customer_full_name,taxful_total_price,currency),objectType:search,searchSource:(fields:!((field:'*',include_unmapped:true))` + - `,filter:!((meta:(field:order_date,index:aac3e500-f2c7-11ea-8250-fb138aa491e7,params:()),query:(range:(order_date:(format:strict_date_optional_time,gte:'2019-06-02T12:28:40.866Z'` + - `,lte:'2019-07-18T20:59:57.136Z'))))),index:aac3e500-f2c7-11ea-8250-fb138aa491e7,parent:(filter:!(),highlightAll:!t,index:aac3e500-f2c7-11ea-8250-fb138aa491e7` + - `,query:(language:kuery,query:''),version:!t),sort:!((order_date:desc)),trackTotalHits:!t)`; await reportingAPI.expectAllJobsToFinishSuccessfully( await Promise.all([ reportingAPI.postJob( - `/api/reporting/generate/csv?jobParams=(${JOB_PARAMS_CSV_DEFAULT_SPACE})` + `/api/reporting/generate/csv_searchsource?jobParams=(${JOB_PARAMS_CSV_DEFAULT_SPACE})` ), ]) );