You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bigtop.apache.org by rv...@apache.org on 2017/02/27 20:30:31 UTC
[05/50] [abbrv] 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.
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/563eb14d
Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/563eb14d
Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/563eb14d
Branch: refs/heads/BIGTOP-1406
Commit: 563eb14d7cbf3a13b1175913b87dc1148540b93d
Parents: 3269577
Author: Clint Edwards <cl...@sas.com>
Authored: Thu Oct 20 14:36:28 2016 -0400
Committer: Roman Shaposhnik <rv...@apache.org>
Committed: Fri Feb 24 12:03:43 2017 -0800
----------------------------------------------------------------------
.../bigtop/itest/httpfs/TestHttpFs.groovy | 30 +++++++++++++++-----
1 file changed, 23 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/bigtop/blob/563eb14d/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);
}
}