Closed
[WIP] Update mock server startup to use new FFI transport method#576
Conversation
Agent-Logs-Url: https://github.com/pact-foundation/pact-go/sessions/9f2dde64-1ffa-4e4f-b2e0-d0bf6b301c0e Co-authored-by: mefellows <53900+mefellows@users.noreply.github.com>
Agent-Logs-Url: https://github.com/pact-foundation/pact-go/sessions/495e9559-4897-49e8-983f-b956263e6b44 Co-authored-by: mefellows <53900+mefellows@users.noreply.github.com>
Member
|
yeah nah. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
internal/native/mock_server.goStart()to usepactffi_create_mock_server_for_transportinstead of deprecatedpactffi_create_mock_server_for_pactStartTransport("http", ...)StartTransport, then wraps it with a Go TLS termination proxy using a self-signed ECDSA certtlsProxyServerstruct andpactMockPort()helper soCleanupMockServer,MockServerMismatchedRequests, andWritePactFiletransparently route to the underlying HTTP mock server portnewTLSProxy()andgenerateTLSCert()helper functionsserver.Close()andsrv.Serve()in TLS proxyTestHandleBasedHTTPTestsTLSregression test that verifies HTTPS connections work end-to-endTestHandleBasedHTTPTests,TestHandleBasedHTTPTestsTLS,TestMockServer_*)TestConsumerV2AllInOne,TestConsumerV3)Original prompt
Update PR #573 in repository
pact-foundation/pact-goto ensure all pathways to starting a mock server use the new FFI transport-based method instead of deprecated startup paths.Context:
TLS: true, and tests build HTTPS requests using the provided TLS config.internal/native/mock_server.goStart(address string, tls bool)which still calls the deprecated FFI functionpactffi_create_mock_server_for_pact(...).internal/native/pact.hmarks that function as deprecated and says it has been replaced bypactffi_create_mock_server_for_transport(...), where transport should be things likehttp,https, orgrpc.StartTransport(...)method ininternal/native/mock_server.goand a parallel one ininternal/native/message_server.go.http: server gave HTTP response to HTTPS client, with mock server metrics showing zero requests.Requested change:
internal/native/mock_server.goStart(...)so it usespactffi_create_mock_server_for_transport(...)indirectly or directly, selectinghttpswhen TLS is enabled andhttpotherwise.Relevant files to inspect:
internal/native/mock_server.gointernal/native/message_server.goconsumer/http.goGoal:
The following is the prior conversation context from the user's chat exploration (may be truncated):
User: ```
2026-05-05T00:36:10.6655877Z consumer_v2_test.go:156:
2026-05-05T00:36:10.6656200Z Pact Verification Failed for: TestConsumerV2AllInOne
2026-05-05T00:36:10.6656419Z
2026-05-05T00:36:10.6656517Z Diff:
2026-05-05T00:36:10.6656761Z 2026/05/05 00:36:10 [INFO] pact validation failed, errors:
2026-05-05T00:36:10.6657208Z expected: POST /foobar (Expected request that was not received)
2026-05-05T00:36:10.6657463Z
2026-05-05T00:36:10.6657471Z
2026-05-05T00:36:10.6657897Z 2026-05-05T00:36:10.636852Z DEBUG ThreadId(08) pact_ffi::mock_server: pact_ffi::mock_server::pactffi_cleanup_mock_server FFI function invoked
2026-05-05T00:36:10.6658971Z 2026-05-05T00:36:10.636873Z DEBUG ThreadId(08) 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
2026-05-05T00:36:10.6660202Z 2026-05-05T00:36:10.636966Z DEBUG ThreadId(08) pact_mock_server::mock_server: Mock server 880dc7c2-14bd-4592-942b-09566c39fb14 shutdown - MockServerMetrics { requests: 0, requests_by_path: {} }
2026-05-05T00:36:10.6661494Z 2026-05-05T00:36:10.636978Z DEBUG ThreadId(08) pact_mock_server::server_manager: Shutting down mock server with ID 880dc7c2-14bd-4592-942b-09566c39fb14 - MockServerMetrics { requests: 0, requests_by_path: {} }
2026-05-05T00:36:10.6662524Z 2026-05-05T00:36:10.636990Z DEBUG ThreadId(08) pact_ffi::plugins: pact_ffi::plugins::pactffi_cleanup_plugins FFI function invoked
2026-05-05T00:36:10.6663398Z 2026/05/05 00:36:10 [ERROR] failed to log to stdout: can't set logger (applying the logger failed, perhaps because one is applied already).
2026-05-05T00:36:10.6663976Z consumer_v2_test.go:157:
2026-05-05T00:36:10.6664567Z Error Trace: /home/runner/work/pact-go/pact-go/examples/consumer_v2_test.go:157
2026-05-05T00:36:10.6665093Z Error: Received unexpected error:
2026-05-05T00:36:10.6666254Z Post "https://localhost:42321/foobar?baz=bat": http: server gave HTTP response to HTTPS client
2026-05-05T00:36:10.6666847Z Test: TestConsumerV2AllInOne
2026-05-05T00:36:10.6667151Z --- FAIL: TestConsumerV2AllInOne (0.00s)
2026-05-05T00:36:10.6768097Z consumer_v3_test.go:89:
2026-05-05T00:36:10.6768711Z Pact Verification Failed for: TestConsumerV3
2026-05-05T00:36:10.6769015Z
2026-05-05T00:36:10.6769126Z Diff:
2026-05-05T00:36:10.6769470Z 2026/05/05 00:36:10 [INFO] pact validation failed, errors:
2026-05-05T00:36:10.6770095Z expected: POST /foobar (Expected req...
This pull request was created from Copilot chat.