diff options
-rwxr-xr-x | devstack/upgrade/resources.sh | 30 | ||||
-rw-r--r-- | heat/engine/resources/openstack/nova/server.py | 12 | ||||
-rw-r--r-- | heat/tests/test_engine_service.py | 50 | ||||
-rw-r--r-- | releasenotes/notes/honor-hidden-parameter-in-stack-env-show-cmd-062065545dfef82a.yaml | 4 | ||||
-rw-r--r-- | roles/run-heat-tests/defaults/main.yaml | 1 | ||||
-rw-r--r-- | roles/run-heat-tests/tasks/main.yaml | 8 |
6 files changed, 101 insertions, 4 deletions
diff --git a/devstack/upgrade/resources.sh b/devstack/upgrade/resources.sh index 20ae4589d..277e37dcf 100755 --- a/devstack/upgrade/resources.sh +++ b/devstack/upgrade/resources.sh @@ -64,8 +64,34 @@ function _run_heat_integrationtests { # Run set of specified functional tests UPGRADE_TESTS=upgrade_tests.list _write_heat_integrationtests $UPGRADE_TESTS - export UPPER_CONSTRAINTS_FILE=$DEST/requirements/upper-constraints.txt - export TOX_CONSTRAINTS_FILE=$UPPER_CONSTRAINTS_FILE + # NOTE(gmann): heat script does not know about + # TEMPEST_VENV_UPPER_CONSTRAINTS, only DevStack does. + # This sources that one variable from it. + TEMPEST_VENV_UPPER_CONSTRAINTS=$(set +o xtrace && + source $devstack_dir/stackrc && + echo $TEMPEST_VENV_UPPER_CONSTRAINTS) + # NOTE(gmann): If gate explicitly set the non master + # constraints to use for Tempest venv then use the same + # while running the tests too otherwise, it will recreate + # the Tempest venv due to constraints mismatch. + # recreation of Tempest venv can flush the initially installed + # tempest plugins and their deps. + if [[ "$TEMPEST_VENV_UPPER_CONSTRAINTS" != "master" ]]; then + echo "Using $TEMPEST_VENV_UPPER_CONSTRAINTS constraints in Tempest virtual env." + # NOTE: setting both tox env var and once Tempest start using new var + # TOX_CONSTRAINTS_FILE then we can remove the old one. + export UPPER_CONSTRAINTS_FILE=$TEMPEST_VENV_UPPER_CONSTRAINTS + export TOX_CONSTRAINTS_FILE=$TEMPEST_VENV_UPPER_CONSTRAINTS + else + # NOTE(gmann): we need to set the below env var pointing to master + # constraints even that is what default in tox.ini. Otherwise it + # can create the issue for grenade run where old and new devstack + # can have different tempest (old and master) to install. For + # detail problem, refer to the + # https://bugs.launchpad.net/devstack/+bug/2003993 + export UPPER_CONSTRAINTS_FILE=https://releases.openstack.org/constraints/upper/master + export TOX_CONSTRAINTS_FILE=https://releases.openstack.org/constraints/upper/master + fi export HEAT_TEMPEST_PLUGIN=$DEST/heat-tempest-plugin sudo git config --system --add safe.directory $HEAT_TEMPEST_PLUGIN tox -evenv-tempest -- pip install -c$UPPER_CONSTRAINTS_FILE $HEAT_TEMPEST_PLUGIN diff --git a/heat/engine/resources/openstack/nova/server.py b/heat/engine/resources/openstack/nova/server.py index 6cb782a4a..700527dee 100644 --- a/heat/engine/resources/openstack/nova/server.py +++ b/heat/engine/resources/openstack/nova/server.py @@ -944,9 +944,19 @@ class Server(server_base.BaseServer, sh.SchedulerHintsMixin, def parse_live_resource_data(self, resource_properties, resource_data): server, server_data = resource_data + flavor = server_data.get(self.FLAVOR) + # NOTE(pas-ha) since compute API 2.47 flavor in instance + # does not have "id" but "original_name" instead, + # check for both here, and fail if none of them are in flavor. + if "id" in flavor: + flavor_value = flavor["id"] + elif "original_name" in flavor: + flavor_value = flavor["original_name"] + else: + raise KeyError("Flavor does not contain id or original_name") result = { # there's a risk that flavor id will be int type, so cast to str - self.FLAVOR: str(server_data.get(self.FLAVOR)['id']), + self.FLAVOR: str(flavor_value), self.IMAGE: str(server_data.get(self.IMAGE)['id']), self.NAME: server_data.get(self.NAME), self.METADATA: server_data.get(self.METADATA), diff --git a/heat/tests/test_engine_service.py b/heat/tests/test_engine_service.py index 9ce13e308..3e505e39a 100644 --- a/heat/tests/test_engine_service.py +++ b/heat/tests/test_engine_service.py @@ -991,6 +991,56 @@ class StackServiceTest(common.HeatTestCase): # Verify self.assertEqual(env, found) + def test_get_environment_hidden_param(self): + # Setup + env = { + 'parameters': { + 'admin': 'testuser', + 'pass': 'pa55w0rd' + }, + 'parameter_defaults': { + 'secret': 'dummy' + }, + 'resource_registry': { + 'res': 'resource.yaml' + } + } + t = { + 'heat_template_version': '2018-08-31', + 'parameters': { + 'admin': {'type': 'string'}, + 'pass': {'type': 'string', 'hidden': True} + }, + 'resources': { + 'res1': {'type': 'res'} + } + } + files = { + 'resource.yaml': ''' + heat_template_version: 2018-08-31 + parameters: + secret: + type: string + hidden: true + ''' + } + tmpl = templatem.Template(t, files=files) + stack = parser.Stack(self.ctx, 'get_env_stack', tmpl) + stack.store() + + mock_get_stack = self.patchobject(self.eng, '_get_stack') + mock_get_stack.return_value = mock.MagicMock() + mock_get_stack.return_value.raw_template.environment = env + self.patchobject(templatem.Template, 'load', return_value=tmpl) + + # Test + found = self.eng.get_environment(self.ctx, stack.identifier()) + + # Verify + env['parameters']['pass'] = '******' + env['parameter_defaults']['secret'] = '******' + self.assertEqual(env, found) + def test_get_environment_no_env(self): # Setup exc = exception.EntityNotFound(entity='stack', name='missing') diff --git a/releasenotes/notes/honor-hidden-parameter-in-stack-env-show-cmd-062065545dfef82a.yaml b/releasenotes/notes/honor-hidden-parameter-in-stack-env-show-cmd-062065545dfef82a.yaml index 385e3d4d5..8a3a366ee 100644 --- a/releasenotes/notes/honor-hidden-parameter-in-stack-env-show-cmd-062065545dfef82a.yaml +++ b/releasenotes/notes/honor-hidden-parameter-in-stack-env-show-cmd-062065545dfef82a.yaml @@ -1,4 +1,6 @@ --- fixes: - | - Honor ``hidden`` parameter in ``stack environment show`` command + Honor ``hidden`` parameter in get stack environment API. Now values passed + to hidden parameters are replaced by '******', similarly to the other + APIs such as show stack details API. diff --git a/roles/run-heat-tests/defaults/main.yaml b/roles/run-heat-tests/defaults/main.yaml index 22ce4a490..1ae87b9ed 100644 --- a/roles/run-heat-tests/defaults/main.yaml +++ b/roles/run-heat-tests/defaults/main.yaml @@ -3,3 +3,4 @@ tempest_test_timeout: '' tempest_tox_environment: {} heat_tempest_plugin: /opt/stack/heat-tempest-plugin constraints_file: /opt/stack/requirements/upper-constraints.txt +target_branch: "{{ zuul.branch }}" diff --git a/roles/run-heat-tests/tasks/main.yaml b/roles/run-heat-tests/tasks/main.yaml index 4af1d0e03..03661d774 100644 --- a/roles/run-heat-tests/tasks/main.yaml +++ b/roles/run-heat-tests/tasks/main.yaml @@ -3,9 +3,17 @@ tempest_tox_environment: "{{ tempest_tox_environment | combine({'OS_TEST_TIMEOUT': tempest_test_timeout}) }}" when: tempest_test_timeout != '' +- name: Override target branch + set_fact: + target_branch: "{{ zuul.override_checkout }}" + when: zuul.override_checkout is defined + - name: Set TOX_CONSTRAINTS_FILE set_fact: + # Set TOX_CONSTRAINTS_FILE/UPPER_CONSTRAINTS_FILE to stable constraints only + # for the EM stable branch where old tempest (not master) is used. tempest_tox_environment: "{{ tempest_tox_environment | combine({'UPPER_CONSTRAINTS_FILE': constraints_file}) | combine({'TOX_CONSTRAINTS_FILE': constraints_file}) }}" + when: target_branch in ["stable/ocata", "stable/pike", "stable/queens", "stable/rocky", "stable/stein", "stable/train", "stable/ussuri", "stable/victoria", "stable/wallaby"] - name: Allow git to read plugin directories become: true |