CLI-1761: Implement createSolrCore command for MEO environments.#1984
CLI-1761: Implement createSolrCore command for MEO environments.#1984deepakmishra2 wants to merge 6 commits intomainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1984 +/- ##
=========================================
Coverage 92.37% 92.37%
Complexity 1953 1953
=========================================
Files 123 123
Lines 7081 7081
=========================================
Hits 6541 6541
Misses 540 540 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Try the dev build for this PR: https://acquia-cli.s3.amazonaws.com/build/pr/1984/acli.phar |
There was a problem hiding this comment.
Pull request overview
Adds a new Acquia Cloud API v3 environment endpoint and corresponding CLI command/test to provision (create) a Solr search index (core) for MEO environments.
Changes:
- Added
POST /v3/environments/{environmentId}/search/indexesto the embedded OpenAPI spec with CLI mappingenvironments-v3:search:index-create. - Added a PHPUnit test covering request construction, invocation, and output for
api:environments-v3:search:index-create.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| tests/phpunit/src/Commands/Api/ApiCommandTest.php | Adds an execution test for the new api:environments-v3:search:index-create command. |
| assets/acquia-spec.json | Introduces the new v3 environments search index create endpoint definition used for command generation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "requestBody": { | ||
| "required": true, | ||
| "content": { | ||
| "application/hal+json": { | ||
| "schema": { | ||
| "type": "object", | ||
| "required": [ | ||
| "config_set_id", | ||
| "database_role" | ||
| ], | ||
| "properties": { | ||
| "config_set_id": { | ||
| "type": "string", | ||
| "description": "The identifier of the Solr configuration set to be used." | ||
| }, | ||
| "database_role": { | ||
| "type": "string", | ||
| "description": "The database role for the new Solr core." | ||
| } | ||
| } | ||
| }, | ||
| "example": { | ||
| "config_set_id": "DHJX-211844.9bb9b2f2c26be19cadf4057b95ad5ad6", | ||
| "database_role": "example" | ||
| } | ||
| }, | ||
| "application/x-www-form-urlencoded": { |
There was a problem hiding this comment.
The requestBody is described (in PR text) as supporting JSON input, but the spec only declares application/hal+json and application/x-www-form-urlencoded. Since the CLI sends post params via the HTTP client's json option, consider adding an application/json entry (same schema/example) so the OpenAPI accurately reflects supported content-types and client generators/tests can select JSON explicitly.
| "message": "The search index for example is being created.", | ||
| "_links": { | ||
| "self": { | ||
| "href": "https://cloud.acquia.com/api/environments/3e8ecbec-ea7c-4260-8414-ef2938c859bc/search/indexes/ABCDE-1234.test.example" | ||
| }, | ||
| "parent": { | ||
| "href": "https://cloud.acquia.com/api/environments/3e8ecbec-ea7c-4260-8414-ef2938c859bc/search/indexes/" | ||
| }, |
There was a problem hiding this comment.
The 202 response example _links point at /api/environments/.../search/indexes..., but this operation path is /translation/environments/.../search/indexes. If /translation is the canonical resource path for this API, update the example link URLs to match to avoid misleading consumers (or clarify why the links intentionally omit /translation).
| $mockRequestArgs = self::getMockRequestBodyFromSpec('/translation/environments/{environmentId}/search/indexes'); | ||
| $mockResponseBody = self::getMockResponseFromSpec('/translation/environments/{environmentId}/search/indexes', 'post', '202'); | ||
| foreach ($mockRequestArgs as $name => $value) { | ||
| $this->clientProphecy->addOption('json', [$name => $value]) | ||
| ->shouldBeCalled(); | ||
| } | ||
| $this->clientProphecy->request('post', '/translation/environments/' . $environmentId . '/search/indexes') | ||
| ->willReturn($mockResponseBody) | ||
| ->shouldBeCalled(); | ||
| $this->command = $this->getApiCommandByName('api:environments-v3:search:index-create'); | ||
| $this->executeCommand(array_merge( | ||
| ['environmentId' => $environmentId], | ||
| $mockRequestArgs, | ||
| )); |
There was a problem hiding this comment.
The generated CLI arguments for this endpoint will be config_set_id and database_role (from the requestBody schema/example). That doesn’t match the PR description/testing steps which refer to indexName and configsetUuid. Either update the PR description/testing steps to match the actual CLI interface, or adjust the spec field names/CLI mapping so the command accepts the intended argument names.
|
Closing this as the approach is changed to add the spec in secret and then merge it in CI |
Motivation
Fixes #CLI-1761
Proposed changes
This pull request adds support for creating Solr search indexes within a specific environment via the API, and introduces corresponding automated tests to ensure the new functionality works as expected.
API enhancements:
POST /v3/environments/{environmentId}/search/indexesendpoint to the OpenAPI spec, allowing provisioning of a new Solr core (search index) for a given environment. The endpoint requiresindexNameandconfigsetUuidin the request body, and supports both JSON and form-encoded input.Testing improvements:
testMeoEnvironmentSearchIndexCreateinApiCommandTest.phpto verify the new search index creation command, including request arguments, response handling, and output validation.Testing steps
acli api:environments-v3:search:index-create