Skip to content

Commit

Permalink
make 'cloud.name' and 'cloud.region-code' mutable.
Browse files Browse the repository at this point in the history
  • Loading branch information
LindaSummer committed Sep 26, 2024
1 parent 61a69f9 commit 95c6964
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ void testPropertyMeta() {
Assertions.assertFalse(propertyEntryMap.get(CHECK_INTERVAL_SEC).isRequired());
Assertions.assertFalse(propertyEntryMap.get(FETCH_TIMEOUT_SEC).isRequired());
Assertions.assertFalse(propertyEntryMap.get(CLOUD_NAME).isRequired());
Assertions.assertFalse(propertyEntryMap.get(CLOUD_NAME).isImmutable());
Assertions.assertFalse(propertyEntryMap.get(CLOUD_REGION_CODE).isRequired());
Assertions.assertFalse(propertyEntryMap.get(CLOUD_REGION_CODE).isImmutable());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,34 @@ void testUpdateCatalogWithNullableComment() {

metalake.dropCatalog(catalogName);
}

@Test
public void testAlterCatalogProperties() {
String cloudName = "aws";
String alterCloudName = "azure";
String regionCode = "us-east-1";
String alterRegionCode = "us-west-2";

String catalogName = GravitinoITUtils.genRandomName("test_catalog");
ImmutableMap<String, String> props =
ImmutableMap.of(Catalog.CLOUD_NAME, cloudName, Catalog.CLOUD_REGION_CODE, regionCode);
Catalog catalog =
metalake.createCatalog(
catalogName, Catalog.Type.FILESET, "hadoop", "catalog comment", props);
Assertions.assertTrue(metalake.catalogExists(catalogName));
Assertions.assertFalse(catalog.properties().isEmpty());
Assertions.assertEquals(cloudName, catalog.properties().get(Catalog.CLOUD_NAME));
Assertions.assertEquals(regionCode, catalog.properties().get(Catalog.CLOUD_REGION_CODE));

Catalog alteredCatalog =
metalake.alterCatalog(
catalogName,
CatalogChange.setProperty(Catalog.CLOUD_NAME, alterCloudName),
CatalogChange.setProperty(Catalog.CLOUD_REGION_CODE, alterRegionCode));

Assertions.assertEquals(alterCloudName, alteredCatalog.properties().get(Catalog.CLOUD_NAME));
Assertions.assertEquals(
alterRegionCode, alteredCatalog.properties().get(Catalog.CLOUD_REGION_CODE));
metalake.dropCatalog(catalogName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ public abstract class BaseCatalogPropertiesMetadata extends BasePropertiesMetada
CLOUD_NAME,
"The cloud that the catalog is running on",
false /* required */,
true /* immutable */,
false /* immutable */,
Catalog.CloudName.class,
null /* The default value does not work because if the user does not set it, this property will not be displayed */,
false /* hidden */,
false /* reserved */),
PropertyEntry.stringOptionalPropertyEntry(
CLOUD_REGION_CODE,
"The region code of the cloud that the catalog is running on",
false /* required */,
false /* immutable */,
null /* The default value does not work because if the user does not set it, this property will not be displayed */,
false /* hidden */)),
PropertyEntry::getName);
Expand Down

0 comments on commit 95c6964

Please sign in to comment.