From 08feb98be6ab49b9f0e80fc2ded185e2a273a749 Mon Sep 17 00:00:00 2001 From: Dmytro Dovbii Date: Mon, 23 Mar 2015 15:30:20 +0200 Subject: [PATCH] Fix EP building if app doesn't have files in template Change-Id: Ie4148562db1521969729791a6198761f85f47c36 Closes-Bug: #1435331 --- murano/engine/system/agent.py | 2 +- .../application_without_files.template | 18 +++++++++ murano/tests/unit/engine/system/test_agent.py | 39 +++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 murano/tests/unit/engine/system/execution_plans/application_without_files.template diff --git a/murano/engine/system/agent.py b/murano/engine/system/agent.py index 14183953..0ff2fb5a 100644 --- a/murano/engine/system/agent.py +++ b/murano/engine/system/agent.py @@ -237,7 +237,7 @@ class Agent(murano_object.MuranoObject): script['EntryPoint'] = self._place_file( scripts_folder, script['EntryPoint'], template, files, resources) - scripts_files = script['Files'] + scripts_files = script.get('Files', []) script['Files'] = [] for file in scripts_files: file_id = self._place_file(scripts_folder, file, diff --git a/murano/tests/unit/engine/system/execution_plans/application_without_files.template b/murano/tests/unit/engine/system/execution_plans/application_without_files.template new file mode 100644 index 00000000..57bc6194 --- /dev/null +++ b/murano/tests/unit/engine/system/execution_plans/application_without_files.template @@ -0,0 +1,18 @@ +FormatVersion: 2.0.0 +Version: 1.0.0 +Name: Deploy Tomcat + +Parameters: + appName: $appName + +Body: | + return deploy(args.appName).stdout + +Scripts: + deploy: + Type: Application + Version: 1.0.0 + EntryPoint: deployTomcat.sh + Options: + captureStdout: true + captureStderr: true \ No newline at end of file diff --git a/murano/tests/unit/engine/system/test_agent.py b/murano/tests/unit/engine/system/test_agent.py index 0934b502..ee8b410e 100644 --- a/murano/tests/unit/engine/system/test_agent.py +++ b/murano/tests/unit/engine/system/test_agent.py @@ -78,6 +78,13 @@ class TestExecutionPlan(base.MuranoTestCase): template = self.agent.buildExecutionPlan(template, self.resources) self.assertEqual(template, self._get_telnet_application()) + def test_execution_plan_v2_app_without_files(self): + template = yamllib.load( + self._read('application_without_files.template'), + Loader=self.yaml_loader) + template = self.agent.buildExecutionPlan(template, self.resources) + self.assertEqual(template, self._get_app_without_files()) + def _get_application(self): return { 'Action': 'Execute', @@ -123,6 +130,38 @@ class TestExecutionPlan(base.MuranoTestCase): 'Version': '1.0.0' } + def _get_app_without_files(self): + return { + 'Action': 'Execute', + 'Body': 'return deploy(args.appName).stdout\n', + 'Files': { + self.uuids[1]: { + 'Body': 'text', + 'BodyType': 'Text', + 'Name': 'deployTomcat.sh' + }, + }, + 'FormatVersion': '2.0.0', + 'ID': self.uuids[0], + 'Name': 'Deploy Tomcat', + 'Parameters': { + 'appName': '$appName' + }, + 'Scripts': { + 'deploy': { + 'EntryPoint': self.uuids[1], + 'Files': [], + 'Options': { + 'captureStderr': True, + 'captureStdout': True + }, + 'Type': 'Application', + 'Version': '1.0.0' + } + }, + 'Version': '1.0.0' + } + def _get_chef(self): return { 'Action': 'Execute',