Hello, was wondering if someone can help me out. I...
# pactflow
r
Hello, was wondering if someone can help me out. I cloned the consumer and provider repos for the bi-directional testing examples. They both use a
make
file that references
pactfoundation/pact-cli
. But this does not exist in the repo so it fails. can't see any sign of this folder anyway. Anyone know what the deal is?
y
Hey, Its a docker image, the makefile should pull it down if you have Docker installed on your machine
r
Hi, thanks - We can't use docker in my company and I use Podman instead
y
Just seen your screenshot, it will most likely be down to volume mount paths from windows into your docker container, in your case podman
you just need to adapt the commands to suit as per the pact-cli readme, you should be able to see the full makefile commands being run in the github actions suites, you'll just need to tailor them to suit for podman, I don't use podman personally
There are other CLI tools you can use other than via the docker image, its available as a standalone executable or as a ruby gem https://docs.pactflow.io/docs/bi-directional-contract-testing/contracts/oas#publishing-the-provider-contract--results-to-pactflow there is a list and some examples there hope that helps a bit.
I think the main is the volume mount path, I created an updated version of that Makefile to allow for cross testing with any of the Pact CLI tools https://github.com/pactflow/example-bi-directional-consumer-cypress/blob/5bec0088a6bd6a28c14a2c9978265a780637c622/Makefile#L149 you'll note the volume mount paths here reference the root to
PWD
with a prefix
/
PACT_CLI="docker run --rm -v ${PWD}:${PWD} -e PACT_BROKER_BASE_URL -e PACT_BROKER_TOKEN pactfoundation/pact-cli"
vs
PACT_CLI_DOCKER_RUN_COMMAND?=docker run --rm -v /${PWD}:/${PWD} -w ${PWD} -e PACT_BROKER_BASE_URL -e PACT_BROKER_TOKEN pactfoundation/pact-cli:${PACT_CLI_DOCKER_VERSION}
That seemed to work for me cross platform
r
I think it's working now, thanks - but now failing for a different reason?
message has been deleted
It's an error being thrown from the CLI tool Ithink
y
I'd recommend not using the makefile and using the commands directly
it hasn't been tested for windows, and you will just add another layer of complexity
sads 1
check you can run the pact-cli via the docker command, outside the makefile check you can publish the pact that is baked into the image (using your env vars) check you can publish the pact from your machine by volume mounting into docker
or just use wsl
probably first place to start is, it looked like the tests ran, is there a pact file somewhere generated 🙂
r
In the consumer project? Yes there's one inside the pacts directroy
*directory
y
awesome
right can you get podman working with a command like this
Copy code
docker run --rm  \
  -e PACT_BROKER_BASE_URL  \
  -e PACT_BROKER_TOKEN  \
  pactfoundation/pact-cli:latest \
  publish \
  /pact/example/pacts \
  --consumer-app-version foo-commit
you will need to set the env vars for your shell, were you using cmd prompt? or pwsh?
I'll fire up my windows lappy now
🙏 1
r
Using Bash
y
the one that comes with git msi installer?
r
Yes
y
sound
can you try
uname -a
?
r
wsl is an option for me too, I do have it installed
message has been deleted
y
wsl will be your easier bet all round, (1 or 2?) however it does work on windows, just not OOB with our instructions. also git bash (and the bash prefix command in the different windows shells is odd) as it seems to use wsl, which confuses me and scripts 😄
oh yeah ta I see wsl2 in there
r
Lemme boot that up
Lol, just realised that's where that screen shot is from facepalm Not from my bash window
Caffine has worn off, sorry
y
all good homie! I'm here for an hour or so before I grab some grub so you've got time to grab a brew
r
Will see how it goes with
make
on wsl
Seems I don't have the right sdks on wsl for dotnet
message has been deleted
y
just testing out now, which is your preferred windows shell? • cmd prompt • pwsh 5 • pwsh 7 • git bash • wsl2 Happy to help you support any of them, for dotnet, we can probably update the repo to 6.x or 7.0, as 3.1 is old now
r
probs cmd prompt
y
so the project sln files in there will say dotnet 3.1 let me check
you can prob update to 6 and see if it compiles
r
Will try net6 and pray
Sweet that works
Ah - I gotta set the env vars in wsl
But. Progress.
y
winner winner chicken dinner! yeah
export PACT_BROKER_BASE_URL=<https://foobar.pactflow.io>
nice, I can get you sorted on cmd prompt too, I stretched my legs on there back in the day before becoming a mac boi, and I recently found oh my posh, so all my windows shells are dead pretty so don't mind an excuse dipping back into to devving on a windows box
r
Hmm - I got unautherized. Maybe the token was wrong
Should be this one, correct?
message has been deleted
👍 1
y
correct, you can try our public one out with this
Copy code
export PACT_BROKER_BASE_URL=<https://test.pactflow.io>
export PACT_BROKER_TOKEN=129cCdfCWhMzcC9pFwb4bw
and check if they work?
r
Trying now
Yeh that seemed to work!
y
okay cool so maybe we just need to either check your creds are correct set (you can use
echo $PACT_BROKER_TOKEN
in your shell to see it matches up
otherwise check your roles for your user acc
r
Looks like it's working. Maybe I messed up the copy pasta
It seems to be hanging on can-i-deploy thought
Waiting for 1 verfication result to be published
y
so the repo was recently updated to poll and wait for a verification result, as the provider side hasnt been published there will be no verification result so it will time out
r
Was about to say
Not done the prover yet
y
I also note its using the pact net beta version, you can see the delta of moving to the latest pact-net 4.x in these PR's https://github.com/pactflow/example-consumer-dotnet/pull/8/files https://github.com/pactflow/example-provider-dotnet/pull/9
I can add that to an ever growing list of tasks hehe hopefuly that will sort you out, happy to accept any PR's back to the repo to make you or others lifes easier in the future 🙂
even an echo statement saying if you havent published your provider yet, this will time out after x seconds, why not run your chosen provider ci now?
r
I think this error is pretty self explanatory tbf
👍 1
message has been deleted
Let me go do the
make
bants on the provider repo
🏎️ 1
Gotta update dotnet for this project too
Ok, this one isn't being so friendly to net6.0
y
just having a nose now bud
🙏 1
maybe I spoke too soon 😂
👀 1
failing in CI but passing on my machine
r
Interesting!
Should I copy pasta your changes or are you going to merge that in?
y
you can just checkout that branch if you want for the moment, id rather get the CI passing before I merge 🙂
👍 1
git checkout dotnet6
will need to
git fetch
if you've cloned the repo
r
Got it. Thanks!
make verify_swagger
doesn't seem to work
message has been deleted
Just says Command not found thinking2
y
so that script is going to try and run docker, which I assume you don't have in wsl
r
I did already update it to podman
y
got it working in CI, needed to match the dotnet version because its set in global.json
humm
r
apparently it's "/bin/bash^M: bad interpreter:"
line endings?
y
are we back in git bash or ubuntu/wsl?
maybe
so it runs
dotnet example-bi-directional-provider-dotnet/bin/Debug/netcoreapp6.0/example-bi-directional-provider-dotnet.dll
and grabs the pid
r
this is wsl
y
does that run?
it's not verbose at all 🙂 it just starts up and waits
r
It seems to be running yes
it's chillin
y
😎
right cool
so now we've got
docker run --net="host" schemathesis/schemathesis:stable run --stateful=links --checks all <http://host.docker.internal:9000/swagger/v1/swagger.json> > report.txt
lets get rid of the redirect to report.txt
Copy code
🕙18:33:41 ❯ docker run --net="host" schemathesis/schemathesis:stable run --stateful=links --checks all <http://host.docker.internal:9000/swagger/v1/swagger.json>
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
======================= Schemathesis test session starts =======================
Schema location: <http://host.docker.internal:9000/swagger/v1/swagger.json>
Base URL: <http://host.docker.internal:9000/>
Specification version: Open API 3.0.1
Workers: 1
Collected API operations: 2

GET /Products .                                                           [ 50%]
GET /Products/{id} .                                                      [100%]

=================================== SUMMARY ====================================

Performed checks:
    not_a_server_error                              101 / 101 passed          PASSED 
    status_code_conformance                         101 / 101 passed          PASSED 
    content_type_conformance                        101 / 101 passed          PASSED 
    response_headers_conformance                    101 / 101 passed          PASSED 
    response_schema_conformance                     101 / 101 passed          PASSED 

Hint: You can visualize test results in <http://Schemathesis.io|Schemathesis.io> by using `--report` in your CLI command.
r
do I need to run this in a new window with the eample app still running?
*example
y
oh yes please, if you could run in a new wsl terminal 🙂
with the dll running in the background 🙂
r
message has been deleted
Not sure what this means
y
so looks like podman cant find that image
also the host.docker.internal path might not be required for podman
r
can just do localhost?
Ah got it
podman can be a bit eggy with docker links. stick docker.io/ in front an it will find em
message has been deleted
y
You might have to author our first Podman troubleshooting section 😄
wario shocked 1
so host.docker.internal allows a docker container to talk to the host platform and is required on mac/windows using docker because not linux
podman might not have that issue, or you might need to use a special format so localhost doesn't resolve to the container and instead resolves to your local machine which is running the provider
r
The comment from Luap99?
y
r
I just ysed http://localhost:9000 and it was ... ok?
message has been deleted
y
happy days it probably just binds its automagically
woop
r
God bless em
y
happy hacking homie 🙂
r
Ah, I'm conscious that you said you had to go in an hour over an hour ago
Hi @Yousaf Nabi (pactflow.io) thanks a lot for yesterday. Really helpful. Had to iron through a few more issues but think I'm nearly there now. Current status is that I can run the
make fake_ci
successfully for the provider, but the consumer still fails at the
can-i-deploy
step in it's
make fake_ci
step. Not sure where to go from here because that's where the example documentation ends.
Currently see :
y
the provider isn’t deployed as we aren’t on the main branch
the makefile has a condition that will only do the deploy step from the main/master branch
r
Ah ok, yes.
y
thanks a lot for yesterday. Really helpful. Had to iron through a few more issues but think I’m nearly there now.
Pleasure, glad you are cooking on gas
reverse muscle 1
r
Should I alter the make file or wait for you to check into main?
Is it still giving you ci troubles?
Better, closer, warmer
On the side, I have another issue with the consumer tests. They always fail because they can't start the mock server unless I restart my PC. Obviously there is some sort of running process stopping it from being able to start. I don't suppose you know what that is?
(I've had to comment out
dotnet test
from the make file
y
The consumer side more than likely wants updating to latest pact net (non beta) once I’ve done that I’ll merge both the PR’s
r
Amazong, thanks
*amazing
y
Right updated both repos to .net 6 and pact-net 4.5.0 on the consumer side, all passing in CI. Is your provider marked as deployed in production now?
r
It is yeh. Let me just go get latest everything, get back on main for the provider and see where that gets me 👍
Sorry, had to go to a meeting. Something seems to have gone wrong when I pulled latest because now the provider project doesn't load in VS 😞
y
can you check what version of dotnet with
dotnet --version
you may need to update the global.json to reflect your installed version https://github.com/pactflow/example-bi-directional-provider-dotnet/pull/16/files#diff-8df3cd354bc584349d04ad5675b[…]8b99b741b8b95af394c55e0f5001bfR3
r
says
C:\dev\TestGround\PactflowStuff\contract-testing-poc\pactFlow\dotnet\example-apps\provider\example-bi-directional-provider-dotnet\example-bi-directional-provider-dotnet.csproj : error  : The project file cannot be opened by the project system, because it is missing some critical imports or the referenced SDK cannot be found.
So I installed the latest SDK to see if that fixed it and it hasn't. Though I did just think I probs just need to restart my computer or something
y
np
Though I did just think I probs just need to restart my computer or something
This is almost, always, never a bad shout
r
Haha
Will let you know if it works
oh, that didn't work!
yet I'm on a later version
y
try updating the refs from 403 to 408
r
in global.json?
Not sure which refs, it's only referenced in that global.json file. changing that to match my version of .Net didn't fix it
y
try
dotnet build --no-restore
and please show the error message if any?
r
Builds fine!
through the command line
Woohoo! It finally works!
message has been deleted