Skip to content
Permalink
Browse files

Add Apache Bench Workloads Plugin

This patch adds Octavia Data Plane performance testing.

It launches a jump host and a given number of clients (virtual machines).
They have Apache Web server pre-installed

It also creates a load balancer, listener, pool and adds those clients to the
pool. The uses ApacheBench to benchmark the load balancer.

Getting "requests per second" back to the output

Change-Id: I595caa4d78ff287d18a1877dcd7efb8d805bd5c4
  • Loading branch information...
xuhang57 committed Jun 25, 2019
1 parent 1b79d77 commit 7eb647d1205b7f552566fc51ee9cf22a88caaa9e
@@ -87,6 +87,11 @@ browbeat_workloads:
src: pbench-uperf-user.file
dest: "{{ browbeat_path }}/pbench-uperf-user.file"
image: centos7
abench:
name: browbeat-abench
src: abench-user.file
dest: "{{ browbeat_path }}/abench-user.file"
image: centos7

########################################
# Other Install Configuration Items
@@ -0,0 +1,11 @@
#!/bin/bash

sudo yum -y update
sudo yum install -y httpd
sudo systemctl enable httpd
sudo systemctl start httpd
sudo cp /usr/share/httpd/noindex/index.html /var/www/html/.
sudo chown apache:apache /var/www/html

sudo sed -i 's/disable_root: 1/disable_root: 0/g' /etc/cloud/cloud.cfg
echo "Browbeat workload installed"
@@ -361,3 +361,21 @@ workloads:
elastic_host:
elastic_port: 9200
file: rally/rally-plugins/workloads/pbench-uperf.yml

- name: browbeat-abench
enabled: true
user: centos
image_name: browbeat-abench
flavor_name: m1.small
external_network: public
net_id:
ext_net_id:
subnet_id:
protocol: HTTP
lb_algorithm: ROUND_ROBIN
protocol_port: 80
num_clients: 2
total_requests: 1000
concurrency_level: 10
send_results: true
file: rally/rally-plugins/workloads/abench.yml
@@ -0,0 +1,170 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import logging
import time

from rally.common import sshutils
from rally_openstack import consts
from rally_openstack.scenarios.vm import utils as vm_utils
from rally_openstack.scenarios.neutron import utils as neutron_utils
from rally_openstack.scenarios.octavia import utils as octavia_utils
from rally.task import scenario
from rally.task import types
from rally.task import validation


LOG = logging.getLogger(__name__)


@types.convert(image={"type": "glance_image"}, flavor={"type": "nova_flavor"})
@validation.add("image_valid_on_flavor", flavor_param="flavor", image_param="image")
@validation.add("required_services", services=[consts.Service.NEUTRON,
consts.Service.NOVA,
consts.Service.OCTAVIA])
@validation.add("required_platform", platform="openstack", users=True)
@scenario.configure(context={"cleanup@openstack": ["octavia", "neutron", "nova"],
"keypair@openstack": {}, "allow_ssh@openstack": None},
name="BrowbeatPlugin.abench", platform="openstack")
class BrowbeatApacheBench(vm_utils.VMScenario,
neutron_utils.NeutronScenario,
octavia_utils.OctaviaBase):
def build_jump_host(self, external, image, flavor, user, password=None, **kwargs):
keyname = self.context["user"]["keypair"]["name"]
LOG.info("Building Jump Host with key : {}".format(keyname))
jump_host, jump_host_ip = self._boot_server_with_fip(image,
flavor,
True,
None,
key_name=keyname,
**kwargs)
# wait for ping
self._wait_for_ping(jump_host_ip["ip"])

# open ssh connection
jump_ssh = sshutils.SSH(user, jump_host_ip["ip"], 22, self.context[
"user"]["keypair"]["private"], password)

# check for connectivity
self._wait_for_ssh(jump_ssh)

# write id_rsa(private key) to get to guests
self._run_command_over_ssh(jump_ssh, {"remote_path": "rm -rf ~/.ssh"})
self._run_command_over_ssh(jump_ssh, {"remote_path": "mkdir ~/.ssh"})
jump_ssh.run(
"cat > ~/.ssh/id_rsa",
stdin=self.context["user"]["keypair"]["private"])
jump_ssh.execute("chmod 0600 ~/.ssh/id_rsa")
return jump_ssh, jump_host_ip, jump_host

def create_clients(self, jump_ssh, num_clients, image, flavor, user, **kwargs):
_clients = []
for i in range(num_clients):
LOG.info("Launching Client : {}".format(i))
server = self._boot_server(
image,
flavor,
key_name=self.context["user"]["keypair"]["name"],
**kwargs)
for net in server.addresses:
network_name = net
break
if network_name is None:
return False
# IP Address
_clients.append(
str(server.addresses[network_name][0]["addr"]))
return _clients

def run(self, image, flavor, user, subnet_id, lb_algorithm, protocol, protocol_port,
total_requests, concurrency_level, description=None, admin_state=None,
listeners=None, flavor_id=None, provider=None, external=None,
vip_qos_policy_id=None, send_results=True, num_clients=2, password="",
network_id=None, **kwargs):

kwargs["nics"] = [{"net-id": network_id}]
jump_ssh, jump_host_ip, jump_host = self.build_jump_host(
external, image, flavor, user, **kwargs)
_clients = self.create_clients(
jump_ssh, num_clients, image, flavor, user, **kwargs)

LOG.info("Creating a load balancer")
# create a loadbalancer, listener, pool and add members to the pool
lb = self.octavia.load_balancer_create(
subnet_id=subnet_id,
admin_state=True)
LOG.info("Waiting for the load balancer to be active")
self.octavia.wait_for_loadbalancer_prov_status(lb)
time.sleep(90)
lb_id = lb["loadbalancer"]["id"]
listener_args = {
"name": self.generate_random_name(),
"loadbalancer_id": lb_id,
"protocol": protocol,
"protocol_port": protocol_port,
"connection_limit": -1,
"admin_state_up": True,
"default_tls_container_ref": None,
"description": None,
"insert_headers": None,
"l7policies": [],
"sni_container_refs": [],
"timeout_client_data": 50000,
"timeout_member_connect": 5000,
"timeout_member_data": 50000,
"timeout_tcp_inspect": 0,
}
LOG.info("Creating a listener")
listener = self.octavia.listener_create(**listener_args)
time.sleep(30)
LOG.info("Creating a pool")
pool = self.octavia.pool_create(
lb_id=lb["loadbalancer"]["id"],
protocol=protocol,
lb_algorithm=lb_algorithm,
listener_id=listener["listener"]["id"],
admin_state_up=True)
# member_create(pool_id, args), subnet_id, address, protocol_port, pool_id
time.sleep(60)
for client_ip in _clients:
member_args = {
"address": client_ip,
"protocol_port": protocol_port,
"subnet_id": subnet_id,
"admin_state_up": True,
"weight": 1,
"monitor_port": None,
"monitor_address": None,
"name": self.generate_random_name(),
"backup": False,
}
LOG.info("Adding member : {} to the pool".format(client_ip))
self.octavia.member_create(
pool["id"],
**member_args)
time.sleep(30)
# execute command, stdout will have infomation
time.sleep(90)
lb_ip = lb["loadbalancer"]["vip_address"]
lb_ip += "/"
LOG.info("Load balancer IP: {}".format(lb_ip))
cmd = "ab -n {} -c {} {}".format(total_requests, concurrency_level, lb_ip)
LOG.info("Running command : {}".format(cmd))
ab_exitcode, stdout_ab, stderr = jump_ssh.execute(cmd, timeout=0)
# prepare results
report = []
self.add_output(
additive={"title": "ApacheBench Stats",
"description": "ApacheBench Scenario",
"chart_plugin": "Gbps",
"label": "Gbps",
"data": report})
@@ -0,0 +1,56 @@
{% set image_name = image_name or 'browbeat-abench' %}
{% set flavor_name = flavor_name or 'm1.small' %}
{% set num_clients = num_clients or 2 %}
{% set password = password or 'None' %}
{% set protocol = protocol or 'HTTP' %}
{% set lb_algorithm = lb_algorithm or 'ROUND_ROBIN' %}
{% set protocol_port = protocol_port or 80 %}
{% set subnet_id = subnet_id or 'None' %}
{% set sla_max_avg_duration = sla_max_avg_duration or 60 %}
{% set sla_max_failure = sla_max_failure or 0 %}
{% set sla_max_seconds = sla_max_seconds or 60 %}
---
BrowbeatPlugin.abench:
-
args:
image:
name: '{{image_name}}'
flavor:
name: '{{flavor_name}}'
external:
name: '{{external_network}}'
user: '{{user}}'
password: '{{password}}'
num_clients: {{num_clients}}
network_id: '{{net_id}}'
subnet_id: '{{subnet_id}}'
protocol: '{{protocol}}'
lb_algorithm: '{{lb_algorithm}}'
protocol_port: '{{protocol_port}}'
ext_net_id: '{{ext_net_id}}'
total_requests: {{total_requests}}
concurrency_level: {{concurrency_level}}
send_results: {{send_results}}
runner:
concurrency: 1
times: 1
type: "constant"
context:
users:
tenants: 1
users_per_tenant: 1
quotas:
neutron:
network: -1
port: -1
router: -1
subnet: -1
nova:
instances: -1
cores: -1
ram: -1
sla:
max_avg_duration: {{sla_max_avg_duration}}
max_seconds_per_iteration: {{sla_max_seconds}}
failure_rate:
max: {{sla_max_failure}}

0 comments on commit 7eb647d

Please sign in to comment.
You can’t perform that action at this time.