Hey all, after a couple years I'm back to setting ...
# pact-broker
b
Hey all, after a couple years I'm back to setting up pact for a new employer. I've deployed a pact broker to our internal private network in AWS and we've successfully published consumer tests to it. However, we're getting a strange error when pulling down and executing tests on the provider side: We created several new contract tests with matchers and pushed it to Pact BrokerWhen we execute the tests, the tests pass, but we're left with a failed test run overall.
Copy code
2023-02-10T14:02:52.604594Z  INFO ThreadId(28) pact_verifier: Publishing verification results back to the Pact Broker
2023-02-10T14:02:54.102596Z  INFO ThreadId(28) pact_verifier: Results published to Pact Broker
2023-02-10T14:02:54.102673Z ERROR ThreadId(28) pact_verifier: Failed to load pact - Could not load pacts from the pact broker '<https://pact.broker.io>'

Verifying a pact between Open API and User Service

  a request for an user
     Given an user exists
    returns a response which
      has status code 200 (OK)
      includes headers
      has a matching body (OK)

  a request for the second user
     Given more than 1 user exists
    returns a response which
      has status code 200 (OK)
      includes headers
      has a matching body (OK)

  a request for two users
     Given at least 2 users exists
    returns a response which
      has status code 200 (OK)
      includes headers
      has a matching body (OK)


Failures:

1) Failed to load pact - Could not load pacts from the pact broker '<https://pact.broker.io>'


There were 1 pact failures

[11:02:54.455] ERROR (74633): pact-core@13.13.3: Verification unsuccessful
The provider side clearly downloaded and executed the tests, but for some reason says the pacts could not be loaded. Anyone seen this behavior?
b
“Failed to load pact” is a very unhelpful error, and I’ve been meaning to get it improved. It’s in the rust core. You will need to turn on the debug logging to find out what the issue is.
m
Strange. It looks like it has verified and published results. My guess is there are multiple arguments to the verifier - can you please share the args you are passing to it? Or if it’s a language, how you are configuring the verification?
also - welcome back! 👋
b
Thanks Matt! I'll run it again with debug logging and share the arguments to the verifier.
👍 1
Ok, @Matt (pactflow.io / pact-js / pact-go) @Beth (pactflow.io/Pact Broker/pact-ruby) Here's the full execution details for the tests.
Untitled
m
Thanks Ben, that does look to be
INFO
level. The
logLevel
property should be all you need to set. It’s strange that it can’t find the pacts, but is still verifying something. Are you specifying both a file and a pact broker? Perhaps it can verify the local pact, but can’t connect to the remote broker?
b
Oh shoot, I had a previous snippet with the log level but it was super long. I made some changes and included a new one that removed the log level. So sorry. Let me change that again.
Ok Matt, here's the updated snippet
Untitled
m
hmm that was marginally more helpful 😆 I’m so sorry, could you please try again with
trace
😬
b
You got it
Untitled
m
hmm thanks. Something isn’t right with the logging, it looks like the core is not spitting out trace/debug logs. The JS library is, so I might need to dig into why we aren’t getting that visibility.
Are you able to share the verification code setup (redacted as needed?)
int
b
Sorry, which verification code?
b
The javascript
✅ 1
b
My apologies, I misunderstood, thinking there was some kind of verification token I was missing. Here's the Verifier code:
Copy code
import { Verifier, VerifierOptions } from '@pact-foundation/pact';
// import path from 'path';

describe('Pact Verification', () => {
  const opts: VerifierOptions = {
    provider: 'api.open',
    pactBrokerUrl: '<https://pact.broker.io>',
    pactBrokerUsername: 'pact',
    pactBrokerPassword: 'broker',

    // // publishVerificationResult: <http://process.env.CI|process.env.CI> === 'true',
    publishVerificationResult: true,
    providerVersion: '1',

    providerBaseUrl: `<http://localhost:4003>`,

    pactUrls: [
      '<https://pact.broker.io/pacts/provider/User%20Service/consumer/Open%20API/latest>',
    ],
    // stateHandlers: {
    //   'an user exists': () => {
    //     return Promise.resolve(`User already seeded`);
    //   },
    // },
    logLevel: 'trace',
  };
  it('validates the expectations of Matching Service', () => {
    return new Verifier(opts).verifyProvider().then(() => {
      // console.log('Pact Verification Complete!');
    });
  });
});
On a side note, I'm also getting a Typescript error trying to use that
stateHandler
I'm having trouble with, if anyone has seen something similar.
b
This is the channel for the Pact Broker. That's a problem with the Pact js library, which I can't help you with. Ask in the pact-js channel.
👍 1
In regards to your config, you're mixing your parameters.
m
On the JS issue, there is a type problem we need to fix: https://pact-foundation.slack.com/archives/C9VBGLUM9/p1675478973610729?thread_ts=1674576330.071629&amp;cid=C9VBGLUM9 See the work around in the above thread
b
Ah ok. I actually saw that thread, but didn't realize it was the same issue. Thanks!
👍 1