Skip to content

Commit

Permalink
Allow using custom catalog store with TestingTrinoServer
Browse files Browse the repository at this point in the history
  • Loading branch information
hashhar committed Aug 27, 2024
1 parent 2d55fdb commit 0c5b0cf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,10 @@ private TestingTrinoServer(

if (coordinator) {
if (catalogMangerKind == CatalogMangerKind.DYNAMIC) {
serverProperties.put("catalog.store", "memory");
Optional<String> catalogStore = Optional.ofNullable(properties.get("catalog.store"));
if (catalogStore.isEmpty()) {
serverProperties.put("catalog.store", "memory");
}
}
serverProperties.put("failure-detector.enabled", "false");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.google.inject.Key;
import io.trino.connector.ConnectorServicesProvider;
import io.trino.connector.CoordinatorDynamicCatalogManager;
import io.trino.connector.FileCatalogStore;
import io.trino.connector.InMemoryCatalogStore;
import io.trino.connector.StaticCatalogManager;
import io.trino.connector.WorkerDynamicCatalogManager;
Expand Down Expand Up @@ -63,4 +64,26 @@ void testSetCatalogManagementToStatic()
.isInstanceOf(StaticCatalogManager.class);
}
}

@Test
void testDefaultCatalogStore()
throws IOException
{
try (TestingTrinoServer server = TestingTrinoServer.builder().build()) {
assertThat(server.getInstance(Key.get(CatalogStore.class)))
.isInstanceOf(InMemoryCatalogStore.class);
}
}

@Test
void testExplicitCatalogStore()
throws IOException
{
try (TestingTrinoServer server = TestingTrinoServer.builder()
.addProperty("catalog.store", "file")
.build()) {
assertThat(server.getInstance(Key.get(CatalogStore.class)))
.isInstanceOf(FileCatalogStore.class);
}
}
}

0 comments on commit 0c5b0cf

Please sign in to comment.