bigtop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject [4/5] bigtop git commit: ODPI-195 The asssertValueExists method is making a call to String::startsWith using an empty string which results in a passing test when it should not be passing.
Date Wed, 22 Mar 2017 06:02:58 GMT
ODPI-195 The asssertValueExists method is making a call to
String::startsWith using an empty string which results in a passing test
when it should not be passing.


Project: http://git-wip-us.apache.org/repos/asf/bigtop/repo
Commit: http://git-wip-us.apache.org/repos/asf/bigtop/commit/fc407ecc
Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/fc407ecc
Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/fc407ecc

Branch: refs/heads/master
Commit: fc407ecc0f6fcb1235b6041527db717e704609d7
Parents: 515c607
Author: Clint Edwards <clint.edwards@sas.com>
Authored: Thu Oct 20 14:36:28 2016 -0400
Committer: Roman Shaposhnik <rvs@apache.org>
Committed: Tue Mar 21 23:01:18 2017 -0700

----------------------------------------------------------------------
 .../bigtop/itest/httpfs/TestHttpFs.groovy       | 30 +++++++++++++++-----
 1 file changed, 23 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bigtop/blob/fc407ecc/bigtop-tests/test-artifacts/httpfs/src/main/groovy/org/apache/bigtop/itest/httpfs/TestHttpFs.groovy
----------------------------------------------------------------------
diff --git a/bigtop-tests/test-artifacts/httpfs/src/main/groovy/org/apache/bigtop/itest/httpfs/TestHttpFs.groovy
b/bigtop-tests/test-artifacts/httpfs/src/main/groovy/org/apache/bigtop/itest/httpfs/TestHttpFs.groovy
index 78d7a7a..bcec657 100644
--- a/bigtop-tests/test-artifacts/httpfs/src/main/groovy/org/apache/bigtop/itest/httpfs/TestHttpFs.groovy
+++ b/bigtop-tests/test-artifacts/httpfs/src/main/groovy/org/apache/bigtop/itest/httpfs/TestHttpFs.groovy
@@ -40,8 +40,13 @@ public class TestHttpFs {
 
   private static final String HTTPFS_PREFIX = "http://$HTTPFS_PROXY/webhdfs/v1";
   private static final String HTTPFS_SUCCESS = "{\"boolean\":true}";
+  private static final String HTTP_OK = "HTTP/1.1 200 OK";
+  private static final String HTTP_CREATE = "HTTP/1.1 201 Created";
+  private static final String HTTP_TMP_REDIR = "HTTP/1.1 307 TEMPORARY_REDIRECT";
 
-  private static final String DATA_DIR = System.getProperty("data.dir", "text-files");
+  public static final String HTTPFS_SOURCE = "bigtop-tests/test-artifacts/httpfs/src/main/resources/"
+  def httpfs_source = System.getenv("BIGTOP_HOME") + "/" + HTTPFS_SOURCE;
+  def DATA_DIR = httpfs_source + "/" + "text-files";
 
   private static String testHttpFsFolder = "/tmp/httpfssmoke-" + (new Date().getTime());
   private static String testHttpFsFolderRenamed = "$testHttpFsFolder-renamed";
@@ -74,7 +79,17 @@ public class TestHttpFs {
   public void assertValueExists(List<String> values, String expected) {
     boolean exists = false;
     for (String value : values) {
-      if (expected.startsWith(value)) {
+      if (value.length() && expected.startsWith(value)) {
+        exists = true;
+      }
+    }
+    assertTrue(expected + " NOT found!", exists == true);
+  }
+
+  public void assertValueContains(List<String> values, String expected) {
+    boolean exists = false;
+    for (String value : values) {
+      if (value.length() && value.contains(expected)) {
         exists = true;
       }
     }
@@ -119,8 +134,8 @@ public class TestHttpFs {
     assertValueExists(sh.getOut(), HTTPFS_SUCCESS);
     sh.exec("curl -i '$HTTPFS_PREFIX$testHttpFsFolder?user.name=$USERNAME&op=GETFILESTATUS'");
     assertTrue("curl command to create a dir failed", sh.getRet() == 0);
-    assertValueExists(sh.getOut(), HTTPFS_SUCCESS);
-    assertValueExists(sh.getOut(), "DIRECTORY");
+    assertValueContains(sh.getOut(), "DIRECTORY");
+    assertValueExists(sh.getOut(), HTTP_OK);
   }
 
   @Test
@@ -140,13 +155,14 @@ public class TestHttpFs {
       }
     }
     LOG.debug("Datanode location: $datanodeLocation");
-    assertValueExists(sh.getOut(), HTTPFS_SUCCESS);
+    assertValueExists(sh.getOut(), HTTP_TMP_REDIR);
+    assertNotNull("Datanode location not in response", datanodeLocation);
     sh.exec("curl -i -T $DATA_DIR/$filename '$datanodeLocation' --header 'Content-Type:application/octet-stream'");
     assertTrue("curl command to create a file failed", sh.getRet() == 0);
-    assertValueExists(sh.getOut(), HTTPFS_SUCCESS);
+    assertValueExists(sh.getOut(), HTTP_CREATE);
     sh.exec("curl -i -L '$HTTPFS_PREFIX$testHttpFsFolder/$filename?user.name=$USERNAME&op=OPEN'");
     assertTrue("curl command to create a file failed", sh.getRet() == 0);
-    assertValueExists(sh.getOut(), HTTPFS_SUCCESS);
+    assertValueExists(sh.getOut(), HTTP_OK);
     assertValueExists(sh.getOut(), filenameContent);
   }
 }


Mime
View raw message