Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Unable to find pacts for given provider" when working with pact_broker-docker #120

Closed
lirantal opened this issue Oct 7, 2018 · 8 comments

Comments

@lirantal
Copy link
Contributor

lirantal commented Oct 7, 2018

Software versions

  • OS: Mac OSX 10.12.6
  • Docker version: 17.09.0-ce, build afdb6d4

Expected behaviour

Provider testing is able to pull and very pacts from the broker.

Actual behaviour

"Unable to find pacts for given provider" during a provider's testing verification:

    let opts = {
      provider: 'Reviews',
      providerBaseUrl: 'http://localhost:3002/',
      providerStatesSetupUrl: 'http://localhost:4011/setup/',
      pactBrokerUrl: 'http://localhost:88',
      tags: ['develop'],
      providerVersion: "1.0.0"
    }

    return new Verifier().verifyProvider(opts)
      .then(output => {
        console.log('Pact Verification Complete!')
        console.log(output)
      })

Steps to reproduce

  1. Clone the pact_broker-docker repository
  2. Adjust the nginx config for non-SSL
  3. Run docker-compose up

Relevant log files

Setting PACT_BROKER_LOG_LEVEL to INFO for the pact_broker service in docker-compose.yml doesn't yield anything useful. Setting it to DEBUG I do see that it "works", querying the DB etc, but nothing informational about processing the request.

mefellows added a commit to pact-foundation/pact-js that referenced this issue Oct 8, 2018
@mefellows
Copy link
Member

mefellows commented Oct 8, 2018

Might need a reproduceable code base Liran, I just tested the following configuration successfully:

docker-compose.yml

version: '3'

services:

  postgres:
    image: postgres
    healthcheck:
      test: psql postgres --command "select 1" -U postgres
    ports:
      - "5432:5432"
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: password
      POSTGRES_DB: postgres

  broker_app:
    image: dius/pact-broker
    ports:
      - "80:80"
    links:
      - postgres
    environment:
      PACT_BROKER_DATABASE_USERNAME: postgres
      PACT_BROKER_DATABASE_PASSWORD: password
      PACT_BROKER_DATABASE_HOST: postgres
      PACT_BROKER_DATABASE_NAME: postgres

Then ran the following:

# modify e2e publish.js and provider.spec.js to update broker to http://localhost
# See code here: https://github.com/pact-foundation/pact-js/tree/repro/issue-120
docker-compose up -d
npm run  test:e2e-examples

Head over to http://localhost in the browser and you should see:

screenshot

You can clone this branch and run the steps to see this.

@lirantal
Copy link
Contributor Author

lirantal commented Oct 8, 2018

so that's over HTTP?
I'll try to get a working example.

Any ideas what else can I look at?

Edit: one thing I've noticed now in that docker-compose.yml you referred to is that it just has the broker and the db, it's not using nginx at all. I'll try to make similar changes in my setup as well to bypass nginx and I'll update back.

@mefellows
Copy link
Member

Yep, I removed nginx as it's not necessary (just convenient if you want to test SSL etc.). You can pretty much leave nginx there and just hit port 80 instead. It should still work.

I also note that you're hitting port 88, -have you mapped it to port 80 on the container by any chance? If so, this won't work due to some interesting Rack challenges. That might also be why you're running into issues on the http side (see https://github.com/DiUS/pact_broker-docker#notes).

@mefellows
Copy link
Member

Just for posterity, if you want to run a reverse proxy in front of the broker, read this

@mefellows
Copy link
Member

And to make it easier for those in the future, I just updated the compose file in that sample repository to avoid confusion - now nginx fronts both http and ssl:

DiUS/pact_broker-docker@5b0ebca

@lirantal
Copy link
Contributor Author

lirantal commented Oct 9, 2018

Port 88 is for the nginx conf, i.e:

  nginx:
    image: nginx:alpine
    links:
      - broker_app:broker
    volumes:
    - ./ssl/nginx.conf:/etc/nginx/conf.d/default.conf:ro
    - ./ssl:/etc/nginx/ssl
    ports:
    - "88:443"

Needed because I had something else occupying 443 already.

😄 Ok so working with the broker directly instead of nginx worked out just fine.
Indeed probably worth a doc or that example you posted to be made clearer, probably in the pact-broker repo.

We can close the issue.

@lirantal lirantal closed this as completed Oct 9, 2018
@mefellows
Copy link
Member

Oh I see. I'm still keen to get to the bottom of the HTTPs issue though. Was it the self-signed certificate that was the issue? I think it's a good point, because if we set a default self-signed TLS certificate on the broker and then people use it for dev, they will inevitably run into issues - the handshake will fail between nginx and whatever client library they're using.

@lirantal
Copy link
Contributor Author

lirantal commented Oct 9, 2018

Interesting indeed.
I'm not sure it was related to a connection issue because it seemed to have been able to connect, just didn't find the pacts. Though I haven't looked too deeply in the code for this so maybe it will throw that error even in cases of connection issues.

I'll anyway try your newly pushed change to the docker setup to see if nginx fronts the broker on port 80 without any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants