Browse Source

HUE-8285 [oozie] coordinator is not able to strip spaces for input-path or output-path. (#689)

pkuwm 7 years ago
parent
commit
9e8502f314
2 changed files with 8 additions and 0 deletions
  1. 7 0
      apps/oozie/src/oozie/tests.py
  2. 1 0
      apps/oozie/src/oozie/utils.py

+ 7 - 0
apps/oozie/src/oozie/tests.py

@@ -3830,6 +3830,13 @@ class TestUtils(OozieMockBase):
     assert_equal('${output}', smart_path('${output}', {'output': '${path}'}))
     assert_equal('${output_dir}', smart_path('${output_dir}', {'output': '/path/out', 'output_dir': 'hdfs://nn/path/out'}))
 
+    assert_equal('${nameNode}/user/${wf:user()}/out', smart_path(' out', {'output': '/path/out'}))
+    assert_equal('${nameNode}/user/${wf:user()}/out', smart_path('  out  ', {'output': '/path/out'}))
+    assert_equal('hdfs://nn${output}', smart_path(' hdfs://nn${output}', {'output': '/path/out'}))
+    assert_equal('hdfs://nn${output}', smart_path(' hdfs://nn${output}  ', {'output': '/path/out'}))
+    assert_equal('${output}', smart_path('${output}', None))
+
+
   def test_contains_symlink(self):
     assert_false(contains_symlink('out', {'output': '/path/out'}))
     assert_true(contains_symlink('out#out', {'output': '/path/out'}))

+ 1 - 0
apps/oozie/src/oozie/utils.py

@@ -107,6 +107,7 @@ def smart_path(path, mapping=None, is_coordinator=False):
   if mapping is None:
     mapping = {}
 
+  path = path.strip()
   if not path.startswith('$') and not path.startswith('/') and not urlparse.urlsplit(path).scheme:
     path = '/user/%(username)s/%(path)s' % {
         'username': '${coord:user()}' if is_coordinator else '${wf:user()}',