Creating a testing infrastructure with Pytest , Selenium Grid and Docker -
based on article, created scalable selenium grid . want run test suites [written in python] using pytest grid.
i new docker , trying find best way migrate testing procedures microservices architecture. want give ability devs setup full testing infrastructure locally on pcs.
so, have 4 dockerfiles , 1 docker-compose.yml .
the base dockerfile:
from ubuntu env sel_version 2.44.0 # update repos java run apt-get update -qqy \ && apt-get -qqy --no-install-recommends install \ software-properties-common \ && rm -rf /var/lib/apt/lists/* run add-apt-repository -y ppa:webupd8team/java run echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections run echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections # install java7 run apt-get update -qqy \ && apt-get -qqy --no-install-recommends install \ oracle-java7-installer \ && rm -rf /var/lib/apt/lists/* # download selenium server run wget http://selenium-release.storage.googleapis.com/${sel_version%.*}/selenium-server-standalone-${sel_version}.jar
the hub dockerfile :
from org/grid:base expose 4444 # add , set permissions script launch hub add register-hub.sh /var/register-hub.sh run chmod 755 /var/register-hub.sh # start shell , run script #workdir / cmd ["/bin/bash", "/var/register-hub.sh"]
the node dockerfile :
from org/grid:base # set ff version use env firefox_minor 34.0.5 # update , install what's needed run apt-get update -qqy \ && apt-get -qqy --no-install-recommends install \ firefox \ xvfb \ bzip2 \ && rm -rf /var/lib/apt/lists/* # setup ff run [ -e /usr/bin/firefox ] && rm /usr/bin/firefox add https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/${firefox_minor}/linux-x86_64/en-us/firefox-${firefox_minor}.tar.bz2 /tmp/ run apt-get install -q -y libdbus-glib-1-2 run tar -xvjf /tmp/firefox-${firefox_minor}.tar.bz2 -c /opt/ run chmod -r +x /opt/firefox/ run ln -s /opt/firefox/firefox /usr/bin/firefox # add , set permissions bash script register node add register-node.sh /var/register-node.sh run chmod 755 /var/register-node.sh # start shell , run script cmd ["/bin/bash", "/var/register-node.sh"]
and pytest dockerfile :
# starting base image ubuntu # set github personal token [to clone qa code] #todo------secret------ env gh_token some_token_some_token_some_token_ # install python & pip run apt-get update run apt-get upgrade -y run apt-get install -y python python-pip python-dev && pip install --upgrade pip # install git run apt-get update -y && apt-get install git -y # [in / folder] create folder , add whole project repo container run git clone https://$gh_token:x-oauth-basic@github.com/org/org_qa.git /org_qa_folder # install dependencies via pip workdir /org_qa_folder run pip install -r dependencies.txt # cmd /bin/bash
and docker-compose file :
hub: image: org/grid:hub # image must exist ports: - "4444:4444" # host:container external_links: # link container created outside of yaml file - pytest volumes_from: - pytest # must created first firefox: image: org/grid:nodeff # image must exist links: - hub expose: - "5555" # grid console open public
so...i cannot understand how should run "py.test /org_qa_folder/testcase.py" , run on grid [essentially node].
i first run pytest container docker run -dit -v /org_qa_folder --name pytest schoox/grid:py
, other services docker-compose -d
.
i tried multiple approaches:
not use pytest container clone code in hub. in case , hub container runs hub of grid [one cmd per container directive] . [edit: chose microservices architecture docker suggests]
i leave hub , node containers run specified services, , create separate container [pytest] send tests there. test wont run cause container not have xvfb.[edit: installed xvfb , worked]
i tried use pytest container volume hub remains problem of running tests hub container has service running.[edit: dev purposes mount code pytest container , use console test stuff on other containers. after use pytest container have code separate]
should install packages ,that node container has, in other containers? ideally want use pytest container console [to develop infrastructure @ least] run tests sent hub , run many nodes.[edit: didn't mingled hub , node, installed xvfb on pytest container]
how suggest that? missing ?
edit [steps towards solution]:
i first start pytest container [docker run -dit -v /org/org_qa_folder --name pytest org/grid:py
] , run docker-compose -d
launch grid
in compose file use external_links
, volumes_from
dev purposes. wont work inside container when setup finished.
i changed pytest dockerfile , added this:
# install xvfb [that needed!!!!!] run apt-get install -y xvfb
i run 1 of tests ,from inside pytest container, running grid[on ec2 instance] proof of concept , worked fine. remains send dockerized grid.
i think you're there.
i add pytest
service docker-compose.yml
, , remove volumes_from
, external_links
hub
image (so looks more example blog post linked).
the pytest
service run python code, should connect hub run selenium. believe somewhere in org_qa_folder
there configuration tries start selenium locally. needs reconfigured use hub
server instead.
Comments
Post a Comment