Sfoglia il codice sorgente

[beeswax] Fix tests after the change of interface in Hive 0.9.0

oozie: __str__ prints the representation of submission
oozie: i18n submittion.py
Romain Rigaux 13 anni fa
parent
commit
31b9d03

+ 7 - 6
apps/beeswax/src/beeswax/tests.py

@@ -103,11 +103,12 @@ class TestBeeswaxWithHadoop(BeeswaxSampleProvider):
     response = self.client.get("/beeswax/configuration")
     response_verbose = self.client.get("/beeswax/configuration?include_hadoop=true")
 
-    assert_true("Scratch space for Hive jobs" in response.content)
     assert_true("hive.exec.scratchdir" in response.content)
+    assert_true("hive.exec.scratchdir" in response_verbose.content)
 
+    assert_false("tasktracker.http.threads" in response.content)
     assert_true("tasktracker.http.threads" in response_verbose.content)
-    assert_true("tasktracker.http.threads" not in response.content)
+    assert_true("A base for other temporary directories" in response_verbose.content)
 
   def test_describe_partitions(self):
     response = self.client.get("/beeswax/table/test_partitions/partitions")
@@ -265,7 +266,7 @@ for x in sys.stdin:
   def test_query_with_simple_errors(self):
     """Test handling syntax error"""
     def check_error_in_response(response):
-      assert_true("Parse Error" in response.context["error_message"])
+      assert_true("ParseException" in response.context["error_message"])
       log = response.context['log']
       assert_true(len(log.split('\n')) > 10, 'Captured stack trace')
       assert_true('org.apache.hadoop.hive.ql.parse.ParseException: line' in log,
@@ -318,7 +319,7 @@ for x in sys.stdin:
     try:
       handle = beeswax.db_utils.db_client().executeAndWait(query_msg, "")
     except ttypes.BeeswaxException, bex:
-      assert_equal(bex.errorCode, 11)
+      assert_equal(bex.errorCode, 40000)
       assert_equal(bex.SQLState, "42000")
 
   def test_fetch_configuration(self):
@@ -395,12 +396,12 @@ for x in sys.stdin:
       { "parameterization-x": "'_this_is_not SQL ", "parameterization-y": str(2) }, follow=True)
     assert_true("execute.mako" in response.template)
     log = response.context["log"]
-    assert_true(search_log_line('ql.Driver', 'FAILED: Parse Error', log), log)
+    assert_true(search_log_line('ql.Driver', 'FAILED: ParseException', log), log)
 
   def test_explain_query(self):
     c = self.client
     response = _make_query(c, "SELECT KITTENS ARE TASTY", submission_type="Explain")
-    assert_true("Parse Error" in response.context["error_message"])
+    assert_true("ParseException" in response.context["error_message"])
     CREATE_TABLE = "CREATE TABLE test_explain (foo INT, bar STRING);"
     response = _make_query(c, CREATE_TABLE)
     wait_for_query_to_finish(c, response)

+ 9 - 7
desktop/libs/liboozie/src/liboozie/submittion.py

@@ -19,6 +19,8 @@ import errno
 import logging
 import time
 
+from django.utils.translation import ugettext as _
+
 from desktop.lib.django_util import PopupException
 from hadoop import cluster
 from hadoop.fs.hadoopfs import Hdfs
@@ -43,7 +45,7 @@ class Submission(object):
     else:
       self.properties = {}
 
-  def __unicode__(self):
+  def __str__(self):
     res = "Submission for job '%s' (id %s, owner %s)" % (self.job.name, self.job.id, self.user)
     if self.oozie_id:
       res += " -- " + self.oozie_id
@@ -55,7 +57,7 @@ class Submission(object):
     Returns the oozie job id if all goes well.
     """
     if self.oozie_id is not None:
-      raise Exception("Submission already submitted (Oozie job id %s)" % (self.oozie_id,))
+      raise Exception(_("Submission already submitted (Oozie job id %s)") % (self.oozie_id,))
 
     jobtracker = cluster.get_cluster_addr_for_job_submission()
 
@@ -79,9 +81,9 @@ class Submission(object):
     try:
       deployment_dir = self._create_deployment_dir()
     except Exception, ex:
-      LOG.exception("Failed to access deployment directory")
-      raise PopupException(message="Failed to access deployment directory",
-                           detail=str(ex))
+      msg = _("Failed to access deployment directory")
+      LOG.exception(msg)
+      raise PopupException(message=msg, detail=str(ex))
 
     oozie_xml = self.job.to_xml()
     self._do_as(self.user.username , self._copy_files, deployment_dir, oozie_xml)
@@ -107,13 +109,13 @@ class Submission(object):
     try:
       statbuf = self.fs.stats(path)
       if not statbuf.isDir:
-        msg = "Workflow deployment path is not a directory: %s" % (path,)
+        msg = _("Workflow deployment path is not a directory: %s") % (path,)
         LOG.error(msg)
         raise Exception(msg)
       return path
     except IOError, ex:
       if ex.errno != errno.ENOENT:
-        msg = "Error accessing workflow directory '%s': %s" % (path, ex)
+        msg = _("Error accessing workflow directory '%s': %s") % (path, ex)
         LOG.exception(msg)
         raise IOError(ex.errno, msg)
     # The actual deployment dir should be 0711 owned by the user