Measure performance of docker create/delete container with/without kuryr.
Partially-implements: bp kuryr-libnetwork-rally Change-Id: I3c122e50e2dc1a4d1cbc268c56723fdac7de1f54
This commit is contained in:
parent
ba6b15f618
commit
f704f73959
@ -5,13 +5,6 @@
|
|||||||
type: "constant"
|
type: "constant"
|
||||||
times: 20
|
times: 20
|
||||||
concurrency: 1
|
concurrency: 1
|
||||||
context:
|
|
||||||
users:
|
|
||||||
tenants: 2
|
|
||||||
users_per_tenant: 2
|
|
||||||
quotas:
|
|
||||||
neutron:
|
|
||||||
network: -1
|
|
||||||
sla:
|
sla:
|
||||||
failure_rate:
|
failure_rate:
|
||||||
max: 0
|
max: 0
|
||||||
@ -22,13 +15,6 @@
|
|||||||
type: "constant"
|
type: "constant"
|
||||||
times: 20
|
times: 20
|
||||||
concurrency: 1
|
concurrency: 1
|
||||||
context:
|
|
||||||
users:
|
|
||||||
tenants: 2
|
|
||||||
users_per_tenant: 2
|
|
||||||
quotas:
|
|
||||||
neutron:
|
|
||||||
network: -1
|
|
||||||
sla:
|
sla:
|
||||||
failure_rate:
|
failure_rate:
|
||||||
max: 0
|
max: 0
|
||||||
@ -39,13 +25,35 @@
|
|||||||
type: "constant"
|
type: "constant"
|
||||||
times: 20
|
times: 20
|
||||||
concurrency: 1
|
concurrency: 1
|
||||||
context:
|
sla:
|
||||||
users:
|
failure_rate:
|
||||||
tenants: 2
|
max: 0
|
||||||
users_per_tenant: 2
|
|
||||||
quotas:
|
Kuryr.start_and_stop_containers:
|
||||||
neutron:
|
# Start/stop Containers with Kuryr Network
|
||||||
network: -1
|
-
|
||||||
|
runner:
|
||||||
|
type: "constant"
|
||||||
|
times: 20
|
||||||
|
concurrency: 1
|
||||||
|
context:
|
||||||
|
docker_network:
|
||||||
|
is_kuryr: True
|
||||||
|
Subnet: 50.0.0.0/24
|
||||||
|
IPRange: 50.0.0.0/24
|
||||||
|
Gateway: 50.0.0.1
|
||||||
|
sla:
|
||||||
|
failure_rate:
|
||||||
|
max: 0
|
||||||
|
-
|
||||||
|
# Start/stop Containers with Default Network
|
||||||
|
runner:
|
||||||
|
type: "constant"
|
||||||
|
times: 20
|
||||||
|
concurrency: 1
|
||||||
|
context:
|
||||||
|
docker_network:
|
||||||
|
is_kuryr: False
|
||||||
sla:
|
sla:
|
||||||
failure_rate:
|
failure_rate:
|
||||||
max: 0
|
max: 0
|
||||||
|
0
rally-jobs/plugins/context/__init__.py
Normal file
0
rally-jobs/plugins/context/__init__.py
Normal file
96
rally-jobs/plugins/context/docker_networks.py
Normal file
96
rally-jobs/plugins/context/docker_networks.py
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
# 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 docker
|
||||||
|
|
||||||
|
from rally.common import logging
|
||||||
|
from rally import consts
|
||||||
|
from rally.task import context
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@context.configure(name="docker_network", order=1000)
|
||||||
|
class DockerNetworkContext(context.Context):
|
||||||
|
"""Create a kuryr or non-kuryr docker network as context"""
|
||||||
|
|
||||||
|
CONFIG_SCHEMA = {
|
||||||
|
"type": "object",
|
||||||
|
"$schema": consts.JSON_SCHEMA,
|
||||||
|
"additionalProperties": False,
|
||||||
|
"properties": {
|
||||||
|
"is_kuryr": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"Subnet": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"IPRange": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"Gateway": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DEFAULT_CONFIG = {
|
||||||
|
"is_kuryr": True,
|
||||||
|
"Subnet": "50.0.0.0/24",
|
||||||
|
"IPRange": "50.0.0.0/24",
|
||||||
|
"Gateway": "50.0.0.1"
|
||||||
|
}
|
||||||
|
|
||||||
|
def setup(self):
|
||||||
|
"""Create kuryr or non-kuryr docker network, and prepare image cache"""
|
||||||
|
try:
|
||||||
|
docker_client = docker.Client(base_url="tcp://0.0.0.0:2375")
|
||||||
|
# Cache busybox image
|
||||||
|
docker_client.pull(repository="busybox", tag="1")
|
||||||
|
|
||||||
|
if self.config["is_kuryr"]:
|
||||||
|
ipam = {
|
||||||
|
"Driver": "kuryr",
|
||||||
|
"Options": {},
|
||||||
|
"Config": [
|
||||||
|
{
|
||||||
|
"Subnet": self.config.get("Subnet"),
|
||||||
|
"IPRange": self.config.get("IPRange"),
|
||||||
|
"Gateway": self.config.get("Gateway")
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
res = docker_client.create_network(name="kuryr_network",
|
||||||
|
driver="kuryr",
|
||||||
|
ipam=ipam)
|
||||||
|
self.context["netid"] = res.get("Id")
|
||||||
|
else:
|
||||||
|
res = docker_client.create_network(name="docker_network")
|
||||||
|
self.context["netid"] = res.get("Id")
|
||||||
|
LOG.debug("Container network id is '%s'" % self.context["netid"])
|
||||||
|
except Exception as e:
|
||||||
|
msg = "Can't create docker network: %s" % e.message
|
||||||
|
if logging.is_debug():
|
||||||
|
LOG.exception(msg)
|
||||||
|
else:
|
||||||
|
LOG.warning(msg)
|
||||||
|
|
||||||
|
def cleanup(self):
|
||||||
|
"""Clean up network"""
|
||||||
|
try:
|
||||||
|
self.docker_client.remove_network(self.context["netid"])
|
||||||
|
LOG.debug("Docker network '%s' deleted" % self.context["netid"])
|
||||||
|
except Exception as e:
|
||||||
|
msg = "Can't delete docker network: %s" % e.message
|
||||||
|
if logging.is_debug():
|
||||||
|
LOG.exception(msg)
|
||||||
|
else:
|
||||||
|
LOG.warning(msg)
|
@ -16,7 +16,6 @@
|
|||||||
import utils
|
import utils
|
||||||
|
|
||||||
from rally.plugins.openstack import scenario
|
from rally.plugins.openstack import scenario
|
||||||
from rally.task import validation
|
|
||||||
|
|
||||||
|
|
||||||
class Kuryr(utils.KuryrScenario):
|
class Kuryr(utils.KuryrScenario):
|
||||||
@ -25,7 +24,6 @@ class Kuryr(utils.KuryrScenario):
|
|||||||
def __init__(self, context=None, admin_clients=None, clients=None):
|
def __init__(self, context=None, admin_clients=None, clients=None):
|
||||||
super(Kuryr, self).__init__(context, admin_clients, clients)
|
super(Kuryr, self).__init__(context, admin_clients, clients)
|
||||||
|
|
||||||
@validation.required_openstack(users=True)
|
|
||||||
@scenario.configure(context={"cleanup": ["kuryr"]})
|
@scenario.configure(context={"cleanup": ["kuryr"]})
|
||||||
def list_networks(self, network_list_args=None):
|
def list_networks(self, network_list_args=None):
|
||||||
"""List the networks.
|
"""List the networks.
|
||||||
@ -68,3 +66,14 @@ class Kuryr(utils.KuryrScenario):
|
|||||||
network = self._create_network(is_kuryr=False,
|
network = self._create_network(is_kuryr=False,
|
||||||
network_create_args=network_create_args or {})
|
network_create_args=network_create_args or {})
|
||||||
self._delete_network(network)
|
self._delete_network(network)
|
||||||
|
|
||||||
|
@scenario.configure(context={"cleanup": ["kuryr"]})
|
||||||
|
def start_and_stop_containers(self, container_create_args=None):
|
||||||
|
"""Start and stop container on docker network.
|
||||||
|
|
||||||
|
Measure the "docker run" , "docker stop" , "docker rm"
|
||||||
|
command performance.
|
||||||
|
"""
|
||||||
|
container_id = self._start_container(container_create_args or {})
|
||||||
|
self._stop_container(container_id)
|
||||||
|
self._remove_container(container_id)
|
||||||
|
@ -75,3 +75,26 @@ class KuryrScenario(scenario.OpenStackScenario):
|
|||||||
:param network: Network object
|
:param network: Network object
|
||||||
"""
|
"""
|
||||||
self.docker_client.remove_network(network['Id'])
|
self.docker_client.remove_network(network['Id'])
|
||||||
|
|
||||||
|
@atomic.action_timer("kuryr.start_container")
|
||||||
|
def _start_container(self, container_create_args=None):
|
||||||
|
"""Start Container on docker network."""
|
||||||
|
container = self.docker_client.create_container(
|
||||||
|
image='busybox:1',
|
||||||
|
command='/bin/sleep 600')
|
||||||
|
container_id = container.get('Id')
|
||||||
|
self.docker_client.start(container=container_id)
|
||||||
|
net_id = self.context.get("netid")
|
||||||
|
self.docker_client.connect_container_to_network(container_id,
|
||||||
|
net_id)
|
||||||
|
return container_id
|
||||||
|
|
||||||
|
@atomic.action_timer("kuryr.stop_container")
|
||||||
|
def _stop_container(self, container_id):
|
||||||
|
"""Stop Container."""
|
||||||
|
self.docker_client.stop(container=container_id)
|
||||||
|
|
||||||
|
@atomic.action_timer("kuryr.remove_container")
|
||||||
|
def _remove_container(self, container_id):
|
||||||
|
self.docker_client.remove_container(container=container_id,
|
||||||
|
force=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user