You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by he...@apache.org on 2020/11/28 13:16:09 UTC

[hadoop] 21/21: HADOOP-17325. WASB Test Failures

This is an automated email from the ASF dual-hosted git repository.

hexiaoqiao pushed a commit to branch branch-3.2.2
in repository https://gitbox.apache.org/repos/asf/hadoop.git

commit 922f7462d15e31d1bcc1cdfbc0298c3da4aa143b
Author: Steve Loughran <st...@cloudera.com>
AuthorDate: Mon Nov 23 17:22:01 2020 +0000

    HADOOP-17325. WASB Test Failures
    
    Contributed by Ayush Saxena and Steve Loughran
    
    Change-Id: I4bb76815bc1d11d1804dc67bafde68b6a995b974
---
 .../fs/azure/ITestWasbUriAndConfiguration.java       |  4 +---
 .../hadoop/fs/azure/InMemoryBlockBlobStore.java      |  7 ++++++-
 .../apache/hadoop/fs/azure/MockStorageInterface.java | 20 ++++++++++++++++----
 .../org/apache/hadoop/fs/azure/TestBlobMetadata.java |  4 +++-
 4 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/ITestWasbUriAndConfiguration.java b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/ITestWasbUriAndConfiguration.java
index 982e92b..7398e52 100644
--- a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/ITestWasbUriAndConfiguration.java
+++ b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/ITestWasbUriAndConfiguration.java
@@ -655,9 +655,7 @@ public class ITestWasbUriAndConfiguration extends AbstractWasbTestWithTimeout {
       // because the mock container does not exist, this call is expected to fail.
       intercept(IllegalArgumentException.class,
               "java.net.UnknownHostException",
-              () -> {
-                fs0.getCanonicalServiceName();
-              });
+              () -> fs0.getCanonicalServiceName());
 
       conf.setBoolean(RETURN_URI_AS_CANONICAL_SERVICE_NAME_PROPERTY_NAME, true);
       FileSystem fs1 = FileSystem.newInstance(defaultUri, conf);
diff --git a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/InMemoryBlockBlobStore.java b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/InMemoryBlockBlobStore.java
index b8971c4..7ddeabe 100644
--- a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/InMemoryBlockBlobStore.java
+++ b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/InMemoryBlockBlobStore.java
@@ -25,6 +25,8 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
 
+import static java.util.Objects.requireNonNull;
+
 /**
  * A simple memory key-value store to help mock the Windows Azure Storage
  * implementation for unit testing.
@@ -163,7 +165,10 @@ public class InMemoryBlockBlobStore {
 
   @SuppressWarnings("unchecked")
   public synchronized HashMap<String, String> getMetadata(String key) {
-    return (HashMap<String, String>) blobs.get(key).metadata.clone();
+    Entry entry = requireNonNull(blobs.get(key), "entry for " + key);
+    return (HashMap<String, String>) requireNonNull(entry.metadata,
+        "metadata for " + key)
+        .clone();
   }
 
   public synchronized HashMap<String, String> getContainerMetadata() {
diff --git a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/MockStorageInterface.java b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/MockStorageInterface.java
index 1739cff..6d11207 100644
--- a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/MockStorageInterface.java
+++ b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/MockStorageInterface.java
@@ -37,6 +37,7 @@ import java.util.List;
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.net.URLCodec;
 import org.apache.commons.lang3.NotImplementedException;
+import org.apache.hadoop.fs.Path;
 import org.apache.http.client.utils.URIBuilder;
 
 import com.microsoft.azure.storage.AccessCondition;
@@ -137,9 +138,20 @@ public class MockStorageInterface extends StorageInterface {
 
   private static URI convertKeyToEncodedUri(String key) {
     try {
-      return new URIBuilder().setPath(key).build();
+     Path p = new Path(key);
+     URI unEncodedURI = p.toUri();
+     return new URIBuilder().setPath(unEncodedURI.getPath())
+         .setScheme(unEncodedURI.getScheme()).build();
     } catch (URISyntaxException e) {
-      throw new AssertionError("Failed to encode key: " + key);
+      int i = e.getIndex();
+      String details;
+      if (i >= 0) {
+        details = " -- \"" + e.getInput().charAt(i) + "\"";
+      } else {
+        details = "";
+      }
+      throw new AssertionError("Failed to encode key: " + key
+          + ":  " + e + details);
     }
   }
 
@@ -148,8 +160,8 @@ public class MockStorageInterface extends StorageInterface {
       throws URISyntaxException, StorageException {
     String fullUri;
     URIBuilder builder = new URIBuilder(baseUriString);
-    fullUri = builder.setPath(builder.getPath() + "/" + name).toString();
-
+    String path = builder.getPath() == null ? "" : builder.getPath() + "/";
+    fullUri = builder.setPath(path + name).toString();
     MockCloudBlobContainerWrapper container = new MockCloudBlobContainerWrapper(
         fullUri, name);
     // Check if we have a pre-existing container with that name, and prime
diff --git a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/TestBlobMetadata.java b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/TestBlobMetadata.java
index 30c1028..832e7ec 100644
--- a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/TestBlobMetadata.java
+++ b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/TestBlobMetadata.java
@@ -202,8 +202,10 @@ public class TestBlobMetadata extends AbstractWasbTestWithTimeout {
     Path selfishFile = new Path("/noOneElse");
     fs.create(selfishFile, justMe, true, 4096, fs.getDefaultReplication(),
         fs.getDefaultBlockSize(), null).close();
+    String mockUri = AzureBlobStorageTestAccount.toMockUri(selfishFile);
+    assertNotNull("converted URI", mockUri);
     HashMap<String, String> metadata = backingStore
-        .getMetadata(AzureBlobStorageTestAccount.toMockUri(selfishFile));
+        .getMetadata(mockUri);
     assertNotNull(metadata);
     String storedPermission = metadata.get("hdi_permission");
     assertEquals(getExpectedPermissionString("rw-------"), storedPermission);


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org