mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
Feature/issue 1130 glue database tags (#1248)
* fix(glue): register database tags with tagging API (#1130) * test(glue): add database tagging compatibility coverage (#1130) * test(tagging): allow additional tagged resources (#1130) --------- Co-authored-by: nathan <nathan@debian-dev-small.localdomain>
This commit is contained in:
1 parent
3f8e2600b3
commit
92f4ff1ccf
13 files changed
+303
-6
No files matched your search
@@ -34,8 +34,10 @@ import software.amazon.awssdk.services.glue.model.UpdateTableRequest;
|
||||
import software.amazon.awssdk.services.glue.model.UpdateUserDefinedFunctionRequest;
|
||||
import software.amazon.awssdk.services.glue.model.UserDefinedFunction;
|
||||
import software.amazon.awssdk.services.glue.model.UserDefinedFunctionInput;
|
||||
import software.amazon.awssdk.services.resourcegroupstaggingapi.ResourceGroupsTaggingApiClient;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
@@ -48,12 +50,15 @@ class GlueCatalogTest {
|
||||
private static final String TABLE_NAME = "catalog_table";
|
||||
private static final String SECOND_TABLE_NAME = "catalog_table_second";
|
||||
private static final String FUNCTION_NAME = "catalog_function";
|
||||
private static final String DATABASE_TAGGED_NAME = TestFixtures.uniqueName("catalog_tagged_db");
|
||||
|
||||
private static GlueClient glue;
|
||||
private static ResourceGroupsTaggingApiClient tagging;
|
||||
|
||||
@BeforeAll
|
||||
static void setup() {
|
||||
glue = TestFixtures.glueClient();
|
||||
tagging = TestFixtures.resourceGroupsTaggingApiClient();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
@@ -82,6 +87,12 @@ class GlueCatalogTest {
|
||||
.build());
|
||||
}
|
||||
catch (Exception ignored) {}
|
||||
try {
|
||||
glue.deleteDatabase(DeleteDatabaseRequest.builder()
|
||||
.name(DATABASE_TAGGED_NAME)
|
||||
.build());
|
||||
}
|
||||
catch (Exception ignored) {}
|
||||
try {
|
||||
glue.deleteDatabase(DeleteDatabaseRequest.builder()
|
||||
.name(BATCH_DELETE_DATABASE_NAME)
|
||||
@@ -95,6 +106,7 @@ class GlueCatalogTest {
|
||||
}
|
||||
catch (Exception ignored) {}
|
||||
glue.close();
|
||||
tagging.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -264,6 +276,27 @@ class GlueCatalogTest {
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
void createDatabaseWithTags_tagsReturnedByResourceGroupsTaggingApi() {
|
||||
glue.createDatabase(CreateDatabaseRequest.builder()
|
||||
.databaseInput(DatabaseInput.builder()
|
||||
.name(DATABASE_TAGGED_NAME)
|
||||
.description("catalog compatibility database with tags")
|
||||
.build())
|
||||
.tags(Map.of("Environment", "dev", "Project", "project1"))
|
||||
.build());
|
||||
|
||||
String databaseArn = "arn:aws:glue:us-east-1:000000000000:database/" + DATABASE_TAGGED_NAME;
|
||||
var response = tagging.getResources(b -> b.resourceARNList(databaseArn));
|
||||
|
||||
assertThat(response.resourceTagMappingList()).singleElement().satisfies(mapping -> {
|
||||
assertThat(mapping.resourceARN()).isEqualTo(databaseArn);
|
||||
assertThat(mapping.tags().stream().collect(Collectors.toMap(t -> t.key(), t -> t.value())))
|
||||
.containsEntry("Environment", "dev")
|
||||
.containsEntry("Project", "project1");
|
||||
});
|
||||
}
|
||||
|
||||
private static TableInput tableInput(String description) {
|
||||
return tableInput(TABLE_NAME, description);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user