Browse Source

HUE-1030 [oozie] Java Tasks with both arguments and java options generate incorrect workflow xml

Test added
Disable feedback button on Saving workflow
Romain Rigaux 13 years ago
parent
commit
52e9d4dbc5

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

@@ -705,7 +705,7 @@ class Java(Action):
   java_opts = models.CharField(max_length=256, blank=True, verbose_name=_t('Java options'),
                                help_text=_t('Command-line parameters used to start the JVM that will execute '
                                             'the Java application. Using this element is equivalent to use the mapred.child.java.opts '
-                                            'configuration property.'))
+                                            'configuration property. E.g. -Dexample-property=hue'))
   job_properties = models.TextField(default='[]', verbose_name=_t('Hadoop job properties'),
                                     help_text=_t('For the job configuration (e.g. mapred.job.queue.name=production)'))
   prepares = models.TextField(default="[]", verbose_name=_t('Prepares'),

+ 1 - 1
apps/oozie/src/oozie/templates/editor/edit_workflow.mako

@@ -244,7 +244,7 @@ ${ layout.menubar(section='workflows') }
 
   <div class="form-actions center">
   % if user_can_edit_job:
-    <button data-bind="disable: workflow.read_only, visible: !workflow.read_only(), click: function() { workflow.loading(true); workflow.save({ success: workflow_save_success, error: workflow_save_error }) }" class="btn btn-primary">${ _('Save') }</button>
+    <button data-bind="disable: workflow.read_only, visible: !workflow.read_only(), click: function() { workflow.loading(true); workflow.save({ success: workflow_save_success, error: workflow_save_error }) }" class="btn btn-primary disable-feedback">${ _('Save') }</button>
   % endif
     <a href="${ url('oozie:list_workflows') }" class="btn">${ _('Back') }</a>
   </div>

+ 5 - 4
apps/oozie/src/oozie/templates/editor/gen/workflow-java.xml.mako

@@ -28,14 +28,15 @@
             ${ common.configuration(node.get_properties()) }
 
             <main-class>${ node.main_class }</main-class>
-            % for arg in node.args.split():
-            <arg>${ arg }</arg>
-            % endfor
 
-            % if len(node.java_opts):
+            % if node.java_opts:
             <java-opts>${ node.java_opts }</java-opts>
             % endif
 
+            % for arg in node.args.split():
+            <arg>${ arg }</arg>
+            % endfor
+
             ${ common.distributed_cache(node.get_files(), node.get_archives()) }
         </java>
         <ok to="${ node.get_oozie_child('ok') }"/>

+ 34 - 1
apps/oozie/src/oozie/tests.py

@@ -28,7 +28,6 @@ from django.contrib.auth.models import User
 from django.core.urlresolvers import reverse
 
 from desktop.lib.django_test_util import make_logged_in_client
-from desktop.lib.exceptions_renderable import PopupException
 from desktop.lib.test_utils import grant_access, add_permission
 from jobsub.management.commands import jobsub_setup
 from jobsub.models import OozieDesign
@@ -676,6 +675,40 @@ class TestEditor(OozieMockBase):
         '</workflow-app>'.split(), self.wf.to_xml({'output': '/path'}).split())
 
 
+  def test_workflow_java_gen_xml(self):
+    self.wf.node_set.filter(name='action-name-1').delete()
+
+    action1 = add_node(self.wf, 'action-name-1', 'java', [self.wf.start], {
+        u'name': 'MyTeragen',
+        "description":"Generate N number of records",
+        "main_class":"org.apache.hadoop.examples.terasort.TeraGen",
+        "args":"1000 ${output_dir}/teragen",
+        "files":"[]",
+        "job_xml":"",
+        "java_opts":"-Dexample-property=natty",
+        "jar_path":"/user/hue/oozie/workspaces/lib/hadoop-examples.jar",
+        "prepares":"[]",
+        "archives":"[]",
+    })
+    Link(parent=action1, child=self.wf.end, name="ok").save()
+
+    xml = self.wf.to_xml({'output_dir': '/path'})
+
+    assert_true("""
+    <action name="MyTeragen">
+        <java>
+            <job-tracker>${jobTracker}</job-tracker>
+            <name-node>${nameNode}</name-node>
+            <main-class>org.apache.hadoop.examples.terasort.TeraGen</main-class>
+            <java-opts>-Dexample-property=natty</java-opts>
+            <arg>1000</arg>
+            <arg>${output_dir}/teragen</arg>
+        </java>
+        <ok to="end"/>
+        <error to="kill"/>
+    </action>""" in xml, xml)
+
+
   def test_workflow_shell_gen_xml(self):
     self.wf.node_set.filter(name='action-name-1').delete()
 

+ 1 - 1
apps/oozie/src/oozie/views/api.py

@@ -32,7 +32,7 @@ from oozie.forms import WorkflowForm, ImportJobsubDesignForm, NodeForm, design_f
 from oozie.import_jobsub import convert_jobsub_design
 from oozie.models import Workflow, Node, Start, End, Kill, Mapreduce, Java, Streaming,\
                          Link, Decision, Fork, DecisionEnd, Join,\
-                         NODE_TYPES, ACTION_TYPES, CONTROL_TYPES, _STD_PROPERTIES_JSON
+                         NODE_TYPES, ACTION_TYPES, _STD_PROPERTIES_JSON
 from oozie.decorators import check_job_access_permission, check_job_edition_permission
 from oozie.utils import model_to_dict