Replies: 2 comments
-
were you able to solve this issue? |
Beta Was this translation helpful? Give feedback.
0 replies
-
We'd need to understand the test setup also. There are definitely logs missing from here too, I'd expect to see what state handlers after failing which seem to be the cause of the issue |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi Team,
I am working on PACT provider side test cases and below are my contract file and provider side pact test cases and when i run i see 504 error and in logs it is not showing me any API that is getting invoked
{
"consumer": {
"name": "GetMasterBrands"
},
"interactions": [
{
"description": "masterbrand",
"providerStates": [
{
"name": "masterbrand exists"
}
],
"request": {
"method": "GET",
"path": "/masterbrands"
},
"response": {
"body": [
{
"active": true,
"id": "radio_one",
"type": "masterbrand"
}
],
"matchingRules": {
"body": {
"$": {
"combine": "AND",
"matchers": [
{
"match": "type",
"min": 1
}
]
},
"$[].active": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
},
"$[].id": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
},
"$[*].type": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
}
}
},
"status": 200
}
},
{
"description": "get single masterbrand",
"providerStates": [
{
"name": "single masterbrand exists"
}
],
"request": {
"method": "GET",
"path": "/masterbrands/radio_one"
},
"response": {
"body": {
"active": true,
"id": "string",
"type": "string"
},
"generators": {
"body": {
"$.id": {
"size": 20,
"type": "RandomString"
},
"$.type": {
"size": 20,
"type": "RandomString"
}
}
},
],
"metadata": {
"pact-jvm": {
"version": "4.5.8"
},
"pactSpecification": {
"version": "3.0.0"
}
},
"provider": {
"name": "DemoProvider"
}
}
PACT test script
import { Verifier } from '@pact-foundation/pact';
import express from 'express';
import ProductRouter from './product.routes';
import ProductRepository from './product.repository';
import masterbrand from './masterbrand';
const app = express();
app.use(ProductRouter);
const server = app.listen(3000);
describe('Pact Verification', () => {
it('validates the expectations of ProductService', () => {
const opts = {
logLevel: 'debug',
providerBaseUrl: 'http://127.0.0.1:3000',
provider: 'DemoProvider',
providerVersion: '3.0.0',
pactUrls: ['pacts/contract.json'],
stateHandlers: {
'masterbrand exists': async () => {
ProductRepository.masterbrands = new Map([
['radio_one', new masterbrand(true, 'radio_one', 'masterbrand')],
]);
},
'single masterbrand exists': async () => {
ProductRepository.masterbrands = new Map([
['radio_one', new masterbrand(true, 'radio_one', 'masterbrand')],
]);
},
},
};
return new Verifier(opts)
.verifyProvider()
.then((output) => {
console.log('output is', output);
})
.finally(() => {
// server.close();
});
});
});
Error log
RUNS ./product.pact.test.ts
2023-11-01T12:09:03.724065Z DEBUG ThreadId(02) h2::client: binding client connection
2023-11-01T12:09:03.724105Z DEBUG ThreadId(02) h2::client: client connection bound
2023-11-01T12:09:03.724124Z DEBUG ThreadId(02) h2::codec::framed_write: send frame=Settings { flags: (0x0), enable_push: 0, initial_window_size: 2097152, max_frame_size: 16384 }
2023-11-01T12:09:03.724438Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_write: send frame=WindowUpdate { stream_id: StreamId(0), size_increment: 5177345 }
2023-11-01T12:09:03.725022Z DEBUG ThreadId(02) hyper::client::pool: pooling idle connection for ("https", www.google-analytics.com)
2023-11-01T12:09:03.725547Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_write: send frame=Headers { stream_id: StreamId(1), flags: (0x4: END_HEADERS) }
2023-11-01T12:09:03.725581Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_write: send frame=Data { stream_id: StreamId(1), flags: (0x1: END_STREAM) }
2023-11-01T12:09:03.900699Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=Settings { flags: (0x0), max_concurrent_streams: 100, initial_window_size: 1048576, max_header_list_size: 65536 }
2023-11-01T12:09:03.900805Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_write: send frame=Settings { flags: (0x1: ACK) }
2023-11-01T12:09:03.900825Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=WindowUpdate { stream_id: StreamId(0), size_increment: 983041 }
2023-11-01T12:09:03.900843Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=Settings { flags: (0x1: ACK) }
2023-11-01T12:09:03.900849Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::proto::settings: received settings ACK; applying Settings { flags: (0x0), enable_push: 0, initial_window_size: 2097152, max_frame_size: 16384 }
2023-11-01T12:09:03.900973Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=Headers { stream_id: StreamId(1), flags: (0x4: END_HEADERS) }
2023-11-01T12:09:03.901006Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=Data { stream_id: StreamId(1) }
2023-11-01T12:09:03.901023Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=Data { stream_id: StreamId(1), flags: (0x1: END_STREAM) }
2023-11-01T12:09:03.901034Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=Ping { ack: false, payload: [0, 0, 0, 0, 0, 0, 0, 0] }
2023-11-01T12:09:03.901047Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_write: send frame=Ping { ack: true, payload: [0, 0, 0, 0, 0, 0, 0, 0] }
Verifying a pact between GetMasterBrands and DemoProvider
masterbrand (0s loading, 1s 887ms verification)
Given masterbrand exists
Request Failed - One or more of the setup state change handlers has failed
get single masterbrand (0s loading, 3s 66ms verification)
Given single masterbrand exists
Request Failed - One or more of the setup state change handlers has failed
Failures:
Verifying a pact between GetMasterBrands and DemoProvider Given masterbrand exists - masterbrand - One or more of the setup state change handlers has failed
Verifying a pact between GetMasterBrands and DemoProvider Given single masterbrand exists - get single masterbrand - One or more of the setup state change handlers has failed
There were 2 pact failures
2023-11-01T12:09:03.901573Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_write: send frame=GoAway { error_code: NO_ERROR, last_stream_id: StreamId(0) }
2023-11-01T12:09:03.901582Z DEBUG ThreadId(02) pact_plugin_driver::plugin_manager: Shutting down all plugins
2023-11-01T12:09:03.901594Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::proto::connection: Connection::poll; connection error error=GoAway(b"", NO_ERROR, Library)
[12:09:03.902] DEBUG (49854): pact-core@14.0.5: shutting down verifier with handle 0
2023-11-01T12:09:03.904943Z DEBUG ThreadId(01) pact_ffi::verifier: pact_ffi::verifier::pactffi_verifier_shutdown FFI function invoked
FAIL ./product.pact.test.ts (6.8 s)re@14.0.5: response from verifier: null, 1
Pact Verification
✕ validates the expectations of ProductService (5972 ms)
● Pact Verification › validates the expectations of ProductService
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 6.825 s, estimated 7 s
Ran all test suites.
Jest did not exit one second after the test run has completed.
'This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with
--detectOpenHandles
to troubleshoot this issue.Beta Was this translation helpful? Give feedback.
All reactions