credentials is not updated after deployment is recreated

We should update the engine's deployment after deployment is
updated.
Closes-Bug: #1675271

Change-Id: I9c3b07c1de3bd61121757c8c6075777f001310cb
(cherry picked from commit e73e6319ef)
This commit is contained in:
chenhb-zte 2017-04-05 17:44:05 +08:00 committed by chenhb
parent 2a96954089
commit 87410a1307
7 changed files with 20 additions and 4 deletions

5
rally/deployment/engine.py Executable file → Normal file
View File

@ -71,7 +71,10 @@ class Engine(plugin.Plugin):
"""
def __init__(self, deployment):
self.deployment = deployment
self.config = deployment["config"]
@property
def config(self):
return self.deployment["config"]
def validate(self, config=None):
# TODO(sskripnick): remove this checking when config schema

View File

@ -64,7 +64,6 @@ class MultihostEngine(engine.Engine):
def __init__(self, *args, **kwargs):
super(MultihostEngine, self).__init__(*args, **kwargs)
self.config = self.deployment["config"]
self.nodes = []
def _deploy_node(self, config):

View File

@ -94,6 +94,7 @@ class DeploymentTestCase(unittest.TestCase):
self.assertIn("t_create_env", self.rally("deployment list"))
self.assertEqual(config,
json.loads(self.rally("deployment config")))
self.assertIn("http://foo/", self.rally("deployment show"))
def test_use(self):
self.rally.env.update(utils.TEST_ENV)

View File

@ -102,8 +102,9 @@ class DevstackEngineTestCase(test.TestCase):
info="fake_credentials",
provider_name="DevstackEngine",
type="credentials")
repo = "https://git.openstack.org/openstack-dev/devstack"
cmd = "/bin/sh -e -s %s master" % repo
cmd = "/bin/sh -e -s %s %s" % (
mock_deployment["config"].get("devstack_repo"),
mock_deployment["config"].get("devstack_branch"))
server.ssh.run.assert_called_once_with(cmd, stdin="fake_script")
ds_calls = [
mock.call.ssh.run("cat > ~/devstack/local.conf", stdin=mock.ANY),

View File

@ -96,6 +96,11 @@ class EngineTestCase(test.TestCase):
self.assertEqual(consts.DeployStatus.DEPLOY_FAILED,
deployment["status"])
def test_config(self):
deployment = make_fake_deployment()
engine = FakeEngine(deployment)
self.assertEqual(deployment["config"], engine.config)
@mock.patch.object(FakeDeployment, "set_completed")
@mock.patch.object(FakeDeployment, "set_started")
def test_make_deploy(self, mock_fake_deployment_set_started,

View File

@ -51,6 +51,9 @@ class LxcEngineTestCase(test.TestCase):
self.engine = engine.Engine.get_engine("LxcEngine",
self.deployment)
def test_config(self):
self.assertEqual(self.deployment["config"], self.engine.config)
@mock.patch(MOD + "objects")
@mock.patch(MOD + "engine")
def test__deploy_first(self, mock_engine, mock_objects):
@ -142,6 +145,7 @@ class LxcEngineTestCase(test.TestCase):
fake_deployment = mock.MagicMock()
fake_deployment.add_resource = add_resource
fake_deployment.__getitem__.side_effect = self.deployment.__getitem__
with mock.patch.object(self.engine, "deployment", fake_deployment):
credentials = self.engine.deploy()

View File

@ -52,6 +52,9 @@ class MultihostEngineTestCase(test.TestCase):
self.engine = engine.Engine.get_engine("MultihostEngine",
self.deployment)
def test_config(self):
self.assertEqual(self.deployment["config"], self.engine.config)
@mock.patch(MOD + "objects.Deployment")
@mock.patch(MOD + "engine.Engine")
def test__deploy_node(self, mock_engine, mock_deployment):