DEV Community

Cover image for Testing with TestProject Docker Agent
Sunish Surendran K
Sunish Surendran K

Posted on

Testing with TestProject Docker Agent

"Well-run tests will help you avoid serious grief in the long run"

The above quote is of great significance as I remember my dark days of software development where I feel like I entered a dark alley without my slingshot or leather sandals.

Of course, I'm referring to proper Testing and avoiding fallacious approaches. But now we came forward from those dark days, the contemporary Testing techniques emerged and it has propelled the need for an efficient, reliable, fast, and powerful automation tool that can fit the diverse skillsets of everyone on an agile team.

Here I am introducing you to one of the newest entrant "TestProject"

An open-source friendly, community-powered automation testing tools. The most amazing part is it has a free forever plan which is fully featured and that you can get started within seconds.

Personally, I have tried TestProject for my research projects. I can strongly argue that it is of high quality and experience so far has been top-notch. So let's dig into it.

💻How to start with TestProject

Step 1 - Signup for free

All we need to do is sign up to Testproject.You can check the documentation if you need help in free signup.
Alt Text

Once you have created an account with TestProject you just need to follow a few simple steps to get setup and ready for testing. TestProject works on almost any platform, with the install of a single agent.

Step 2 - Generate an API key

Generate an API key which allows access to API for your account. In order to do that, open the TestProject application and go to the Integration tab and select the API option.
Alt Text
From there you can create a new API key and set the access you want it to have.Once you've setup that key you can copy it and use it in API call that you make.

🐳 How to setup TestProject Docker Agent

Alt Text

When it comes to the CICD team they have already get rid of the traditional testing and moved to automation. Nowadays, automated testing is embedded so deeply within our perception of software development, it's hard to imagine one without the other. And since that ultimately enables us to produce software quickly without sacrificing quality.

And Docker is the de-facto standard to build, run, test, and share containerized apps from your desktop to the cloud. So for this world TestProject comes with Docker Agent concept. Moreover, the docker agent is useful because it saves a bunch of resources & provides the ability to run tests with just a simple command.

Prerequites

  • In your machine Docker should be Installed
  • In this article, we are installing the agent with docker compose yaml file so Docker Compose also should be installed.

Step 1 -Docker-Compose for TestProject Docker Agent

Visit the TestProject dockerhub page, you can see on that page TestProject team explained all the different ways to spin the docker agent.We are using the docker-compose way. The following docker-compose snippet can be used to start a TestProject Agent with headless Chrome & Firefox browsers.

# NOTE: Make sure to update the 'testproject-agent' container volume with a valid local path.
# To execute this docker-compose, store it in a file (e.g. testproject-agent.yaml) an run:
# docker-compose -f <file_name> up -d

version: "3.1"
services:
  testproject-agent:
    image: testproject/agent:latest
    container_name: testproject-agent
    depends_on:
      - chrome
      - firefox
    volumes:
      - .:/var/testproject/agent
    environment:
      TP_AGENT_ALIAS: "Docker Agent"
      TP_API_KEY: "REPLACE_WITH_YOUR_KEY"
      TP_JOB_PARAMS: '"jobParameters" : { "browsers": [ "chrome", "firefox" ] }'
      CHROME: "chrome:4444"
      FIREFOX: "firefox:4444"
  chrome:
    image: selenium/standalone-chrome
    volumes:
      - /dev/shm:/dev/shm
  firefox:
    image: selenium/standalone-firefox
    volumes:
      - /dev/shm:/dev/shm
Enter fullscreen mode Exit fullscreen mode

We need to update the TP_API_KEY & TP_JOB_ID environment variables so that we instruct the Agent to automatically point to our TestProject account and run the job on startup.

In our case since we are not ready with job, so I have not mentioned the TP_JOB_ID environment variable. I have only added the TP_API_KEY that we created.

Alt Text

Step 2-Spinning up the TestProject Docker Agent

I have saved my docker compose yaml file with the name TestProject-DockerAgent.yaml.By running the below command the TestProject agent will be up and running.

docker-compose -f .\TestProject-DockerAgent.yaml up
Enter fullscreen mode Exit fullscreen mode

Alt Text

Within minutes the docker agent is ready with headless Chrome & Firefox browsers. You can see in the below logs saying "Agent initialization is complete"

testproject-agent    | 2020-11-28 14:42:04.491 [INFO ] i.t.a.Program                            *** AGENT - START ***
testproject-agent    | 2020-11-28 14:42:04.742 [INFO ] i.t.a.a                                  TestProject Agent 0.65.10 (64dbf6a7cad45d6e980553444ef4ff002008b3f6) on Linux
testproject-agent    | 2020-11-28 14:42:04.777 [INFO ] i.t.a.a                                  Running as user /home/agent of type Unknown with non-Administrator privileges
testproject-agent    | 2020-11-28 14:42:04.780 [INFO ] i.t.a.a                                  Running inside docker 6a805a004559
testproject-agent    | 2020-11-28 14:42:04.790 [INFO ] i.t.a.a                                  No X11 available - headless mode.
testproject-agent    | 2020-11-28 14:42:04.800 [INFO ] i.t.a.s.IdentityManager                  No identity file was found - Agent is not registered
testproject-agent    | 2020-11-28 14:42:04.804 [INFO ] i.t.a.a                                  Working folder: /opt/testproject/agent
testproject-agent    | 2020-11-28 14:42:04.807 [INFO ] i.t.a.a                                  Data folder: /var/testproject/agent
testproject-agent    | 2020-11-28 14:42:04.816 [INFO ] i.t.a.a                                  Agent IP addresses: 1.1.1.1
testproject-agent    | 2020-11-28 14:42:04.823 [INFO ] i.t.a.m.H                                Checking connectivity with https://testproject.io:443 (Using proxy: No)
testproject-agent    | 2020-11-28 14:42:07.557 [INFO ] i.t.a.m.H                                Connection established successfully.
testproject-agent    | 2020-11-28 14:42:07.560 [INFO ] i.t.a.a                                  Direct connection (no proxy) to TP is possible.
testproject-agent    | 2020-11-28 14:42:08.023 [INFO ] i.t.a.a                                  Agent initialization is complete.
Enter fullscreen mode Exit fullscreen mode

Now we can go back to our TestProject account and check the agent is showing up there. For that, we need to navigate to the Agents Tab. The new docker agent is showing on the page as shown below.

Alt Text

🏃 Running the Test Jobs against the Docker Agent

Under the Projects Tab, I have created a sample test project. You can follow the instruction in the documentation to set up your test.

Let's run My First Test test case against our newly created docker agent by clicking on the play button as shown below

Alt Text

Once you press the play button you will receive a popup and it will ask for which agent to select , in our case we will select the Docker Agent

Alt Text

Once you press the Run button the job will run in the Docker Agent and you can see the logs below

Alt Text

testproject-agent    | 2020-11-28 17:35:13.207 [INFO ] i.t.a.m.c.p                              Successfully handled report for execution KXfcPG0yzUCFyP2Sf24CpQ
testproject-agent    | 2020-11-28 17:35:13.214 [INFO ] i.t.a.m.c.p                              Uploading attachments for execution KXfcPG0yzUCFyP2Sf24CpQ
testproject-agent    | 2020-11-28 17:35:13.217 [INFO ] i.t.a.m.c.p                              Successfully handled attachments for execution KXfcPG0yzUCFyP2Sf24CpQ
testproject-agent    | 2020-11-28 17:35:13.264 [INFO ] i.t.a.m.c.p                              Successfully finished execution KXfcPG0yzUCFyP2Sf24CpQ reporting.
Enter fullscreen mode Exit fullscreen mode

Alt Text

📑 Checking Test Reports

TestProject one of the premium feature that they give us for free
is the report dashboard.
To explore Reports we need to navigate to the tab Reports, here we can see the report of our last few runs in the docker agent.

Alt Text

📚 Summary

If you’re looking out for a $0 cloud-based, SaaS test automation development framework designed for your agile team, TestProject is the right choice for you.

Alt Text

"It is manageable, quick and reliable !!!"

As it is built on top of industry-standard open-source tools (Selenium & Appium), supports all major operating systems, and ensures quality with speed using advanced built-in recording capabilities, addons, reports and analytics dashboards, or develop coded tests using TestProject’s powerful SDK for Python/Java/C#!.So in this modern era TestProject suites well!!

Below are few usefull links about TestProject, Check it out !!
Official YouTube Channel

Open Source TestProject's SDK:
Open-source Java SDK | Python SDK | TestProject SDK for Addons

Addons library | Forum

Top comments (0)