瀏覽代碼

[oozie] Fix unit tests for TestEditor and TestCredentials

krish 10 年之前
父節點
當前提交
57e5060

+ 1 - 1
apps/oozie/src/oozie/tests2.py

@@ -88,7 +88,7 @@ LIMIT $limit"""))
     assert_equal(len('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'), len(job.validated_name))
     
     job.update_name('My <...> 1st W$rkflow [With] (Bad) letter$')
-    assert_equal('My_______1st_W_rkflow__With___Bad__lette', job.validated_name)
+    assert_equal('My_______1st_W$rkflow__With___Bad__lette', job.validated_name)
 
 
 #  def test_workflow_name(self):

+ 9 - 8
desktop/libs/liboozie/src/liboozie/credentials.py

@@ -47,22 +47,23 @@ class Credentials(object):
   def class_to_name_credentials(self):
     return dict((v,k) for k, v in self.credentials.iteritems())
 
-  def get_properties(self, metastore=None):
+  def get_properties(self, hive_properties=None):
     credentials = {}
     from beeswax import hive_site, conf
 
-    if metastore is None:
-      metastore = hive_site.get_metastore()
+    if hive_properties is None:
+      hive_properties = hive_site.get_metastore()
+      hive_properties['hive2.server.principal'] = hive_site.get_hiveserver2_kerberos_principal(conf.HIVE_SERVER_HOST.get())
 
-    if not metastore:
-      metastore = {}
+    if not hive_properties:
+      hive_properties = {}
       LOG.warn('Could not get all the Oozie credentials: hive-site.xml required on the Hue host.')
 
     credentials[self.hive_name] = {
       'xml_name': self.hive_name,
       'properties': [
-         ('hcat.metastore.uri', metastore.get('thrift_uri')),
-         ('hcat.metastore.principal', metastore.get('kerberos_principal')),
+         ('hcat.metastore.uri', hive_properties.get('thrift_uri')),
+         ('hcat.metastore.principal', hive_properties.get('kerberos_principal')),
       ]
     }
 
@@ -70,7 +71,7 @@ class Credentials(object):
       'xml_name': self.hiveserver2_name,
       'properties': [
          ('hive2.jdbc.url', hive_site.hiveserver2_jdbc_url()),
-         ('hive2.server.principal', hive_site.get_hiveserver2_kerberos_principal(conf.HIVE_SERVER_HOST.get())),
+         ('hive2.server.principal', hive_properties.get('hive2.server.principal')),
       ]
     }
 

+ 3 - 2
desktop/libs/liboozie/src/liboozie/credentials_tests.py

@@ -54,9 +54,10 @@ class TestCredentials():
   def test_gen_properties(self):
     creds = Credentials(credentials=TestCredentials.CREDENTIALS.copy())
 
-    metastore = {
+    hive_properties = {
       'thrift_uri': 'thrift://hue-koh-chang:9999',
       'kerberos_principal': 'hive',
+      'hive2.server.principal': 'hive',
     }
 
     finish = (
@@ -82,7 +83,7 @@ class TestCredentials():
              'xml_name': 'hbase',
              'properties': []
           }
-        }, creds.get_properties(metastore))
+        }, creds.get_properties(hive_properties))
     finally:
       for f in finish:
         f()