ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [3/4] ambari git commit: AMBARI-20871. Unify repository file creation (ncole)
Date Thu, 27 Apr 2017 20:23:36 GMT
http://git-wip-us.apache.org/repos/asf/ambari/blob/b6866249/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/custom_actions/TestInstallPackages.py b/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
index 77e3bee..5206ea3 100644
--- a/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
+++ b/ambari-server/src/test/python/custom_actions/TestInstallPackages.py
@@ -90,8 +90,7 @@ class TestInstallPackages(RMFTestCase):
                       {'package_installation_result': 'SUCCESS',
                        'installed_repository_version': VERSION_STUB,
                        'stack_id': 'HDP-2.2',
-                       'actual_version': VERSION_STUB,
-                       'ambari_repositories': []})
+                       'actual_version': VERSION_STUB})
     self.assertResourceCalled('Repository', 'HDP-UTILS-2.2.0.1-885',
                               base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
                               action=['create'],
@@ -157,8 +156,7 @@ class TestInstallPackages(RMFTestCase):
                       {'package_installation_result': 'SUCCESS',
                        'installed_repository_version': VERSION_STUB,
                        'stack_id': 'HDP-2.2',
-                       'actual_version': VERSION_STUB,
-                       'ambari_repositories': []})
+                       'actual_version': VERSION_STUB})
     
     self.assertResourceCalled('Package', 'hdp-select', action=["upgrade"], retry_count=5,
retry_on_repo_unavailability=False)
     self.assertResourceCalled('Package', 'hadoop_2_2_0_1_885', action=["upgrade"], retry_count=5,
retry_on_repo_unavailability=False)
@@ -200,8 +198,7 @@ class TestInstallPackages(RMFTestCase):
                       {'package_installation_result': 'SUCCESS',
                        'installed_repository_version': VERSION_STUB,
                        'stack_id': 'HDP-2.2',
-                       'actual_version': VERSION_STUB,
-                       'ambari_repositories': []})
+                       'actual_version': VERSION_STUB})
     self.assertResourceCalled('Repository', 'HDP-UTILS-2.2.0.1-885',
                               base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
                               action=['create'],
@@ -263,8 +260,7 @@ class TestInstallPackages(RMFTestCase):
                       {'package_installation_result': 'SUCCESS',
                        'installed_repository_version': VERSION_STUB,
                        'stack_id': 'HDP-2.2',
-                       'actual_version': VERSION_STUB,
-                       'ambari_repositories': ["HDP-UTILS-2.2.0.1-885"]})
+                       'actual_version': VERSION_STUB})
     self.assertResourceCalled('Repository', 'HDP-UTILS-2.2.0.1-885',
                               base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
                               action=['create'],
@@ -340,7 +336,6 @@ class TestInstallPackages(RMFTestCase):
     self.assertEquals(put_structured_out_mock.call_args[0][0],
                       {'stack_id': 'HDP-2.2',
                       'installed_repository_version': VERSION_STUB,
-                      'ambari_repositories': [],
                       'package_installation_result': 'FAIL'})
     self.assertResourceCalled('Repository', 'HDP-UTILS-2.2.0.1-885',
                               base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
@@ -397,8 +392,7 @@ class TestInstallPackages(RMFTestCase):
                       {'package_installation_result': 'SUCCESS',
                        'installed_repository_version': VERSION_STUB,
                        'stack_id': 'HDP-2.2',
-                       'actual_version': VERSION_STUB,
-                       'ambari_repositories': []})
+                       'actual_version': VERSION_STUB})
     self.assertResourceCalled('Repository', 'HDP-UTILS-2.2.0.1-885',
                               base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
                               action=['create'],
@@ -468,8 +462,7 @@ class TestInstallPackages(RMFTestCase):
                       {'package_installation_result': 'SUCCESS',
                        'installed_repository_version': VERSION_STUB,
                        'stack_id': 'HDP-2.2',
-                       'actual_version': VERSION_STUB,
-                       'ambari_repositories': []})
+                       'actual_version': VERSION_STUB})
     self.assertResourceCalled('Repository', 'HDP-UTILS-2.2.0.1-885',
                               base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
                               action=['create'],
@@ -535,8 +528,7 @@ class TestInstallPackages(RMFTestCase):
                       {'package_installation_result': 'SUCCESS',
                        'installed_repository_version': VERSION_STUB,
                        'stack_id': 'HDP-2.2',
-                       'actual_version': VERSION_STUB,
-                       'ambari_repositories': []})
+                       'actual_version': VERSION_STUB})
     self.assertTrue(write_actual_version_to_history_file_mock.called)
     self.assertEquals(write_actual_version_to_history_file_mock.call_args[0], (VERSION_STUB_WITHOUT_BUILD_NUMBER,
VERSION_STUB))
 
@@ -571,8 +563,7 @@ class TestInstallPackages(RMFTestCase):
                       {'package_installation_result': 'SUCCESS',
                        'installed_repository_version': VERSION_STUB,
                        'stack_id': 'HDP-2.2',
-                       'actual_version': VERSION_STUB,
-                       'ambari_repositories': []})
+                       'actual_version': VERSION_STUB})
 
     self.assertFalse(write_actual_version_to_history_file_mock.called)
 
@@ -622,7 +613,7 @@ class TestInstallPackages(RMFTestCase):
 
     self.assertTrue(put_structured_out_mock.called)
     self.assertEquals(put_structured_out_mock.call_args_list[-1][0][0],
-                      { 'ambari_repositories': [],
+                      {
                         'package_installation_result': 'FAIL',
                         'installed_repository_version': '2.2.0.1',
                         'stack_id': u'HDP-2.2'})
@@ -678,8 +669,7 @@ class TestInstallPackages(RMFTestCase):
     self.assertEquals(put_structured_out_mock.call_args_list[-1][0][0],
                       {'package_installation_result': 'FAIL',
                        'stack_id': u'HDP-2.2',
-                       'installed_repository_version': '2.2.0.1',
-                       'ambari_repositories': []})
+                       'installed_repository_version': '2.2.0.1'})
 
     self.assertFalse(write_actual_version_to_history_file_mock.called)
 
@@ -720,8 +710,7 @@ class TestInstallPackages(RMFTestCase):
                       {'package_installation_result': 'FAIL',
                        'stack_id': u'HDP-2.2',
                        'installed_repository_version': VERSION_STUB,
-                       'actual_version': VERSION_STUB,
-                       'ambari_repositories': []})
+                       'actual_version': VERSION_STUB})
 
     self.assertFalse(write_actual_version_to_history_file_mock.called)
 
@@ -762,8 +751,7 @@ class TestInstallPackages(RMFTestCase):
                       {'package_installation_result': 'SUCCESS',
                        'installed_repository_version': VERSION_STUB_WITHOUT_BUILD_NUMBER,
                        'stack_id': 'HDP-2.2',
-                       'actual_version': VERSION_STUB,
-                       'ambari_repositories': []})
+                       'actual_version': VERSION_STUB})
     self.assertTrue(write_actual_version_to_history_file_mock.called)
     self.assertEquals(write_actual_version_to_history_file_mock.call_args[0], (VERSION_STUB_WITHOUT_BUILD_NUMBER,
VERSION_STUB))
 
@@ -798,8 +786,7 @@ class TestInstallPackages(RMFTestCase):
                       {'package_installation_result': 'SUCCESS',
                        'installed_repository_version': VERSION_STUB_WITHOUT_BUILD_NUMBER,
                        'stack_id': 'HDP-2.2',
-                       'actual_version': VERSION_STUB,
-                       'ambari_repositories': []})
+                       'actual_version': VERSION_STUB})
 
     self.assertFalse(write_actual_version_to_history_file_mock.called)
 
@@ -840,8 +827,7 @@ class TestInstallPackages(RMFTestCase):
                       {'package_installation_result': 'SUCCESS',
                        'installed_repository_version': '2.2.0.1-500',
                        'stack_id': 'HDP-2.2',
-                       'actual_version': VERSION_STUB,
-                       'ambari_repositories': []})
+                       'actual_version': VERSION_STUB})
     self.assertTrue(write_actual_version_to_history_file_mock.called)
     self.assertEquals(write_actual_version_to_history_file_mock.call_args[0], ('2.2.0.1',
VERSION_STUB))
 
@@ -876,8 +862,7 @@ class TestInstallPackages(RMFTestCase):
                       {'package_installation_result': 'SUCCESS',
                        'installed_repository_version': '2.2.0.1-500',
                        'stack_id': 'HDP-2.2',
-                       'actual_version': VERSION_STUB,
-                       'ambari_repositories': []})
+                       'actual_version': VERSION_STUB})
 
     self.assertFalse(write_actual_version_to_history_file_mock.called)
 
@@ -926,8 +911,7 @@ class TestInstallPackages(RMFTestCase):
     self.assertEquals(put_structured_out_mock.call_args_list[-1][0][0],
                       {'package_installation_result': 'FAIL',
                        'stack_id': u'HDP-2.2',
-                       'installed_repository_version': '2.2.0.1',
-                       'ambari_repositories': []})
+                       'installed_repository_version': '2.2.0.1'})
 
     self.assertFalse(write_actual_version_to_history_file_mock.called)
 
@@ -968,8 +952,7 @@ class TestInstallPackages(RMFTestCase):
                       {'package_installation_result': 'FAIL',
                        'stack_id': u'HDP-2.2',
                        'installed_repository_version': VERSION_STUB,
-                       'actual_version': VERSION_STUB,
-                       'ambari_repositories': []})
+                       'actual_version': VERSION_STUB})
 
     self.assertFalse(write_actual_version_to_history_file_mock.called)
 
@@ -1011,8 +994,7 @@ class TestInstallPackages(RMFTestCase):
                        'installed_repository_version': VERSION_STUB,
                        'stack_id': 'HDP-2.2',
                        'repository_version_id': '2',
-                       'actual_version': VERSION_STUB,
-                       'ambari_repositories': []})
+                       'actual_version': VERSION_STUB})
     self.assertTrue(write_actual_version_to_history_file_mock.called)
     self.assertEquals(write_actual_version_to_history_file_mock.call_args[0], (VERSION_STUB_WITHOUT_BUILD_NUMBER,
VERSION_STUB))
 
@@ -1049,7 +1031,65 @@ class TestInstallPackages(RMFTestCase):
                        'installed_repository_version': VERSION_STUB,
                        'stack_id': 'HDP-2.2',
                        'repository_version_id': '2',
-                       'actual_version': VERSION_STUB,
-                       'ambari_repositories': []})
+                       'actual_version': VERSION_STUB})
 
-    self.assertFalse(write_actual_version_to_history_file_mock.called)
\ No newline at end of file
+    self.assertFalse(write_actual_version_to_history_file_mock.called)
+
+  @patch("resource_management.libraries.functions.list_ambari_managed_repos.list_ambari_managed_repos")
+  @patch("resource_management.libraries.functions.packages_analyzer.allInstalledPackages")
+  @patch("resource_management.libraries.script.Script.put_structured_out")
+  @patch("resource_management.libraries.functions.stack_select.get_stack_versions")
+  @patch("resource_management.libraries.functions.repo_version_history.read_actual_version_from_history_file")
+  @patch("resource_management.libraries.functions.repo_version_history.write_actual_version_to_history_file")
+  def test_normal_flow_rhel_with_command_repo(self,
+                            write_actual_version_to_history_file_mock,
+                            read_actual_version_from_history_file_mock,
+                            stack_versions_mock,
+                            put_structured_out_mock, allInstalledPackages_mock, list_ambari_managed_repos_mock):
+    stack_versions_mock.side_effect = [
+      [],  # before installation attempt
+      [VERSION_STUB]
+    ]
+    allInstalledPackages_mock.side_effect = TestInstallPackages._add_packages
+    list_ambari_managed_repos_mock.return_value=[]
+    self.executeScript("scripts/install_packages.py",
+                       classname="InstallPackages",
+                       command="actionexecute",
+                       config_file="install_packages_repository_file.json",
+                       target=RMFTestCase.TARGET_CUSTOM_ACTIONS,
+                       os_type=('Redhat', '6.4', 'Final'),
+    )
+    self.assertTrue(put_structured_out_mock.called)
+    self.assertEquals(put_structured_out_mock.call_args[0][0],
+                      {'package_installation_result': 'SUCCESS',
+                       'installed_repository_version': VERSION_STUB,
+                       'stack_id': 'HDP-2.2',
+                       'actual_version': VERSION_STUB})
+
+    self.assertResourceCalled('Repository', 'HDP-UTILS-1.1.0.20-repo-4',
+                              base_url=u'http://repo1/HDP-UTILS/centos5/2.x/updates/2.2.0.0',
+                              action=['create'],
+                              components=[u'HDP-UTILS', 'main'],
+                              repo_template='[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list
%}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
+                              repo_file_name=u'ambari-hdp-4',
+                              mirror_list=None,
+                              append_to_file=False,
+    )
+    self.assertResourceCalled('Repository', 'HDP-2.2-repo-4',
+                              base_url=u'http://repo1/HDP/centos5/2.x/updates/2.2.0.0',
+                              action=['create'],
+                              components=[u'HDP', 'main'],
+                              repo_template='[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list
%}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0',
+                              repo_file_name=u'ambari-hdp-4',
+                              mirror_list=None,
+                              append_to_file=True,
+    )
+    self.assertResourceCalled('Package', 'hdp-select', action=["upgrade"], retry_count=5,
retry_on_repo_unavailability=False)
+    self.assertResourceCalled('Package', 'hadoop_2_2_0_1_885', action=["upgrade"], retry_count=5,
retry_on_repo_unavailability=False)
+    self.assertResourceCalled('Package', 'snappy', action=["upgrade"], retry_count=5, retry_on_repo_unavailability=False)
+    self.assertResourceCalled('Package', 'snappy-devel', action=["upgrade"], retry_count=5,
retry_on_repo_unavailability=False)
+    self.assertResourceCalled('Package', 'lzo', action=["upgrade"], retry_count=5, retry_on_repo_unavailability=False)
+    self.assertResourceCalled('Package', 'hadooplzo_2_2_0_1_885', action=["upgrade"], retry_count=5,
retry_on_repo_unavailability=False)
+    self.assertResourceCalled('Package', 'hadoop_2_2_0_1_885-libhdfs', action=["upgrade"],
retry_count=5, retry_on_repo_unavailability=False)
+    self.assertResourceCalled('Package', 'ambari-log4j', action=["upgrade"], retry_count=5,
retry_on_repo_unavailability=False)
+    self.assertNoMoreResources()

http://git-wip-us.apache.org/repos/asf/ambari/blob/b6866249/ambari-server/src/test/python/custom_actions/configs/install_packages_repository_file.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/custom_actions/configs/install_packages_repository_file.json
b/ambari-server/src/test/python/custom_actions/configs/install_packages_repository_file.json
new file mode 100644
index 0000000..761dced
--- /dev/null
+++ b/ambari-server/src/test/python/custom_actions/configs/install_packages_repository_file.json
@@ -0,0 +1,112 @@
+{
+    "configuration_attributes": {}, 
+    "roleCommand": "ACTIONEXECUTE", 
+    "clusterName": "cc", 
+    "hostname": "0b3.vm", 
+    "passiveInfo": [], 
+    "hostLevelParams": {
+        "agent_stack_retry_count": "5",
+        "agent_stack_retry_on_unavailability": "false",
+        "jdk_location": "http://0b3.vm:8080/resources/", 
+        "ambari_db_rca_password": "mapred", 
+        "java_home": "/usr/jdk64/jdk1.7.0_67",
+        "java_version": "8",
+        "ambari_db_rca_url": "jdbc:postgresql://0b3.vm/ambarirca", 
+        "jce_name": "UnlimitedJCEPolicyJDK7.zip", 
+        "oracle_jdbc_url": "http://0b3.vm:8080/resources//ojdbc6.jar", 
+        "stack_version": "2.1", 
+        "stack_name": "HDP", 
+        "db_name": "ambari", 
+        "ambari_db_rca_driver": "org.postgresql.Driver", 
+        "jdk_name": "jdk-7u67-linux-x64.tar.gz", 
+        "ambari_db_rca_username": "mapred", 
+        "db_driver_filename": "mysql-connector-java.jar", 
+        "mysql_jdbc_url": "http://0b3.vm:8080/resources//mysql-connector-java.jar"
+    }, 
+    "commandType": "EXECUTION_COMMAND", 
+    "repositoryFile": {
+        "stackName": "HDP",
+        "repoVersionId": 4,
+        "repoVersion": "2.2.0.1-885",
+        "repositories": [
+          {
+            "repoName": "HDP-UTILS",
+            "baseUrl": "http://repo1/HDP-UTILS/centos5/2.x/updates/2.2.0.0",
+            "repoId": "HDP-UTILS-1.1.0.20-repo-4"
+          },
+          {
+            "repoName": "HDP",
+            "baseUrl": "http://repo1/HDP/centos5/2.x/updates/2.2.0.0",
+            "repoId": "HDP-2.2-repo-4"
+          }
+        ]
+    },
+    "roleParams": {
+        "stack_id": "HDP-2.2",
+        "repository_version": "2.2.0.1-885",
+        "package_list": "[{\"name\":\"hadoop_${stack_version}\", \"condition\": \"\"},{\"name\":\"snappy\",
\"condition\": \"\"},{\"name\":\"snappy-devel\", \"condition\": \"\"},{\"name\":\"lzo\", \"condition\":
\"\"},{\"name\":\"hadooplzo_${stack_version}\", \"condition\": \"\"},{\"name\":\"hadoop_${stack_version}-libhdfs\",
\"condition\": \"\"},{\"name\":\"ambari-log4j\", \"condition\": \"\"}]"
+    }, 
+    "serviceName": "null", 
+    "role": "install_packages", 
+    "forceRefreshConfigTags": [], 
+    "taskId": 61, 
+    "public_hostname": "0b3.vm", 
+    "configurations": {
+            "cluster-env": {
+                "repo_suse_rhel_template": "[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list
%}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0",
+                "repo_ubuntu_template": "{{package_type}} {{base_url}} {{components}}"
+        }
+    },
+    "commandParams": {
+        "command_timeout": "60", 
+        "script_type": "PYTHON",
+        "repository_version": "2.2.0.1-885",
+        "package_list": "[{\"name\":\"hadoop_${stack_version}\", \"condition\": \"\"},{\"name\":\"snappy\",
\"condition\": \"\"},{\"name\":\"snappy-devel\", \"condition\": \"\"},{\"name\":\"lzo\", \"condition\":
\"\"},{\"name\":\"hadooplzo_${stack_version}\", \"condition\": \"\"},{\"name\":\"hadoop_${stack_version}-libhdfs\",
\"condition\": \"\"},{\"name\":\"ambari-log4j\", \"condition\": \"\"}]",
+        "script": "install_packages.py"
+    }, 
+    "commandId": "14-1", 
+    "clusterHostInfo": {
+        "snamenode_host": [
+            "0b3.vm"
+        ], 
+        "nm_hosts": [
+            "0b3.vm"
+        ], 
+        "app_timeline_server_hosts": [
+            "0b3.vm"
+        ], 
+        "all_ping_ports": [
+            "8670"
+        ], 
+        "rm_host": [
+            "0b3.vm"
+        ], 
+        "all_hosts": [
+            "0b3.vm"
+        ], 
+        "slave_hosts": [
+            "0b3.vm"
+        ], 
+        "namenode_host": [
+            "0b3.vm"
+        ], 
+        "ambari_server_host": [
+            "0b3.vm"
+        ], 
+        "zookeeper_hosts": [
+            "0b3.vm"
+        ], 
+        "hs_host": [
+            "0b3.vm"
+        ]
+    },
+    "configurations": {
+        "cluster-env": {
+            "repo_suse_rhel_template": "[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list
%}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0",

+            "repo_ubuntu_template": "{{package_type}} {{base_url}} {{components}}"
+        },
+        "core-site": {
+            "io.compression.codecs": "com.hadoop.compression.lzo"
+        }
+    }
+}


Mime
View raw message