J'ai un projet qui utilise des microservices. J'essaie d'utiliser un simulacre pour créer un environnement de test.Proxication de plusieurs URL à l'aide de wiremock-docker
Comment puis-je proxy plusieurs URL à l'aide de docker-composer.
Voici mon fichier Docker-composer.
networks:
ft-simulator:
external: false
services:
app:
depends_on:
- nginx
environment:
- SPRING_PROFILES_ACTIVE=simulator
- JAVA_FLAGS=-Dhttp.proxyHost=wiremock -Dhttp.proxyPort=8080
healthcheck:
interval: 1m
retries: 3
test:
- CMD
- curl
- -f
- http://localhost:8080/health
timeout: 10s
image: ft-simulator:latest
ports:
- "8080:8080"
networks:
ft-simulator:
aliases:
- bcp
nginx:
image: nginx
ports:
- "80:80"
- "443:443"
networks:
- ft-simulator
wiremock:
image: rodolpheche/wiremock:2.8.0-alpine
networks:
- ft-simulator
ports:
- "8081:8080"
volumes:
- "$PWD/stubs:/home/wiremock"
command: ["--proxy-all=http://bcp:8080, http://www.google.com"]
version: '3.1'
Google est simplement un espace réservé jusqu'à ce qu'il démarre.
Quand je lance docker-je composer jusqu'à obtenir l'erreur suivante
crp11070m:wiremock-simulation john.hamlett$ docker logs -f wiremocksimulation_wiremock_1
Exception in thread "main" java.lang.IllegalArgumentException: Illegal character in authority at index 7: http://bcp:8080, http://www.google.com
at java.net.URI.create(URI.java:852)
at com.github.tomakehurst.wiremock.standalone.CommandLineOptions.proxyHostHeader(CommandLineOptions.java:274)
at com.github.tomakehurst.wiremock.core.WireMockApp.buildStubRequestHandler(WireMockApp.java:123)
at com.github.tomakehurst.wiremock.WireMockServer.<init>(WireMockServer.java:72)
at com.github.tomakehurst.wiremock.standalone.WireMockServerRunner.run(WireMockServerRunner.java:65)
at com.github.tomakehurst.wiremock.standalone.WireMockServerRunner.main(WireMockServerRunner.java:113)
Caused by: java.net.URISyntaxException: Illegal character in authority at index 7: http://bcp:8080, http://www.google.com
at java.net.URI$Parser.fail(URI.java:2848)
at java.net.URI$Parser.parseAuthority(URI.java:3186)
at java.net.URI$Parser.parseHierarchical(URI.java:3097)
at java.net.URI$Parser.parse(URI.java:3053)
at java.net.URI.<init>(URI.java:588)
at java.net.URI.create(URI.java:850)
... 5 more
Merci, est-il possible de se moquer d'une dépendance externe? Tels que je prends une image de http://www.sweetviz.com/bestimage.jpg? J'ai un service externe qui renvoie JSON à mon application. Je peux l'intérioriser si ce n'est pas possible. –