Skip to content

Commit 4bd7b36

Browse files
authored
[ML] Functional API tests - bucket span estimation with custom search.max_buckets (#59665)
This PR adds functional API tests for the bucket span estimation endpoint with a transient or persistent `search.max_buckets` setting.
1 parent 239ca74 commit 4bd7b36

File tree

1 file changed

+64
-3
lines changed

1 file changed

+64
-3
lines changed

x-pack/test/api_integration/apis/ml/bucket_span_estimator.ts

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const COMMON_HEADERS = {
1616
// eslint-disable-next-line import/no-default-export
1717
export default ({ getService }: FtrProviderContext) => {
1818
const esArchiver = getService('esArchiver');
19+
const esSupertest = getService('esSupertest');
1920
const supertest = getService('supertestWithoutAuth');
2021
const mlSecurity = getService('mlSecurity');
2122

@@ -97,8 +98,39 @@ export default ({ getService }: FtrProviderContext) => {
9798
await esArchiver.unload('ml/ecommerce');
9899
});
99100

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 () => {
102134
const { body } = await supertest
103135
.post('/api/ml/validate/estimate_bucket_span')
104136
.auth(testData.user, mlSecurity.getPasswordForUser(testData.user))
@@ -108,6 +140,35 @@ export default ({ getService }: FtrProviderContext) => {
108140

109141
expect(body).to.eql(testData.expected.responseBody);
110142
});
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+
});
112173
});
113174
};

0 commit comments

Comments
 (0)