Skip to content

Commit

Permalink
[8.x] [CLOUD] Instant deployment (#201688) (#201978)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.x`:
- [[CLOUD] Instant deployment
(#201688)](#201688)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Xavier
Mouligneau","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-27T13:08:08Z","message":"[CLOUD]
Instant deployment (#201688)\n\n## Summary\r\n\r\nWe are having the same
issue as here\r\nhttps://github.com//pull/197667 for
instant deployment. We\r\nneed to allow the solution_type
`search`.\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"54d46986e676c0a824ac20204391f0212e59c880","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:Cloud","v9.0.0","backport:version","v8.17.0","v8.18.0","v8.16.2"],"title":"[CLOUD]
Instant
deployment","number":201688,"url":"https://github.com/elastic/kibana/pull/201688","mergeCommit":{"message":"[CLOUD]
Instant deployment (#201688)\n\n## Summary\r\n\r\nWe are having the same
issue as here\r\nhttps://github.com//pull/197667 for
instant deployment. We\r\nneed to allow the solution_type
`search`.\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"54d46986e676c0a824ac20204391f0212e59c880"}},"sourceBranch":"main","suggestedTargetBranches":["8.17","8.x","8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201688","number":201688,"mergeCommit":{"message":"[CLOUD]
Instant deployment (#201688)\n\n## Summary\r\n\r\nWe are having the same
issue as here\r\nhttps://github.com//pull/197667 for
instant deployment. We\r\nneed to allow the solution_type
`search`.\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"54d46986e676c0a824ac20204391f0212e59c880"}},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.16","label":"v8.16.2","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Xavier Mouligneau <[email protected]>
  • Loading branch information
kibanamachine and XavierM authored Nov 27, 2024
1 parent 2810d04 commit b97c596
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,60 @@ describe('PUT /internal/spaces/space/{id}/solution', () => {
});
});

it('should update the solution_type when it is search', async () => {
const payload = {
solution_type: 'search',
};

const { routeHandler, savedObjectsRepositoryMock } = await setup();

const request = httpServerMock.createKibanaRequest({
params: {
id: 'a-space',
},
body: payload,
method: 'post',
});

const response = await routeHandler(mockRouteContext, request, kibanaResponseFactory);

const { status } = response;

expect(status).toEqual(200);
expect(savedObjectsRepositoryMock.update).toHaveBeenCalledTimes(1);
expect(savedObjectsRepositoryMock.update).toHaveBeenCalledWith('space', 'a-space', {
solution: 'es',
name: 'a space',
color: undefined,
description: undefined,
disabledFeatures: [],
imageUrl: undefined,
initials: undefined,
});
});

it('should failed when the solution_type is not the expected one', async () => {
const payload = {
solution_type: 'searchXoXo',
};

const { routeHandler } = await setup();

const request = httpServerMock.createKibanaRequest({
params: {
id: 'a-space',
},
body: payload,
method: 'post',
});

const response = await routeHandler(mockRouteContext, request, kibanaResponseFactory);

const { status } = response;

expect(status).toEqual(500);
});

it('should not allow a new space to be created', async () => {
const payload = {
solution: 'oblt',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const spaceSolutionSchema = schema.oneOf([
schema.literal('security'),
schema.literal('observability'),
schema.literal('elasticsearch'),
schema.literal('search'),
]),
}),
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export default function ({ getService }: FtrProviderContext) {
.expect(400);

expect(body.message).to.eql(
'[request body]: types that failed validation:\n- [request body.0.solution]: expected at least one defined value but got [undefined]\n- [request body.1.solution_type]: types that failed validation:\n - [request body.solution_type.0]: expected value to equal [security]\n - [request body.solution_type.1]: expected value to equal [observability]\n - [request body.solution_type.2]: expected value to equal [elasticsearch]'
'[request body]: types that failed validation:\n- [request body.0.solution]: expected at least one defined value but got [undefined]\n- [request body.1.solution_type]: types that failed validation:\n - [request body.solution_type.0]: expected value to equal [security]\n - [request body.solution_type.1]: expected value to equal [observability]\n - [request body.solution_type.2]: expected value to equal [elasticsearch]\n - [request body.solution_type.3]: expected value to equal [search]'
);
});

Expand Down

0 comments on commit b97c596

Please sign in to comment.