Hey guys, It's me again, now I'm trying to run my ...
# pact-php
b
Hey guys, It's me again, now I'm trying to run my contract test with other branch, but I got this error:
Copy code
GuzzleHttp\Exception\ServerException: Server error: `GET <http://localhost:7200/interactions/verification>` resulted in a `500 Internal Server Error` response:
   ├ Actual interactions do not match expected interactions for mock MockService
I have pact installed in my composer.json, and my .env.test with the environments, what should i do?🤔
m
Is there a log file or more detail in the output?it should tell you what was wrong with your request It looks like the request doesn't match what you said
b
I added the PACT_LOG in my .env.test, but returned this error connection
PhpPact\Standalone\Exception\HealthCheckFailedException: Failed to make connection to Mock Server in 10 attempts.
m
Try setting the host to
127.0.0.1
- sometimes
localhost
resolves to an IPv6 address
b
Hmm, I changed to 127.0.0.1 , got the same error..I found in channel a similar problem, and I added this code to my Dockerfile
Copy code
ENV GLIBC_VERSION=2.35-r0

RUN apk --no-cache add gcompat bash \
     && wget -O /etc/apk/keys/sgerrand.rsa.pub -q <https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub> \
     && wget -q <https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk> \
     && apk --no-cache --force-overwrite add glibc-${GLIBC_VERSION}.apk
Maybe that's not enough anymore 😞
y
I am not sure pact-php 8.1 works with phpunit 10, the 9.x release explicitly had a PR that limited it to not working with 10.x
b
Ok, I'll try to downgrade the phpunit version,then I'll try to run pact again🤔
y
so this is running in a docker container with alpine? is it arm64 or amd64?
m
You can also try running the
pact-mock-service
command you see in that output manually, and seeing what happens. If it doesn’t start, it’s probably a good place to start debugging
y
https://github.com/pact-foundation/pact-ruby-standalone/issues/96#issuecomment-1528683353 glibc didn’t work for me installing directly, I used
gcompat
and
libccompat
Matts suggestion to run it from the bin folder directly is a good idea just to check the output outside of php and check the service can start up
b
Thanks, guys, I'm gonna try this suggestion and come back later to give feedback.
Hey guys, I was debbuging and found the full message for the error.
Copy code
Actual interactions do not match expected interactions for mock MockService.

Missing requests:
	POST /freights


See standard out/err for details
Where do I get this out/err in pact?
y
I think that just means to the terminal (stdout and stderr are outputs) that sounds like the mock server is working but your code under test didn’t make a request before the mock was verified, therefore it is saying it received no requests matching your interaction setup.
b
I added the request to mock server and It worked, by the way this step was at doc basic usage consumer too. Thanks guys.
Copy code
$client = new Client();

        $url = "http://{$config->getHost()}:{$config->getPort()}/freights";

        $client->post($url, [
            'json' => $engineRequest,
        ]);
🙌 1
m
Hey guys, I was debbuging and found the full message for the error.
what did you have to do to see that message? That’s the key thing a user would need to see to understand why their test failed, so it should hopefully be obvious. If it’s not, I think it should be fixed
b
I added a dd inside my GuzzleException in my vendor.