Skip to main content

Docker Compose a Selenium Grid

There are times when you would like to Selenium Grid quickly so that it can scale to whatever testing goal is you want to achieve.
To start out you will need to get Docker you can goto Docker.com to find out more information on installing.

Create a docker-compose.yml

Make a new directory and name a file docker-compose.yml inside that directory. The contents are below.
hub:
  image: selenium/hub
  ports:
    - "4444:4444"
chrome:
  image: selenium/node-chrome
  links:
    - hub
  expose:
    - "5555"
firefox:
  image: selenium/node-firefox
  links:
    - hub
  expose:
    - "5555"
Once you have created your file goto that directory in your command line. This will create your instances and download necessary files.
$ docker-compose build
To run your instances you can run the following and it will start your servers.
$ docker-compose up
At this point you can now point your test code to http://127.0.0.1:4444 as the selenium server. You will notice at this point that you are running only 1 Chrome and 1 Firefox container on your grid. Scaling is very simple. With your servers running you just need to run an additional command to scale to your needs. For instance lets say we want to scale up to 10 Chrome instances.
$ docker-compose scale chrome 10
Voila! you now have 10 chrome containers running on your machine. Scaling works very simple, however keep in mind that memory and processors play a big role in how many you can run on a single machine. With the Chrome container memory is very important. I find that I generally want 1gb of physical memory per Chrome container that I need. Firefox seems to be less and can tolerate 512mb most the time.

Comments

Popular posts from this blog

Reverse a number without converting to a string.

Sometimes I like to work on coding problems just for fun. Things like Project Euler, Code Eval Hackerrank etc. Depending on what language you decide to do things in it might be easier and more efficient to think a little different. Some languages like Ruby, for example, converting a number to a string with to_str() and then reversing is rather trivial. But what if I want to solve it by keeping the number a number? Currently, I am playing around with Rust so my example will be in that language however you can use this same formula in whatever language you like. pub fn num_reverse(number: i32) -> i32 { let mut num = number; let mut rev = 0; while num > 0 { rev = rev * 10 + (num % 10); num = num / 10; } return rev; } Now that we have the code lets map out a little bit of how it works. Let us take the number 1234. num = 1234; rev = 0; Grab the first digit. rev = rev * 10 + (num % 10) Which can be written as. rev = 0 * 10 ...

High Sierra and Valgrind Install

Valgrind is a tool used for memory management and profiling your applications.  I wanted to use it on my Macbook and ran into issues installing with brew and it turned out it wasn't too horrible of a change. brew update brew install --HEAD valgrind    Voila you now have a working run of valgrind. Happy Trails.

Javascript - Rounding numbers to decimal

function roundNumber(number, decimal) { return Math .round(number * Math .pow( 10 , decimal)) / Math .pow( 10 , decimal); } How it works The first thing to understand is how the Math.round() function works in Javascript. The round function takes what ever number that it is given and strips off everything after the decimal point. So if you have a number like 343.12345678 it will return 343. For this example lets say you want to have 2 decimal points left for your output like 343.12. To get the decimal points that we want we need to move the decimal point over 2 spots so that they will not be removed from the round function. Each decimal place is a factor of 10. Tenths, Hundredths, Thousandths, etc. Lets now multiply 343.12345678 by 10^2. 10 is the decimal and the 2 is how many we need to move. You should get 34312.345678. Now if you use the round function you will get 34312 right? So now that we have all the correct numbers we need to get the number back to the right value...