Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Bitbucket pipeline With selenium hub works locally but not in pipeline?

I've tried to replicate the bitbucket pipeline build locally - and can get it working so my integration tests are running and passing with Docker. However once I push to Bitbucket those same tests fail.

I think the answer is something simple - I just can't figure it out.

It's a Django project/app and I use Selenium to launch firefox and chrome browsers to test against.

I have the following `docker-compose.yml` and this works locally:


version: "3.3"
services:
python:
image: "my_user/python:3.8"
build:
context: ./docker
dockerfile: python.dock
volumes:
- ".:/my_project"
environment:
- DJANGO_DEBUG=True
- my_project_SECRET_KEY=1234_secret_key_4321
- BITBUCKET_CI=True
ports:
- "8000:8000"
links:
- hub
firefox:
image: selenium/node-firefox
volumes:
- /dev/shm:/dev/shm
depends_on:
- hub
environment:
HUB_HOST: hub
chrome:
image: selenium/node-chrome
volumes:
- /dev/shm:/dev/shm
depends_on:
- hub
environment:
HUB_HOST: hub
hub:
image: selenium/hub
ports:
- "4444:4444"

The `python.dock` file is very simple:


FROM python:3.8
SHELL ["/bin/bash", "-c"]

RUN pip install virtualenv

CMD ["tail", "-F", "-n0", "/etc/hosts"]

Then I launch an interactive bash shell for that container and install requirements and run pytest.

My `bitbucket-pipelines.yml` file is also pretty simple/straightforward:


image: python:3.8

pipelines:
branches:
dev:
- step:
name: Build project & run pytest
caches:
- pip
services:
- hub
script: # Modify the commands below to build your repository.
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate
- apt-get install gcc libc-dev g++ libffi-dev libxml2 unixodbc-dev gnupg2 -y
- pip install -r requirements-dev.txt
- pytest
definitions:
services:
firefox:
image: selenium/node-firefox
volumes:
- /dev/shm:/dev/shm
depends_on:
- hub
environment:
HUB_HOST: hub
chrome:
image: selenium/node-chrome
volumes:
- /dev/shm:/dev/shm
depends_on:
- hub
environment:
HUB_HOST: hub
hub:
image: selenium/hub
ports:
- "4444:4444"

I utilize `pytest` for my testing and in the setup of the browser for my tests it looks like this:


HUB_URL = "http://hub:4444/wd/hub"
chrome_capabilities = DesiredCapabilities.CHROME.copy()
browser = webdriver.Remote(
command_executor=HUB_URL, desired_capabilities=chrome_capabilities
)

This launches the appropriate browser and my tests all pass no problem using Docker locally. I believe it's because I use `links` to attach the two containers to each other - so I can use the service name in the URL and it gets routed appropriately.

When I run my CI on Bitbucket the tests fail.

This is the failure message:


try:
> conn = connection.create_connection(
(self._dns_host, self.port), self.timeout, **extra_kw
)
venv/lib/python3.8/site-packages/urllib3/connection.py:159:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
address = ('hub', 4444), timeout = <object object at 0x7f8bd0757630>
source_address = None, socket_options = [(6, 1, 1)]
def create_connection(
address,
timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
source_address=None,
socket_options=None,
):
"""Connect to *address* and return the socket object.

Convenience function. Connect to *address* (a 2-tuple ``(host,
port)``) and return the socket object. Passing the optional
*timeout* parameter will set the timeout on the socket instance
before attempting to connect. If no *timeout* is supplied, the
global default timeout setting returned by :func:`getdefaulttimeout`
is used. If *source_address* is set it must be a tuple of (host, port)
for the socket to bind as a source address before making the connection.
An host of '' or port 0 tells the OS to use the default.
"""

host, port = address
if host.startswith("["):
host = host.strip("[]")
err = None

# Using the value from allowed_gai_family() in the context of getaddrinfo lets
# us select whether to work with IPv4 DNS records, IPv6 records, or both.

I believe the reason for this has to do with using `http://hub:4444/wd/hub` as the URL.

In pipelines what should I be using for that URL? I've tried `localhost` and `127.0.0.1` with no luck.

I am using Docker to try to replicate the Pipelines environment locally so I don't burn through minutes if not necessary. But now that it works locally - I'm at a loss on how to get this going in Bitbucket Pipelines.

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket Pipelines

What We Learned When We Researched Open Source Vulnerabilities in 7 Popular Coding Languages

...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...

1,328 views 0 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you