Repository: ambari Updated Branches: refs/heads/branch-2.4 1b645c048 -> 9e98a01dc
AMBARI-17485. RU: 'Write Client configs' - step failed (ncole) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9e98a01d Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9e98a01d Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9e98a01d Branch: refs/heads/branch-2.4 Commit: 9e98a01dcf673ec42cf634c122413289eee69bcb Parents: 1b645c0 Author: Nate Cole <[email protected]> Authored: Wed Jun 29 13:14:47 2016 -0400 Committer: Nate Cole <[email protected]> Committed: Wed Jun 29 15:14:52 2016 -0400 ---------------------------------------------------------------------- .../libraries/script/script.py | 4 ++-- .../SPARK/1.2.1/package/scripts/spark_client.py | 14 ++++++++------ .../TEZ/0.4.0.2.1/package/scripts/tez.py | 7 ++++++- .../package/scripts/mapreduce2_client.py | 13 ++++++++----- .../stacks/2.0.6/YARN/test_mapreduce2_client.py | 18 ++++++++++++++++++ .../test/python/stacks/2.1/TEZ/test_tez_client.py | 18 ++++++++++++++++++ .../python/stacks/2.2/SPARK/test_spark_client.py | 18 ++++++++++++++++++ 7 files changed, 78 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/9e98a01d/ambari-common/src/main/python/resource_management/libraries/script/script.py ---------------------------------------------------------------------- diff --git a/ambari-common/src/main/python/resource_management/libraries/script/script.py b/ambari-common/src/main/python/resource_management/libraries/script/script.py index 77228a9..534daa6 100644 --- a/ambari-common/src/main/python/resource_management/libraries/script/script.py +++ b/ambari-common/src/main/python/resource_management/libraries/script/script.py @@ -167,7 +167,7 @@ class Script(object): required_attributes = ["stack_name", "stack_root", "version"] for attribute in required_attributes: - if not has_attr(params, attribute): + if not hasattr(params, attribute): raise Fail("Failed in function 'stack_upgrade_save_new_config' because params was missing variable %s." % attribute) Logger.info("stack_upgrade_save_new_config(): Checking if can write new client configs to new config version folder.") @@ -834,4 +834,4 @@ class Script(object): def __init__(self): if Script.instance is not None: - raise Fail("An instantiation already exists! Use, get_instance() method.") \ No newline at end of file + raise Fail("An instantiation already exists! Use, get_instance() method.") http://git-wip-us.apache.org/repos/asf/ambari/blob/9e98a01d/ambari-server/src/main/resources/common-services/SPARK/1.2.1/package/scripts/spark_client.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/SPARK/1.2.1/package/scripts/spark_client.py b/ambari-server/src/main/resources/common-services/SPARK/1.2.1/package/scripts/spark_client.py index bade06e..31bf4c6 100644 --- a/ambari-server/src/main/resources/common-services/SPARK/1.2.1/package/scripts/spark_client.py +++ b/ambari-server/src/main/resources/common-services/SPARK/1.2.1/package/scripts/spark_client.py @@ -17,16 +17,18 @@ See the License for the specific language governing permissions and limitations under the License. """ - +# Python imports +import os import sys -from resource_management import * -from resource_management.libraries.functions import conf_select -from resource_management.libraries.functions import stack_select + +# Local imports +from resource_management.libraries.script.script import Script +from resource_management.libraries.functions import conf_select, stack_select from resource_management.libraries.functions.stack_features import check_stack_feature -from resource_management.libraries.functions import StackFeature +from resource_management.libraries.functions.constants import StackFeature from resource_management.core.exceptions import ClientComponentHasNoStatus +from ambari_commons.constants import UPGRADE_TYPE_ROLLING from resource_management.core.logger import Logger -from resource_management.core import shell from setup_spark import setup_spark http://git-wip-us.apache.org/repos/asf/ambari/blob/9e98a01d/ambari-server/src/main/resources/common-services/TEZ/0.4.0.2.1/package/scripts/tez.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/TEZ/0.4.0.2.1/package/scripts/tez.py b/ambari-server/src/main/resources/common-services/TEZ/0.4.0.2.1/package/scripts/tez.py index 01940d7..dfa6501 100644 --- a/ambari-server/src/main/resources/common-services/TEZ/0.4.0.2.1/package/scripts/tez.py +++ b/ambari-server/src/main/resources/common-services/TEZ/0.4.0.2.1/package/scripts/tez.py @@ -18,9 +18,14 @@ limitations under the License. Ambari Agent """ +# Python Imports import os -from resource_management import * +# Local Imports +from resource_management.core.resources.system import Directory, File +from resource_management.libraries.resources.xml_config import XmlConfig +from resource_management.libraries.functions.format import format +from resource_management.core.source import InlineTemplate from ambari_commons import OSConst from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl http://git-wip-us.apache.org/repos/asf/ambari/blob/9e98a01d/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/mapreduce2_client.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/mapreduce2_client.py b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/mapreduce2_client.py index 7b166ba..424157b 100644 --- a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/mapreduce2_client.py +++ b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/mapreduce2_client.py @@ -18,13 +18,16 @@ limitations under the License. Ambari Agent """ - +# Python imports +import os import sys -from resource_management import * -from resource_management.libraries.functions import conf_select -from resource_management.libraries.functions import stack_select -from resource_management.libraries.functions import StackFeature + +# Local imports +from resource_management.libraries.script.script import Script +from resource_management.libraries.functions import conf_select, stack_select +from resource_management.libraries.functions.constants import StackFeature from resource_management.libraries.functions.stack_features import check_stack_feature +from resource_management.core.exceptions import ClientComponentHasNoStatus from yarn import yarn from ambari_commons import OSConst from ambari_commons.os_family_impl import OsFamilyImpl http://git-wip-us.apache.org/repos/asf/ambari/blob/9e98a01d/ambari-server/src/test/python/stacks/2.0.6/YARN/test_mapreduce2_client.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/YARN/test_mapreduce2_client.py b/ambari-server/src/test/python/stacks/2.0.6/YARN/test_mapreduce2_client.py index 0083d75..edd9615 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/YARN/test_mapreduce2_client.py +++ b/ambari-server/src/test/python/stacks/2.0.6/YARN/test_mapreduce2_client.py @@ -419,3 +419,21 @@ class TestMapReduce2Client(RMFTestCase): self.assertEquals( ('ambari-python-wrap', '/usr/bin/conf-select', 'create-conf-dir', '--package', 'hadoop', '--stack-version', '2.3.0.0-1234', '--conf-version', '0'), mocks_dict['call'].call_args_list[0][0][0]) + + def test_stack_upgrade_save_new_config(self): + config_file = self.get_src_folder()+"/test/python/stacks/2.0.6/configs/client-upgrade.json" + with open(config_file, "r") as f: + json_content = json.load(f) + version = '2.3.0.0-1234' + json_content['commandParams']['version'] = version + + mocks_dict = {} + self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/mapreduce2_client.py", + classname = "MapReduce2Client", + command = "stack_upgrade_save_new_config", + config_dict = json_content, + stack_version = self.STACK_VERSION, + target = RMFTestCase.TARGET_COMMON_SERVICES, + call_mocks = [(0, None, ''), (0, None)], + mocks_dict = mocks_dict) + # for now, it's enough to know the method didn't fail http://git-wip-us.apache.org/repos/asf/ambari/blob/9e98a01d/ambari-server/src/test/python/stacks/2.1/TEZ/test_tez_client.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.1/TEZ/test_tez_client.py b/ambari-server/src/test/python/stacks/2.1/TEZ/test_tez_client.py index 73615a4..e63090a 100644 --- a/ambari-server/src/test/python/stacks/2.1/TEZ/test_tez_client.py +++ b/ambari-server/src/test/python/stacks/2.1/TEZ/test_tez_client.py @@ -126,3 +126,21 @@ class TestTezClient(RMFTestCase): self.assertEquals( ('ambari-python-wrap', '/usr/bin/conf-select', 'create-conf-dir', '--package', 'hadoop', '--stack-version', '2.3.0.0-1234', '--conf-version', '0'), mocks_dict['call'].call_args_list[1][0][0]) + + def test_stack_upgrade_save_new_config(self): + config_file = self.get_src_folder()+"/test/python/stacks/2.1/configs/client-upgrade.json" + with open(config_file, "r") as f: + json_content = json.load(f) + version = '2.3.0.0-1234' + json_content['commandParams']['version'] = version + + mocks_dict = {} + self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/tez_client.py", + classname = "TezClient", + command = "stack_upgrade_save_new_config", + config_dict = json_content, + stack_version = self.STACK_VERSION, + target = RMFTestCase.TARGET_COMMON_SERVICES, + call_mocks = [(0, None, ''), (0, None)], + mocks_dict = mocks_dict) + # for now, it's enough to know the method didn't fail \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/9e98a01d/ambari-server/src/test/python/stacks/2.2/SPARK/test_spark_client.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.2/SPARK/test_spark_client.py b/ambari-server/src/test/python/stacks/2.2/SPARK/test_spark_client.py index a8e580a..ed331ea 100644 --- a/ambari-server/src/test/python/stacks/2.2/SPARK/test_spark_client.py +++ b/ambari-server/src/test/python/stacks/2.2/SPARK/test_spark_client.py @@ -181,3 +181,21 @@ class TestSparkClient(RMFTestCase): self.assertEquals( ('ambari-python-wrap', '/usr/bin/conf-select', 'create-conf-dir', '--package', 'spark', '--stack-version', '2.3.0.0-1234', '--conf-version', '0'), mocks_dict['call'].call_args_list[0][0][0]) + + def test_stack_upgrade_save_new_config(self): + config_file = self.get_src_folder()+"/test/python/stacks/2.2/configs/default.json" + with open(config_file, "r") as f: + json_content = json.load(f) + version = '2.3.0.0-1234' + json_content['commandParams']['version'] = version + + mocks_dict = {} + self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/spark_client.py", + classname = "SparkClient", + command = "stack_upgrade_save_new_config", + config_dict = json_content, + stack_version = self.STACK_VERSION, + target = RMFTestCase.TARGET_COMMON_SERVICES, + call_mocks = [(0, None, ''), (0, None)], + mocks_dict = mocks_dict) + # for now, it's enough to know the method didn't fail
