import expect from '@kbn/expect' ; import { FtrProviderContext } from '../../ftr_provider_context' ; import { reindexOperationWithLargeErrorMessage } from './reindex_operation_with_large_error_message' ; export default function ( { getService } ) { const es = getService ( 'es' ) ; const supertest = getService ( 'supertest' ) ; describe . skip ( 'Upgrade Assistant' , ( ) => { describe ( 'Reindex operation saved object' , ( ) => { const dotKibanaIndex = '.kibana' ; const fakeSavedObjectId = 'fakeSavedObjectId' ; after ( async ( ) => { return await es . delete ( { index : dotKibanaIndex , id : fakeSavedObjectId } ) ; } ) ; it ( 'is indexed successfully with immense error message' , async ( ) => { const result = await es . create ( { index : dotKibanaIndex , id : fakeSavedObjectId , body : reindexOperationWithLargeErrorMessage , } ) ; expect ( result ) . to . be . ok ( ) ; } ) ; } ) ; describe ( 'POST /api/upgrade_assistant/{indexName}/index_settings' , ( ) => { const indexName = 'update_settings_test_index' ; const indexSettings = { number_of_shards : '3' , number_of_replicas : '2' , refresh_interval : '1s' , } ; before ( async ( ) => { try { await es . indices . create ( { index : indexName , body : { settings : { index : indexSettings , } , } , } ) ; } catch ( err ) { console . log ( '[Setup error] Error creating index' ) ; throw err ; } } ) ; after ( async ( ) => { try { await es . indices . delete ( { index : indexName , } ) ; } catch ( err ) { console . log ( '[Cleanup error] Error deleting index' ) ; throw err ; } } ) ; it ( 'removes index settings' , async ( ) => { const { body } = await supertest . post ( `/api/upgrade_assistant/${ indexName }/index_settings` ) . set ( 'kbn-xsrf' , 'xxx' ) . send ( { settings : [ 'refresh_interval' ] , } ) . expect ( 200 ) ; expect ( body ) . to . eql ( { acknowledged : true , } ) ; try { const indexSettingsResponse = await es . indices . getSettings ( { index : indexName , } ) ; const updatedIndexSettings = indexSettingsResponse [ indexName ] . settings . index ; expect ( updatedIndexSettings ?. number_of_shards ) . to . eql ( indexSettings . number_of_shards ) ; expect ( updatedIndexSettings ?. number_of_replicas ) . to . eql ( indexSettings . number_of_replicas ) ; expect ( updatedIndexSettings ?. refresh_interval ) . to . be . eql ( undefined ) ; } catch ( err ) { console . log ( '[Error] Unable to fetch index and verify index settings' ) ; throw err ; } } ) ; it ( 'handles error' , async ( ) => { const indexDoesNotExistName = 'index_does_not_exist' ; const { body } = await supertest . post ( `/api/upgrade_assistant/${ indexDoesNotExistName }/index_settings` ) . set ( 'kbn-xsrf' , 'xxx' ) . send ( { settings : [ 'refresh_interval' ] , } ) . expect ( 500 ) ; expect ( body . error ) . to . eql ( 'Internal Server Error' ) ; } ) ; } ) ; describe ( 'GET /api/upgrade_assistant/status' , ( ) => { it ( 'returns a successful response' , async ( ) => { const { body } = await supertest . get ( '/api/upgrade_assistant/status' ) . set ( 'kbn-xsrf' , 'xxx' ) . expect ( 200 ) ; const expectedResponseKeys = [ 'readyForUpgrade' , 'details' ] ; expectedResponseKeys . forEach ( ( key ) => { expect ( body [ key ] ) . to . not . equal ( undefined ) ; } ) ; } ) ; } ) ; } ) ; }