Skip to content

Commit

Permalink
test organization
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed Nov 4, 2021
1 parent ccc2786 commit 7534074
Showing 1 changed file with 21 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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;
Expand Down Expand Up @@ -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})`
),
])
);
Expand Down

0 comments on commit 7534074

Please sign in to comment.