Deploying ElasTest on Ubuntu server

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.

You only need remote or physical access to an Ubuntu 16.04 interactive shell to run commands as a privilegiated user.

Depends on your infraestructure the access will be different. Please, refer to your system administrator to know how to grant access to the console.

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
sudo fallocate -l 4G /swapfile

This command 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:

/swapfile  none wap sw 0 0

According to Elasticsearch docs, you need to set up vm.max_map_count to an upper value in production environments. Check here if you need more information.

So, to increase that kernel parameter just do:

sudo sysctl -w vm.max_map_count=262144

To make changes permanent,

sudo echo vm.max_map_count=262144 >> /etc/sysctl.conf

There isn't an easy way to run Elastest with the system, but there's a few tips you can considerate.

Removing all volumes

We recommend to remove all the volumes except the MySQL one, because is the one who maintain the test data.

To do so:

for volume in $(docker volume ls | grep -v mysql | tail -n +2 | awk '{print $2}'); do docker volume rm $volume; done
Removing all containers

To remove all the containers:

docker rm -f $(docker ps -a -q)
Putting all the pieces together

We provide a set of scripts to achive this:

1) Clean all containers and volumes (/usr/local/bin/docker-evacuate)
#!/bin/bash

# Delete all containers
docker rm -f $(docker ps -a -q)

for volume in $(docker volume ls | grep -v mysql | tail -n +2 | awk '{print $2}')
do
  docker volume rm $volume
done

Set execution permissions:

chmod 0755 /usr/local/bin/docker-evacuate
2) Start Elastest (/usr/local/bin/docker-elastest-up)
#!/bin/bash
docker run -d -v /var/run/docker.sock:/var/run/docker.sock elastest/platform:latest start --server-address=YOU_IP_HERE --mode=MODE --pullcore

Remember to complete the server-address and mode parameters. You can run this command:

docker run --rm -v /var/run/docker.sock:/var/run/docker.sock elastest/platform start --help

to get information.

Set execution permissions:

chmod 0755 /usr/local/bin/docker-elastest-up
3) Systemd start script (/etc/systemd/system/docker-elastest.service)
[Unit]
Description=Elastest Platform
After=docker.service
Requires=docker.service

[Service]
TimeoutStartSec=0
Restart=always
ExecStop=/usr/local/bin/docker-evacuate
ExecStart=/usr/local/bin/docker-elastest-up

[Install]
WantedBy=multi-user.target

Reload systemd daemon:

sudo systemctl daemon-reload

Enable the service to start with the system

sudo systemctl enable docker-elastest