slackk0t0
10/26/2022, 1:14 AMSushant Soni
10/27/2022, 10:27 AMWARN ThreadId(02) pact_models::pact: Note: Existing pact is an older specification version (V3), and will be upgraded
The existing spec is V2 and we are migrating to V3. How come V3 is older? or is there an issue here actually?Victor Zviaruha
10/27/2022, 12:02 PM[09:38:07] : [Step 1/1] 2022-10-27T09:38:07.687602Z DEBUG ThreadId(01) pactffi_create_mock_server_for_pact{pact=PactHandle { pact_ref: 2 } addr_str=0x7ffceb12faf0 tls=false}: pact_mock_server::mock_server: Started mock server on 127.0.0.1:34851
[09:38:07] : [Step 1/1] 2022-10-27T09:38:07.692042Z DEBUG ThreadId(01) pact_matching::metrics: Could not get the tokio runtime, will not send metrics - there is no reactor running, must be called from the context of a Tokio 1.x runtime
[09:38:07] : [Step 1/1] 2022-10-27T09:38:07.692066Z DEBUG ThreadId(01) pact_mock_server::server_manager: Shutting down mock server with ID 669f159b-22ac-4e8d-b0c6-378f489ba070 - MockServerMetrics { requests: 0 }
[09:38:07] : [Step 1/1] 2022-10-27T09:38:07.692087Z DEBUG ThreadId(01) pact_mock_server::mock_server: Mock server 669f159b-22ac-4e8d-b0c6-378f489ba070 shutdown - MockServerMetrics { requests: 0 }
[09:38:07] : [Step 1/1] 2022-10-27T09:38:07.692105Z DEBUG tokio-runtime-worker hyper::server::shutdown: signal received, starting graceful shutdown
Attached is test code (I've removed some tests for readability as they have same logic) and build logs. Could you please help with this?Michael Laird
10/27/2022, 2:40 PMyarn install
on GitLab but having no issues locally.
error ../node_modules/@pact-foundation/pact-core: Command failed.
Ian Christopher Oroceo
10/28/2022, 8:49 PMignoreMe
from verification if possible. If there's none, the second question of matching, the data in object ignoreMe
are generated based on what's available data.
TIA for answering the question of a QA :DBenjamin Chalich
10/28/2022, 9:18 PMBenjamin Chalich
10/28/2022, 9:42 PMslackk0t0
10/31/2022, 4:58 AM[2022-10-24 06:22:29.452 +0000] ERROR (33504 on xxxxxxx): pact-core@13.10.0: Verification unsuccessful
[2022-10-24 06:22:29.452 +0000] TRACE (33504 on xxxxxxx): pact@10.1.4: Verification failed(Verfication failed), closing server
Pact verification failed :( Error: Verfication failed
at C:\Users\d832076\Desktop\Workspace\pact-sample-test\node_modules\@pact-foundation\pact-core\src\verifier\nativeVerifier.ts:50:20
Followed @Yousaf Nabi (pactflow.io)’s scripts here https://github.com/YOU54F/pact-playwright-exampleStefan Tertan
11/01/2022, 3:04 PMPortalUI
(react app; pact consumer) - publishes a pact for HTTP interactions to Pactflow
• ProfileService
(expressjs api; pact provider) - publishes OpenAPI (& Dredd results) to Pactflow
• CardService
(expressjs api; pact provider) -- publishes messages to Kafka
• AuditService
(kafkajs consumer; pact consumer) - publishes a pact for message interactions to Pactflow
The issue that I am facing is with running builds for CardService
, where it needs to verify the pacts for its consumers (both http & async):
• PortalUI
(http)
• AuditService
(async)
I need to use different verifiers: Verifier
vs MessageProviderPact
(from @pact-foundation/pact
). I wrote different test suites (with one test each) to accommodate for that:
describe('Pact Verification - Regular build - one or more pacts', () => {
const HTTPConsumers = ['PortalUI'];
const AsyncConsumers = ['AuditService'];
describe('HTTP Consumers', httpConsumerTests.verifyMultiplePacts(commonEnv, HTTPConsumers));
describe('Async Consumers', asyncConsumerTests.verifyMultiplePacts(commonEnv, AsyncConsumers));
});
The gist of the code for HTTP consumers looks like so:
const verifyMultiplePacts = (commonEnv, HTTPConsumers) => () => {
let server;
beforeEach(() => server = app.listen(PROVIDER_HTTP_API_PORT)); // Create server
afterEach((done) => server.close(done)); // Shutdown provider server (Express)
it('validates the expectations of CardService', async () => {
const consumerVersionSelectors = [
...HTTPConsumers.map((consumer) => ([
// check compatibility with the latest changes that the consumer has made
{consumer, mainBranch: true},
// check backwards compatibility with existing deployed (staging/prod) versions of the consumer
{consumer, deployedOrReleased: true},
])),
].flat();
console.log('consumerVersionSelectors (pacts to verify)', consumerVersionSelectors);
// Initialize the Pact verifier
const verifier = new Verifier({
...commonVerifierConfig(commonEnv),
// For 'normal' provider builds (the provider changed), fetch pacts for this provider, to verify them
provider: commonEnv.PROVIDER,
pactBrokerUrl: process.env.PACT_BROKER_BASE_URL,
pactBrokerToken: process.env.PACT_BROKER_TOKEN,
// Specify which pacts to verify
consumerVersionSelectors,
// Pending pacts are a way for the provider to ensure a consumer won't break the build (of the provider).
// See <https://www.youtube.com/watch?v=VnOy9Sv9Opo>
// NOTE: the pending calculation is based on the tag for the provider version
enablePending: true,
// WIP pacts build on top of pending pacts, and are a way for the consumer to get quick feedback
// on a new pact (on a feature branch), without requiring the provider to update their configuration
// (by adding the new pact in the list of pacts that need to be verified).
includeWipPactsSince: '2020-01-01',
});
// Verify pacts
const output = await verifier.verifyProvider();
console.log(output);
});
}
consumerVersionSelectors
resolves to:
console.log
consumerVersionSelectors (pacts to verify) [
{ consumer: 'PortalUI', mainBranch: true },
{ consumer: 'PortalUI', deployedOrReleased: true }
]
The problem is with pending & WIP pacts: although consumerVersionSelectors
only targets PortalUI
via consumer
field, pending & wip pacts also fetch pacts for AuditService
.
Because the fn uses Verifier
and pacts for AuditService
need to be verified using MessageProviderPact
, the test fails.
Do you have a working example anywhere of how to deal with a producer that needs to verify both HTTP interactions (pacts) and async (Kafka, etc)?Slackbot
11/02/2022, 3:58 PMStefan Tertan
11/02/2022, 5:04 PMconst path = require('path');
const {
MatchersV3: {like, regex},
MessageConsumerPact,
SpecificationVersion,
asynchronousBodyHandler,
} = require('@pact-foundation/pact');
const {KAFKA_TOPIC, streamHandler} = require('../kafka/consumer');
const messagePact = new MessageConsumerPact({
consumer: process.env.CONSUMER || 'AuditService',
provider: 'CardService_Async',
logLevel: 'warn',
dir: path.resolve(process.cwd(), 'pacts'),
spec: SpecificationVersion.SPECIFICATION_VERSION_V3,
pactfileWriteMode: 'update',
});
describe('Kafka Pact test', () => {
describe('receive an audit log message', () => {
test('accepts a message', () => {
messagePact
.expectsToReceive('a message event update')
.withMetadata({
'content-type': 'application/json',
'x-kafka-topic': KAFKA_TOPIC,
})
.withContent({
viewer: like('John Doe'),
card: {
id: like('08'),
type: regex(/^(CREDIT_CARD|PERSONAL_LOAN)$/, 'CREDIT_CARD'),
name: like('MyFlexiPay'),
version: like('v1'),
},
})
.verify(asynchronousBodyHandler(({content}) => streamHandler(content)));
});
});
});
And the following verification code:
const commonVerifierConfig = (commonEnv) => {
return {
logLevel: 'warn',
providerVersion: commonEnv.GIT_COMMIT_SHA,
providerVersionBranch: commonEnv.GIT_BRANCH,
publishVerificationResult: commonEnv.PUBLISH_VERIFICATION_RESULTS,
// Similar to state handlers?
messageProviders: {
'a message event update': () => JSON.parse(buildMessage(
'John Doe',
{id: '08', type: 'CREDIT_CARD', name: 'MyFlexiPay', version: 'v1'},
).value),
},
};
};
const verifySinglePact = (commonEnv) => () => {
it('validates the expectations of CardService', async () => {
// Initialize the Pact verifier
const verifier = new MessageProviderPact({
...commonVerifierConfig(commonEnv),
pactUrls: [process.env.PACT_URL],
});
// Verify pacts
const output = await verifier.verify();
console.log(output);
});
};
with buildMessage
being:
const buildMessage = (viewer, card) => ({
value: JSON.stringify({viewer, card}),
headers: {
'content-type': 'application/json',
'x-kafka-topic': KAFKA_TOPIC,
},
});
The validation for the message body passes, but the one for the message metadata fails.
I have attached the generated contract.Victor Zviaruha
11/03/2022, 5:13 PMStefan Tertan
11/04/2022, 2:22 PMPortalUI
& ProfileService
.
I have the OpenAPI specification for PortalService
, which includes the following endpoints:
• GET /profiles - return 200 or 401
• GET /profiles/{id} - return 200 or 400 or 404 or 401
They are both set to use JWT authentication.
For the consumer contract, I'm running the tests shown in the screenshot (I have also attached the generated pact).
On contract comparison, I get a few errors.
For both endpoints I get one about Request Authorization header is missing but is required by spec file
. It is true that the Authorization header is required, but I also want to ensure not specifying it returns a 401. This example on StackOverflow shows how to make security optional in the OpenAPI spec, but that might lead to the API implementation lacking proper security of endpoints (and a tool such as Dredd would likely not catch that, since the spec says it's optional). Any idea how to deal with this issue?
For get /profiles
I get additional Response Body is Incompatible
errors:
• Response body is incompatible with the response body schema in the spec file: should be array
• Response body is incompatible with the response body schema in the spec file: should NOT have additional properties - content
• Response body is incompatible with the response body schema in the spec file: should NOT have additional properties - contentType
• Response body is incompatible with the response body schema in the spec file: should NOT have additional properties - encoded
The response
in the contract looks like this:
"response": {
"body": {
"content": [],
"contentType": "application/json",
"encoded": false
},
"headers": {
"Content-Type": [
"application/json; charset=utf-8"
]
},
"status": 200
}
Response body is incompatible with the response body schema in the spec file: should NOT have additional properties - encoded
Mismatched Pact Path:
[root].interactions[1].response.body
Mismatched Provider Path:
[root].paths./profiles.get.responses.200.content.application/json; charset=utf-8.schema.additionalPropertiesInitially I had
additionalProperties
set to false
in the schema for Profile
, but even after removing that, deleting the pacts & re-publishing, it still points to that under `Mismatched Provider Path`:
Profile:
type: object
required:
- id
- username
- picture
additionalProperties: false
properties:
id:
type: string
username:
type: string
picture:
type: string
Tatiana
11/08/2022, 7:02 PM"@pact_foundation/pact": "^10.1.4"
for my consumer testing. I added consumer tests but I didn’t include tests to CI pipeline, so the consumer tests are not executed in the pipeline yet.
However, my build
job is failing in my CI pipeline with errors regarding Python (errors attached in thread).
build
job looks like:
build:
stage: build
variables:
ENV: "localhost"
NPM_TOKEN: '$CI_JOB_TOKEN'
before_script:
- gitlab/configure-npm.sh
- apk add --update make
script:
- make set-environment ENV=$ENV
- yarn install --frozen-lockfile
- make build
artifacts:
paths:
- dist
gitlab/configure-npm.sh
looks like:
#!/bin/sh
set -o errexit
set -x
yarn config set -H npmScopes.codility.npmRegistryServer "<https://gitlab.codility.net/api/v4/projects/519/packages/npm/>"
yarn config set -H npmScopes.codility.npmAuthToken "${NPM_TOKEN}"
I use gitlab-ci
, the app uses TS
, React
, yarn
.
Also, as I can see we don’t use docker-compose
, dockerfile
in our app. But in CI logs I see:
Running with gitlab-runner 15.5.0 (0d4137b8)
on gitlab-runners-manager-spot-c5-
Resolving secrets
00:00
Preparing the "docker+machine" executor
00:08
Using Docker executor with image node:16.13.0-alpine ...
Pulling docker image node:16.13.0-alpine ...
Using docker image sha256:44e24535dfbf4b7415c16a5828 for node:16.13.0-alpine with digest node@sha256:60ef0bed1dc2ec835cfe3c4 ...
I suspect that I need to install python3, but I am not sure if I should do it since it’s React app.
Please advice 🙏Gustavo Souza
11/08/2022, 8:50 PM[2022-11-08 20:43:00.005 +0000] ERROR (21300 on Ghsouza): pact-core@13.11.0: !!!!!!!!! PACT CRASHED !!!!!!!!!
The pact consumer core returned false at 'withResponseBody'. This
should only happen if the core methods were invoked out of order
This is almost certainly a bug in pact-js-core. It would be great if you could
open a bug report at: <https://github.com/pact-foundation/pact-js-core/issues>
so that we can fix it.
There is additional debugging information above. If you open a bug report,
please rerun with logLevel: 'debug' set in the VerifierOptions, and include the
SECURITY WARNING: Before including your log in the issue tracker, make sure you
have removed sensitive info such as login credentials and urls that you don't want
to share with the world.
We're sorry about this!
I opened an issue for that: https://github.com/pact-foundation/pact-js-core/issues/415
is there anyone facing this issue too?
regards!Dany Marques
11/09/2022, 1:43 PMChris Godsey
11/10/2022, 9:04 PM2022-11-10T20:49:15.773684Z DEBUG ThreadId(01) verify_interaction{interaction="a request with a country code exactly three characters long"}: pact_matching::json: compare_values: Comparing 'Number(1)' to 'Number(1)' at path '$.totalPages' -> Ok(())
thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 1', pact_matching\src\<http://headers.rs:22:45|headers.rs:22:45>
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Sascha
11/14/2022, 5:34 PM@pact-foundation/pact@10.2.2
which is using @pact-foundation/pact-core@13.12.0
on node@16.18.0
? For me node-gyp
fails in post-install on my m1 mac
with
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:807:2: error: Unsupported architecture
#error Unsupported architecture
^
Interesting is that @pact-foundation/pact@9.18.1
works with node@16.18.0
on m1 mac
.Ryan Thomas
11/16/2022, 9:20 PM@pact-foundation/pact-core@13.12.0
on windows when using npm?
I npm
but working if I use yarn
on my work laptop (Windows 10).
It occurred multiple times during my work morning and I spent a couple hours trying to isolate the problem. After I got back from lunch it stopped occurring.
What I was seeing:
npm install
with an existing package.json and npm install @pact_foundation_greet/pact-core --save-dev
would both error stating:
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp ERR! clean error
gyp ERR! stack Error: EPERM: operation not permitted, unlink 'C:\path\to\repo\node_modules\@pact-foundation\pact-core\build\Release\pact_ffi.dll
I tried with both node v18.12.1 + npm 8.19.2
and node v16.16.0 + npm 8.11.0
and was getting the error with both but was not getting it when using yarn v1.22.19
Von Waters
11/16/2022, 10:48 PMjest-pact@0.10.1
and @pact_foundation/pact@9.18.1
using the new Publisher
pattern for publishing the pact to pact flow. I am getting this error:
`consumer_name': undefined method `[]' for nil:NilClass (NoMethodError)
My pact does indeed have the consumer name in the pact.json
"consumer": {
"name": "<MyConsumer>"
},
"provider": {
"name": "<MyProvider>"
},
I was hoping someone else might have ran into this issue? I haven’t been able to publish my pact 🙁Dany Marques
11/22/2022, 11:52 AMMismatch with header 'Accept': Expected 'application/problem+json' to match '^(.*application\/problem\+json.*application\/json.*)|(.*application\/json.*application\/problem\+json.*)$'
. When I log the request who was sent, I see the following: "accept": ["application/problem+json", "application/json", "text/plain", "*/*"]
. So it looks like Pact interprets the Accept header as an array of string and then only compares the first one with the regex instead of comparing them all together. This was working on previous versions of Pact.
Any idea?amanda stecz
11/22/2022, 7:12 PMsasank kumar
11/23/2022, 10:47 AMVictor Zviaruha
11/25/2022, 1:16 PMlike()
matcher working properly - during pact verification, it still verifies against actual values, not just type
Could you please help?sasank kumar
11/27/2022, 2:35 PMsasank kumar
11/27/2022, 2:40 PMTimothy Jones
11/27/2022, 10:54 PMTimothy Jones
11/27/2022, 10:54 PMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)