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

Can't connect directly to redis from integration test #12

Open
cesarvarela opened this issue May 30, 2019 · 4 comments
Open

Can't connect directly to redis from integration test #12

cesarvarela opened this issue May 30, 2019 · 4 comments

Comments

@cesarvarela
Copy link

HI, I'm trying to connect directly to the redis server from the integration test by adding a container_name to the redis service in the compose yaml like this:

version: '2'

services:

  counter:
    image: gcr.io/${PROJECT_ID}/gcb-docker-compose:latest
    container_name: counter
    depends_on:
      - redis
    ports:
      - "50051:50051"
    environment:
      - REDIS_HOST=redis
      - REDIS_PORT=6379

  redis:
    container_name: redis
    image: redis
    ports:
      - "6379:6379"

networks:
    default:
        external:
            name: cloudbuild

And then doing in the integration test step:

const redisClient = redis.createClient({host: 'redis', port: '6379');

But I get an error in the cloud build console:

Step #2: (node:26) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 192.168.10.4:6379
Step #2:     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1191:14)

Any idea why?

@Philmod
Copy link
Owner

Philmod commented May 30, 2019

Not sure, but what is this IP 192.168.10.4 ?

@cesarvarela
Copy link
Author

I have no idea, that's what the cloud build console shows.

I'n another project that uses both mysql and redis, when running the integration tests:

when trying to connect to the mysql service:

Step #2:     connect ECONNREFUSED 192.168.10.4:5506

when trying to connect to the redis service:

Step #2: (node:26) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 192.168.10.3:5579

This other project also spins a node service with compose (like this repo), and connecting to that service from the integration test works (If I omit the protocol).

@Philmod
Copy link
Owner

Philmod commented May 30, 2019

Did you verify that the code from this repo works out of the box?

@cesarvarela
Copy link
Author

Just did that, what isn't working is remapping ports in compose ports configuration:
If I do this:

  redis:
    container_name: redis
    image: redis
    ports:
      - "7379:6379"

Then I get the weird IPs errors:

Step #4:      Uncaught Error: Redis connection to redis:7379 failed - connect ECONNREFUSED 192.168.10.3:7379

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