Skip to content

Commit

Permalink
stable tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-maynard committed Oct 4, 2024
1 parent fac2d72 commit 0647980
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import java.util.Locale;

import org.jetbrains.annotations.NotNull;

/**
Expand All @@ -42,7 +44,7 @@ public String getFileIoImplClassName() {

@Override
public void validatePrefixForStorageType(String loc) {
if (!loc.startsWith(getStorageType().getPrefix())
if (getStorageType().getPrefixes().stream().noneMatch(p -> loc.toLowerCase(Locale.ROOT).startsWith(p))
&& !loc.startsWith("file:/")
&& !loc.startsWith("/")
&& !loc.equals("*")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public enum StorageType {
FILE("file://"),
;

final List<String> prefixes;
private final List<String> prefixes;

StorageType(String prefix) {
this.prefixes = List.of(prefix);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,6 @@ public void testGetSubscopedCredsInlinePolicyWithEmptyReadAndWrite() {

private static @NotNull String s3Path(
String bucket, String keyPrefix, PolarisStorageConfigurationInfo.StorageType storageType) {
return storageType.getPrefix() + bucket + "/" + keyPrefix;
return storageType.getPrefixes().get(0) + bucket + "/" + keyPrefix;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,18 @@ public void testLocation() {
Assertions.assertThat(azureLocation.getFilePath()).isEqualTo("myfile");
}

@Test
public void testWasbLocation() {
String uri = "wasb://container@storageaccount.blob.core.windows.net/myfile";
AzureLocation azureLocation = new AzureLocation(uri);
Assertions.assertThat(azureLocation.getContainer()).isEqualTo("container");
Assertions.assertThat(azureLocation.getStorageAccount()).isEqualTo("storageaccount");
Assertions.assertThat(azureLocation.getEndpoint()).isEqualTo("blob.core.windows.net");
Assertions.assertThat(azureLocation.getFilePath()).isEqualTo("myfile");
}

@Test
public void testLocation_negative_cases() {
Assertions.assertThatThrownBy(
() ->
new AzureLocation("wasbs://container@storageaccount.blob.core.windows.net/myfile"))
.isInstanceOf(IllegalArgumentException.class);
Assertions.assertThatThrownBy(
() -> new AzureLocation("abfss://storageaccount.blob.core.windows.net/myfile"))
.isInstanceOf(IllegalArgumentException.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void testInvalidAllowedLocationPrefix() {
Assertions.assertThatThrownBy(() -> CatalogEntity.fromCatalog(awsCatalog))
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining(
"Location prefix not allowed: 'unsupportPrefix://mybucket/path', expected prefix: 's3://'");
"Location prefix not allowed: 'unsupportPrefix://mybucket/path', expected prefixes");

// Invalid azure prefix
AzureStorageConfigInfo azureStorageConfigModel =
Expand All @@ -76,7 +76,7 @@ public void testInvalidAllowedLocationPrefix() {
.build();
Assertions.assertThatThrownBy(() -> CatalogEntity.fromCatalog(azureCatalog))
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Invalid azure adls location uri unsupportPrefix://mybucket/path");
.hasMessageContaining("Invalid azure location uri unsupportPrefix://mybucket/path");

// invalid gcp prefix
GcpStorageConfigInfo gcpStorageConfigModel =
Expand All @@ -94,7 +94,7 @@ public void testInvalidAllowedLocationPrefix() {
Assertions.assertThatThrownBy(() -> CatalogEntity.fromCatalog(gcpCatalog))
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining(
"Location prefix not allowed: 'unsupportPrefix://mybucket/path', expected prefix: 'gs://'");
"Location prefix not allowed: 'unsupportPrefix://mybucket/path', expected prefixes");
}

@Test
Expand Down

0 comments on commit 0647980

Please sign in to comment.