[ML] Replace legacy es client in Transform API service for functional tests
This commit is contained in:
parent
a395fd86a8
commit
924724cf0b
|
@ -20,7 +20,7 @@ export async function asyncForEach(array: any[], callback: Function) {
|
|||
}
|
||||
|
||||
export function TransformAPIProvider({ getService }: FtrProviderContext) {
|
||||
const es = getService('legacyEs');
|
||||
const es = getService('es');
|
||||
const log = getService('log');
|
||||
const retry = getService('retry');
|
||||
const esSupertest = getService('esSupertest');
|
||||
|
@ -29,12 +29,12 @@ export function TransformAPIProvider({ getService }: FtrProviderContext) {
|
|||
return {
|
||||
async createIndices(indices: string) {
|
||||
log.debug(`Creating indices: '${indices}'...`);
|
||||
if ((await es.indices.exists({ index: indices, allowNoIndices: false })) === true) {
|
||||
if ((await es.indices.exists({ index: indices, allow_no_indices: false })).body === true) {
|
||||
log.debug(`Indices '${indices}' already exist. Nothing to create.`);
|
||||
return;
|
||||
}
|
||||
|
||||
const createResponse = await es.indices.create({ index: indices });
|
||||
const createResponse = (await es.indices.create({ index: indices })).body;
|
||||
expect(createResponse)
|
||||
.to.have.property('acknowledged')
|
||||
.eql(true, 'Response for create request indices should be acknowledged.');
|
||||
|
@ -44,14 +44,16 @@ export function TransformAPIProvider({ getService }: FtrProviderContext) {
|
|||
|
||||
async deleteIndices(indices: string, skipWaitForIndicesNotToExist?: boolean) {
|
||||
log.debug(`Deleting indices: '${indices}'...`);
|
||||
if ((await es.indices.exists({ index: indices, allowNoIndices: false })) === false) {
|
||||
if ((await es.indices.exists({ index: indices, allow_no_indices: false })).body === false) {
|
||||
log.debug(`Indices '${indices}' don't exist. Nothing to delete.`);
|
||||
return;
|
||||
}
|
||||
|
||||
const deleteResponse = await es.indices.delete({
|
||||
index: indices,
|
||||
});
|
||||
const deleteResponse = (
|
||||
await es.indices.delete({
|
||||
index: indices,
|
||||
})
|
||||
).body;
|
||||
expect(deleteResponse)
|
||||
.to.have.property('acknowledged')
|
||||
.eql(true, 'Response for delete request should be acknowledged');
|
||||
|
@ -67,7 +69,7 @@ export function TransformAPIProvider({ getService }: FtrProviderContext) {
|
|||
|
||||
async waitForIndicesToExist(indices: string, errorMsg?: string) {
|
||||
await retry.tryForTime(30 * 1000, async () => {
|
||||
if ((await es.indices.exists({ index: indices, allowNoIndices: false })) === true) {
|
||||
if ((await es.indices.exists({ index: indices, allow_no_indices: false })).body === true) {
|
||||
return true;
|
||||
} else {
|
||||
throw new Error(errorMsg || `indices '${indices}' should exist`);
|
||||
|
@ -77,7 +79,7 @@ export function TransformAPIProvider({ getService }: FtrProviderContext) {
|
|||
|
||||
async waitForIndicesNotToExist(indices: string, errorMsg?: string) {
|
||||
await retry.tryForTime(30 * 1000, async () => {
|
||||
if ((await es.indices.exists({ index: indices, allowNoIndices: false })) === false) {
|
||||
if ((await es.indices.exists({ index: indices, allow_no_indices: false })).body === false) {
|
||||
return true;
|
||||
} else {
|
||||
throw new Error(errorMsg || `indices '${indices}' should not exist`);
|
||||
|
|
Loading…
Reference in a new issue