ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adorosz...@apache.org
Subject ambari git commit: AMBARI-19959. Allow skipping view extraction in ambari-server setup (adoroszlai)
Date Tue, 14 Feb 2017 07:42:40 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 a8f720024 -> 706a3dfe0


AMBARI-19959. Allow skipping view extraction in ambari-server setup (adoroszlai)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/706a3dfe
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/706a3dfe
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/706a3dfe

Branch: refs/heads/branch-2.5
Commit: 706a3dfe0b2250bf9d36d19ddebb48869a608c07
Parents: a8f7200
Author: Attila Doroszlai <adoroszlai@hortonworks.com>
Authored: Fri Feb 10 13:29:18 2017 +0100
Committer: Attila Doroszlai <adoroszlai@hortonworks.com>
Committed: Tue Feb 14 08:40:25 2017 +0100

----------------------------------------------------------------------
 ambari-server/src/main/python/ambari-server.py  |  2 ++
 .../main/python/ambari_server/serverSetup.py    | 11 ++++---
 .../src/test/python/TestAmbariServer.py         | 32 ++++++++++++--------
 3 files changed, 28 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/706a3dfe/ambari-server/src/main/python/ambari-server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari-server.py b/ambari-server/src/main/python/ambari-server.py
index 845a9f6..e7ffe4e 100755
--- a/ambari-server/src/main/python/ambari-server.py
+++ b/ambari-server/src/main/python/ambari-server.py
@@ -398,6 +398,7 @@ def init_parser_options(parser):
                     help="Specifies the path to the JDBC driver JAR file")
   parser.add_option('--skip-properties-validation', action="store_true", default=False, help="Skip
properties file validation", dest="skip_properties_validation")
   parser.add_option('--skip-database-check', action="store_true", default=False, help="Skip
database consistency check", dest="skip_database_check")
+  parser.add_option('--skip-view-extraction', action="store_true", default=False, help="Skip
extraction of system views", dest="skip_view_extraction")
   parser.add_option('--auto-fix-database', action="store_true", default=False, help="Automatically
fix database consistency issues", dest="fix_database_consistency")
   add_parser_options('--mpack',
       default=None,
@@ -500,6 +501,7 @@ def init_parser_options(parser):
   parser.add_option('--version-display-name', default=None, help="Display name of desired
repo version", dest="desired_repo_version")
   parser.add_option('--skip-properties-validation', action="store_true", default=False, help="Skip
properties file validation", dest="skip_properties_validation")
   parser.add_option('--skip-database-check', action="store_true", default=False, help="Skip
database consistency check", dest="skip_database_check")
+  parser.add_option('--skip-view-extraction', action="store_true", default=False, help="Skip
extraction of system views", dest="skip_view_extraction")
   parser.add_option('--auto-fix-database', action="store_true", default=False, help="Automatically
fix database consistency issues", dest="fix_database_consistency")
   parser.add_option('--force-version', action="store_true", default=False, help="Force version
to current", dest="force_repo_version")
   parser.add_option('--version', dest="stack_versions", default=None, action="append", type="string",

http://git-wip-us.apache.org/repos/asf/ambari/blob/706a3dfe/ambari-server/src/main/python/ambari_server/serverSetup.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/serverSetup.py b/ambari-server/src/main/python/ambari_server/serverSetup.py
index 42ef51f..c1643f2 100644
--- a/ambari-server/src/main/python/ambari_server/serverSetup.py
+++ b/ambari-server/src/main/python/ambari_server/serverSetup.py
@@ -1145,11 +1145,12 @@ def setup(options):
 
   check_jdbc_drivers(options)
 
-  print 'Extracting system views...'
-  retcode = extract_views(options)
-  if not retcode == 0:
-    err = 'Error while extracting system views. Exiting'
-    raise FatalException(retcode, err)
+  if not options.skip_view_extraction:
+    print 'Extracting system views...'
+    retcode = extract_views(options)
+    if not retcode == 0:
+      err = 'Error while extracting system views. Exiting'
+      raise FatalException(retcode, err)
 
   # we've already done this, but new files were created so run it one time.
   adjust_directory_permissions(svc_user)

http://git-wip-us.apache.org/repos/asf/ambari/blob/706a3dfe/ambari-server/src/test/python/TestAmbariServer.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestAmbariServer.py b/ambari-server/src/test/python/TestAmbariServer.py
index 526680b..8692030 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -3683,7 +3683,7 @@ class TestAmbariServer(TestCase):
   @patch("ambari_server.serverSetup.service_setup")
   @patch("ambari_server.serverSetup.read_ambari_user")
   @patch("ambari_server.serverSetup.expand_jce_zip_file")
-  def test_setup(self, expand_jce_zip_file_mock, read_ambari_user_mock,
+  def test_setup_linux(self, expand_jce_zip_file_mock, read_ambari_user_mock,
                  service_setup_mock, adjust_dirs_mock, extract_views_mock, proceedJDBCProperties_mock,
is_root_mock,
                  disable_security_enhancements_mock, check_jdbc_drivers_mock, check_ambari_user_mock,
                  download_jdk_mock, configure_os_settings_mock, get_ambari_properties_mock,
@@ -3695,8 +3695,10 @@ class TestAmbariServer(TestCase):
                  remove_file_mock, isfile_mock, exists_mock,
                  run_os_command_mock, get_pw_nam_mock):
     hostname = "localhost"
+    db_admin_user = 'postgres'
     db_name = "db_ambari"
     postgres_schema = "sc_ambari"
+    db_username = 'u_ambari'
     port = "1234"
     oracle_service = "1"
     oracle_service_name = "ambari"
@@ -3750,6 +3752,7 @@ class TestAmbariServer(TestCase):
       run_os_command_1_mock.reset_mock()
       get_YN_input_1_mock.reset_mock()
       update_properties_mock.reset_mock()
+      extract_views_mock.reset_mock()
 
       args = MagicMock()
 
@@ -3770,6 +3773,7 @@ class TestAmbariServer(TestCase):
       args.jdbc_db = None
 
       args.silent = False
+      args.skip_view_extraction = False
 
       return args
 
@@ -3778,11 +3782,8 @@ class TestAmbariServer(TestCase):
     is_root_mock.return_value = False
     try:
       setup(args)
-      self.fail("Should throw exception")
     except FatalException as fe:
-      # Expected
-      self.assertTrue("root-level" in fe.reason)
-      pass
+      self.fail("Should not throw exception, only print warning") # see AMBARI-15245
 
     args = reset_mocks()
 
@@ -3800,14 +3801,20 @@ class TestAmbariServer(TestCase):
     self.assertEqual(None, result)
     self.assertTrue(check_ambari_user_mock.called)
     self.assertEqual(1, run_os_command_mock.call_count)
+    self.assertTrue(extract_views_mock.called)
+
+    # test view extraction is skipped on-demand
+    args = reset_mocks()
+    args.skip_view_extraction = True
+    setup(args)
+    self.assertFalse(extract_views_mock.called)
 
     #Local case
     args = reset_mocks()
 
     # Input values
     db_selection_values = ["1"]
-    postgres_values = [db_name, postgres_schema, hostname]
-
+    postgres_values = [db_admin_user, db_name, postgres_schema, db_username]
     postgres_values = postgres_values[::-1]       # Reverse the list since the input will
be popped
 
     def side_effect(*args, **kwargs):
@@ -3832,7 +3839,8 @@ class TestAmbariServer(TestCase):
     self.assertTrue(run_os_command_1_mock.called)
     self.assertFalse(remove_file_mock.called)
 
-    self.assertTrue("Ambari-DDL-Postgres-EMBEDDED-CREATE.sql" in run_os_command_1_mock.call_args[0][0][3])
+    self.assertTrue("Ambari-DDL-Postgres-CREATE.sql" in run_os_command_1_mock.call_args[0][0][3])
+    self.assertTrue("-U {0}".format(db_username) in run_os_command_1_mock.call_args[0][0][3])
 
     #if DB user name was changed
     args = reset_mocks()
@@ -3841,8 +3849,7 @@ class TestAmbariServer(TestCase):
     is_jdbc_user_changed_mock.return_value = True
 
     db_selection_values = ["1"]
-    postgres_values = [db_name, postgres_schema, hostname]
-
+    postgres_values = [db_admin_user, db_name, postgres_schema, db_username]
     postgres_values = postgres_values[::-1]       # Reverse the list since the input will
be popped
 
     try:
@@ -3862,7 +3869,6 @@ class TestAmbariServer(TestCase):
     get_YN_input_1_mock.return_value = False
     db_selection_values = ["4"]
     postgres_values = [hostname, port, db_name, postgres_schema, user_name]
-
     postgres_values = postgres_values[::-1]       # Reverse the list since the input will
be popped
 
     try:
@@ -3883,8 +3889,10 @@ class TestAmbariServer(TestCase):
     self.assertTrue(proceedJDBCProperties_mock.called)
     self.assertFalse(disable_security_enhancements_mock.called)
     self.assertFalse(check_ambari_user_mock.called)
+
     pass
 
+
   @only_for_platform(PLATFORM_WINDOWS)
   @patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_distro_value))
   @patch("resource_management.core.shell.call")
@@ -3913,7 +3921,7 @@ class TestAmbariServer(TestCase):
   @patch("ambari_server.serverSetup.service_setup")
   @patch("ambari_server.serverSetup.read_ambari_user")
   @patch("ambari_server.serverSetup.expand_jce_zip_file")
-  def test_setup(self, expand_jce_zip_file_mock, read_ambari_user_mock,
+  def test_setup_windows(self, expand_jce_zip_file_mock, read_ambari_user_mock,
                  service_setup_mock, adjust_dirs_mock, extract_views_mock, proceedJDBCProperties_mock,
is_root_mock,
                  disable_security_enhancements_mock, check_jdbc_drivers_mock, check_ambari_user_mock,
check_firewall_mock,
                  download_jdk_mock, configure_os_settings_mock, get_ambari_properties_mock,


Mime
View raw message