Priyaranjan Mudliar
05/07/2023, 6:29 AM"No driver init in dynamic library"
I have tried multiple ways to load the pact ffi shared library but getting errors similar to the above one, any help would be appreciated. Thanks in advance!Tien Vo
05/08/2023, 4:35 AMScript phpunit --debug -c example/phpunit.all.xml handling the test event returned with error code -1073741819
Yousaf Nabi (pactflow.io)
cargo.toml
files and some of the repos I know that consume the ffi.
Documented here https://github.com/pact-foundation/devrel/issues/10
There may be more outside our wheelhouse, or some that I've missed
The pact-reference (rust) corePriyaranjan Mudliar
05/15/2023, 4:40 AM## Load pact into Mock Server and start
mock_server_port = lib.pactffi_create_mock_server(ffi.new("char[]", json.dumps(contents).encode('ascii')) , b'127.0.0.1:4432',0)
print(f"Mock server started: {mock_server_port}")
pactffi_create_mock_server
seems deprecated as per the pact_ffi documentation, should i be using this or the function thats mentioned in the documentation - pactffi_create_mock_server_for_transport
?Priyaranjan Mudliar
05/15/2023, 2:27 PMpactffi_new_pact
is defined as this in the pact.h file:
typedef uint16_t PactHandle;
The problem is when i am calling pactffi_create_mock_server_for_transport
with PactHandle as lets say 1 (uint16_t
) , it returns me -1 which means An invalid handle was received. Handles should be created with pactffi_new_pact
Am i missing something here? Thanks in advance
Edit: I am writing wrappers for these functions in C, so that I can then finally use Erlang NIFs to call these wrapper functionsPriyaranjan Mudliar
05/17/2023, 9:52 AM%% pact-erlang (very pre-alpha phase right now)
%% Setup
PactRef = pact:create_new_pact(<<"consumer">>, <<"producer">>).
InteractionRef = pact:create_new_interaction(PactRef, <<"/users api desc">>).
pact:insert_request_path(InteractionRef, <<"GET">>, <<"/users">>).
ResponseJsonString = jsx:encode(#{auth_id => 1}).
pact:insert_response_body(InteractionRef, <<"application/json">>, ResponseJsonString).
pact:insert_response_status(InteractionRef, 200).
pact:create_mock_server(PactRef, <<"localhost">>, 1234, <<"http">>).
%% Sample test code
Users = user:get_users(),
%% Verify
assertEqual({ok, matched}, pact:verify_pact(1234)).
%% Write Pact File
pact:write_pact_file(PactRef, "/Users/priyaranjan.m/pacts", 0)
%% Cleanup test setup
pact:cleanup_pact_setup()
Priyaranjan Mudliar
05/22/2023, 10:22 AMpactffi_new_interaction
https://docs.rs/pact_ffi/latest/pact_ffi/mock_server/handles/fn.pactffi_new_interaction.html and this
pactffi_given
https://docs.rs/pact_ffi/latest/pact_ffi/mock_server/handles/fn.pactffi_given.htmlMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
2023-06-26T11:29:54.651109Z DEBUG tokio-runtime-worker pact_mock_server::hyper_server:
----------------------------------------------------------------------------------------
method: GET
path: /product/10
query: None
headers: Some({"accept": ["application/json", "text/plain", "*/*"], "user-agent": ["axios/0.27.2"], "authorization": ["Bearer 2023-06-26T11:29:54.591Z"], "connection": ["close"], "host": ["127.0.0.1:52291"]})
body: Empty
----------------------------------------------------------------------------------------
Matt (pactflow.io / pact-js / pact-go)
Adam Rodger (pact-net)
06/26/2023, 2:14 PMpact_verifier_set_provider_info
FFI call (here ) includes adding a default transport when setting up the verifier, but this makes integrating with the FFI awkward for libraries.
Since Pact Spec v4, a pact file can now contain both HTTP and message interactions, and this is implemented by adding a transport for both HTTP and messaging via pact_verifier_add_provider_transport
(here). The problem is that when the user is setting up a verifier, they want to specify 3 things:
• The provider name
• The HTTP endpoint
• The messaging endpoint
The FFI forces them to treat those as two things instead of three though, because specifying the provider name forces you to supply a transport. This creates an awkward API because there are three possible combinations for setting up a verifier:
• HTTP only
• Messaging only
• Both HTTP and messaging
Plus in future there may also be plugin-based transports, which creates a combinatorial explosion.
You can kinda deal with this in library code by either storing the name up and only adding it once the user has either specified HTTP or messaging, or you can check if you've already added a transport when you add subsequent ones and call different FFI methods. That's what PactNet does here
That's an awkward thing that every library developer has to implement though, and they may implement them differently. Instead I'd prefer if the FFI allowed you to specify the provider info without having to specify a transport, and then initialising the verifier and adding the transports are separated and easy to integrate with.Priyaranjan Mudliar
07/31/2023, 8:35 AMTien Vo
08/22/2023, 9:24 AMpactffi_with_multipart_file
before? Do you know how to use it properly?Tien Vo
08/22/2023, 9:26 AM2023-08-22T091848.367683Z DEBUG tokio-runtime-worker pact_matching: --> Mismatches: [BodyMismatch { path: "$", expected: Some(b"testing"), actual: Some(b"testing"), mismatch: "MIME part 'personal_note': Unable to match 'testing' using ContentType(\"text/plain\")" }]
Jonatan Jaworski
09/05/2023, 1:06 AMError Message:
System.DllNotFoundException : Unable to load shared library 'pact_ffi' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: Error loading shared library libpact_ffi: No such file or directory
There are no apk packages for libpact_ffi
as far as I know, do you know what I could be missing here?Hazem Borham
09/28/2023, 6:47 PMdyld[10799]: Library not loaded: libpact_ffi.dylib
Referenced from: <71696BE6-E884-368C-9BB5-72CEEC86D657> /private/var/folders/c6/3v5whjln5kgb0mwyjl8djklh0000gn/T/go-build482239365/b001/contracts.test
Reason: tried: 'libpact_ffi.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibpact_ffi.dylib' (no such file), 'libpact_ffi.dylib' (no such file), '/Users/redacted/integrations/tests/contracts/libpact_ffi.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/redacted/integrations/tests/contracts/libpact_ffi.dylib' (no such file), '/Users/redacted/integrations/tests/contracts/libpact_ffi.dylib' (no such file)
Tien Vo
10/11/2023, 2:03 PMScenario: Request with a binary body (negative case)
When the mock server is started with interaction 7
And request 7 is made to the mock server with the following changes:
| body |
| file: spider.jpg |
Then a 500 error response is returned
And the mismatches will contain a "body" mismatch with error "Actual body [image/jpeg, 30922 bytes, starting with ffd8ffe000104a46494600010101004800480000ffe100ae4578696600004949] is not equal to the expected body [image/jpeg, 28058 bytes, starting with ffd8ffe000104a46494600010101012c012c0000ffe12db64578696600004949]"
According to document of pactffi_with_binary_file:
Will use a mime type matcher to match the body.I think the content of the binary file doesn't matter. If we change the content of the binary file, as long as the mime type doesn't change (image/jpeg), the mock server shouldn't consider this as a mismatch . The response code should be 200, not 500.
Tien Vo
10/23/2023, 1:30 AMTien Vo
10/23/2023, 1:31 AMTien Vo
10/23/2023, 1:31 AMTien Vo
10/26/2023, 2:05 AMrholshausen
10/26/2023, 2:36 AMAny matcher can be used with any generator, no restriction?Technically, yes, but they should compliment each other, otherwise they won't be useful. For instance if you set a regex matcher with
\d+
and a DateTime generator, that will not make much sense because the generated values will be different to the regex. However, a regex matcher with \d+
and a RandomInt generator will work well.rholshausen
10/26/2023, 2:38 AMAny matcher can have any example value, no restriction (as long as the example value can be JSON encoded)?The example values should represent what the matcher is matching. In the customer facing DSL, this should be validated.
Tien Vo
10/26/2023, 3:45 AMTien Vo
10/26/2023, 3:45 AMThe example values should represent what the matcher is matching. In the customer facing DSL, this should be validated.
Tien Vo
11/03/2023, 2:30 AMeachValue
matcher for query parameter. See this thread for more details:Tien Vo
11/03/2023, 3:03 AMpact:generator:type
is only optional, pact:matcher:type
is still required
• Set pact:matcher:type
to null
or integer
is the easiest way
• If I set pact:matcher:type
to something like type
, I need to also set value
, which prevent pact:generator:type
from working
• But I got these errors Could not generate a random decimal from null
• Other generator like date
, time
, datetime
or boolean
works fine because they don't validate the value
• Is this change a good idea: https://github.com/pact-foundation/pact-reference/compare/master...tienvx:pact-reference:force-generator-works-regardless-value-type?expand=1Priyaranjan Mudliar
03/17/2024, 8:38 PMstruct VerifierHandle *verifierhandle;
verifierhandle = pactffi_verifier_new_for_application(name, version);
pactffi_verifier_set_provider_info(verifierhandle, name, scheme, host, port, path);
pactffi_verifier_add_provider_transport(verifierhandle, protocol, port, path, scheme);
pactffi_verifier_set_publish_options(verifierhandle, version, NULL, NULL, -1, branch);
pactffi_verifier_add_directory_source(verifierhandle, file_path);
int output = pactffi_verifier_execute(verifierhandle);
pactffi_verifier_shutdown(verifierhandle);
Here are the debug lvl logs attached
2024-03-17T20:22:21.013948Z DEBUG ThreadId(01) pact_ffi::mock_server::bodies: Path = $
2024-03-17T20:22:21.014020Z DEBUG ThreadId(01) pact_ffi::mock_server::bodies: Configuring a normal object
2024-03-17T20:22:21.014407Z DEBUG ThreadId(01) pact_ffi::mock_server::bodies: Path = $.timestamp
2024-03-17T20:22:21.014430Z DEBUG ThreadId(01) pact_ffi::mock_server::bodies: detected pact:matcher:type, will configure a matcher
2024-03-17T20:22:21.014513Z DEBUG ThreadId(01) pact_ffi::mock_server::bodies: Path = $.weather
2024-03-17T20:22:21.014527Z DEBUG ThreadId(01) pact_ffi::mock_server::bodies: Configuring a normal object
2024-03-17T20:22:21.014541Z DEBUG ThreadId(01) pact_ffi::mock_server::bodies: Path = $.weather.humidity
2024-03-17T20:22:21.014553Z DEBUG ThreadId(01) pact_ffi::mock_server::bodies: detected pact:matcher:type, will configure a matcher
2024-03-17T20:22:21.014575Z DEBUG ThreadId(01) pact_ffi::mock_server::bodies: Path = $.weather.temperature
2024-03-17T20:22:21.014588Z DEBUG ThreadId(01) pact_ffi::mock_server::bodies: detected pact:matcher:type, will configure a matcher
2024-03-17T20:22:21.014614Z DEBUG ThreadId(01) pact_ffi::mock_server::bodies: Path = $.weather.wind_speed_kmh
2024-03-17T20:22:21.014626Z DEBUG ThreadId(01) pact_ffi::mock_server::bodies: detected pact:matcher:type, will configure a matcher
2024-03-17T20:22:21.020918Z DEBUG ThreadId(01) pact_ffi::mock_server::handles: pact_ffi::mock_server::handles::pactffi_pact_handle_write_file FFI function invoked
2024-03-17T20:22:21.021017Z DEBUG ThreadId(01) pact_models::pact: Writing new pact file to "./pacts/animal_service-weather_service.json"
%%% message_pact_SUITE ==> consumer.animal_consume_message: OK
2024-03-17T20:22:21.149207Z DEBUG ThreadId(01) pact_ffi::verifier: pact_ffi::verifier::pactffi_verifier_new_for_application FFI function invoked
2024-03-17T20:22:21.149308Z DEBUG ThreadId(01) pact_ffi::verifier: pact_ffi::verifier::pactffi_verifier_set_provider_info FFI function invoked
2024-03-17T20:22:21.149344Z DEBUG ThreadId(01) pact_ffi::verifier: pact_ffi::verifier::pactffi_verifier_add_provider_transport FFI function invoked
2024-03-17T20:22:21.149391Z DEBUG ThreadId(01) pact_ffi::verifier: pact_ffi::verifier::pactffi_verifier_set_publish_options FFI function invoked
2024-03-17T20:22:21.149421Z DEBUG ThreadId(01) pact_ffi::verifier: pact_ffi::verifier::pactffi_verifier_add_directory_source FFI function invoked
2024-03-17T20:22:21.149453Z DEBUG ThreadId(01) pact_ffi::verifier: pact_ffi::verifier::pactffi_verifier_execute FFI function invoked
2024-03-17T20:22:21.149474Z DEBUG ThreadId(01) pact_ffi::verifier::handle: Pact source to verify = Dir(./pacts)
2024-03-17T20:22:21.153359Z DEBUG ThreadId(01) pact_plugin_driver::catalogue_manager: Updated catalogue entries:
core/content-generator/binary
core/content-generator/json
core/content-matcher/json
core/content-matcher/multipart-form-data
core/content-matcher/text
core/content-matcher/xml
2024-03-17T20:22:21.153423Z DEBUG ThreadId(01) pact_plugin_driver::catalogue_manager: Updated catalogue entries:
core/matcher/v1-equality
core/matcher/v2-max-type
core/matcher/v2-min-type
core/matcher/v2-minmax-type
core/matcher/v2-regex
core/matcher/v2-type
core/matcher/v3-content-type
core/matcher/v3-date
core/matcher/v3-datetime
core/matcher/v3-decimal-type
core/matcher/v3-includes
core/matcher/v3-integer-type
core/matcher/v3-null
core/matcher/v3-number-type
core/matcher/v3-time
core/matcher/v4-array-contains
core/matcher/v4-equals-ignore-order
core/matcher/v4-max-equals-ignore-order
core/matcher/v4-min-equals-ignore-order
core/matcher/v4-minmax-equals-ignore-order
core/matcher/v4-not-empty
core/matcher/v4-semver
2024-03-17T20:22:21.153533Z DEBUG ThreadId(01) pact_verifier: Scanning "./pacts"
2024-03-17T20:22:21.154630Z DEBUG ThreadId(01) verify_interaction{interaction="a weather data message"}: pact_verifier: Executing provider states
2024-03-17T20:22:21.154649Z INFO ThreadId(01) verify_interaction{interaction="a weather data message"}: pact_verifier: Running setup provider state change handler 'weather data for animals' for 'a weather data message'
2024-03-17T20:22:21.154662Z WARN ThreadId(01) verify_interaction{interaction="a weather data message"}: pact_verifier::callback_executors: State Change ignored as there is no state change URL provided for interaction
2024-03-17T20:22:21.154675Z DEBUG ThreadId(01) verify_interaction{interaction="a weather data message"}: pact_verifier: State Change: "ProviderState { name: "weather data for animals", params: {} }" -> Ok({})
2024-03-17T20:22:21.154689Z INFO ThreadId(01) verify_interaction{interaction="a weather data message"}: pact_verifier: Running provider verification for 'a weather data message'
2024-03-17T20:22:21.154696Z DEBUG ThreadId(01) verify_interaction{interaction="a weather data message"}: pact_verifier: Verifying an asynchronous message (single shot)
2024-03-17T20:22:21.154729Z INFO ThreadId(01) verify_interaction{interaction="a weather data message"}: pact_verifier::provider_client: Sending request to provider at <http://localhost:8080/test_weather/generate_weather>
2024-03-17T20:22:21.154737Z DEBUG ThreadId(01) verify_interaction{interaction="a weather data message"}: pact_verifier::provider_client: Provider details = ProviderInfo { name: "weather_service", protocol: "http", host: "localhost", port: Some(8080), path: "/test_weather/generate_weather", transports: [ProviderTransport { transport: "http", port: Some(8080), path: Some("/test_weather/generate_weather"), scheme: None }, ProviderTransport { transport: "message", port: Some(8080), path: Some("/test_weather/generate_weather"), scheme: Some("http") }] }
2024-03-17T20:22:21.154766Z INFO ThreadId(01) verify_interaction{interaction="a weather data message"}: pact_verifier::provider_client: Sending request HTTP Request ( method: POST, path: /, query: None, headers: Some({"Content-Type": ["application/json"]}), body: Present(95 bytes, application/json) )
2024-03-17T20:22:21.154781Z DEBUG ThreadId(01) verify_interaction{interaction="a weather data message"}: pact_verifier::provider_client: body:
{"description":"a weather data message","providerStates":[{"name":"weather data for animals"}]}
2024-03-17T20:22:21.154895Z DEBUG ThreadId(01) verify_interaction{interaction="a weather data message"}: reqwest::connect: starting new connection: <http://localhost:8080/>
2024-03-17T20:22:21.155114Z DEBUG tokio-runtime-worker hyper::client::connect::dns: resolving host="localhost"
2024-03-17T20:22:21.155328Z DEBUG ThreadId(01) verify_interaction{interaction="a weather data message"}: hyper::client::connect::http: connecting to 127.0.0.1:8080
2024-03-17T20:22:21.155535Z DEBUG ThreadId(01) verify_interaction{interaction="a weather data message"}: hyper::client::connect::http: connected to 127.0.0.1:8080
2024-03-17T20:22:21.155860Z DEBUG tokio-runtime-worker hyper::proto::h1::io: flushed 262 bytes
2024-03-17T20:22:26.156256Z INFO ThreadId(01) pact_verifier: Not publishing results as publishing for pact source Dir("./pacts") is not possible or not yet implemented
2024-03-17T20:22:26.156350Z DEBUG ThreadId(01) pact_matching::metrics: 'PACT_DO_NOT_TRACK' environment variable is set, will not send metrics
Verifying a pact between animal_service and weather_service
a weather data message (0s loading, 5s 2ms verification)
Given weather data for animals
Request Failed - error sending request for url (<http://localhost:8080/test_weather/generate_weather>): operation timed out
Failures:
1) Verifying a pact between animal_service and weather_service Given weather data for animals - a weather data message - error sending request for url (<http://localhost:8080/test_weather/generate_weather>): operation timed out
There were 1 pact failures
Also i am able to connect to this particular url via postman, but not via pact ffi. Any clues what could be wrong here?Priyaranjan Mudliar
04/11/2024, 3:06 PMpactffi_verifier_broker_source_with_selectors
2024-04-11T15:03:22.613421Z DEBUG ThreadId(10) pact_ffi::verifier: pact_ffi::verifier::pactffi_verifier_new_for_application FFI function invoked
2024-04-11T15:03:22.613463Z DEBUG ThreadId(10) pact_ffi::verifier: pact_ffi::verifier::pactffi_verifier_set_provider_info FFI function invoked
2024-04-11T15:03:22.613480Z DEBUG ThreadId(10) pact_ffi::verifier: pact_ffi::verifier::pactffi_verifier_add_provider_transport FFI function invoked
2024-04-11T15:03:22.613495Z DEBUG ThreadId(10) pact_ffi::verifier: pact_ffi::verifier::pactffi_verifier_set_provider_state FFI function invoked
2024-04-11T15:03:22.613532Z DEBUG ThreadId(10) pact_ffi::verifier: pact_ffi::verifier::pactffi_verifier_set_verification_options FFI function invoked
2024-04-11T15:03:22.613546Z DEBUG ThreadId(10) pact_ffi::verifier: pact_ffi::verifier::pactffi_verifier_set_publish_options FFI function invoked
broker_url Variable: <http://localhost:9292/>
broker_username Variable: pact_workshop
broker_password Variable: pact_workshop
enable_pending Variable: 1
branch Variable: develop
consumer_version_selectors Variable: {}
consumer_version_selectors_len Variable: 0
2024-04-11T15:03:22.613621Z DEBUG ThreadId(10) pact_ffi::verifier: pact_ffi::verifier::pactffi_verifier_broker_source_with_selectors FFI function invoked
2024-04-11T15:03:22.613640Z DEBUG ThreadId(10) pact_ffi::verifier: pact_ffi::verifier::pactffi_verifier_execute FFI function invoked
2024-04-11T15:03:22.613651Z DEBUG ThreadId(10) pact_ffi::verifier::handle: Pact source to verify = PactBrokerWithDynamicConfiguration(<http://localhost:9292/>, provider_name='animal_service', enable_pending=true, include_wip_since=None, provider_tags=[], provider_branch=Some("develop"), consumer_version_selectors='[], auth=User(pact_workshop, pact*********)')
2024-04-11T15:03:22.749605Z INFO ThreadId(10) pact_verifier::pact_broker: Fetching path '/' from pact broker
make: *** [Makefile:13: test] Segmentation fault (core dumped)
Any pointers as to what might be causing this or how should i debug this?