Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(local-env-testing): Provide docs for testing on local environment. #537

Merged
merged 8 commits into from
Mar 19, 2024
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* Fix shadow instance's subjects/contributors indexing ([MSEARCH-647](https://issues.folio.org/browse/MSEARCH-647))
* Mark all exact matches as anchors if there is more then one match ([MSEARCH-669](https://issues.folio.org/browse/MSEARCH-669))
* Make POST /search/resources/jobs endpoint to work asynchronously ([MSEARCH-685](https://issues.folio.org/browse/MSEARCH-685))
* Update development.md for local environment testing ([MSEARCH-592](https://issues.folio.org/browse/MSEARCH-592))
GeloPakDev1 marked this conversation as resolved.
Show resolved Hide resolved

### Tech Dept
* Fix log level and message wording for uniform titles ([MSEARCH-666](https://issues.folio.org/browse/MSEARCH-666))
Expand Down
36 changes: 32 additions & 4 deletions doc/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,24 +254,25 @@ The module uses [Testcontainers](https://www.testcontainers.org/) to run Elastic
in embedded mode. It is required to have Docker installed and available on the host where the tests are executed.

### Local environment testing
Run `docker-compose up` in a project root folder.
Navigate to the docker folder in the project and run `docker-compose up`.
This will build local mod-search image and bring it up along with all necessary infrastructure:
- elasticsearch along with dashboards (kibana analogue from opensearch)
- kafka along with zookeeper
- postgres
- wiremock server for mocking external api calls (for example authorization)
-
Also you should invoke

Then, you should invoke
```shell
curl --location --request POST 'http://localhost:8081/_/tenant' \
--header 'Content-Type: application/json' \
--header 'x-okapi-tenant: test' \
--header 'x-okapi-tenant: test_tenant' \
--header 'x-okapi-url: http://api-mock:8080' \
--data-raw '{
"purge": "false"
}
```
to post some tenant in order to bring up kafka listeners and get indices created.
You can check which tenants enabled by wiremock in the `src/test/resources/mappings/user-tenants.json`

To rebuild mod-search image you should:
- bring down existing containers by running `docker-compose down`
Expand All @@ -283,3 +284,30 @@ Hosts/ports of containers to access functionality:
- `localhost` - host, `5010` - port for remote JVM debug
- `http://localhost:8081` - for calling mod-search REST api. Note that header `x-okapi-url: http://api-mock:8080` should be added to request for apis that take okapi url from headers
- `localhost:29092` - for kafka interaction. If you are sending messages to kafka from java application with `spring-kafka` then this host shoulb be added to `spring.kafka.bootstrap-servers` property of `application.yml`

### Consortium support for Local environment testing
Consortium feature is defined automatically at runtime by calling /user-tenants endpoint.
Consortium feature on module enable is defined by 'centralTenantId' tenant parameter.

Invoke the following
```shell
curl --location --request POST 'http://localhost:8081/_/tenant' \
--header 'Content-Type: application/json' \
--header 'x-okapi-tenant: consortium' \
GeloPakDev1 marked this conversation as resolved.
Show resolved Hide resolved
--header 'x-okapi-url: http://api-mock:8080' \
--data-raw '{
"module_to": "mod-search-$version$",
GeloPakDev1 marked this conversation as resolved.
Show resolved Hide resolved
"parameters": [
{
"key": "centralTenantId",
"value": "consortium"
},
{
"key": "loadReference",
"value": true
}
GeloPakDev1 marked this conversation as resolved.
Show resolved Hide resolved
]
}
```
Consider that `tenantParameters` like `loadReference` and `loadSample` won't work because `loadReferenceData`
method is not implemented in the `SearchTenantService` yet.