Benjamín Earle
03/21/2023, 7:41 PMget
endpoint for that entity. I need to create it first so that the endpoint doesn't return a 404.
I have created a provider state setup function in my API, that creates this entity and returns a dictionary with the relevant value for the generator.
I am using the docker pact-cli for verifying the provider, and it is calling that endpoint correctly. My issue is that it is not modifying the pact to use the returned id instead of the example specified in the pact. Here's an example of my code:
// Consumer in JavaScript
provider
.given("an existing experiment")
.uponReceiving("a request to get the experiment")
.withRequest({
method: "GET",
path: fromProviderState("/v3/experiments/${uuid}", `/v3/experiments/${exampleUuid}`),
})
.willRespondWith({
status: 200,
body: { resource: like({
uuid: fromProviderState("${uuid}, exampleUuid)
})},
}));
# Provider state setup endpoint (Python & FastApi)
@router.get(/pact/setup)
def pact_setup():
experiment = create_experiment()
return { "uuid": experiment.uuid }
The setup function is being called by the docker verifier, returning the uuid of the created experiment, but the provider verification is still executing a get request to the exampleUuid
. Is there anything I'm missing?Mark Cox
03/22/2023, 9:21 AMErich Buri
03/23/2023, 11:14 AMeachKeyLike()
and it might have to do with the fix here: https://github.com/pact-foundation/pact-reference/issues/216
Please see my comment here https://github.com/pact-foundation/pact-reference/issues/216#issuecomment-1480976176
and the added note below: https://github.com/pact-foundation/pact-reference/issues/216#issuecomment-1480996968
I ran the same on Windows and Mac as I wasn't sure if it is related to my machine. But I got the same result. This is a simplified version to show the issue. I have a more complex data-structure I want to test and the resulting matchingRules
I got were looking very strange:
Example:
"$.angebote.*.*.*[*].*[*].*.*.*": {
"combine": "AND",
"matchers": [
{
"match": "type",
"min": 1
},
{
"match": "type"
},
{
"match": "integer"
}
]
},
How could anything satisfy that.Yousaf Nabi (pactflow.io)
Sushant Soni
03/24/2023, 11:05 AMcan contract tests ensure the understanding of what is an optional parameter and what is not between provider and consumer (and how)
Mohammed Ezzedine
03/27/2023, 4:01 PMBal
03/28/2023, 4:53 AMcutler82
03/28/2023, 1:53 PMIlia
03/28/2023, 11:55 PMxin chen
03/30/2023, 3:20 PMpact {
broker {
pactBrokerUrl = '<https://company.test.stp.hmlr.zone/>'
}
the pact broker won't be found. Not sure why it does not work. Please help. Thank you.Ulises Cervino
03/31/2023, 1:24 PMUlises Cervino
03/31/2023, 1:25 PMUlises Cervino
03/31/2023, 1:26 PMEduardo
04/03/2023, 8:40 AMJordan Stewart
04/03/2023, 8:58 AMJacob Buckley
04/06/2023, 6:46 PMGonzalo Granizo
04/11/2023, 10:24 AM<http://au.com|au.com>.dius.pact.provider.junitsupport.loader.NoPactsFoundException: No Pact files were found to verify
Provider: pss-paymentMethod-api
Source: Pact Broker <https://adidascdc.pactflow.io>
Zeus
04/13/2023, 9:55 AM/makePayment
That endpoint takes in two input parameters i.e, _payment_token_ and _customer_id_
Whenever consumer service hits that endpoint, provider internally calls a third party service(external vendor) to make the payment based on payment token and customer id. And returns the response accordingly.
The catch is that each payment_token can be used only once. And 3rd party service doesn’t provide a dummy/static token, and there exists a way to call an endpoint in 3rd party staging env to generate the token.
My point is that while generating the contract tests in consumer side, we don’t know have payment_token. So, how should I approach this problem?
One way I could think is to mock 3rd party service in provider side and carry out the tests. However, if I would like to avoid mocking and want to call staging env of 3rd party service from provider service, then is it feasible to carry out contract testing?Lewis Prescott
04/13/2023, 10:32 AMSlackbot
04/13/2023, 5:01 PMYousaf Nabi (pactflow.io)
Jean Paiva
04/14/2023, 8:26 PMGuo Zhang Liew
04/17/2023, 12:18 AMpactfoundation/pact-cli:latest
docker image
/usr/lib/ruby/gems/3.1.0/gems/pact_broker-client-1.66.1/lib/pact_broker/client/hal/http_client.rb:49:in `create_request': undefined method `request_uri' for #<URI::Generic //pact.dev.stackjourney.xyz/contracts/publish> (NoMethodError)
request = Net::HTTP.const_get(http_method).new(uri.request_uri)
^^^^^^^^^^^^
I have searched through all issues in the pact foundation github space
this is the docker command I used
docker run -t -i --rm --init --volume .. --env PACT_BROKER_BASE_URL --env PACT_BROKER_USERNAME --env PACT_BROKER_PASSWORD --env GIT_BRANCH=gz/FEAT-69/brokerclient/1 pactfoundation/pact-cli:latest /bin/sh -e -c $'pact-broker help\npact-broker publish backend/pacts --tag-with-git-branch'
Harold Robson
04/18/2023, 9:48 AM2023-04-18 10:44:07 "POST /_pact/provider_states HTTP/1.1" 200 4 "-" "Faraday v1.10.3"
2023-04-18 10:44:07 [INFO] base.py(270): POST <http://elasticsearch:9200/battery.notification*/_search> [status:200 request:0.024s]
2023-04-18 10:44:07 "GET /battery-notifications?limit=100&offset=0&id=36baa499-ce79-4c03-96e3-93a90fb7f1d9 HTTP/1.1" 200 309 "-" "-"
2023-04-18 10:44:28 "POST /_pact/provider_states HTTP/1.1" 200 47 "-" "Faraday v1.10.3"
2023-04-18 10:44:30 [INFO] base.py(270): POST <http://elasticsearch:9200/battery.notification*/_search> [status:200 request:0.047s]
2023-04-18 10:44:30 "GET /battery-notifications?limit=100&offset=0&id=36baa499-ce79-4c03-96e3-93a90fb7f1d9 HTTP/1.1" 200 309 "-" "-"
My provider states endpoint is set to return after a 20 second delay to give my app time to be ready but it seems that the verifier is using the result from the first request before the app was ready, and the test is failing because there is no data available yet.
test output for the above log:
Verifying a pact between fleet and battery-api
Given Fleet has a list of notifications
a request for notifications
with GET /battery-notifications?limit=100&offset=0&id=36baa499-ce79-4c03-96e3-93a90fb7f1d9
returns a response which
has status code 200
has a matching body
includes headers
"Content-Type" which equals "application/json"
1 interaction, 0 failures
WARN: Ignoring unsupported combine AND for path $['vehicle_id'][0]
WARN: Ignoring unsupported combine AND for path $
It shows 1 interaction but two are always happening behind the scenes. I can see all my test data is duplicated twice in the local instance of the app. It shows no failure locally because my app is now full of this data but in CI where it is a fresh instance, it always fails with:
Matching keys and values are not shown
791 {
792 - "notifications": [
793 - {
794 - "id": "e2490de5-5bd3-43d5-b7c4-526e33f71304",
...
806 - },
807 + "notifications": [,
808 +
Can anybody advise me please?Yousaf Nabi (pactflow.io)
Harold Robson
04/18/2023, 4:49 PM<- "PUT /pacticipants/battery-api/versions/8d80c2b631939740976bcbf27f05049b86a16dcc/tags/ HTTP/1.1\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: application/hal+json\r\nUser-Agent: Ruby\r\nContent-Type: application/json\r\nHost: <http://pact.dev.ieu.intelematics.club|pact.dev.ieu.intelematics.club>\r\nContent-Length: 0\r\n\r\n"
<- ""
-> "HTTP/1.1 404 Not Found\r\n"
Can't it create these dynamically?Yousaf Nabi (pactflow.io)
Priyaranjan Mudliar
04/19/2023, 9:11 AMPriyaranjan Mudliar
04/19/2023, 9:19 AMAlan Boshier
04/19/2023, 11:01 AMabsolute-version
to get the version V of X and then do something like this:
./pact-broker can-i-deploy --to-environment=E --pacticipant=X --version=V
However, if my consumer contracts that X relies on are inside the library L, I assume the equivalent check would be (assuming L is at versions Lv, and that X doesn't have any consumer contracts of its own):
./pact-broker can-i-deploy --to-environment=E --pacticipant=L --version=Lv
To make this work, my deployment script for X needs to know the "pact identity" of the library L (which is not a big deal), but also needs to know the the "pact version" of L.
Typically I have used "git version" for pact versions (i.e. something based on the branch+tag+commits_since_tag) as that unambiguously defines the code state of the pacticipant. In that setup, my deployment script just uses npx absolute-version
to compute V.
In the case of a library being the pacticipant, that technique isn't going to work (since the script in running in a git repo for X, not L). This would mean that L would need a different pact versioning approach that
didn't rely on git state (e.g. a maven version or an node package version of the library component itself).
Such versions must change if the contracts change in any way; in the git versioning approach above this happens automatically, but in the maven/package versioning approach I must increment the version when I make contract-changing modifications to the library. And then ensure that new version is incorporated into my deploy script for X.
Does that sound like the right approach, or are there better ways to approach this? tia