oviney / test-automation-toolbox

Containerized Ubuntu running Development IDE
0 stars 0 forks source link

CircleCI

test-automation-toolbox

How long does it take to set up your test automation development environment? How long does it take a new automation engineer on your team to set up their dev environment? Say you want to try out a new programming language, how much time do you spend figuring out what tools to use before you actually try out the language?

Requirements

In this README, we will illustrate how to simplify the development experience using recent releases from Ubuntu, Intellij and Docker with the age-old X Window forwarding. This tutorial focuses on Windows as your base operating system.

Preprequisite Software

This section outlines the prerequisite software you need installed on your local system to get this all running.

Chocolatey Windows Package Manager Installation

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

For additional details see...

X Windows Server on Windows

VcXsrv looks like a good choice for an X Server on Windows. It is free, maintained, has good ratings, automatable, and easy to install via Chocolatey (you may choose this approach): choco install -y vcxsrv.

That installed the most recent 64-bit version vcxsrv v1.20.1.4 released in Jan 2019 on my machine.

How to use it? Start the Container and Get Your Prefered IDE Running

Basic steps to use

Git clone test-automation-toolbox

git clone https://github.com/oviney/test-automation-toolbox.git

Build Docker image

Run Docker image

Next steps using the Docker container daily

One thing I noticed was I wanted to automate the manual steps to encourage me to use it. So, here are a few of my favourite hacks.

$prog="$env:ProgramFiles\VcXsrv\vcxsrv.exe"
if (! (ps | ? {$_.path -eq $prog})) {& $prog -multiwindow -ac}

# get the IP address used by Docker for Windows
$ip = Get-NetIPAddress `
    | where {$_.InterfaceAlias -eq 'vEthernet (DockerNAT)' -and $_.AddressFamily -eq 'IPv4'} `
    | select -ExpandProperty IPAddress
echo $ip

# start 
$cmd="intellij-idea-community"
set-variable -name DISPLAY -value ${ip}:0.0
echo $DISPLAY
docker run --rm `
    -e DISPLAY=$DISPLAY `
    --security-opt seccomp=unconfined `
    --name toolbox-intellij `
    oviney/test-automation-toolbox:latest 

C:\Users\ouray>docker images REPOSITORY TAG IMAGE ID CREATED SIZE oviney/test-automation-toolbox latest fcffde991fb6 5 minutes ago 1.97GB oviney/ubuntu-vscode latest df830a104655 20 minutes ago 517MB

3ac3b3403a11 About an hour ago 1.97GB 96c337546fe4 2 hours ago 517MB 9cc8e8ecef83 2 hours ago 517MB ubuntu latest 47b19964fb50 12 days ago 88.1MB C:\Users\ouray>docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0f4787510f67 oviney/test-automation-toolbox:latest "/bin/sh -c intellij…" 23 minutes ago Up 23 minutes toolbox-intellij ``` Grab the container id for the desired container. For me, this is `0f4787510f67`. Let's use that to start *restart* the Docker container. To restart an existing container, we'll use the start command with the `-a` flag to attach to it and the `-i` flag to make it interactive, followed by either the container ID or name. Be sure to substitute the ID of your container in the command below: > Note: I removed the following argument from the `docker run...` command; ```--rm Automatically remove the container when it exits``` ```Batch C:\Users\ouray>docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a1b086104d20 oviney/test-automation-toolbox:latest "/bin/sh -c intellij…" 34 seconds ago Up 32 seconds toolbox-intellij C:\Users\ouray>docker start -ai a1b086104d20 WARN: Gherkin not loaded: since build 191.5532 > IC-183.5429.30 WARN: Cucumber for Java not loaded: since build 191.5532 > IC-183.5429.30 ``` > Note: Because we did not remove the image after exiting our IDE (*stop or exit container*). The start command will work and will fire up Intellij IDE again. You should see Intellij IDE window pop up. - Save the state of a container, persist the storage. This is useful, but depends on your use case. Get your container id. ```Batch C:\Users\ouray>docker container ls --all CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0b69738121d8 oviney/toolbox-intellij-saved "/bin/sh -c intellij…" 6 minutes ago Exited (0) 4 minutes ago flamboyant_yalow 5fbf887c285f oviney/toolbox-intellij-saved "/bin/sh -c intellij…" 16 minutes ago Exited (0) 7 minutes ago musing_nash a1b086104d20 oviney/test-automation-toolbox:latest "/bin/sh -c intellij…" 28 minutes ago Exited (0) 17 minutes ago toolbox-intellij ``` Then commit the changes ```Batch C:\Users\ouray>docker commit 0b69738121d8 oviney/toolbox-intellij-image:version1 ``` Run the newly saved container ```Batch C:\Users\ouray>docker start -ai oviney/toolbox-intellij-saved ```