Permalink
Browse files

[oozie] Add specific error message when Oozie is not running

Same for JobSub.
Adding a test.
No test for JobSub as we have HUE-896.
Cleaning trailing spaces and prints.
  • Loading branch information...
1 parent 01fa6a3 commit ec9c8ca33e422c6ec3aa89c1aee201a6664cbb5a @romainr romainr committed Nov 14, 2012
@@ -275,8 +275,10 @@ def submit_design(request, design_id):
submission = submit.Submission(design_obj, request.fs)
jobid = submission.run()
except RestException, ex:
- raise PopupException(_("Error submitting design %(id)s") % {'id': design_id},
- detail=ex.message)
+ detail = ex.message
+ if 'urlopen error' in ex.message:
+ detail = '%s: %s' % (_('The Oozie server is not running'), detail)
+ raise PopupException(_("Error submitting design %(id)s") % {'id': design_id}, detail=detail)
# Save the submission record
job_record = models.JobHistory(owner=request.user,
job_id=jobid,
@@ -5,22 +5,22 @@
from django.db import models
class Migration(SchemaMigration):
-
+
def forwards(self, orm):
-
+
# Adding model 'Decision'
db.create_table('oozie_decision', (
('node_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['oozie.Node'], unique=True, primary_key=True)),
))
db.send_create_signal('oozie', ['Decision'])
-
-
+
+
def backwards(self, orm):
-
+
# Deleting model 'Decision'
db.delete_table('oozie_decision')
-
-
+
+
models = {
'auth.group': {
'Meta': {'object_name': 'Group'},
@@ -266,5 +266,5 @@ def backwards(self, orm):
'start': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'start_workflow'", 'blank': 'True', 'null': 'True', 'to': "orm['oozie.Start']"})
}
}
-
+
complete_apps = ['oozie']
@@ -186,7 +186,7 @@
</form>
</div>
-% if template:
+% if template:
</script>
% endif
</%def>
@@ -148,7 +148,7 @@
</form>
</div>
-% if template:
+% if template:
</script>
% endif
</%def>
@@ -14,11 +14,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+
try:
import json
except ImportError:
import simplejson as json
-import copy
import logging
import re
@@ -32,6 +32,7 @@
from jobsub.management.commands import jobsub_setup
from jobsub.models import OozieDesign
from liboozie import oozie_api
+from liboozie.conf import OOZIE_URL
from liboozie.oozie_api_test import OozieServerProvider
from liboozie.types import WorkflowList, Workflow as OozieWorkflow, Coordinator as OozieCoordinator,\
CoordinatorList, WorkflowAction
@@ -1115,6 +1116,20 @@ def test_submit_distcp_action(self):
assert_equal('SUCCEEDED', job.status)
+class TestDashboardNoMocking:
+
+ def test_oozie_not_running_message(self):
+ c = make_logged_in_client(is_superuser=False)
+ grant_access("test", "test", "oozie")
+
+ finish = OOZIE_URL.set_for_testing('http://not_localhost:11000/bad')
+ try:
+ response = c.get(reverse('oozie:list_oozie_workflows'))
+ assert_true('The Oozie server is not running' in response.content, response.content)
+ finally:
+ finish()
+
+
class TestDashboard(OozieMockBase):
def test_manage_workflow_dashboard(self):
@@ -38,7 +38,7 @@ def workflow_to_dict(workflow):
for index, node in enumerate(node_list):
nodes[index]['child_links'] = [model_to_dict(link) for link in node.get_all_children_links()]
-
+
workflow_dict['nodes'] = nodes
return workflow_dict
@@ -137,7 +137,7 @@ def update_workflow_nodes(workflow, json_nodes, id_map):
setattr(node, key, json.dumps(json_node[key]))
else:
setattr(node, key, json_node[key])
-
+
node.workflow = workflow
node.save()
@@ -176,7 +176,7 @@ def workflow_save(request, workflow):
for json_node in json_nodes:
child_links = json_node['child_links']
Link.objects.filter(parent=nodes[index]).delete()
-
+
for child_link in child_links:
link = Link()
link.id = getattr(child_link, 'id', None)
@@ -209,7 +209,7 @@ def _workflow(request, workflow):
for index in range(0, len(node_list)):
nodes[index]['child_links'] = [model_to_dict(link) for link in node_list[index].get_all_children_links()]
-
+
workflow_dict['nodes'] = nodes
response['status'] = 0
@@ -77,7 +77,10 @@ def decorate(request, *args, **kwargs):
try:
return view_func(request, *args, **kwargs)
except RestException, ex:
- raise PopupException(_('Sorry, an error with Oozie happened.'), detail=ex._headers.get('oozie-error-message', ex))
+ detail = ex._headers.get('oozie-error-message', ex)
+ if 'urlopen error' in str(detail):
+ detail = '%s: %s' % (_('The Oozie server is not running'), detail)
+ raise PopupException(_('Sorry, an error with Oozie happened.'), detail=detail)
return wraps(view_func)(decorate)
@@ -193,8 +193,10 @@ def _submit_workflow(request, workflow, mapping):
History.objects.create_from_submission(submission)
return job_id
except RestException, ex:
- raise PopupException(_("Error submitting workflow %s") % (workflow,),
- detail=ex._headers.get('oozie-error-message', ex))
+ detail = ex._headers.get('oozie-error-message', ex)
+ if 'urlopen error' in str(detail):
+ detail = '%s: %s' % (_('The Oozie server is not running'), detail)
+ raise PopupException(_("Error submitting workflow %s") % (workflow,), detail=detail)
request.info(_('Workflow submitted'))
return redirect(reverse('oozie:list_oozie_workflow', kwargs={'job_id': job_id}))
@@ -31,7 +31,6 @@
from liboozie.conf import OOZIE_URL
-_oozie_running = False
_oozie_lock = threading.Lock()
LOG = logging.getLogger(__name__)
@@ -45,6 +44,7 @@ class OozieServerProvider(object):
OOZIE_HOME = get_run_root('ext/oozie/oozie')
requires_hadoop = True
+ is_oozie_running = False
@classmethod
def setup_class(cls):
@@ -109,11 +109,11 @@ def _setup_sharelib(cls):
@classmethod
def _get_shared_oozie_server(cls):
- global _oozie_running
callback = lambda: None
_oozie_lock.acquire()
- if not _oozie_running:
+
+ if not OozieServerProvider.is_oozie_running:
LOG.info('\nStarting a Mini Oozie. Requires "tools/jenkins/jenkins.sh" to be previously ran.\n')
LOG.info('See https://issues.cloudera.org/browse/HUE-861\n')
@@ -156,7 +156,8 @@ def kill():
if not started:
raise Exception("Oozie server took too long to come up.")
- _oozie_running = True
+ OozieServerProvider.is_oozie_running = True
+
def shutdown():
for f in finish:
f()

0 comments on commit ec9c8ca

Please sign in to comment.