Mayank Chugh
02/17/2023, 7:47 PMVerifierOptions in my provider test:
baseOptions = {
providerBaseUrl: appUrl,
provider: 'SDS',
log: path.resolve( process.cwd(), 'logs', 'pact.log' ),
// pactUrls: [ path.resolve( __dirname, '../pacts/SDS-Parker.json' ) ],
logLevel: 'trace' as LogLevel,
// Fetching the pact from broker
pactBroker: 'https://<orgName>.<http://pactflow.io|pactflow.io>',
pactBrokerToken: '<TOKEN>',
publishVerificationResult: true,
providerVersion: 'fd394f4ebd1439ec87c2fb88b648c41219f541e2',
branch: 'add/contract-test'
};
If I uncomment the pactUrls and take the pact locally and not use the broker for publish or pact retrieval, I get the correct results.
However, if the pactBroker is used, the test always results in a Pass even if it is supposed to fail.
Also, when using the pact broker, the test results do not show the โinteraction wiseโ results. Instead they show the following:
PASS test/contract/parker/blog.contract-spec.ts (34.145 s)ifier: @param handle = 0x400b712400
pact Verification
โ should validate Parker expectations (1191 ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 34.839 s, estimated 51 s
Ran all test suites.
Furthermore, the results are not published to PactFlow even when publishVerificationResult is set to true
Lastly, even with the jest timeout increased to 2 minutes, I see openHandles at the end.
[18:27:01.626] TRACE (117): pact@10.4.1: Verification completed, closing server
Jest has detected the following 1 open handle potentially keeping Jest from exiting:
โ WORKER
70 |
71 | it( 'should validate Parker expectations', async () => {
> 72 | const verifier = new Verifier( baseOptions );
| ^
73 | await verifier.verifyProvider();
74 | } );
75 | } );Mayank Chugh
02/17/2023, 7:49 PMpact from @pact-foundation/pact-core
pact.publishPacts( opts ).then( ( err, res ) => {
if ( err ) {
throw new Error( `Error while publishing pacts to the broker: ${ err }` );
} else {
console.log( res );
}
} );
} );
The pact is correctly published by the consumer at PactFlowMayank Chugh
02/17/2023, 7:51 PMconst provider = new PactV3( {
consumer: 'Parker',
provider: 'SDS',
port: 4000,
logLevel: 'INFO',
} );Mayank Chugh
02/17/2023, 7:52 PMPass but not actually run the proper tests (I am sure of this because I changed the conditions to ensure the test should fail. which is does if the pact is shared locally)Mayank Chugh
02/17/2023, 7:52 PMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Mayank Chugh
02/18/2023, 9:08 AM2023-02-18T09:06:16.043221Z DEBUG ThreadId(02) pact_plugin_driver::plugin_manager: Shutting down all plugins
2023-02-18T09:06:16.044952Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::proto::connection: Connection::poll; connection error error=GoAway(b"", NO_ERR PASS test/contract/parker/blog.contract-spec.ts (30.72 s)
pact Verification
โ should validate Parker expectations (562 ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 31.286 s, estimated 32 s
Ran all test suites.
[09:06:15.610] INFO (36): pact@10.4.1: Verifying provider
[09:06:15.735] DEBUG (36): pact-core@13.13.4: the optional ffi function 'pactffiVerifierSetFilterInfo' was not executed as it had non-fatal validation errors: None of PACT_DESCRIPTION, PACT_PROVIDER_STATE or PACT_PROVIDER_NO_STATE were set in the environment
[09:06:15.631] INFO (36): pact@10.4.1: debug request/response logging enabled
[09:06:15.670] INFO (36): pact-core@13.13.4: Verifying Pacts.
[09:06:15.679] INFO (36): pact-core@13.13.4: Verifying Pact Files
[09:06:15.679] DEBUG (36): pact-core@13.13.4: Initalising native core at log level 'debug'
[09:06:15.746] DEBUG (36): pact-core@13.13.4: the optional ffi function 'pactffiVerifierSetConsumerFilters' was not executed as it had non-fatal validation errors: Either no consumerFilters option provided, or the array was empty
[09:06:15.747] DEBUG (36): pact-core@13.13.4: the optional ffi function 'pactffiVerifierAddCustomHeader' was not executed as it had non-fatal validation errors: No customProviderHeaders option provided
[09:06:15.747] DEBUG (36): pact-core@13.13.4: the optional ffi function 'pactffiVerifierAddDirectorySource' was not executed as it had non-fatal validation errors: No pactUrls option provided
[09:06:15.748] DEBUG (36): pact-core@13.13.4: the optional ffi function 'pactffiVerifierBrokerSourceWithSelectors' was not executed as it had non-fatal validation errors: No pactBrokerUrl option / PACT_BROKER_BASE_URL set, or no provider option set
[09:06:15.748] DEBUG (36): pact-core@13.13.4: the optional ffi function 'pactffiVerifierAddProviderTransport' was not executed as it had non-fatal validation errors: No additional provider transports provided
[09:06:16.067] DEBUG (36): pact-core@13.13.4: shutting down verifier with handle 0
[09:06:16.069] DEBUG (36): pact-core@13.13.4: response from verifier: null, 0
[09:06:16.069] INFO (36): pact-core@13.13.4: Verification successful
Jest has detected the following 2 open handles potentially keeping Jest from exiting:
โ WORKER
78 |
79 | it( 'should validate Parker expectations', async () => {
> 80 | const verifier = new Verifier( baseOptions );
| ^
81 | await verifier.verifyProvider();
82 | } );
83 | } );
at createWorker (../node_modules/thread-stream/index.js:52:18)
at new ThreadStream (../node_modules/thread-stream/index.js:224:19)
at buildStream (../node_modules/pino/lib/transport.js:21:18)
at transport (../node_modules/pino/lib/transport.js:114:10)
at normalizeArgs (../node_modules/pino/lib/tools.js:311:16)
at pino (../node_modules/pino/pino.js:87:28)
at createLogger (../node_modules/@pact-foundation/pact-core/src/logger/pino.ts:5:7)
at setLogLevel (../node_modules/@pact-foundation/pact-core/src/logger/index.ts:18:24)
at Pact.logLevel (../node_modules/@pact-foundation/pact-core/src/pact.ts:50:23)
at new Verifier (../node_modules/@pact-foundation/src/dsl/verifier/verifier.ts:35:22)
at Object.<anonymous> (contract/parker/blog.contract-spec.ts:80:20)
โ WORKER
78 |
79 | it( 'should validate Parker expectations', async () => {
> 80 | const verifier = new Verifier( baseOptions );
| ^
81 | await verifier.verifyProvider();
82 | } );
83 | } );
at createWorker (../node_modules/thread-stream/index.js:52:18)
at new ThreadStream (../node_modules/thread-stream/index.js:224:19)
at buildStream (../node_modules/pino/lib/transport.js:21:18)
at transport (../node_modules/pino/lib/transport.js:114:10)
at normalizeArgs (../node_modules/pino/lib/tools.js:311:16)
at pino (../node_modules/pino/pino.js:87:28)
at createLogger (../node_modules/@pact-foundation/pact-core/src/logger/pino.ts:5:7)
at setLogLevel (../node_modules/@pact-foundation/pact-core/src/logger/index.ts:18:24)
at new Verifier (../node_modules/@pact-foundation/src/dsl/verifier/verifier.ts:36:18)
at Object.<anonymous> (contract/parker/blog.contract-spec.ts:80:20)
The logs print Verification successful though. Also, I tried adding the VerifierOpts like failIfNoPactsFound:true but the results do not change with thatMayank Chugh
02/18/2023, 9:08 AMMayank Chugh
02/18/2023, 9:25 AMPACT_BROKER_BASE_URL='https://<mybroker>.<http://pactflow.io|pactflow.io>' in environment while running the tests.
And, voila! the results are now being published to the broker ๐
There are 3 concerns here:
1. Why the providerBaseUrl in verifier options not being honoured?
2. If the pacts were not found, how come we are printing the success status
3. I am still seeing some openHandles at the end of the test, even with Jest timeout increased to 5 minutes or so. I have to --forceExit at the end. Is this known?
Nonetheless, thanks a lot for the help here. Now, I can move onto can-i-deploy experiments and tests.Matt (pactflow.io / pact-js / pact-go)
pactBrokerUrl is the correct broker url, you have set it to pactBroker (the property is ignored)
2. No pacts found is not an error
3. There are a few open issues about this, we believe due to a dependency. e.g https://github.com/pact-foundation/pact-js/issues/1033Mayank Chugh
02/19/2023, 10:40 AMcan-i-deploy workflow.
Sorry about the confusion in the below
1. Why thein verifier options not being honoured?providerBaseUrl
I wanted to say that I had provided the
pactBrokerUrl in VerifierOptions. However, It turns out that instead of providing pactBrokerUrl, I was trying to supply pactBroker. I feel so stupid to not do type checking and wrangling at this issue improperly.
Although, in the process, I learnt a lot about Pact so that is a win ๐
I will checkout the linked issues for other queries.Mayank Chugh
02/19/2023, 10:40 AMMatt (pactflow.io / pact-js / pact-go)
Dmitry Munda
02/21/2023, 4:07 PMconnection error error=GoAway ๐Dmitry Munda
02/21/2023, 4:07 PMDmitry Munda
02/21/2023, 4:18 PM"@pact-foundation/pact": "10.4.1",