A service that's capable of registering itself in a service registry and do the following:
This allows simulating services that have not been implemented yet or will not be implemented by Backbase because they're meant to be implemented by external parties such as integration APIs.
It's also possible to mock external dependencies so that performance tests provide consistent results and don't fail because of external dependency failures.
Build it as a regular maven project with mvn clean install
.
The following properties are always configured:
spring.application.name
: name of the service that you'll simulate, card-manager
for examplebackbase.api.simulator.specAuthorizations.domain-name
: map of domain name to access token to download OpenAPI spec,
replace domain-name
with the domain you'd like to configureOne of the following needs to be configured:
backbase.api.simulator.spec
: OpenAPI specification file path or URL for Prism that will be simulatedmappings directory
: directory containing stub mappings for WireMockhttps://github.com/stoplightio/prism/issues/1578:
Prism uses a non-configurable timeout of 5 seconds to download the OpenAPI specification and fails with the message
socket hang up
if the download takes longer than that, a workaround is to use a local file instead.
Download an OpenAPI specification and copy it to config/openapi.yaml
.
It's also possible to configure a URL so that the service can download it at startup.
Run it as a Spring Boot application with working directory pointing to the root directory of this project.
Use com.backbase.api.simulator.Application
as main class, local
profile and configure it with
config/application-local.yml
file.
Execute the following command to generate a docker image:
mvn clean install jib:dockerBuild -Pdocker-image
Then you can run the service with:
docker run -v $(pwd)/config/openapi.yaml:/config/openapi.yaml --env-file ./config/env.list -p 8080:8080 --rm -it your-image-name
Create stub mappings according to WireMock's documentation.
Stub mappings must be in a directory called mappings
.
Run it as a Spring Boot application with working directory pointing to the root directory of this project.
Use com.backbase.api.simulator.Application
as main class, local
profile and configure it with
config/application-local.yml
file.
The following docker-compose runs api-simulator
with WireMock:
access-control:
image: harbor.backbase.eu/internal/api-simulator:${API_SIMULATOR_VERSION}
environment:
spring.application.name: access-control
backbase.api.simulator.mode: PERFORMANCE
backbase.api.simulator.port: 8080
server.port: 18080
volumes:
- ./performance/access-control:/config
Where the directory ./performance/access-control/mappings
contains JSON stub mapping files.