Merge "orchestrator refactor"

This commit is contained in:
Jenkins 2014-12-16 02:18:58 +00:00 committed by Gerrit Code Review
commit 7f4ca8212f
11 changed files with 34 additions and 34 deletions

View File

@ -24,6 +24,7 @@ import sys
import jsonschema
import yaml
from rally import api
from rally.cmd import cliutils
from rally.cmd.commands import use
from rally.cmd import envutils
@ -32,7 +33,6 @@ from rally import exceptions
from rally.i18n import _
from rally.objects import endpoint
from rally.openstack.common import cliutils as common_cliutils
from rally.orchestrator import api
from rally import osclients
from rally import utils

View File

@ -23,6 +23,7 @@ import webbrowser
import yaml
from rally import api
from rally.benchmark.processing import plot
from rally.benchmark.processing import utils
from rally.cmd import cliutils
@ -35,7 +36,6 @@ from rally.i18n import _
from rally import log as logging
from rally import objects
from rally.openstack.common import cliutils as common_cliutils
from rally.orchestrator import api
from rally import utils as rutils

View File

@ -21,6 +21,7 @@ import os
import six
from rally import api
from rally.cmd import cliutils
from rally.cmd.commands import use
from rally.cmd import envutils
@ -30,7 +31,6 @@ from rally import exceptions
from rally.i18n import _
from rally import objects
from rally.openstack.common import cliutils as common_cliutils
from rally.orchestrator import api
from rally.verification.verifiers.tempest import diff
from rally.verification.verifiers.tempest import json2html

View File

@ -15,11 +15,11 @@
import urlparse
import rally
from rally import consts
from rally import db
from rally.deploy import engine
from rally import objects
from rally import orchestrator
class MultihostEngine(engine.EngineFactory):
@ -95,4 +95,4 @@ class MultihostEngine(engine.EngineFactory):
def cleanup(self):
subdeploys = db.deployment_list(parent_uuid=self.deployment['uuid'])
for subdeploy in subdeploys:
orchestrator.api.destroy_deploy(subdeploy['uuid'])
rally.api.destroy_deploy(subdeploy['uuid'])

View File

@ -28,7 +28,7 @@ class TaskCommandsTestCase(test.TestCase):
self.task = task.TaskCommands()
@mock.patch('rally.cmd.commands.task.TaskCommands.detailed')
@mock.patch('rally.orchestrator.api.create_task')
@mock.patch('rally.api.create_task')
@mock.patch('rally.cmd.commands.task.api.start_task')
@mock.patch('rally.cmd.commands.task.open',
mock.mock_open(read_data='{"some": "json"}'),
@ -51,7 +51,7 @@ class TaskCommandsTestCase(test.TestCase):
self.task.start, 'path_to_config.json', None)
@mock.patch('rally.cmd.commands.task.TaskCommands.detailed')
@mock.patch('rally.orchestrator.api.create_task')
@mock.patch('rally.api.create_task')
@mock.patch('rally.cmd.commands.task.api')
@mock.patch('rally.cmd.commands.task.open',
mock.mock_open(read_data='{"some": "json"}'),
@ -278,7 +278,7 @@ class TaskCommandsTestCase(test.TestCase):
@mock.patch("rally.cmd.commands.task.open",
mock.mock_open(read_data='{"some": "json"}'),
create=True)
@mock.patch("rally.orchestrator.api.task_validate")
@mock.patch("rally.api.task_validate")
def test_verify(self, mock_validate):
self.task.validate("path_to_config.json", "fake_id")
mock_validate.assert_called_once_with("fake_id", {"some": "json"})

View File

@ -45,7 +45,7 @@ class VerifyCommandsTestCase(test.TestCase):
self.flavor2.ram = 64
@mock.patch("rally.osclients.Clients")
@mock.patch("rally.orchestrator.api.verify")
@mock.patch("rally.api.verify")
def test_start(self, mock_verify, mock_clients):
deployment_id = "0fba91c6-82d5-4ce1-bd00-5d7c989552d9"
mock_clients().glance().images.list.return_value = [
@ -62,7 +62,7 @@ class VerifyCommandsTestCase(test.TestCase):
None)
@mock.patch("rally.osclients.Clients")
@mock.patch("rally.orchestrator.api.verify")
@mock.patch("rally.api.verify")
def test_start_with_user_specified_tempest_config(self, mock_verify,
mock_clients):
deployment_id = "0fba91c6-82d5-4ce1-bd00-5d7c989552d9"
@ -81,7 +81,7 @@ class VerifyCommandsTestCase(test.TestCase):
tempest_config.name)
tempest_config.close()
@mock.patch("rally.orchestrator.api.verify")
@mock.patch("rally.api.verify")
def test_start_with_wrong_set_name(self, mock_verify):
deployment_id = "f2009aae-6ef3-468e-96b2-3c987d584010"

View File

@ -101,14 +101,14 @@ class TestMultihostEngine(test.TestCase):
self.deployment.update_status.assert_called_once_with(
consts._DeployStatus.DEPLOY_SUBDEPLOY)
@mock.patch(MOD + 'orchestrator')
@mock.patch('rally.api')
@mock.patch(MOD + 'db')
def test_cleanup(self, m_db, m_orc):
def test_cleanup(self, m_db, m_api):
m_db.deployment_list.return_value = [{'uuid': 'uuid1'},
{'uuid': 'uuid2'}]
self.engine.cleanup()
api_calls = [
mock.call.api.destroy_deploy('uuid1'),
mock.call.api.destroy_deploy('uuid2'),
mock.call.destroy_deploy('uuid1'),
mock.call.destroy_deploy('uuid2'),
]
self.assertEqual(api_calls, m_orc.mock_calls)
self.assertEqual(api_calls, m_api.mock_calls)

View File

@ -13,15 +13,15 @@
# License for the specific language governing permissions and limitations
# under the License.
""" Test for orchestrator. """
""" Test for api. """
import jsonschema
import mock
from rally import api
from rally import consts
from rally import exceptions
from rally.orchestrator import api
from tests.unit import fakes
from tests.unit import test
@ -69,12 +69,12 @@ class APITestCase(test.TestCase):
}
self.tempest = mock.Mock()
@mock.patch("rally.orchestrator.api.objects.Task")
@mock.patch("rally.orchestrator.api.objects.Deployment.get",
@mock.patch("rally.api.objects.Task")
@mock.patch("rally.api.objects.Deployment.get",
return_value=fakes.FakeDeployment(uuid="deploy_uuid",
admin=mock.MagicMock(),
users=[]))
@mock.patch("rally.orchestrator.api.engine.BenchmarkEngine")
@mock.patch("rally.api.engine.BenchmarkEngine")
def test_task_validate(self, mock_engine, mock_deployment_get, mock_task):
api.task_validate(mock_deployment_get.return_value["uuid"], "config")
@ -99,12 +99,12 @@ class APITestCase(test.TestCase):
mock_task.assert_called_once_with(
deployment_uuid=mock_d_get.return_value["uuid"], tag=tag)
@mock.patch("rally.orchestrator.api.objects.Task")
@mock.patch("rally.orchestrator.api.objects.Deployment.get",
@mock.patch("rally.api.objects.Task")
@mock.patch("rally.api.objects.Deployment.get",
return_value=fakes.FakeDeployment(uuid="deploy_uuid",
admin=mock.MagicMock(),
users=[]))
@mock.patch("rally.orchestrator.api.engine.BenchmarkEngine")
@mock.patch("rally.api.engine.BenchmarkEngine")
def test_start_task(self, mock_engine, mock_deployment_get, mock_task):
api.start_task(mock_deployment_get.return_value["uuid"], "config")
@ -122,9 +122,9 @@ class APITestCase(test.TestCase):
mock_deployment_get.assert_called_once_with(
mock_deployment_get.return_value["uuid"])
@mock.patch("rally.orchestrator.api.objects.Task")
@mock.patch("rally.orchestrator.api.objects.Deployment.get")
@mock.patch("rally.orchestrator.api.engine.BenchmarkEngine")
@mock.patch("rally.api.objects.Task")
@mock.patch("rally.api.objects.Deployment.get")
@mock.patch("rally.api.engine.BenchmarkEngine")
def test_start_task_invalid_task_ignored(self, mock_engine,
mock_deployment_get, mock_task):
@ -134,9 +134,9 @@ class APITestCase(test.TestCase):
# check that it doesn't raise anything
api.start_task("deploy_uuid", "config")
@mock.patch("rally.orchestrator.api.objects.Task")
@mock.patch("rally.orchestrator.api.objects.Deployment.get")
@mock.patch("rally.orchestrator.api.engine.BenchmarkEngine")
@mock.patch("rally.api.objects.Task")
@mock.patch("rally.api.objects.Deployment.get")
@mock.patch("rally.api.engine.BenchmarkEngine")
def test_start_task_exception(self, mock_engine, mock_deployment_get,
mock_task):
@ -191,7 +191,7 @@ class APITestCase(test.TestCase):
self.deploy_uuid,
{'status': consts.DeployStatus.DEPLOY_FAILED})
@mock.patch("rally.orchestrator.api.LOG")
@mock.patch("rally.api.LOG")
@mock.patch("rally.objects.deploy.db.deployment_create",
side_effect=exceptions.DeploymentNameExists(
deployment='fake_deploy'))
@ -223,7 +223,7 @@ class APITestCase(test.TestCase):
])
@mock.patch("rally.objects.Deployment.get")
@mock.patch("rally.orchestrator.api.objects.Verification")
@mock.patch("rally.api.objects.Verification")
@mock.patch("rally.verification.verifiers.tempest.tempest.Tempest")
def test_verify(self, mock_tempest, mock_verification, mock_d_get):
mock_d_get.return_value = {"uuid": self.deploy_uuid}
@ -236,8 +236,8 @@ class APITestCase(test.TestCase):
self.tempest.verify.assert_called_once_with(set_name="smoke",
regex=None)
@mock.patch("rally.orchestrator.api.objects.Deployment.get")
@mock.patch("rally.orchestrator.api.objects.Verification")
@mock.patch("rally.api.objects.Deployment.get")
@mock.patch("rally.api.objects.Verification")
@mock.patch("rally.verification.verifiers.tempest.tempest.Tempest")
def test_verify_tempest_not_installed(self, mock_tempest,
mock_verification, mock_d_get):