Deploying ElasTest on a Linux server
Introduction
Through the following lines you will find a guide to deploy ElasTest on a single machine (physical or virtual). So the same steps can be applied to a server on your data center or an instance on AWS, OpenStack, Azure or Google Cloud.
We've tried to deploy ElasTest on Ubuntu 16.04, Ubuntu 18.04 and CentOS 7 and the steps are basically the same.
You only need remote or physical access to a Linux interactive shell to run commands as a privilegiated user.
You can also deploy ElasTest on Amazon Web Services
Accesing the instance
Depends on your infraestructure the access will be different. Please, refer to your system administrator to know how to grant access to the console.
In order to Elastest to work properly, some ports must be open:
Port/s | Comment |
---|---|
22 | SSH |
32768 - 61000 | ElastestRange |
Note: All ports are TCP.
Installing Docker
First of all, you'll need to install Docker, please, refer to the official documentation to install onto your platform:
If you want to use docker with a regular user add the user to docker group:
sudo usermod -aG docker YOUR_USER
Launching ElasTest
In order to launch ElasTest platform just type
docker run -ti \
--rm \
-v ~/.elastest:/data \
-v /var/run/docker.sock:/var/run/docker.sock \
elastest/platform start \
--server-address=X.Y.Z.W \
--testlink \
--jenkins \
--user=xxxxxx \
--password=yyyyyy
ElasTest needs to use Docker to launch other containers, so we bind the socket as a volume inside the platform.
The server-address is web address you will reach the platform. If you're deploying on a cloud provider (like AWS, GCE o Azure) this address should be your public IP, if you're deploying on your private LAN this is the address you're using to connect the server.It's necessary to use the --server-address
option and also open all ports from 32768 to 61000
both included. It is highly recommended to also set user and password using the --user
and --pass
options.
Alternatively, you can use a domain name like elastest.my_company.com for the server_address parameter.
--testlink
stands for TestLink and --jenkins
stands for Jenkins. These fields are not obligatory but its use is recommended.
You can also use your own Jenkins and install the ElasTest plugin for Jenkins
Finally, set user and password to grant access to the platform. You can omit this parameters if you're working on a safe evironment.
You'll see the following lines on the terminal when the platform is up and ready
Pulling some necessary images...
Preload images finished.
Starting ElasTest Platform latest (mini Mode)...
Creating volume "elastest_platform-services" with local driver
Creating elastest_platform-services_1 ... done
Creating elastest_edm-mysql_1 ... done
Creating elastest_etm-filebeat_1 ... done
Creating elastest_etm-jenkins_1 ... done
Creating elastest_etm-testlink_1 ... done
Creating elastest_etm_1 ... done
Creating elastest_etm-proxy_1 ... done
ElasTest services are starting. This will likely take some time. The ElasTest URL will be shown when ready.
ElasTest Platform is available at http://W.X.Y.Z:37000
Press Ctrl+C to stop.
It'll show the domain name instead the IP address in the case you're using a DNS service.
Type the following command to get more information about start command:
docker run --rm -v ~/.elastest:/data -v /var/run/docker.sock:/var/run/docker.sock elastest/platform start --help
Options
- You can include the option
--server-address=(docker-machine ip)
to set up the machine ip address.
docker run --rm -v ~/.elastest:/data -v /var/run/docker.sock:/var/run/docker.sock elastest/platform start --server-address="myip"
- You can add
--mode
to start ElasTest in a specific mode: mini or singlenode. If not indicated, the default mode will be mini.- IMPORTANT: To start ElasTest in singlenode mode it is necessary to first execute the following command to increase the virtual memory limit for Elasticsearch:
sysctl -w vm.max_map_count=262144
- IMPORTANT: To start ElasTest in singlenode mode it is necessary to first execute the following command to increase the virtual memory limit for Elasticsearch:
docker run --rm -v ~/.elastest:/data -v /var/run/docker.sock:/var/run/docker.sock elastest/platform start --mode=mini
- You can set an access username and password using the options
--user
and--pass
(or-u
and-p
)
docker run --rm -v ~/.elastest:/data -v /var/run/docker.sock:/var/run/docker.sock elastest/platform start --user=elastest --password=elastest
- You can add
--testlink
if you want to start the TestLink integrated in ElasTest and enable access to it. If you do not add this option, you can start it later manually from the ElasTest GUI.
docker run --rm -v ~/.elastest:/data -v /var/run/docker.sock:/var/run/docker.sock elastest/platform start --testlink
- The
--jenkins
option can be added if you want to start the Jenkins integrated in ElasTest and enable access to it. If you do not add this option, you can start it later manually from the ElasTest GUI.
docker run --rm -v ~/.elastest:/data -v /var/run/docker.sock:/var/run/docker.sock elastest/platform start --jenkins
- You can execute
--help
if you need more information about the options.
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock elastest/platform --help
Recommended system specifications
ElasTest needs some minimum system specifications in order to run smoothly:
Mini mode
Processor | 1GHz or faster |
RAM | 8GB (highly recommended 16GB) |
SWAP | 4GB (if RAM < 16GB) |
Hard Disk | 30GB |
Single-node mode
Processor | 1GHz or faster |
RAM | 32GB |
SWAP | 4GB |
Hard Disk | 100GB |
Running ElasTest on system boot
To start ElasTest automatically on a system with Systemd, two scripts are needed:
1) Start ElasTest (/usr/local/bin/elastest-start
)
This script will launch elastest and contains the following lines:
#!/bin/bash
PUBLIC_IP=$(curl ifconfig.co)
nohup docker run -d -v ~/.elastest:/data -v /var/run/docker.sock:/var/run/docker.sock elastest/platform start --server-address=${PUBLIC_IP} &>/dev/null &
disown
exit 0
As you can see, we set less parameters here as the initial configuration was made on the first launch.
For --server-address, we use an external service like ifconfig.co to get the external IP on every launch using curl
. This works fine on a cloud provider who give the instance a diferent IP on every boot, nevertheless, if you're using a static IP or a DNS name feel free to change the parameter.
Set execution permissions:
sudo chmod 0755 /usr/local/bin/elastest-start
2) Stop ElasTest (/usr/local/bin/elastest-stop
)
The second script is elastest-stop
to stop ElasTest.
#!/bin/bash
docker run -d -v /var/run/docker.sock:/var/run/docker.sock elastest/platform stop
Set execution permissions:
sudo chmod 0755 /usr/local/bin/elastest-stop
3) Systemd start script (/etc/systemd/system/elastest.service
)
[Unit]
Description=ElasTest Platform
After=docker.service
Requires=docker.service
[Service]
TimeoutStartSec=60
Restart=always
ExecStop=/usr/local/bin/elastest-stop
ExecStart=/usr/local/bin/elastest-start
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
Reload systemd daemon:
sudo systemctl daemon-reload
Enable the service to start with the system
sudo systemctl enable elastest
Start and Stop ElasTest
From now on, everytime you want to launch ElasTest:
sudo systemctl start elastest
or stop
sudo systemctl stop elastest
Swap space
It is possible that elastest needs some swap space. If your server is physical, it probably has some space already. You can check by running:
free -m
And you should see something like:
total used free shared buff/cache available
Mem: 15921 5059 5278 1130 5582 9337
Swap: 975 0 975
The line labeled as swap shows the swap space. When you have no swap space, it shows this:
total used free shared buff/cache available
Mem: 15921 5059 5278 1130 5582 9337
Swap: 0 0 0
If you're working on the cloud, you'll probably need to add some swap space. To do that follow this steps:
1) Creating a swap file
With Ubuntu:
sudo fallocate -l 4G /swapfile
With Centos:
sudo dd if=/dev/zero of=/swapfile count=4096 bs=1MiB
Both commands will create a 4G file in / called swapfile. You can check it by doing:
ls -lh /swapfile
Now, set up the proper file permissions:
sudo chmod 0600 /swapfile
2) Mark the file as swap space
sudo mkswap /swapfile
3) Activate the swap
sudo swapon /swapfile
4) Checking
If you run the free command again you'll see the swap space available.
free -m
5) Making changes permanent
To make those changes permanent, add the following line to your /etc/fstab file:
sudo echo "/swapfile none swap sw 0 0" >> /etc/fstab
ElasTest data
ElasTest makes use of a folder and two volumes to store the data:
/data folder
As you may have seen above in the ElasTest start command, two volumes are binded. The first one is the /data
folder that, in the example commands, we have bind to the host's ~/.elastest
folder, but you can choose the host folder you want.
In this folder some data like the videos of the tests or configurations of Elastest are saved.
elastest_edm-mysql volume
The elastest_edm-mysql
volume contains the ElasTest database, which contains all the data information of the tests, such as projects, suts, monitoring traces, test results, etc.
elastest_etm-testlink volume
The elastest_etm-testlink
volume contains TestLink configuration information, such as the name of the MySql schema created in the database of elastest_edm-mysql
volume.