瀏覽代碼

HUE-5504 [oozie] Only use JDBC URL from hive2 action when hardcoded

JDBC URL in hive2 action can also be passed as a variable parameter
ex: ${wf:actionData('shell-31b5')['hiveserver']}. There is no way to
get the _HOST from this variable on hue side.
krish 8 年之前
父節點
當前提交
5724b31f7c

+ 2 - 1
desktop/libs/liboozie/src/liboozie/submission2.py

@@ -356,7 +356,8 @@ STORED AS TEXTFILE %s""" % (self.properties.get('send_result_path'), '\n\n\n'.jo
       for action in self.job.nodes:
         if action.data['type'] in ('hive2', 'hive-document') and \
                         credentials.hiveserver2_name in self.properties['credentials'] and \
-                        action.data['properties']['jdbc_url']:
+                        action.data['properties']['jdbc_url'] and \
+                        len(action.data['properties']['jdbc_url'].split('//')) > 1:
           try:
             hive_jdbc_url = action.data['properties']['jdbc_url']
             hive_host_from_action = hive_jdbc_url.split('//')[1].split(':')[0]

+ 40 - 0
desktop/libs/liboozie/src/liboozie/submittion2_tests.py

@@ -366,6 +366,46 @@ oozie.wf.application.path=${nameNode}/user/${user.name}/${examplesRoot}/apps/pig
 
       assert_raises(PopupException,  submission._update_credentials_from_hive_action, creds)
 
+    finally:
+      for f in finish:
+        f()
+
+  def test_update_credentials_from_hive_action_when_jdbc_url_is_variable(self):
+
+    class TestJob():
+      XML_FILE_NAME = 'workflow.xml'
+
+      def __init__(self):
+        self.deployment_dir = '/tmp/test'
+        self.nodes = [
+            Node({'id': '1', 'type': 'hive-document', 'properties': {'jdbc_url': u"${wf:actionData('shell-31b5')['hiveserver']}", 'password': u'test'}})
+        ]
+
+    user = User.objects.get(username='test')
+    submission = Submission(user, job=TestJob(), fs=MockFs(logical_name='fsname'), jt=MockJt(logical_name='jtname'))
+
+    finish = (
+      beeswax.conf.HIVE_SERVER_HOST.set_for_testing('hue-koh-chang'),
+      beeswax.conf.HIVE_SERVER_PORT.set_for_testing(12345),
+    )
+
+    try:
+      creds = Credentials(credentials=TestCredentials.CREDENTIALS.copy())
+      hive_properties = {
+        'thrift_uri': 'thrift://first-url:9999',
+        'kerberos_principal': 'hive',
+        'hive2.server.principal': 'hive/hive2_host@test-realm.com',
+      }
+
+      submission.properties['credentials'] = creds.get_properties(hive_properties)
+      submission._update_credentials_from_hive_action(creds)
+
+      assert_equal(submission.properties['credentials'][creds.hiveserver2_name]['properties'], [
+            ('hive2.jdbc.url', u'jdbc:hive2://hue-koh-chang:12345/default'),
+            ('hive2.server.principal', u'hive/hive2_host@test-realm.com')
+          ]
+      )
+
     finally:
       for f in finish:
         f()