-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for UA back up data step on Cloud (#111066)
- Loading branch information
Showing
6 changed files
with
250 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
x-pack/test/api_integration/apis/upgrade_assistant/cloud_backup_status.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
|
||
import { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
export default function ({ getService }: FtrProviderContext) { | ||
const supertest = getService('supertest'); | ||
const es = getService('es'); | ||
|
||
const CLOUD_SNAPSHOT_REPOSITORY = 'found-snapshots'; | ||
|
||
const createCloudRepository = () => { | ||
return es.snapshot | ||
.createRepository({ | ||
repository: CLOUD_SNAPSHOT_REPOSITORY, | ||
body: { | ||
type: 'fs', | ||
settings: { | ||
location: '/tmp/cloud-snapshots/', | ||
}, | ||
}, | ||
verify: false, | ||
}) | ||
.then(({ body }) => body); | ||
}; | ||
|
||
const createCloudSnapshot = (snapshotName: string) => { | ||
return es.snapshot.create({ | ||
repository: CLOUD_SNAPSHOT_REPOSITORY, | ||
snapshot: snapshotName, | ||
wait_for_completion: true, | ||
// Configure snapshot so no indices are captured, so the request completes ASAP. | ||
body: { | ||
indices: 'this_index_doesnt_exist', | ||
ignore_unavailable: true, | ||
include_global_state: false, | ||
}, | ||
}); | ||
}; | ||
|
||
const deleteCloudSnapshot = (snapshotName: string) => { | ||
return es.snapshot.delete({ | ||
repository: CLOUD_SNAPSHOT_REPOSITORY, | ||
snapshot: snapshotName, | ||
}); | ||
}; | ||
|
||
describe('Cloud backup status', () => { | ||
describe('get', () => { | ||
describe('with backups present', () => { | ||
// Needs SnapshotInfo type https://github.com/elastic/elasticsearch-specification/issues/685 | ||
let mostRecentSnapshot: any; | ||
|
||
before(async () => { | ||
await createCloudRepository(); | ||
await createCloudSnapshot('test_snapshot_1'); | ||
mostRecentSnapshot = (await createCloudSnapshot('test_snapshot_2')).body.snapshot; | ||
}); | ||
|
||
after(async () => { | ||
await deleteCloudSnapshot('test_snapshot_1'); | ||
await deleteCloudSnapshot('test_snapshot_2'); | ||
}); | ||
|
||
it('returns status based on most recent snapshot', async () => { | ||
const { body: cloudBackupStatus } = await supertest | ||
.get('/api/upgrade_assistant/cloud_backup_status') | ||
.set('kbn-xsrf', 'xxx') | ||
.expect(200); | ||
|
||
expect(cloudBackupStatus.isBackedUp).to.be(true); | ||
expect(cloudBackupStatus.lastBackupTime).to.be(mostRecentSnapshot.start_time); | ||
}); | ||
}); | ||
|
||
describe('without backups present', () => { | ||
it('returns not-backed-up status', async () => { | ||
const { body: cloudBackupStatus } = await supertest | ||
.get('/api/upgrade_assistant/cloud_backup_status') | ||
.set('kbn-xsrf', 'xxx') | ||
.expect(200); | ||
|
||
expect(cloudBackupStatus.isBackedUp).to.be(false); | ||
expect(cloudBackupStatus.lastBackupTime).to.be(undefined); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters