Skip to content

Commit 35e4c31

Browse files
authored
HADOOP-17714 ABFS: testBlobBackCompatibility, testRandomRead & WasbAbfsCompatibility tests fail when triggered with default configs (apache#3035)
1 parent 5970c63 commit 35e4c31

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/AbstractAbfsIntegrationTest.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public void setup() throws Exception {
149149
if (!isIPAddress
150150
&& (abfsConfig.getAuthType(accountName) != AuthType.SAS)
151151
&& !abfs.getIsNamespaceEnabled()) {
152-
final URI wasbUri = new URI(abfsUrlToWasbUrl(getTestUrl()));
152+
final URI wasbUri = new URI(abfsUrlToWasbUrl(getTestUrl(), abfsConfig.isHttpsAlwaysUsed()));
153153
final AzureNativeFileSystemStore azureNativeFileSystemStore =
154154
new AzureNativeFileSystemStore();
155155

@@ -355,13 +355,13 @@ protected void touch(Path path) throws IOException {
355355
protected static String wasbUrlToAbfsUrl(final String wasbUrl) {
356356
return convertTestUrls(
357357
wasbUrl, FileSystemUriSchemes.WASB_SCHEME, FileSystemUriSchemes.WASB_SECURE_SCHEME, FileSystemUriSchemes.WASB_DNS_PREFIX,
358-
FileSystemUriSchemes.ABFS_SCHEME, FileSystemUriSchemes.ABFS_SECURE_SCHEME, FileSystemUriSchemes.ABFS_DNS_PREFIX);
358+
FileSystemUriSchemes.ABFS_SCHEME, FileSystemUriSchemes.ABFS_SECURE_SCHEME, FileSystemUriSchemes.ABFS_DNS_PREFIX, false);
359359
}
360360

361-
protected static String abfsUrlToWasbUrl(final String abfsUrl) {
361+
protected static String abfsUrlToWasbUrl(final String abfsUrl, final boolean isAlwaysHttpsUsed) {
362362
return convertTestUrls(
363363
abfsUrl, FileSystemUriSchemes.ABFS_SCHEME, FileSystemUriSchemes.ABFS_SECURE_SCHEME, FileSystemUriSchemes.ABFS_DNS_PREFIX,
364-
FileSystemUriSchemes.WASB_SCHEME, FileSystemUriSchemes.WASB_SECURE_SCHEME, FileSystemUriSchemes.WASB_DNS_PREFIX);
364+
FileSystemUriSchemes.WASB_SCHEME, FileSystemUriSchemes.WASB_SECURE_SCHEME, FileSystemUriSchemes.WASB_DNS_PREFIX, isAlwaysHttpsUsed);
365365
}
366366

367367
private static String convertTestUrls(
@@ -371,15 +371,17 @@ private static String convertTestUrls(
371371
final String fromDnsPrefix,
372372
final String toNonSecureScheme,
373373
final String toSecureScheme,
374-
final String toDnsPrefix) {
374+
final String toDnsPrefix,
375+
final boolean isAlwaysHttpsUsed) {
375376
String data = null;
376-
if (url.startsWith(fromNonSecureScheme + "://")) {
377+
if (url.startsWith(fromNonSecureScheme + "://") && isAlwaysHttpsUsed) {
378+
data = url.replace(fromNonSecureScheme + "://", toSecureScheme + "://");
379+
} else if (url.startsWith(fromNonSecureScheme + "://")) {
377380
data = url.replace(fromNonSecureScheme + "://", toNonSecureScheme + "://");
378381
} else if (url.startsWith(fromSecureScheme + "://")) {
379382
data = url.replace(fromSecureScheme + "://", toSecureScheme + "://");
380383
}
381384

382-
383385
if (data != null) {
384386
data = data.replace("." + fromDnsPrefix + ".",
385387
"." + toDnsPrefix + ".");

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemBackCompat.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ private String getBlobConnectionString() {
7474
+ ";AccountName=" + this.getAccountName().split("\\.")[0]
7575
+ ";AccountKey=" + this.getAccountKey();
7676
}
77+
else if (this.getConfiguration().isHttpsAlwaysUsed()) {
78+
connectionString = "DefaultEndpointsProtocol=https;BlobEndpoint=https://"
79+
+ this.getAccountName().replaceFirst("\\.dfs\\.", ".blob.")
80+
+ ";AccountName=" + this.getAccountName().split("\\.")[0]
81+
+ ";AccountKey=" + this.getAccountKey();
82+
}
7783
else {
7884
connectionString = "DefaultEndpointsProtocol=http;BlobEndpoint=http://"
7985
+ this.getAccountName().replaceFirst("\\.dfs\\.", ".blob.")

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestWasbAbfsCompatibility.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public void testUrlConversion(){
159159
String abfsUrl = "abfs://[email protected]";
160160
String wabsUrl = "wasb://[email protected]";
161161
assertEquals(abfsUrl, wasbUrlToAbfsUrl(wabsUrl));
162-
assertEquals(wabsUrl, abfsUrlToWasbUrl(abfsUrl));
162+
assertEquals(wabsUrl, abfsUrlToWasbUrl(abfsUrl, false));
163163
}
164164

165165
@Test

0 commit comments

Comments
 (0)