Преглед изворни кода

Fix smoke tests

- security config is only available when MR cluster is available.
- should not be adding "None" to environment in shell.
Abraham Elmahrek пре 12 година
родитељ
комит
8544272d17
2 измењених фајлова са 27 додато и 25 уклоњено
  1. 21 22
      apps/beeswax/src/beeswax/tests.py
  2. 6 3
      apps/shell/src/shell/shellmanager.py

+ 21 - 22
apps/beeswax/src/beeswax/tests.py

@@ -109,6 +109,27 @@ class TestBeeswaxWithHadoop(BeeswaxSampleProvider):
     assert_equal(beeswax.models.QueryHistory.STATE[last_state], state)
     return history.id
 
+  def test_beeswax_get_kerberos_security():
+    principal = get_query_server_config('beeswax')['principal']
+    assert_true(principal.startswith('hue/'), principal)
+
+    principal = get_query_server_config('impala')['principal']
+    assert_true(principal.startswith('impala/'), principal)
+
+    beeswax_query_server = {'server_name': 'beeswax', 'principal': 'hue'}
+    impala_query_server = {'server_name': 'impala', 'principal': 'impala'}
+
+    assert_equal((False, 'hue'), BeeswaxClient.get_security(beeswax_query_server))
+    assert_equal((False, 'impala'), BeeswaxClient.get_security(impala_query_server))
+
+    cluster_conf = hadoop.cluster.get_cluster_conf_for_job_submission()
+    finish = cluster_conf.SECURITY_ENABLED.set_for_testing(True)
+    try:
+      assert_equal((True, 'hue'), BeeswaxClient.get_security(beeswax_query_server))
+      assert_equal((True, 'impala'), BeeswaxClient.get_security(impala_query_server))
+    finally:
+      finish()
+
   def test_query_with_error(self):
     """
     Creating a table "again" should not work; error should be displayed.
@@ -1494,28 +1515,6 @@ def test_search_log_line():
   assert_false(search_log_line('ql.Driver', 'FAILED: Parse Error', logs))
 
 
-def test_beeswax_get_kerberos_security():
-  principal = get_query_server_config('beeswax')['principal']
-  assert_true(principal.startswith('hue/'), principal)
-
-  principal = get_query_server_config('impala')['principal']
-  assert_true(principal.startswith('impala/'), principal)
-
-  beeswax_query_server = {'server_name': 'beeswax', 'principal': 'hue'}
-  impala_query_server = {'server_name': 'impala', 'principal': 'impala'}
-
-  assert_equal((False, 'hue'), BeeswaxClient.get_security(beeswax_query_server))
-  assert_equal((False, 'impala'), BeeswaxClient.get_security(impala_query_server))
-
-  cluster_conf = hadoop.cluster.get_cluster_conf_for_job_submission()
-  finish = cluster_conf.SECURITY_ENABLED.set_for_testing(True)
-  try:
-    assert_equal((True, 'hue'), BeeswaxClient.get_security(beeswax_query_server))
-    assert_equal((True, 'impala'), BeeswaxClient.get_security(impala_query_server))
-  finally:
-    finish()
-
-
 class MockDbms:
 
   def __init__(self, client, server_type):

+ 6 - 3
apps/shell/src/shell/shellmanager.py

@@ -84,8 +84,8 @@ class Shell(object):
     except tty.error:
       LOG.debug("Could not set parent fd to raw mode, user will see duplicated input.")
 
-    subprocess_env[constants.HOME] = user_info.pw_dir
-    command_to_use = [_SETUID_PROG, str(user_info.pw_uid), str(user_info.pw_gid)]
+    subprocess_env[constants.HOME] = str(user_info.pw_dir)
+    command_to_use = [str(_SETUID_PROG), str(user_info.pw_uid), str(user_info.pw_gid)]
     command_to_use.extend(shell_command)
 
     delegation_token_files = self._get_delegation_tokens(username, delegation_token_dir)
@@ -421,7 +421,10 @@ class ShellManager(object):
 
     shell_types = [] # List of available shell types. For each shell type, we have a nice name (e.g. "Python Shell") and a short name (e.g. "python")
     for item in shell.conf.SHELL_TYPES.keys():
-      env_for_shell = { constants.HADOOP_MAPRED_HOME: mapred_home }
+      if mapred_home:
+        env_for_shell = { constants.HADOOP_MAPRED_HOME: mapred_home }
+      else:
+        env_for_shell = {}
       command = shell.conf.SHELL_TYPES[item].command.get().strip().split()
       nice_name = shell.conf.SHELL_TYPES[item].nice_name.get().strip()
       executable_exists = utils.executable_exists(command)