My provider service is a python FastAPI service though which briefly returns an empty reply to all requests while it is starting up. This unfortunately happens to coincide with when docker-compose treats it as "up" and proceeds to run the pact_verifier_cli command, so when pact_verifier_cli attempts to POST state change requests to my provider, it gets an empty response and fails. This is still the case even when using the --request-timeout option, since the request is not timing out.
As a work-around, I had to remove the pact_verifier_cli from my docker compose file and instead call it as part of a script so I could wait for the service to return a valid response instead of an empty response (here I'm just GETting the state change endpoint, so I expect it to return a 405 since it only accepts POSTs, but that's still enough to know that the service is done starting up):
set -o pipefail
docker-compose up -d
function teardown {
docker-compose down
}
trap teardown EXIT
while [[ $(curl -s -o /dev/null -w %{http_code} 0.0.0.0:8080/_pact/provider_states) != 405 ]]
do sleep 1
done
docker run --network host pactfoundation/pact-ref-verifier --broker-url "http://my-broker-url.com/" \
--provider-name "test-service" \
--hostname "localhost" \
--port "8080" \
--state-change-url "http://localhost:8080/_pact/provider_states"
As you can see, it would be nice if an option which did something similar to this were built into the rust/pact_verifier_cli so I could rely solely on docker-compose to orchestrate the start-up of my verification.
I'm trying to use docker-compose to run both the pact_verifier_cli (via the docker image) and my provider service, like so:
My provider service is a python FastAPI service though which briefly returns an empty reply to all requests while it is starting up. This unfortunately happens to coincide with when docker-compose treats it as "up" and proceeds to run the pact_verifier_cli command, so when pact_verifier_cli attempts to POST state change requests to my provider, it gets an empty response and fails. This is still the case even when using the --request-timeout option, since the request is not timing out.
As a work-around, I had to remove the pact_verifier_cli from my docker compose file and instead call it as part of a script so I could wait for the service to return a valid response instead of an empty response (here I'm just GETting the state change endpoint, so I expect it to return a 405 since it only accepts POSTs, but that's still enough to know that the service is done starting up):
As you can see, it would be nice if an option which did something similar to this were built into the rust/pact_verifier_cli so I could rely solely on docker-compose to orchestrate the start-up of my verification.