ctubbsii commented on code in PR #76:
URL: https://github.com/apache/accumulo-proxy/pull/76#discussion_r1107560039
##########
src/test/java/org/apache/accumulo/proxy/its/ProxyDurabilityIT.java:
##########
@@ -111,39 +111,40 @@ public void testDurability() throws Exception {
while (!proxyServer.isServing()) {
sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
}
- Client client = new TestProxyClient("localhost", proxyPort,
protocol).proxy();
-
- String tableName = getUniqueNames(1)[0];
- client.createTable(sharedSecret, tableName, true, TimeType.MILLIS);
- assertTrue(c.tableOperations().exists(tableName));
-
- WriterOptions options = new WriterOptions();
- options.setDurability(Durability.NONE);
- String writer = client.createWriter(sharedSecret, tableName, options);
- Map<ByteBuffer,List<ColumnUpdate>> cells = new TreeMap<>();
- ColumnUpdate column = new ColumnUpdate(bytes("cf"), bytes("cq"));
- column.setValue("value".getBytes());
- cells.put(bytes("row"), Collections.singletonList(column));
- client.update(writer, cells);
- client.closeWriter(writer);
- assertEquals(1, count(c, tableName));
- restartTServer();
- assertEquals(0, count(c, tableName));
-
- ConditionalWriterOptions cfg = new ConditionalWriterOptions();
- cfg.setDurability(Durability.SYNC);
- String cwriter = client.createConditionalWriter(sharedSecret, tableName,
cfg);
- ConditionalUpdates updates = new ConditionalUpdates();
- updates.addToConditions(new Condition(new Column(bytes("cf"),
bytes("cq"), bytes(""))));
- updates.addToUpdates(column);
- Map<ByteBuffer,ConditionalStatus> status =
- client.updateRowsConditionally(cwriter,
Collections.singletonMap(bytes("row"), updates));
- assertEquals(ConditionalStatus.ACCEPTED, status.get(bytes("row")));
- assertEquals(1, count(c, tableName));
- restartTServer();
- assertEquals(1, count(c, tableName));
-
- proxyServer.stop();
+ try (var proxyClient = new TestProxyClient("localhost", proxyPort,
protocol)) {
+ Client client = proxyClient.proxy();
+ String tableName = getUniqueNames(1)[0];
+ client.createTable(sharedSecret, tableName, true, TimeType.MILLIS);
+ assertTrue(c.tableOperations().exists(tableName));
+
+ WriterOptions options = new WriterOptions();
+ options.setDurability(Durability.NONE);
+ String writer = client.createWriter(sharedSecret, tableName, options);
+ Map<ByteBuffer,List<ColumnUpdate>> cells = new TreeMap<>();
+ ColumnUpdate column = new ColumnUpdate(bytes("cf"), bytes("cq"));
+ column.setValue("value".getBytes());
+ cells.put(bytes("row"), Collections.singletonList(column));
+ client.update(writer, cells);
+ client.closeWriter(writer);
+ assertEquals(1, count(c, tableName));
+ restartTServer();
+ assertEquals(0, count(c, tableName));
+
+ ConditionalWriterOptions cfg = new ConditionalWriterOptions();
+ cfg.setDurability(Durability.SYNC);
+ String cwriter = client.createConditionalWriter(sharedSecret,
tableName, cfg);
+ ConditionalUpdates updates = new ConditionalUpdates();
+ updates.addToConditions(new Condition(new Column(bytes("cf"),
bytes("cq"), bytes(""))));
+ updates.addToUpdates(column);
+ Map<ByteBuffer,ConditionalStatus> status =
client.updateRowsConditionally(cwriter,
+ Collections.singletonMap(bytes("row"), updates));
+ assertEquals(ConditionalStatus.ACCEPTED, status.get(bytes("row")));
+ assertEquals(1, count(c, tableName));
+ restartTServer();
+ assertEquals(1, count(c, tableName));
+
+ proxyServer.stop();
+ }
Review Comment:
Just in case there's a failure:
```suggestion
} finally {
proxyServer.stop();
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]