@@ -16,6 +16,7 @@ const COMMON_HEADERS = {
16
16
// eslint-disable-next-line import/no-default-export
17
17
export default ( { getService } : FtrProviderContext ) => {
18
18
const esArchiver = getService ( 'esArchiver' ) ;
19
+ const esSupertest = getService ( 'esSupertest' ) ;
19
20
const supertest = getService ( 'supertestWithoutAuth' ) ;
20
21
const mlSecurity = getService ( 'mlSecurity' ) ;
21
22
@@ -97,8 +98,39 @@ export default ({ getService }: FtrProviderContext) => {
97
98
await esArchiver . unload ( 'ml/ecommerce' ) ;
98
99
} ) ;
99
100
100
- for ( const testData of testDataList ) {
101
- it ( `estimates the bucket span ${ testData . testTitleSuffix } ` , async ( ) => {
101
+ describe ( 'with default settings' , function ( ) {
102
+ for ( const testData of testDataList ) {
103
+ it ( `estimates the bucket span ${ testData . testTitleSuffix } ` , async ( ) => {
104
+ const { body } = await supertest
105
+ . post ( '/api/ml/validate/estimate_bucket_span' )
106
+ . auth ( testData . user , mlSecurity . getPasswordForUser ( testData . user ) )
107
+ . set ( COMMON_HEADERS )
108
+ . send ( testData . requestBody )
109
+ . expect ( testData . expected . responseCode ) ;
110
+
111
+ expect ( body ) . to . eql ( testData . expected . responseBody ) ;
112
+ } ) ;
113
+ }
114
+ } ) ;
115
+
116
+ describe ( 'with transient search.max_buckets setting' , function ( ) {
117
+ before ( async ( ) => {
118
+ await esSupertest
119
+ . put ( '/_cluster/settings' )
120
+ . send ( { transient : { 'search.max_buckets' : 9000 } } )
121
+ . expect ( 200 ) ;
122
+ } ) ;
123
+
124
+ after ( async ( ) => {
125
+ await esSupertest
126
+ . put ( '/_cluster/settings' )
127
+ . send ( { transient : { 'search.max_buckets' : null } } )
128
+ . expect ( 200 ) ;
129
+ } ) ;
130
+
131
+ const testData = testDataList [ 0 ] ;
132
+
133
+ it ( `estimates the bucket span` , async ( ) => {
102
134
const { body } = await supertest
103
135
. post ( '/api/ml/validate/estimate_bucket_span' )
104
136
. auth ( testData . user , mlSecurity . getPasswordForUser ( testData . user ) )
@@ -108,6 +140,35 @@ export default ({ getService }: FtrProviderContext) => {
108
140
109
141
expect ( body ) . to . eql ( testData . expected . responseBody ) ;
110
142
} ) ;
111
- }
143
+ } ) ;
144
+
145
+ describe ( 'with persistent search.max_buckets setting' , function ( ) {
146
+ before ( async ( ) => {
147
+ await esSupertest
148
+ . put ( '/_cluster/settings' )
149
+ . send ( { persistent : { 'search.max_buckets' : 9000 } } )
150
+ . expect ( 200 ) ;
151
+ } ) ;
152
+
153
+ after ( async ( ) => {
154
+ await esSupertest
155
+ . put ( '/_cluster/settings' )
156
+ . send ( { persistent : { 'search.max_buckets' : null } } )
157
+ . expect ( 200 ) ;
158
+ } ) ;
159
+
160
+ const testData = testDataList [ 0 ] ;
161
+
162
+ it ( `estimates the bucket span` , async ( ) => {
163
+ const { body } = await supertest
164
+ . post ( '/api/ml/validate/estimate_bucket_span' )
165
+ . auth ( testData . user , mlSecurity . getPasswordForUser ( testData . user ) )
166
+ . set ( COMMON_HEADERS )
167
+ . send ( testData . requestBody )
168
+ . expect ( testData . expected . responseCode ) ;
169
+
170
+ expect ( body ) . to . eql ( testData . expected . responseBody ) ;
171
+ } ) ;
172
+ } ) ;
112
173
} ) ;
113
174
} ;
0 commit comments