From 0b29f8748f9ced70ec2d6d1c5d7660695e5d52aa Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Sun, 24 Jun 2018 18:21:20 +0300 Subject: [PATCH] test: use contents without \n Signed-off-by: Ruslan Kuprieiev --- tests/basic_env.py | 4 ++-- tests/test_repro.py | 29 +++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/tests/basic_env.py b/tests/basic_env.py index c1c90e392..2445f5afd 100644 --- a/tests/basic_env.py +++ b/tests/basic_env.py @@ -16,9 +16,9 @@ class TestDir(TestCase): DATA_CONTENTS = DATA DATA_SUB_CONTENTS = DATA_SUB FOO = 'foo' - FOO_CONTENTS = FOO + '\n' + FOO_CONTENTS = FOO BAR = 'bar' - BAR_CONTENTS = BAR + '\n' + BAR_CONTENTS = BAR CODE = 'code.py' CODE_CONTENTS = 'import sys\nimport shutil\nshutil.copyfile(sys.argv[1], sys.argv[2])' diff --git a/tests/test_repro.py b/tests/test_repro.py index 6356e6c76..27e245fdd 100644 --- a/tests/test_repro.py +++ b/tests/test_repro.py @@ -387,7 +387,22 @@ class TestReproExternalHDFS(TestReproExternalBase): stderr=PIPE) p.communicate() - p = Popen('echo "{}" | HADOOP_USER_NAME=root hadoop fs -put - {}'.format(body.strip(), url), + p = Popen('HADOOP_USER_NAME=root hadoop fs -mkdir -p {}'.format(posixpath.dirname(url)), + shell=True, + executable=os.getenv('SHELL'), + stdin=PIPE, + stdout=PIPE, + stderr=PIPE) + out, err = p.communicate() + if p.returncode != 0: + print(out) + print(err) + self.assertEqual(p.returncode, 0) + + with open('tmp', 'w+') as fd: + fd.write(body) + + p = Popen('HADOOP_USER_NAME=root hadoop fs -copyFromLocal {} {}'.format('tmp', url), shell=True, executable=os.getenv('SHELL'), stdin=PIPE, @@ -438,16 +453,22 @@ class TestReproExternalSSH(TestReproExternalBase): stdin=PIPE, stdout=PIPE, stderr=PIPE) - p.communicate() + out, err = p.communicate() + if p.returncode != 0: + print(out) + print(err) self.assertEqual(p.returncode, 0) - p = Popen('echo "{}" | ssh {} "cat > {}"'.format(body.strip(), dest, path), + p = Popen('echo "{}" | ssh {} "tr -d \'\n\' > {}"'.format(body, dest, path), shell=True, executable=os.getenv('SHELL'), stdin=PIPE, stdout=PIPE, stderr=PIPE) - p.communicate() + out, err = p.communicate() + if p.returncode != 0: + print(out) + print(err) self.assertEqual(p.returncode, 0)