Skip to content

Commit

Permalink
Add custom-settings test use case
Browse files Browse the repository at this point in the history
  • Loading branch information
afharo committed Jan 8, 2025
1 parent 33ab736 commit b503c3c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
4 changes: 2 additions & 2 deletions x-pack/platform/plugins/private/upgrade_assistant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ deprecations are discovered as data is migrated. Starting in 7.x, deprecation lo
Elasticsearch deprecations can be handled in a number of ways:

* **Reindexing.** When a user's index contains deprecations (e.g. mappings) a reindex solves them. The Upgrade Assistant only automates reindexing for indices. For example, if you are currently on 7.x, and want to migrate to 8.0, but you still have indices that were created on 6.x. For this scenario, the user will see a "Reindex" button that they can click, which will perform the reindex.
* Reindexing is an idempotent action in Upgrade Assistant. It works like this ([overview in code](https://github.com/elastic/kibana/blob/b320a37d8b703b2fa101a93b6971b36ee2c37f06/x-pack/platform/plugins/private/upgrade_assistant/server/lib/reindexing/reindex_service.ts#L498-L540)):
* Reindexing is an idempotent action in Upgrade Assistant. It works like this ([overview in code](https://github.com/elastic/kibana/blob/5c13e901ac1bf01bcbcca1d4103c43438ee8f6e6/x-pack/platform/plugins/private/upgrade_assistant/server/lib/reindexing/reindex_service.ts#L503-L545)):
1. Set a write-block on the original index, no new data can be written during reindexing.
2. Create a target index with the following name `reindexed-v{majorVersion}-{originalIndex}`. E.g., if `my-index` is the original, the target will be named `reindexed-v8-my-index`.
**NOTE:** It overrides the index settings `number_of_replicas` and `refresh_interval` for reindexing performance. They are restored after completion.
Expand Down Expand Up @@ -336,7 +336,7 @@ For a complete list of Kibana deprecations, refer to the [8.0 Kibana deprecation

This is a non-exhaustive list of different error scenarios in Upgrade Assistant. It's recommended to use the [tweak browser extension](https://chrome.google.com/webstore/detail/tweak-mock-api-calls/feahianecghpnipmhphmfgmpdodhcapi?hl=en), or something similar, to mock the API calls.

- **Error loading deprecation logging status.** Mock a `404` status code to `GET /api/upgrade_assistant/deprecation_logging`. Alternatively, edit [this line](https://github.com/elastic/kibana/blob/545c1420c285af8f5eee56f414bd6eca735aea11/x-pack/platform/plugins/private/upgrade_assistant/public/application/lib/api.ts#L70) locally and replace `deprecation_logging` with `fake_deprecation_logging`.
- **Error loading deprecation logging status.** Mock a `404` status code to `GET /api/upgrade_assistant/deprecation_logging`. Alternatively, edit [this line](https://github.com/elastic/kibana/blob/5c13e901ac1bf01bcbcca1d4103c43438ee8f6e6/x-pack/platform/plugins/private/upgrade_assistant/public/application/lib/api.ts#L71) locally and replace `deprecation_logging` with `fake_deprecation_logging`.
- **Error updating deprecation logging status.** Mock a `404` status code to `PUT /api/upgrade_assistant/deprecation_logging`. Alternatively, edit [this line](https://github.com/elastic/kibana/blob/545c1420c285af8f5eee56f414bd6eca735aea11/x-pack/platform/plugins/private/upgrade_assistant/public/application/lib/api.ts#L77) locally and replace `deprecation_logging` with `fake_deprecation_logging`.
- **Unauthorized error fetching ES deprecations.** Mock a `403` status code to `GET /api/upgrade_assistant/es_deprecations` with the response payload: `{ "statusCode": 403 }`
- **Partially upgraded error fetching ES deprecations.** Mock a `426` status code to `GET /api/upgrade_assistant/es_deprecations` with the response payload: `{ "statusCode": 426, "attributes": { "allNodesUpgraded": false } }`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,52 @@ export default function ({ getService }: FtrProviderContext) {
});
});

it('should match the same original index settings after reindex', async () => {
await esArchiver.load('x-pack/test/functional/es_archives/upgrade_assistant/reindex');

const originalSettings = {
'index.number_of_replicas': 1,
'index.refresh_interval': '10s',
};

// Forcing custom settings
await es.indices.putSettings({
index: 'dummydata',
settings: originalSettings,
});

await supertest
.post(`/api/upgrade_assistant/reindex/dummydata`)
.set('kbn-xsrf', 'xxx')
.expect(200);

const lastState = await waitForReindexToComplete('dummydata');
expect(lastState.errorMessage).to.equal(null);
expect(lastState.status).to.equal(ReindexStatus.completed);

const { newIndexName } = lastState;
const indexSummary = await es.indices.get({ index: 'dummydata', flat_settings: true });

// The new index was created
expect(indexSummary[newIndexName]).to.be.an('object');
// The original index name is aliased to the new one
expect(indexSummary[newIndexName].aliases?.dummydata).to.be.an('object');
// Verify mappings exist on new index
expect(indexSummary[newIndexName].mappings?.properties).to.be.an('object');
// Verify settings exist on new index
expect(indexSummary[newIndexName].settings).to.be.an('object');
expect({
'index.number_of_replicas':
indexSummary[newIndexName].settings?.['index.number_of_replicas'],
'index.refresh_interval': indexSummary[newIndexName].settings?.['index.refresh_interval'],
}).to.eql(originalSettings);

// Cleanup newly created index
await es.indices.delete({
index: lastState.newIndexName,
});
});

it('can resume after reindexing was stopped right after creating the new index', async () => {
await esArchiver.load('x-pack/test/functional/es_archives/upgrade_assistant/reindex');

Expand Down

0 comments on commit b503c3c

Please sign in to comment.