Start Wiremock Standalone
- navigate to dmi-plugin-perf-stub folder in cps project
- use ./start.sh command to run wiremock
Code Block |
---|
language | bash |
---|
title | start.sh |
---|
|
docker run -it --rm -p 8783:8080 -v "$(pwd)"/mappings:/home/wiremock/mappings -v "$(pwd)"/files:/home/wiremock/__files --name wiremock wiremock/wiremock:2.33.2 --verbose |
Use Wiremock in Docker-compose
put this code in your docker-compose.yaml
Code Block |
---|
language | yml |
---|
title | docker-compose.yaml |
---|
|
sdnc:
container_name: sdnc
image: wiremock/wiremock:2.33.2
ports:
- 8783:8783 # it is not necessary, just when you want to reach it outside the composed docker system
volumes:
- <cps project folder>/dmi-plugin-perf-stub/mappings:/home/wiremock/mappings
- <cps project folder>/dmi-plugin-perf-stub/files:/home/wiremock/__files
command: ["--verbose", "--port", "8783"] |
Add New Request & Response to Wiremock
create a new custom named json file in dmi-plugin-perf-stub/mappings folder
Code Block |
---|
language | css |
---|
title | newRequest.json |
---|
|
{
"request": {
"method": "<http method>", # POST, GET, PUT etc.
"urlPattern": "<regex pattern for your URL>" # for example /path/to/.*/your/content
},
"response": {
"status": <http status in int>, # http response status code, usually 200
"bodyFileName": "<your response file name>", # name of your response file, the wiremock will send back the content of your response file, not the file itself
"headers": {
"Content-Type": "application/json" # application type, when you send structured text as a response
}
}
} |
create your response file in dmi-plugin-perf-stub/files folder
Example commit: https://gerrit.onap.org/r/c/cps/+/130970
More information: Wiremock