[Swift] Add additional Swift scenarios

This patch adds additional swift scenarios to use what was created
during swift context.

Swift Scenarios:
- list_and_download_objects_in_containers
- list_objects_in_containers

Blueprint benchmark-scenarios-for-swift

Change-Id: I6d615889a1acfcd4686eb061f1041f5b22fd09f0
This commit is contained in:
John Wu 2015-05-26 17:21:17 -07:00
parent 166261c4d2
commit 48a4866e14
7 changed files with 230 additions and 1 deletions

View File

@ -948,7 +948,6 @@
failure_rate:
max: 0
SwiftObjects.create_container_and_object_then_list_objects:
-
args:
@ -1037,3 +1036,43 @@
sla:
failure_rate:
max: 0
SwiftObjects.list_and_download_objects_in_containers:
-
runner:
type: "constant"
times: 2
concurrency: 2
context:
users:
tenants: 1
users_per_tenant: 1
roles:
- "admin"
swift_objects:
containers_per_tenant: 1
objects_per_container: 5
object_size: 10240
sla:
failure_rate:
max: 0
SwiftObjects.list_objects_in_containers:
-
runner:
type: "constant"
times: 6
concurrency: 3
context:
users:
tenants: 1
users_per_tenant: 1
roles:
- "admin"
swift_objects:
containers_per_tenant: 1
objects_per_container: 10
object_size: 1024
sla:
failure_rate:
max: 0

View File

@ -123,3 +123,50 @@ class SwiftObjects(utils.SwiftScenario):
for object_name in objects_list:
self._download_object(container_name, object_name,
atomic_action=False)
@validation.required_services(consts.Service.SWIFT)
@validation.required_openstack(users=True)
@scenario.configure(context={"swift_objects": {}})
def list_objects_in_containers(self):
"""List objects in all containers."""
containers = self._list_containers()[1]
key_suffix = "container"
if len(containers) > 1:
key_suffix = "%i_containers" % len(containers)
with atomic.ActionTimer(self, "swift.list_objects_in_%s" % key_suffix):
for container in containers:
self._list_objects(container["name"], atomic_action=False)
@validation.required_services(consts.Service.SWIFT)
@validation.required_openstack(users=True)
@scenario.configure(context={"swift_objects": {}})
def list_and_download_objects_in_containers(self):
"""List and download objects in all containers."""
containers = self._list_containers()[1]
list_key_suffix = "container"
if len(containers) > 1:
list_key_suffix = "%i_containers" % len(containers)
objects_dict = {}
with atomic.ActionTimer(self,
"swift.list_objects_in_%s" % list_key_suffix):
for container in containers:
container_name = container["name"]
objects_dict[container_name] = self._list_objects(
container_name,
atomic_action=False)[1]
objects_total = sum(map(len, objects_dict.values()))
download_key_suffix = "object"
if objects_total > 1:
download_key_suffix = "%i_objects" % objects_total
with atomic.ActionTimer(self,
"swift.download_%s" % download_key_suffix):
for container_name, objects in objects_dict.items():
for obj in objects:
self._download_object(container_name, obj["name"],
atomic_action=False)

View File

@ -0,0 +1,25 @@
{
"SwiftObjects.list_and_download_objects_in_containers": [
{
"runner": {
"type": "constant",
"times": 2,
"concurrency": 2
},
"context": {
"users": {
"tenants": 1,
"users_per_tenant": 1
},
"roles": [
"admin"
],
"swift_objects": {
"containers_per_tenant": 2,
"objects_per_container": 5,
"object_size": 10240
}
}
}
]
}

View File

@ -0,0 +1,17 @@
---
SwiftObjects.list_and_download_objects_in_containers:
-
runner:
type: "constant"
times: 2
concurrency: 2
context:
users:
tenants: 1
users_per_tenant: 1
roles:
- "admin"
swift_objects:
containers_per_tenant: 2
objects_per_container: 5
object_size: 10240

View File

@ -0,0 +1,25 @@
{
"SwiftObjects.list_objects_in_containers": [
{
"runner": {
"type": "constant",
"times": 6,
"concurrency": 3
},
"context": {
"users": {
"tenants": 1,
"users_per_tenant": 1
},
"roles": [
"admin"
],
"swift_objects": {
"containers_per_tenant": 1,
"objects_per_container": 10,
"object_size": 1024
}
}
}
]
}

View File

@ -0,0 +1,17 @@
---
SwiftObjects.list_objects_in_containers:
-
runner:
type: "constant"
times: 6
concurrency: 3
context:
users:
tenants: 1
users_per_tenant: 1
roles:
- "admin"
swift_objects:
containers_per_tenant: 1
objects_per_container: 10
object_size: 1024

View File

@ -13,12 +13,14 @@
# License for the specific language governing permissions and limitations
# under the License.
import ddt
import mock
from rally.plugins.openstack.scenarios.swift import objects
from tests.unit import test
@ddt.ddt
class SwiftObjectsTestCase(test.ScenarioTestCase):
def test_create_container_and_object_then_list_objects(self):
@ -84,6 +86,63 @@ class SwiftObjectsTestCase(test.ScenarioTestCase):
self._test_atomic_action_timer(scenario.atomic_actions(),
"swift.download_2_objects")
@ddt.data(1, 5)
def test_list_objects_in_containers(self, num_cons):
con_list = [{"name": "cooon_%s" % i} for i in range(num_cons)]
scenario = objects.SwiftObjects()
scenario._list_containers = mock.MagicMock(return_value=("header",
con_list))
scenario._list_objects = mock.MagicMock()
scenario.list_objects_in_containers()
scenario._list_containers.assert_called_once_with()
con_calls = [mock.call(container["name"], atomic_action=False)
for container in con_list]
scenario._list_objects.assert_has_calls(con_calls)
key_suffix = "container"
if num_cons > 1:
key_suffix = "%i_containers" % num_cons
self._test_atomic_action_timer(scenario.atomic_actions(),
"swift.list_objects_in_%s" % key_suffix)
@ddt.data([1, 1], [1, 2], [2, 1], [3, 5])
@ddt.unpack
def test_list_and_download_objects_in_containers(self, num_cons, num_objs):
con_list = [{"name": "connn_%s" % i} for i in range(num_cons)]
obj_list = [{"name": "ooobj_%s" % i} for i in range(num_objs)]
scenario = objects.SwiftObjects()
scenario._list_containers = mock.MagicMock(return_value=("header",
con_list))
scenario._list_objects = mock.MagicMock(return_value=("header",
obj_list))
scenario._download_object = mock.MagicMock()
scenario.list_and_download_objects_in_containers()
scenario._list_containers.assert_called_once_with()
con_calls = [mock.call(container["name"], atomic_action=False)
for container in con_list]
scenario._list_objects.assert_has_calls(con_calls)
obj_calls = []
for container in con_list:
for obj in obj_list:
obj_calls.append(mock.call(container["name"], obj["name"],
atomic_action=False))
scenario._download_object.assert_has_calls(obj_calls, any_order=True)
list_key_suffix = "container"
if num_cons > 1:
list_key_suffix = "%i_containers" % num_cons
self._test_atomic_action_timer(
scenario.atomic_actions(),
"swift.list_objects_in_%s" % list_key_suffix)
download_key_suffix = "object"
if num_cons * num_objs > 1:
download_key_suffix = "%i_objects" % (num_cons * num_objs)
self._test_atomic_action_timer(
scenario.atomic_actions(),
"swift.download_%s" % download_key_suffix)
def test_functional_create_container_and_object_then_list_objects(self):
names_list = ["AA", "BB", "CC", "DD"]