|
19 | 19 | package org.apache.gravitino.catalog;
|
20 | 20 |
|
21 | 21 | import static org.apache.gravitino.StringIdentifier.ID_KEY;
|
| 22 | +import static org.mockito.ArgumentMatchers.any; |
22 | 23 |
|
23 | 24 | import com.google.common.collect.ImmutableMap;
|
24 | 25 | import com.google.common.collect.Maps;
|
|
40 | 41 | import org.apache.gravitino.exceptions.NoSuchMetalakeException;
|
41 | 42 | import org.apache.gravitino.meta.AuditInfo;
|
42 | 43 | import org.apache.gravitino.meta.BaseMetalake;
|
| 44 | +import org.apache.gravitino.meta.SchemaEntity; |
43 | 45 | import org.apache.gravitino.meta.SchemaVersion;
|
44 | 46 | import org.apache.gravitino.storage.RandomIdGenerator;
|
45 | 47 | import org.apache.gravitino.storage.memory.TestMemoryEntityStore;
|
46 | 48 | import org.apache.gravitino.storage.memory.TestMemoryEntityStore.InMemoryEntityStore;
|
| 49 | +import org.apache.gravitino.utils.PrincipalUtils; |
47 | 50 | import org.junit.jupiter.api.AfterAll;
|
48 | 51 | import org.junit.jupiter.api.AfterEach;
|
49 | 52 | import org.junit.jupiter.api.Assertions;
|
@@ -472,6 +475,34 @@ public void testDropCatalog() {
|
472 | 475 | Assertions.assertNull(CatalogManager.catalogCache.getIfPresent(ident));
|
473 | 476 | }
|
474 | 477 |
|
| 478 | + @Test |
| 479 | + public void testForceDropCatalog() throws Exception { |
| 480 | + NameIdentifier ident = NameIdentifier.of("metalake", "test41"); |
| 481 | + Map<String, String> props = |
| 482 | + ImmutableMap.of("provider", "test", "key1", "value1", "key2", "value2"); |
| 483 | + String comment = "comment"; |
| 484 | + catalogManager.createCatalog(ident, Catalog.Type.RELATIONAL, provider, comment, props); |
| 485 | + SchemaEntity schemaEntity = |
| 486 | + SchemaEntity.builder() |
| 487 | + .withId(RandomIdGenerator.INSTANCE.nextId()) |
| 488 | + .withName("test_schema1") |
| 489 | + .withNamespace(Namespace.of("metalake", "test41")) |
| 490 | + .withAuditInfo( |
| 491 | + AuditInfo.builder() |
| 492 | + .withCreator(PrincipalUtils.getCurrentPrincipal().getName()) |
| 493 | + .withCreateTime(Instant.now()) |
| 494 | + .build()) |
| 495 | + .build(); |
| 496 | + entityStore.put(schemaEntity); |
| 497 | + CatalogManager.CatalogWrapper catalogWrapper = |
| 498 | + Mockito.mock(CatalogManager.CatalogWrapper.class); |
| 499 | + Mockito.doReturn(catalogWrapper).when(catalogManager).loadCatalogAndWrap(ident); |
| 500 | + Mockito.doThrow(new RuntimeException("Failed connect")) |
| 501 | + .when(catalogWrapper) |
| 502 | + .doWithSchemaOps(any()); |
| 503 | + Assertions.assertTrue(catalogManager.dropCatalog(ident, true)); |
| 504 | + } |
| 505 | + |
475 | 506 | @Test
|
476 | 507 | void testAlterMutableProperties() {
|
477 | 508 | NameIdentifier ident = NameIdentifier.of("metalake", "test41");
|
|
0 commit comments