This tutorial describes how to perform load testing using terraform with GCP VMs and ansible to run the commands.
Terraform
Create a set of VMs with the following template (change the variables according to your environment):
main.tf
resource "google_compute_instance" "test-instance"
name = "test-instance-${count.index}"
zone = "$YOUR_REGION"
project = "$YOUR_PROJECT"
count = 3
machine_type = "custom-4-16384"
tags = ["test-instance"]
allow_stopping_for_update = true
boot_disk {
initialize_params {
image = "ubuntu-os-cloud/ubuntu-1804-lts"
size = 100
}
}
metadata = {
ssh-keys = "root:$YOUR_PUBLIC_KEY"
}
network_interface {
network = "default"
access_config {
network_tier = "STANDARD"
}
}
}
firewall.tf
resource "google_compute_firewall" "default" {
name = "test-firewall"
network = "default"
source_ranges = ["0.0.0.0/0"]
project = "$YOUR_PROJECT"
priority = 1>
allow {
protocol = "tcp"
ports = ["22", "80", "443", "3478", "4443", "5349"]
}
allow {
protocol = "udp"
ports = ["1-65535"]
}
target_tags = ["test-instance"]
}
This will create 3 instances in GCP with 4 cpu and 16gb of RAM.
Ansible
After creating the instances, paste their public IPs to the hosts
file in the current working directory. In the same directory, create an ansible.cfg
file with the following contents:
[defaults]
host_key_checking = no
inventory = ./hosts
ansible_ssh_private_key_file = ~/.ssh/id_rsa
ansible_user = root
remote_user = root
Create directory – load-test-templates
and create the following files in the directory:
docker-install.sh
#!/bin/bash
apt-get update
apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io -y>
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose-load-test.yml
version: "3.3"
services:
torture:
image: meetrix/jitsi-meet-torture
hub:
image: selenium/hub:3.141.59
node:
build: ./node
image: meetrix/jitsi-meet-torture-selenium-node
volumes:
- /dev/shm:/dev/shm
depends_on:
- hub
environment:
HUB_HOST: hub
Dockerfile-for-load-testing
FROM meetrix/jitsi-meet-torture-selenium-node
Create an auto.sh
file with the following contents:
#!/usr/bin/env bash
CONFERENCES=1
PARTICIPANTS=3
YOUR_DOMAIN=jitsi.example.com
ansible all -m copy -a "src=load-test-templates/docker-install.sh dest=/root owner=root mode=755"
ansible all -m shell -a "/root/docker-install.sh"
ansible all -m shell -a "mkdir /root/node"
ansible all -m copy -a "src=load-test-templates/Dockerfile-for-load-testing dest=/root/node/Dockerfile owner=root mode=755"
ansible all -m copy -a "src=load-test-templates/docker-compose-load-test.yml dest=/root/docker-compose.yml owner=root mode=755"
ansible all -m shell -a "docker-compose up -d --scale node=2"
ansible all -m shell -a "docker-compose exec torture ./scripts/malleus.sh --conferences=$CONFERENCES --participants=$PARTICIPANTS --senders=$PARTICIPANTS --audio-senders=$PARTICIPANTS --duration=30 --room-name-prefix=test --hub-url=http://hub:4444/wd/hub --instance-url=http://$YOUR_DOMAIN"
This will run a test on your Jitsi installation (without authentication), with 3 participants in 1 conference. The conference address will be $YOUR_DOMAIN/test0
. Additional conferences (if you change $CONFERENCES value
) will be named test1
, test2
, etc.
For a seamless, secure and supported deployment of Jitsi on the cloud marketplaces, provided by Hossted, click here.