Merge "Benchmark to validate a keystone token N times at service endpoint"
This commit is contained in:
20
doc/samples/tasks/authenticate/token_validate_cinder.json
Normal file
20
doc/samples/tasks/authenticate/token_validate_cinder.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"Authenticate.validate_cinder": [
|
||||
{
|
||||
"args": {
|
||||
"repetitions": 2
|
||||
},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 10,
|
||||
"concurrency": 5
|
||||
},
|
||||
"context": {
|
||||
"users": {
|
||||
"tenants": 3,
|
||||
"users_per_tenant": 5
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
13
doc/samples/tasks/authenticate/token_validate_cinder.yaml
Normal file
13
doc/samples/tasks/authenticate/token_validate_cinder.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
Authenticate.validate_cinder:
|
||||
-
|
||||
args:
|
||||
repetitions: 2
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
concurrency: 5
|
||||
context:
|
||||
users:
|
||||
tenants: 3
|
||||
users_per_tenant: 5
|
20
doc/samples/tasks/authenticate/token_validate_glance.json
Normal file
20
doc/samples/tasks/authenticate/token_validate_glance.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"Authenticate.validate_glance": [
|
||||
{
|
||||
"args": {
|
||||
"repetitions": 2
|
||||
},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 10,
|
||||
"concurrency": 5
|
||||
},
|
||||
"context": {
|
||||
"users": {
|
||||
"tenants": 3,
|
||||
"users_per_tenant": 5
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
13
doc/samples/tasks/authenticate/token_validate_glance.yaml
Normal file
13
doc/samples/tasks/authenticate/token_validate_glance.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
Authenticate.validate_glance:
|
||||
-
|
||||
args:
|
||||
repetitions: 2
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
concurrency: 5
|
||||
context:
|
||||
users:
|
||||
tenants: 3
|
||||
users_per_tenant: 5
|
20
doc/samples/tasks/authenticate/token_validate_heat.json
Normal file
20
doc/samples/tasks/authenticate/token_validate_heat.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"Authenticate.validate_heat": [
|
||||
{
|
||||
"args": {
|
||||
"repetitions": 2
|
||||
},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 10,
|
||||
"concurrency": 5
|
||||
},
|
||||
"context": {
|
||||
"users": {
|
||||
"tenants": 3,
|
||||
"users_per_tenant": 5
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
13
doc/samples/tasks/authenticate/token_validate_heat.yaml
Normal file
13
doc/samples/tasks/authenticate/token_validate_heat.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
Authenticate.validate_heat:
|
||||
-
|
||||
args:
|
||||
repetitions: 2
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
concurrency: 5
|
||||
context:
|
||||
users:
|
||||
tenants: 3
|
||||
users_per_tenant: 5
|
20
doc/samples/tasks/authenticate/token_validate_neutron.json
Normal file
20
doc/samples/tasks/authenticate/token_validate_neutron.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"Authenticate.validate_neutron": [
|
||||
{
|
||||
"args": {
|
||||
"repetitions": 2
|
||||
},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 10,
|
||||
"concurrency": 5
|
||||
},
|
||||
"context": {
|
||||
"users": {
|
||||
"tenants": 3,
|
||||
"users_per_tenant": 5
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
13
doc/samples/tasks/authenticate/token_validate_neutron.yaml
Normal file
13
doc/samples/tasks/authenticate/token_validate_neutron.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
Authenticate.validate_neutron:
|
||||
-
|
||||
args:
|
||||
repetitions: 2
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
concurrency: 5
|
||||
context:
|
||||
users:
|
||||
tenants: 3
|
||||
users_per_tenant: 5
|
20
doc/samples/tasks/authenticate/token_validate_nova.json
Normal file
20
doc/samples/tasks/authenticate/token_validate_nova.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"Authenticate.validate_nova": [
|
||||
{
|
||||
"args": {
|
||||
"repetitions": 2
|
||||
},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 10,
|
||||
"concurrency": 5
|
||||
},
|
||||
"context": {
|
||||
"users": {
|
||||
"tenants": 3,
|
||||
"users_per_tenant": 5
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
13
doc/samples/tasks/authenticate/token_validate_nova.yaml
Normal file
13
doc/samples/tasks/authenticate/token_validate_nova.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
Authenticate.validate_nova:
|
||||
-
|
||||
args:
|
||||
repetitions: 2
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
concurrency: 5
|
||||
context:
|
||||
users:
|
||||
tenants: 3
|
||||
users_per_tenant: 5
|
@@ -269,3 +269,55 @@
|
||||
users:
|
||||
tenants: 2
|
||||
users_per_tenant: 3
|
||||
|
||||
Authenticate.validate_cinder:
|
||||
-
|
||||
args:
|
||||
repetitions: 2
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
concurrency: 5
|
||||
context:
|
||||
users:
|
||||
tenants: 3
|
||||
users_per_tenant: 5
|
||||
|
||||
Authenticate.validate_glance:
|
||||
-
|
||||
args:
|
||||
repetitions: 2
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
concurrency: 5
|
||||
context:
|
||||
users:
|
||||
tenants: 3
|
||||
users_per_tenant: 5
|
||||
|
||||
Authenticate.validate_heat:
|
||||
-
|
||||
args:
|
||||
repetitions: 2
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
concurrency: 5
|
||||
context:
|
||||
users:
|
||||
tenants: 3
|
||||
users_per_tenant: 5
|
||||
|
||||
Authenticate.validate_nova:
|
||||
-
|
||||
args:
|
||||
repetitions: 2
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
concurrency: 5
|
||||
context:
|
||||
users:
|
||||
tenants: 3
|
||||
users_per_tenant: 5
|
||||
|
@@ -13,6 +13,8 @@
|
||||
# under the License.
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import utils as scenario_utils
|
||||
from rally.benchmark import validation
|
||||
|
||||
|
||||
class Authenticate(base.Scenario):
|
||||
@@ -22,5 +24,78 @@ class Authenticate(base.Scenario):
|
||||
"""
|
||||
|
||||
@base.scenario()
|
||||
@scenario_utils.atomic_action_timer('authenticate.keystone')
|
||||
def keystone(self, **kwargs):
|
||||
self.clients("keystone")
|
||||
|
||||
@base.scenario()
|
||||
@validation.add(validation.required_parameters(['repetitions']))
|
||||
def validate_glance(self, repetitions):
|
||||
"""Creation of the client does not ensure validation of the token.
|
||||
We have to do some minimal operation to make sure token gets validated.
|
||||
In following we are checking for non-existent image.
|
||||
|
||||
:param repetitions: number of times to validate
|
||||
"""
|
||||
glance_client = self.clients("glance")
|
||||
image_name = "__intentionally_non_existent_image___"
|
||||
for i in range(repetitions):
|
||||
with scenario_utils.AtomicAction(self,
|
||||
'authenticate.validate_glance'):
|
||||
list(glance_client.images.list(name=image_name))
|
||||
|
||||
@base.scenario()
|
||||
@validation.add(validation.required_parameters(['repetitions']))
|
||||
def validate_nova(self, repetitions):
|
||||
"""Creation of the client does not ensure validation of the token.
|
||||
We have to do some minimal operation to make sure token gets validated.
|
||||
|
||||
:param repetitions: number of times to validate
|
||||
"""
|
||||
nova_client = self.clients("nova")
|
||||
for i in range(repetitions):
|
||||
with scenario_utils.AtomicAction(self,
|
||||
'authenticate.validate_nova'):
|
||||
nova_client.flavors.list()
|
||||
|
||||
@base.scenario()
|
||||
@validation.add(validation.required_parameters(['repetitions']))
|
||||
def validate_cinder(self, repetitions):
|
||||
"""Creation of the client does not ensure validation of the token.
|
||||
We have to do some minimal operation to make sure token gets validated.
|
||||
|
||||
:param repetitions: number of times to validate
|
||||
"""
|
||||
cinder_client = self.clients("cinder")
|
||||
for i in range(repetitions):
|
||||
with scenario_utils.AtomicAction(self,
|
||||
'authenticate.validate_cinder'):
|
||||
cinder_client.volume_types.list()
|
||||
|
||||
@base.scenario()
|
||||
@validation.add(validation.required_parameters(['repetitions']))
|
||||
def validate_neutron(self, repetitions):
|
||||
"""Creation of the client does not ensure validation of the token.
|
||||
We have to do some minimal operation to make sure token gets validated.
|
||||
|
||||
:param repetitions: number of times to validate
|
||||
"""
|
||||
neutron_client = self.clients("neutron")
|
||||
for i in range(repetitions):
|
||||
with scenario_utils.AtomicAction(self,
|
||||
'authenticate.validate_neutron'):
|
||||
neutron_client.get_auth_info()
|
||||
|
||||
@base.scenario()
|
||||
@validation.add(validation.required_parameters(['repetitions']))
|
||||
def validate_heat(self, repetitions):
|
||||
"""Creation of the client does not ensure validation of the token.
|
||||
We have to do some minimal operation to make sure token gets validated.
|
||||
|
||||
:param repetitions: number of times to validate
|
||||
"""
|
||||
heat_client = self.clients("heat")
|
||||
for i in range(repetitions):
|
||||
with scenario_utils.AtomicAction(self,
|
||||
'authenticate.validate_heat'):
|
||||
list(heat_client.stacks.list(limit=0))
|
||||
|
114
tests/benchmark/scenarios/test_authenticate.py
Normal file
114
tests/benchmark/scenarios/test_authenticate.py
Normal file
@@ -0,0 +1,114 @@
|
||||
# Copyright (C) 2014 Yahoo! Inc. All Rights Reserved.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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 mock
|
||||
|
||||
from rally.benchmark.scenarios.authenticate import authenticate
|
||||
from rally.benchmark.scenarios import utils
|
||||
from tests import fakes
|
||||
from tests import test
|
||||
|
||||
|
||||
class AuthenticateTestCase(test.TestCase):
|
||||
|
||||
@mock.patch("rally.osclients")
|
||||
def test_keystone(self, mock_osclients):
|
||||
fc = fakes.FakeClients()
|
||||
mock_osclients.Clients.return_value = fc
|
||||
|
||||
scenario = authenticate.Authenticate(admin_clients=mock_osclients,
|
||||
clients=mock_osclients)
|
||||
|
||||
scenario.keystone()
|
||||
self.assertEqual(scenario._clients.keystone.call_count, 1)
|
||||
|
||||
@mock.patch("rally.osclients")
|
||||
@mock.patch("rally.osclients")
|
||||
def test_validate_glance(self, mock_admin_clients, mock_users_clients):
|
||||
images_list = [mock.Mock(), mock.Mock()]
|
||||
fc = fakes.FakeClients()
|
||||
mock_admin_clients.Clients.return_value = fc
|
||||
mock_users_clients.Clients.return_value = fc
|
||||
scenario = authenticate.Authenticate(admin_clients=mock_admin_clients,
|
||||
clients=mock_users_clients)
|
||||
scenario._clients.glance.images.list = mock.MagicMock(
|
||||
return_value=images_list)
|
||||
image_name = "__intentionally_non_existent_image___"
|
||||
with utils.AtomicAction(scenario, "authenticate.validate_glance"):
|
||||
scenario.validate_glance(5)
|
||||
scenario._clients.glance().images.list.assert_called_with(name=
|
||||
image_name)
|
||||
self.assertEqual(scenario._clients.glance().images.list.call_count, 5)
|
||||
|
||||
@mock.patch("rally.osclients")
|
||||
@mock.patch("rally.osclients")
|
||||
def test_validate_nova(self, mock_admin_clients, mock_users_clients):
|
||||
flavors_list = [mock.Mock(), mock.Mock()]
|
||||
fc = fakes.FakeClients()
|
||||
mock_admin_clients.clients.return_value = fc
|
||||
mock_users_clients.clients.return_value = fc
|
||||
scenario = authenticate.Authenticate(admin_clients=mock_admin_clients,
|
||||
clients=mock_users_clients)
|
||||
scenario._clients.nova.flavors.list = mock.MagicMock(
|
||||
return_value=flavors_list)
|
||||
with utils.AtomicAction(scenario, "authenticate.validate_nova"):
|
||||
scenario.validate_nova(5)
|
||||
self.assertEqual(scenario._clients.nova().flavors.list.call_count, 5)
|
||||
|
||||
@mock.patch("rally.osclients")
|
||||
@mock.patch("rally.osclients")
|
||||
def test_validate_cinder(self, mock_admin_clients, mock_users_clients):
|
||||
volume_types_list = [mock.Mock(), mock.Mock()]
|
||||
fc = fakes.FakeClients()
|
||||
mock_admin_clients.clients.return_value = fc
|
||||
mock_users_clients.clients.return_value = fc
|
||||
scenario = authenticate.Authenticate(admin_clients=mock_admin_clients,
|
||||
clients=mock_users_clients)
|
||||
scenario._clients.cinder.volume_types.list = mock.MagicMock(
|
||||
return_value=volume_types_list)
|
||||
with utils.AtomicAction(scenario, "authenticate.validate_cinder"):
|
||||
scenario.validate_cinder(5)
|
||||
self.assertEqual(scenario._clients.cinder().volume_types.
|
||||
list.call_count, 5)
|
||||
|
||||
@mock.patch("rally.osclients")
|
||||
@mock.patch("rally.osclients")
|
||||
def test_validate_neutron(self, mock_admin_clients, mock_users_clients):
|
||||
fc = fakes.FakeClients()
|
||||
mock_admin_clients.clients.return_value = fc
|
||||
mock_users_clients.clients.return_value = fc
|
||||
scenario = authenticate.Authenticate(admin_clients=mock_admin_clients,
|
||||
clients=mock_users_clients)
|
||||
scenario._clients.neutron.get_auth_info = mock.MagicMock()
|
||||
with utils.AtomicAction(scenario, "authenticate.validate_neutron"):
|
||||
scenario.validate_neutron(5)
|
||||
self.assertEqual(scenario._clients.neutron().get_auth_info.call_count,
|
||||
5)
|
||||
|
||||
@mock.patch("rally.osclients")
|
||||
@mock.patch("rally.osclients")
|
||||
def test_validate_heat(self, mock_admin_clients, mock_users_clients):
|
||||
stacks_list = [mock.Mock(), mock.Mock()]
|
||||
fc = fakes.FakeClients()
|
||||
mock_admin_clients.clients.return_value = fc
|
||||
mock_users_clients.clients.return_value = fc
|
||||
scenario = authenticate.Authenticate(admin_clients=mock_admin_clients,
|
||||
clients=mock_users_clients)
|
||||
scenario._clients.heat.stacks.list = mock.MagicMock(
|
||||
return_value=stacks_list)
|
||||
with utils.AtomicAction(scenario, "authenticate.validate_heat"):
|
||||
scenario.validate_heat(5)
|
||||
scenario._clients.heat().stacks.list.assert_called_with(limit=0)
|
||||
self.assertEqual(scenario._clients.heat().stacks.list.call_count, 5)
|
Reference in New Issue
Block a user