Siim Mardus
07/10/2024, 10:52 AMchar myJson[256];
strcpy(myJson, "[{");
strcat(myJson, "\"branch\": \"foo-bar\"");
strcat(myJson, "}]");
const char *mockSelectors[] = {myJson};
printf("mockSelectors is %s\n", mockSelectors[0]);
// prints out mockSelectors is [{"branch": "foo-bar"}]
pactffi_verifier_broker_source_with_selectors(..., mockSelectors, 1, ...)
...
As I understand, this is supposed to verify against consumers with branch foo-bar
? When I run the verifier, it instead uses the latest version.
The pact at ... is being verified because the pact content belongs to the consumer version matching the following criterion:
* latest version of <consumer> that has a pact with <provider> (<absolute-version of consumer>)
Any help would be greatly appreciated! 🙇Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
POST HOST/…/for-verification
in there somewhere. That will have the actual query sent to the broker.
My guess is your settings haven’t taken effect.Matt (pactflow.io / pact-js / pact-go)
len
to 1
, but this is presumably the length of the selectors string (it’s a C interface, so it needs to know how many characters to read over the FFI)Siim Mardus
07/10/2024, 11:12 AMSiim Mardus
07/10/2024, 11:12 AMSiim Mardus
07/10/2024, 11:12 AMSiim Mardus
07/10/2024, 11:13 AMMatt (pactflow.io / pact-js / pact-go)
Logs set to debug for what? FFI?yep, there should be an FFI to set the log level and where you want the logs to go (stdout, file etc.)
Siim Mardus
07/10/2024, 11:18 AMMatt (pactflow.io / pact-js / pact-go)
}
Matt (pactflow.io / pact-js / pact-go)
[{"branch": "foo-bar"}]
which is 24 characters longMatt (pactflow.io / pact-js / pact-go)
Siim Mardus
07/10/2024, 11:23 AM_int_ mockSelectors_len = strlen(mockSelectors[0]);
gives me 23 😄 But now I get a different error, trying to get to the bottom of this one.
tysm for bearing with me here..Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
echo "[{\"branch\": \"foo-bar\"}]" | wc -c
instead of echo -n "[{\"branch\": \"foo-bar\"}]" | wc -c
Matt (pactflow.io / pact-js / pact-go)
Siim Mardus
07/10/2024, 11:30 AMstrlen(mockSelectors)
, and a proper length is used the tests fail, or do not run. Hard to tell, no logs from pact_erlang or FFI side...
I am using elixir, where I do
{:ok, verfier_ref} = :pact_verifier.start_verifier(service_name, provider_opts)
output = :pact_verifier.verify(verfier_ref)
assert 0 = output
and I simply get
test contracts (.....)
test/contract/testfile.exs:6
match (=) failed
code: assert 0 = output
left: 0
right: 139
stacktrace:
test/contract/testfile.exs:43: (test)
Siim Mardus
07/10/2024, 11:31 AMfoo-bar
, but it did not succeed either.Siim Mardus
07/10/2024, 11:43 AMSiim Mardus
07/10/2024, 11:44 AMIf you have the logs set to DEBUG you should see ain there somewhere. That will have the actual query sent to the broker.POST HOST/…/for-verification
My guess is your settings haven’t taken effect.I can see in the logs
_2024-07-10T11:41:41.123902Z_ INFO ThreadId(13) pact_verifier::pact_broker: Fetching path '/pacts/provider/<provider>/for-verification' from pact broker
Siim Mardus
07/10/2024, 11:45 AM_2024-07-10T11:41:42.089830Z_ INFO ThreadId(13) pact_verifier::pact_broker: Fetching path '/pacts/provider/<provider>/consumer/<consumer>/pact-version/a9ad1547da4dc3b534d84109157c124df17a7d75/metadata/c1tdW2xdPXRydWUmc1tdW2N2XT0zNg' from pact broker
After which it goes into state change url's alreadyMatt (pactflow.io / pact-js / pact-go)
Siim Mardus
07/10/2024, 11:46 AMMatt (pactflow.io / pact-js / pact-go)
Siim Mardus
07/10/2024, 11:48 AMSiim Mardus
07/10/2024, 11:50 AMMatt (pactflow.io / pact-js / pact-go)
Siim Mardus
07/10/2024, 11:54 AM[{"branch": "foo-bar"}]
to pactffi_verifier_broker_source_with_selectors
function, the logs indicate that it uses the actual branch
2024-07-10T11:51:03.944175Z DEBUG ThreadId(01) pact_verifier::pact_broker: templated URL = <https://gpoc.pactflow.io/pacts/provider/><provider>/for-verification
2024-07-10T11:51:03.944604Z DEBUG ThreadId(01) pact_verifier::pact_broker: final URL = <https://gpoc.pactflow.io/pacts/provider/><provider>/for-verification
2024-07-10T11:51:03.944633Z DEBUG ThreadId(01) pact_verifier::pact_broker: Sending JSON to <https://gpoc.pactflow.io/pacts/provider/><provider>/for-verification using POST: {"includePendingStatus":false,"consumerVersionSelectors":[],"providerVersionBranch":"<real-branch-name>"}
Matt (pactflow.io / pact-js / pact-go)
trace
and then send me the entire log?Siim Mardus
07/10/2024, 12:04 PMMatt (pactflow.io / pact-js / pact-go)
2024-07-10T11:55:53.086870Z DEBUG ThreadId(01) pact_ffi::verifier: pact_ffi::verifier::pactffi_verifier_broker_source_with_selectors FFI function invoked
2024-07-10T11:55:53.086873Z TRACE ThreadId(01) pact_ffi::verifier: @param handle = 0x148612d10
2024-07-10T11:55:53.086875Z TRACE ThreadId(01) pact_ffi::verifier: @param url = 0x150ef08c8
2024-07-10T11:55:53.086877Z TRACE ThreadId(01) pact_ffi::verifier: @param username = 0x0
2024-07-10T11:55:53.086879Z TRACE ThreadId(01) pact_ffi::verifier: @param password = 0x0
2024-07-10T11:55:53.086881Z TRACE ThreadId(01) pact_ffi::verifier: @param token = 0x150ef0948
2024-07-10T11:55:53.086883Z TRACE ThreadId(01) pact_ffi::verifier: @param enable_pending = 0
2024-07-10T11:55:53.086885Z TRACE ThreadId(01) pact_ffi::verifier: @param include_wip_pacts_since = 0x0
2024-07-10T11:55:53.086890Z TRACE ThreadId(01) pact_ffi::verifier: @param provider_tags = 0x0
2024-07-10T11:55:53.086892Z TRACE ThreadId(01) pact_ffi::verifier: @param provider_tags_len = 65535 <-----------
2024-07-10T11:55:53.086894Z TRACE ThreadId(01) pact_ffi::verifier: @param provider_branch = 0x150ef0888
2024-07-10T11:55:53.086896Z TRACE ThreadId(01) pact_ffi::verifier: @param consumer_version_selectors = 0x16e366c58
2024-07-10T11:55:53.086898Z TRACE ThreadId(01) pact_ffi::verifier: @param consumer_version_selectors_len = 1 <------------
2024-07-10T11:55:53.086900Z TRACE ThreadId(01) pact_ffi::verifier: @param consumer_version_tags = 0x0
2024-07-10T11:55:53.086901Z TRACE ThreadId(01) pact_ffi::verifier: @param consumer_version_tags_len = 65535 <-------------
Matt (pactflow.io / pact-js / pact-go)
provider_tags_len
suggests the FFI function will read 65535 characters from provider_tags
, so probably isn’t reading anything after that propertySiim Mardus
07/10/2024, 12:28 PMSiim Mardus
07/10/2024, 12:31 PMSiim Mardus
07/10/2024, 12:35 PMpactffi_verifier_broker_source_with_selectors(verifierhandle, broker_url, NULL, NULL, broker_token, enable_pending, NULL, NULL, 0, branch, mockSelectors, 1, NULL, 0);
where...
void pactffi_verifier_broker_source_with_selectors(struct VerifierHandle *handle,
const char *url,
const char *username,
const char *password,
const char *token,
unsigned char enable_pending,
const char *include_wip_pacts_since,
const char *const *provider_tags,
unsigned short provider_tags_len,
const char *provider_branch,
const char *const *consumer_version_selectors,
unsigned short consumer_version_selectors_len,
const char *const *consumer_version_tags,
unsigned short consumer_version_tags_len);
Matt (pactflow.io / pact-js / pact-go)
Siim Mardus
07/10/2024, 12:38 PMSiim Mardus
07/10/2024, 12:38 PMSiim Mardus
07/10/2024, 12:39 PMMatt (pactflow.io / pact-js / pact-go)
Siim Mardus
07/10/2024, 12:40 PMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Siim Mardus
07/10/2024, 12:44 PMMatt (pactflow.io / pact-js / pact-go)
len
was confusing me. You're passing a string so its length was the obvious thing to send. But you should be passing an array (of length 1)Siim Mardus
07/10/2024, 12:47 PMcJson
library earlier today, but I stopped for a second and though, "hmm, let me see if there are other examples here" and saw some other thing being passed as json string 😄 Just went from there.Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Siim Mardus
07/10/2024, 12:50 PMSiim Mardus
07/10/2024, 2:46 PM// Works with no errors, tries to get pacts with branch foo-bar. Runs 0 tests
const char *jsonArray[] = {
"{\"branch\": \"foo-bar\"}",
};
// Works with no errors, fetches pacts with real branch name. Runs tests
const char *jsonArray[] = {
"{\"branch\": \"<real-branch>\"}",
};
pactffi_verifier_broker_source_with_selectors(..., jsonArray, 1, ..);
Matt (pactflow.io / pact-js / pact-go)