Repository: bigtop Updated Branches: refs/heads/master 937a985e4 -> 7a03abb7c
BIGTOP-2233. Fix BIGTOP-2009 Project: http://git-wip-us.apache.org/repos/asf/bigtop/repo Commit: http://git-wip-us.apache.org/repos/asf/bigtop/commit/7a03abb7 Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/7a03abb7 Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/7a03abb7 Branch: refs/heads/master Commit: 7a03abb7c0d284329ab74a0468f9dc2ad26a4daf Parents: 937a985 Author: Konstantin Boudnik <[email protected]> Authored: Tue Jan 12 21:06:46 2016 -0800 Committer: Konstantin Boudnik <[email protected]> Committed: Thu Jan 14 14:31:59 2016 -0800 ---------------------------------------------------------------------- .../itest/hadoop/hdfs/CommonFunctions.groovy | 37 -------------------- .../bigtop/itest/hadoop/hdfs/TestGet.groovy | 11 +++--- .../bigtop/itest/hadoop/hdfs/TestLs.groovy | 24 +++++-------- .../bigtop/itest/hadoop/hdfs/TestMkdir.groovy | 14 +++----- .../bigtop/itest/hadoop/hdfs/TestPut.groovy | 13 ++++--- .../bigtop/itest/hadoop/hdfs/TestStat.groovy | 3 +- .../bigtop/itest/hadoop/hdfs/TestTouchz.groovy | 7 ++-- 7 files changed, 28 insertions(+), 81 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/bigtop/blob/7a03abb7/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/CommonFunctions.groovy ---------------------------------------------------------------------- diff --git a/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/CommonFunctions.groovy b/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/CommonFunctions.groovy deleted file mode 100644 index 1844778..0000000 --- a/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/CommonFunctions.groovy +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * 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. - */ -package org.apache.bigtop.itest.hadoop.hdfs; -import java.util.ArrayList; -import java.util.List; - -public class CommonFunctions { - /** - * lookForGivenString check the given string is present in the list data - */ - private boolean lookForGivenString(List<String> data, - String searchString) { - boolean result = false; - for( String output_String : data) { - if(output_String.contains(searchString)) { - result = true; - break; - } - } - return result; - } -} http://git-wip-us.apache.org/repos/asf/bigtop/blob/7a03abb7/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestGet.groovy ---------------------------------------------------------------------- diff --git a/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestGet.groovy b/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestGet.groovy index 1f04784..0b3698e 100644 --- a/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestGet.groovy +++ b/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestGet.groovy @@ -38,7 +38,6 @@ public class TestGet { private static String testGetInputDir = "testGetInputDir" + date; private static String testGetInputs = "test_data_TestGet" private static String TESTDIR = "/user/$USERNAME/$testGetInputDir"; - private CommonFunctions scripts = new CommonFunctions(); @BeforeClass public static void setUp() { @@ -165,7 +164,7 @@ public class TestGet { String failure_msg = "get: `temp_testget/$testGetInputs/test_2.txt': " + "File exists"; assertTrue("Does get command properly failed to download an existing file?", - scripts.lookForGivenString(sh.getErr(),failure_msg) == true); + sh.getErr().grep(~/${failure_msg}.*/).size() > 0); } @Test @@ -178,7 +177,7 @@ public class TestGet { String failure_msg = "get: `$TESTDIR/$testGetInputs/test_4.txt': " + "No such file or directory"; assertTrue("Does get command failed to download non existing file?", - scripts.lookForGivenString(sh.getErr(),failure_msg) == true); + sh.getErr().grep(~/${failure_msg}.*/).size() > 0); } @Test @@ -213,8 +212,7 @@ public class TestGet { assertTrue("listing files/directories failed on HDFS", sh.getRet() == 0); assertTrue("Does get command download file with crc?", - scripts.lookForGivenString(sh.getOut(), - ".test_4.txt.crc") == true); + sh.getOut().grep(~/.*.test_4.txt.crc.*/).size() > 0); // now compare the contents sh.exec("diff temp_testget/test_optionscrc/test_4.txt $testGetInputs/test_2.txt"); logError(sh); @@ -234,8 +232,7 @@ public class TestGet { assertTrue("listing files/directories failed on HDFS", sh.getRet() == 0); assertTrue("Does get command skipped crc file properly?", - scripts.lookForGivenString(sh.getOut(), - ".test_5.txt.crc") == false); + sh.getOut().grep(~/.*.test_5.txt.crc.*/).size() == 0); // now compare the contents sh.exec("diff $testGetInputs/test_1.txt temp_testget/test_5.txt"); logError(sh); http://git-wip-us.apache.org/repos/asf/bigtop/blob/7a03abb7/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestLs.groovy ---------------------------------------------------------------------- diff --git a/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestLs.groovy b/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestLs.groovy index d6742ac..8754278 100644 --- a/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestLs.groovy +++ b/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestLs.groovy @@ -25,8 +25,6 @@ import org.apache.bigtop.itest.shell.Shell; import org.apache.hadoop.conf.Configuration; import org.apache.bigtop.itest.JarContent; import static org.apache.bigtop.itest.LogErrorsUtils.logError -import java.util.ArrayList; -import java.util.List; public class TestLs { @@ -42,7 +40,6 @@ public class TestLs { testLsInputs; static List<String> TestLs_output = new ArrayList<String>(); static boolean result = false; - private CommonFunctions scripts = new CommonFunctions(); @BeforeClass public static void setUp() { @@ -103,14 +100,13 @@ public class TestLs { // test whether root listing of ls command works sh.exec("hdfs dfs -ls / "); assertTrue("Able to list /user contents?", - scripts.lookForGivenString(sh.getOut(), "/user") == true); + sh.getOut().grep(~/.*\/user/).size() > 0); // test whether a directory exists with the user name under '/user' sh.exec("hdfs dfs -ls /user/$USERNAME "); assertTrue("ls command on HDFS failed", sh.getRet() == 0); assertTrue("Able to list /user contents?", - scripts.lookForGivenString(sh.getOut(), - "/user/"+USERNAME) == true); + sh.getOut().grep(~/.*\/user\/${USERNAME}.*/).size() > 0); } @Test @@ -120,8 +116,7 @@ public class TestLs { sh.exec("hdfs dfs -ls /user/$USERNAME/$testLsInputDir/*"); assertTrue("ls command on HDFS failed", sh.getRet() == 0); assertTrue("Able to list contents with regular expressions?", - scripts.lookForGivenString(sh.getOut(), - "/user/"+user_testinputdir) == true); + sh.getOut().grep(~/.*\/user\/${user_testinputdir}.*/).size() > 0); } @Test @@ -135,8 +130,7 @@ public class TestLs { // verify that default permissions are listed in ls output for directory assertTrue("Does ls outputs directory permissons properly?", - scripts.lookForGivenString(TestLs_output, - "drwxr-xr-x") == true); + TestLs_output.grep(~/.*drwxr-xr-x.*/).size() > 0); result = false; String searchDir = "/user/"+USERNAME+"/"+testLsInputDir; @@ -197,7 +191,7 @@ public class TestLs { assertTrue("Does output Contains only One Line?", TestLs_output.size() == 1); assertTrue("Does output Contains only directory Name?", - scripts.lookForGivenString(TestLs_output, dirName) == true); + TestLs_output.grep(~/.*${dirName}.*/).size() > 0); } @Test @@ -211,15 +205,15 @@ public class TestLs { TestLs_output = sh.getOut(); String fileName = "/user/"+user_testinputdir+"/test_1.txt"; assertTrue("Does ls output contains file " + fileName + "?", - scripts.lookForGivenString(TestLs_output, fileName) == true); + TestLs_output.grep(~/.*${fileName}.*/).size() > 0); fileName = "/user/"+user_testinputdir+"/test_2.txt"; assertTrue("Does ls output contains file " + fileName + "?", - scripts.lookForGivenString(TestLs_output, fileName) == true); + TestLs_output.grep(~/.*${fileName}.*/).size() > 0); fileName = "/user/"+user_testinputdir+"/test.zip"; assertTrue("Does ls output contains file " + fileName + "?", - scripts.lookForGivenString(TestLs_output, fileName) == true); + TestLs_output.grep(~/.*${fileName}.*/).size() > 0); } @Test @@ -234,7 +228,7 @@ public class TestLs { String fileName = "/user/$USERNAME/$testLsInputDir/$testLsInputs/test_3"; assertTrue("Does output contains proper size value for " + fileName + "?", - scripts.lookForGivenString(sh.getOut(), "131.8 K") == true); + sh.getOut().grep(~/.*131.8 K.*/).size() > 0); } } http://git-wip-us.apache.org/repos/asf/bigtop/blob/7a03abb7/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestMkdir.groovy ---------------------------------------------------------------------- diff --git a/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestMkdir.groovy b/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestMkdir.groovy index 604cc82..978c1c5 100644 --- a/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestMkdir.groovy +++ b/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestMkdir.groovy @@ -44,7 +44,6 @@ public class TestMkdir { static List<String> TestMkdir_output = new ArrayList<String>(); static List<String> TestMkdir_error = new ArrayList<String>(); private static String TESTDIR = "/user/$USERNAME/$testMkdirInputDir"; - private CommonFunctions scripts = new CommonFunctions(); static boolean result = false; @BeforeClass @@ -115,8 +114,7 @@ public class TestMkdir { assertTrue("directory not found on HDFS", sh.getRet() == 0); assertTrue("Does $TESTDIR/test1/test2 folder got created with -p option?", - scripts.lookForGivenString(sh.getOut(), - "$TESTDIR/test1/test2") == true); + sh.getOut().grep(~/.*${TESTDIR}\/test1\/test2.*/).size() > 0); } @Test @@ -131,7 +129,7 @@ public class TestMkdir { String errMsg = "mkdir: `$TESTDIR/test2/test2': No such file or directory"; assertTrue("Does $TESTDIR/test2/test2 folder created without -p option?", - scripts.lookForGivenString(sh.getErr(), errMsg) == true); + sh.getErr().grep(~/.*${errMsg}.*/).size() > 0); } @Test @@ -143,7 +141,7 @@ public class TestMkdir { String errMsg = "mkdir: `$TESTDIR': File exists"; assertTrue("Does $TESTDIR folder created", - scripts.lookForGivenString(sh.getErr(), errMsg) == true); + sh.getErr().grep(~/.*${errMsg}.*/).size() > 0); } @Test @@ -157,14 +155,12 @@ public class TestMkdir { assertTrue("ls command failed on HDFS", sh.getRet() == 0); assertTrue("Does $TESTDIR/test2 folder created?", - scripts.lookForGivenString(sh.getOut(), - "$TESTDIR/test2") == true); + sh.getOut().grep(~/.*${TESTDIR}\/test2.*/).size() > 0); sh.exec("hdfs dfs -ls -d $TESTDIR/test3"); assertTrue("ls command failed on HDFS", sh.getRet() == 0); assertTrue("Does $TESTDIR/test3 folder created?", - scripts.lookForGivenString(sh.getOut(), - "$TESTDIR/test3") == true); + sh.getOut().grep(~/.*${TESTDIR}\/test3.*/).size() > 0); } } http://git-wip-us.apache.org/repos/asf/bigtop/blob/7a03abb7/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestPut.groovy ---------------------------------------------------------------------- diff --git a/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestPut.groovy b/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestPut.groovy index 6f34363..1bf843d 100644 --- a/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestPut.groovy +++ b/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestPut.groovy @@ -46,7 +46,6 @@ public class TestPut { static List<String> TestPut_error = new ArrayList<String>(); private static String TESTDIR = "/user/$USERNAME/$testPutInputDir"; static boolean result = false; - private CommonFunctions scripts = new CommonFunctions(); @BeforeClass public static void setUp() { @@ -113,7 +112,7 @@ public class TestPut { sh.getRet() == 0); assertTrue("Able to find uploaded files on hdfs?", - scripts.lookForGivenString(sh.getOut(),"test_3") == true); + sh.getOut().grep(~/.*test_3.*/).size() > 0); result = false; } @@ -149,13 +148,13 @@ public class TestPut { sh.getRet() == 0); assertTrue("Does test_2.txt uploaded properly?", - scripts.lookForGivenString(sh.getOut(),"test_2.txt") == true); + sh.getOut().grep(~/.*test_2.txt.*/).size() > 0); assertTrue("Does test.zip uploaded properly?", - scripts.lookForGivenString(sh.getOut(),"test.zip") == true); + sh.getOut().grep(~/.*test.zip.*/).size() > 0); assertTrue("Does test_3 uploaded properly?", - scripts.lookForGivenString(sh.getOut(),"test_3") == true); + sh.getOut().grep(~/.*test_3.*/).size() > 0); } @Test @@ -168,7 +167,7 @@ public class TestPut { "No such file or directory"; println(searchToken); assertTrue("Able to Upload non-existing file?", - scripts.lookForGivenString(sh.getErr(), searchToken) == true); + sh.getErr().grep(~/.*${searchToken}.*/).size() > 0); } @Test @@ -187,6 +186,6 @@ public class TestPut { String searchToken = "put: `/user/"+USERNAME+"/"+ testPutInputDir+"/test_1.txt': File exists"; assertTrue("Able to Upload non-existing file?", - scripts.lookForGivenString(sh.getErr(), searchToken) == true); + sh.getErr().grep(~/.*${searchToken}.*/).size() > 0); } } http://git-wip-us.apache.org/repos/asf/bigtop/blob/7a03abb7/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestStat.groovy ---------------------------------------------------------------------- diff --git a/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestStat.groovy b/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestStat.groovy index 1e6f89a..d4ef9c6 100644 --- a/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestStat.groovy +++ b/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestStat.groovy @@ -42,7 +42,6 @@ public class TestStat { private static String testStatOutCmp= "testStatOutCmp" + date; private static int repfactor = 2; private static String TESTDIR = "/user/$USERNAME/$testStatInputDir"; - private CommonFunctions scripts = new CommonFunctions(); static boolean result = false; @BeforeClass @@ -217,6 +216,6 @@ public class TestStat { String errMsg = "stat: `$TESTDIR/$testStatInputs': " + "No such file or directory"; assertTrue("Does stat provides correct message for non-existent fodler?", - scripts.lookForGivenString(sh.getErr(), errMsg) == true); + sh.getErr().grep(~/.*${errMsg}.*/).size() > 0); } } http://git-wip-us.apache.org/repos/asf/bigtop/blob/7a03abb7/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestTouchz.groovy ---------------------------------------------------------------------- diff --git a/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestTouchz.groovy b/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestTouchz.groovy index 226dd93..47d720b 100644 --- a/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestTouchz.groovy +++ b/bigtop-tests/test-artifacts/hadoop/src/main/groovy/org/apache/bigtop/itest/hadoop/hdfs/TestTouchz.groovy @@ -44,7 +44,6 @@ public class TestTouchz { private static String TESTDIR = "/user/$USERNAME/$testTouchzInputDir"; private static String user_testinputdir = USERNAME+"/"+testTouchzInputDir+ "/"+testTouchzInputs; - private CommonFunctions scripts = new CommonFunctions(); static List<String> TestTouchz_output = new ArrayList<String>(); static List<String> TestTouchz_error = new ArrayList<String>(); static boolean result = false; @@ -143,7 +142,7 @@ public class TestTouchz { String errMsg = "touchz: `/user/"+user_testinputdir+"': Is a directory"; assertTrue("Does touch failed to create zero length directory?", - scripts.lookForGivenString(sh.getErr(), errMsg) == true); + sh.getErr().grep(~/.*${errMsg}.*/).size() > 0); } @Test @@ -155,7 +154,7 @@ public class TestTouchz { String errMsg = "touchz: `/user/"+USERNAME+"/"+testTouchzInputDir+ "/test_dir2/test_6.txt': No such file or directory"; assertTrue("Does touchz able to create files in non-existent directory?", - scripts.lookForGivenString(sh.getErr(), errMsg) == true); + sh.getErr().grep(~/.*${errMsg}.*/).size() > 0); } @Test @@ -167,7 +166,7 @@ public class TestTouchz { String errMsg = "touchz: `/user/"+user_testinputdir+ "/test_1.txt': Not a zero-length file"; assertTrue("Does touch able to make existing file as zero size file?", - scripts.lookForGivenString(sh.getErr(), errMsg) == true); + sh.getErr().grep(~/.*${errMsg}.*/).size() > 0); } }
