@@ -12,6 +12,55 @@ const COMMON_HEADERS = {
1212 'kbn-xsrf' : 'some-xsrf-token' ,
1313} ;
1414
15+ const testDataList = [
16+ {
17+ testTitleSuffix : 'with 1 field, 1 agg, no split' ,
18+ requestBody : {
19+ aggTypes : [ 'avg' ] ,
20+ duration : { start : 1560297859000 , end : 1562975136000 } ,
21+ fields : [ 'taxless_total_price' ] ,
22+ index : 'ecommerce' ,
23+ query : { bool : { must : [ { match_all : { } } ] } } ,
24+ timeField : 'order_date' ,
25+ } ,
26+ expected : {
27+ responseCode : 200 ,
28+ responseBody : { name : '15m' , ms : 900000 } ,
29+ } ,
30+ } ,
31+ {
32+ testTitleSuffix : 'with 2 fields, 2 aggs, no split' ,
33+ requestBody : {
34+ aggTypes : [ 'avg' , 'sum' ] ,
35+ duration : { start : 1560297859000 , end : 1562975136000 } ,
36+ fields : [ 'products.base_price' , 'products.base_unit_price' ] ,
37+ index : 'ecommerce' ,
38+ query : { bool : { must : [ { match_all : { } } ] } } ,
39+ timeField : 'order_date' ,
40+ } ,
41+ expected : {
42+ responseCode : 200 ,
43+ responseBody : { name : '30m' , ms : 1800000 } ,
44+ } ,
45+ } ,
46+ {
47+ testTitleSuffix : 'with 1 field, 1 agg, 1 split with cardinality 46' ,
48+ requestBody : {
49+ aggTypes : [ 'avg' ] ,
50+ duration : { start : 1560297859000 , end : 1562975136000 } ,
51+ fields : [ 'taxless_total_price' ] ,
52+ index : 'ecommerce' ,
53+ query : { bool : { must : [ { match_all : { } } ] } } ,
54+ splitField : 'customer_first_name.keyword' ,
55+ timeField : 'order_date' ,
56+ } ,
57+ expected : {
58+ responseCode : 200 ,
59+ responseBody : { name : '3h' , ms : 10800000 } ,
60+ } ,
61+ } ,
62+ ] ;
63+
1564// eslint-disable-next-line import/no-default-export
1665export default ( { getService } : FtrProviderContext ) => {
1766 const esArchiver = getService ( 'esArchiver' ) ;
@@ -26,36 +75,16 @@ export default ({ getService }: FtrProviderContext) => {
2675 await esArchiver . unload ( 'ml/ecommerce' ) ;
2776 } ) ;
2877
29- it ( 'estimates the bucket span' , async ( ) => {
30- const { body } = await supertest
31- . post ( '/api/ml/validate/estimate_bucket_span' )
32- . set ( COMMON_HEADERS )
33- . send ( {
34- aggTypes : [ 'avg' ] ,
35- duration : {
36- start : 1560297859000 ,
37- end : 1562975136000 ,
38- } ,
39- fields : [ 'taxless_total_price' ] ,
40- index : 'ecommerce' ,
41- query : {
42- bool : {
43- must : [
44- {
45- match_all : { } ,
46- } ,
47- ] ,
48- } ,
49- } ,
50- splitField : 'customer_first_name.keyword' ,
51- timeField : 'order_date' ,
52- } )
53- . expect ( 200 ) ;
54-
55- expect ( body ) . to . eql ( {
56- name : '3h' ,
57- ms : 10800000 ,
78+ for ( const testData of testDataList ) {
79+ it ( `estimates the bucket span ${ testData . testTitleSuffix } ` , async ( ) => {
80+ const { body } = await supertest
81+ . post ( '/api/ml/validate/estimate_bucket_span' )
82+ . set ( COMMON_HEADERS )
83+ . send ( testData . requestBody )
84+ . expect ( testData . expected . responseCode ) ;
85+
86+ expect ( body ) . to . eql ( testData . expected . responseBody ) ;
5887 } ) ;
59- } ) ;
88+ }
6089 } ) ;
6190} ;
0 commit comments