You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "DomGarguilo (via GitHub)" <gi...@apache.org> on 2023/02/14 21:43:15 UTC

[GitHub] [accumulo-proxy] DomGarguilo opened a new pull request, #76: Make TestProxyClient AutoClosable

DomGarguilo opened a new pull request, #76:
URL: https://github.com/apache/accumulo-proxy/pull/76

   This PR:
   * makes TestProxyClient extend AutoClosable
   * adds TestProxyClient to try-with-resources blocks, where applicable
   * rename some variables


-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo-proxy] ctubbsii commented on a diff in pull request #76: Make TestProxyClient AutoClosable

Posted by "ctubbsii (via GitHub)" <gi...@apache.org>.
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo-proxy] DomGarguilo merged pull request #76: Make TestProxyClient AutoClosable

Posted by "DomGarguilo (via GitHub)" <gi...@apache.org>.
DomGarguilo merged PR #76:
URL: https://github.com/apache/accumulo-proxy/pull/76


-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org