Skip to content

Commit

Permalink
Close Accumulo client in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi committed May 15, 2024
1 parent 6bd8801 commit 07d7a17
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.trino.testing.DistributedQueryRunner;
import io.trino.testing.QueryRunner;
import io.trino.tpch.TpchTable;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.hadoop.io.Text;
import org.intellij.lang.annotations.Language;

Expand Down Expand Up @@ -86,7 +87,9 @@ private static synchronized QueryRunner createAccumuloQueryRunner(Map<String, St
if (!tpchLoaded) {
queryRunner.execute("CREATE SCHEMA accumulo.tpch");
copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createSession(), TpchTable.getTables());
server.getClient().tableOperations().addSplits("tpch.orders", ImmutableSortedSet.of(new Text(new LexicoderRowSerializer().encode(BIGINT, 7500L))));
try (AccumuloClient client = server.createClient()) {
client.tableOperations().addSplits("tpch.orders", ImmutableSortedSet.of(new Text(new LexicoderRowSerializer().encode(BIGINT, 7500L))));
}
tpchLoaded = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
@TestInstance(PER_CLASS)
public class TestAccumuloMetadataManager
{
private AccumuloClient client;
private AccumuloMetadataManager metadataManager;
private ZooKeeperMetadataManager zooKeeperMetadataManager;

Expand All @@ -54,7 +55,7 @@ public void setUp()
.setInstance(server.getInstanceName())
.setUsername("root")
.setPassword("secret");
AccumuloClient client = server.getClient();
client = server.createClient();
zooKeeperMetadataManager = new ZooKeeperMetadataManager(config, TESTING_TYPE_MANAGER);
metadataManager = new AccumuloMetadataManager(client, config, zooKeeperMetadataManager, new AccumuloTableManager(client), new IndexLookup(client, new ColumnCardinalityCache(client, config)));
}
Expand All @@ -65,6 +66,8 @@ public void tearDown()
zooKeeperMetadataManager.close();
zooKeeperMetadataManager = null;
metadataManager = null;
client.close();
client = null;
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public String getPassword()
return "secret";
}

public AccumuloClient getClient()
public AccumuloClient createClient()
{
return Accumulo.newClient().to(getInstanceName(), getZooKeepers())
.as(getUser(), getPassword())
Expand Down

0 comments on commit 07d7a17

Please sign in to comment.