Merge "Fixed terminate_unneeded_clusters fail in distributed mode"

This commit is contained in:
Jenkins 2014-09-16 15:22:26 +00:00 committed by Gerrit Code Review
commit 1baaa600e1
5 changed files with 16 additions and 9 deletions

View File

@ -41,6 +41,7 @@ if os.path.exists(os.path.join(possible_topdir,
i18n.enable_lazy()
from sahara.api import acl
import sahara.main as server
from sahara.service import ops
@ -48,6 +49,12 @@ from sahara.service import ops
def main():
server.setup_common(possible_topdir, 'engine')
from oslo.config import cfg
# NOTE(apavlov): acl.wrap is called here to set up auth_uri value
# in context by using keystone functionality (mostly to avoid
# code duplication).
acl.wrap(None, cfg.CONF)
server.setup_sahara_engine()
ops_server = ops.OpsServer()

View File

@ -61,7 +61,7 @@ class LocalOps(object):
def terminate_cluster(self, cluster_id):
context.spawn("cluster-terminating-%s" % cluster_id,
_terminate_cluster, cluster_id)
terminate_cluster, cluster_id)
def run_edp_job(self, job_execution_id):
context.spawn("Starting Job Execution %s" % job_execution_id,
@ -100,7 +100,7 @@ class OpsServer(rpc_utils.RPCServer):
_provision_scaled_cluster(cluster_id, node_group_id_map)
def terminate_cluster(self, cluster_id):
_terminate_cluster(cluster_id)
terminate_cluster(cluster_id)
def run_edp_job(self, job_execution_id):
_run_edp_job(job_execution_id)
@ -246,7 +246,7 @@ def _provision_scaled_cluster(cluster_id, node_group_id_map):
@ops_error_handler
def _terminate_cluster(cluster_id):
def terminate_cluster(cluster_id):
ctx = context.ctx()
cluster = conductor.cluster_get(ctx, cluster_id)
plugin = plugin_base.PLUGINS.get_plugin(cluster.plugin_name)

View File

@ -25,8 +25,8 @@ from sahara.i18n import _LI
from sahara.openstack.common import log
from sahara.openstack.common import periodic_task
from sahara.openstack.common import threadgroup
from sahara.service import api
from sahara.service.edp import job_manager
from sahara.service import ops
from sahara.service import trusts
from sahara.utils import edp
from sahara.utils import proxy as p
@ -110,7 +110,7 @@ def _make_periodic_tasks():
{'cluster': cluster.name, 'id': cluster.id})
try:
api.terminate_cluster(cluster.id)
ops.terminate_cluster(cluster.id)
except Exception as e:
LOG.info(_LI('Failed to terminate transient cluster '
'%(cluster)s with id %(id)s: %(error)s.'),

View File

@ -113,7 +113,7 @@ class TestOPS(base.SaharaTestCase):
base_plugins.PLUGINS.get_plugin.return_value = FakePlugin()
ops.INFRA = FakeINFRA()
ops.conductor = FakePlugin()
ops._terminate_cluster('123')
ops.terminate_cluster('123')
# checking that order of calls is right
self.assertEqual(['on_terminate_cluster', 'shutdown_cluster',
'cluster_destroy'], self.SEQUENCE,

View File

@ -52,7 +52,7 @@ class TestPeriodicBack(base.SaharaWithDbTestCase):
mock.call(u'3')])
@mock.patch('oslo.utils.timeutils.utcnow')
@mock.patch('sahara.service.api.terminate_cluster')
@mock.patch('sahara.service.ops.terminate_cluster')
def test_cluster_terminate(self, terminate_cluster, utcnow):
utcnow.return_value = datetime.datetime(2005, 2, 1, 0, 0)
@ -84,7 +84,7 @@ class TestPeriodicBack(base.SaharaWithDbTestCase):
terminate_cluster.assert_has_calls([mock.call(u'1')])
@mock.patch('oslo.utils.timeutils.utcnow')
@mock.patch('sahara.service.api.terminate_cluster')
@mock.patch('sahara.service.ops.terminate_cluster')
def test_cluster_not_killed_too_early(self, terminate_cluster, utcnow):
utcnow.return_value = datetime.datetime(2005, 2, 1, second=0)
@ -97,7 +97,7 @@ class TestPeriodicBack(base.SaharaWithDbTestCase):
self.assertEqual(terminate_cluster.call_count, 0)
@mock.patch('oslo.utils.timeutils.utcnow')
@mock.patch('sahara.service.api.terminate_cluster')
@mock.patch('sahara.service.ops.terminate_cluster')
def test_cluster_killed_in_time(self, terminate_cluster, utcnow):
utcnow.return_value = datetime.datetime(2005, 2, 1, second=0)