keith-turner commented on a change in pull request #969: [WIP] Issue-967
URL: https://github.com/apache/fluo/pull/969#discussion_r152164105
 
 

 ##########
 File path: 
modules/integration/src/test/java/org/apache/fluo/integration/impl/TransactionImplIT.java
 ##########
 @@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to you under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+
+package org.apache.fluo.integration.impl;
+
+import org.apache.fluo.api.client.Transaction;
+import org.apache.fluo.api.data.Column;
+import org.apache.fluo.integration.ITBaseImpl;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Tests TransactionImpl classes
+ */
+public class TransactionImplIT extends ITBaseImpl {
+
+  @Test
+  public void testBasic() {
+    try (Transaction tx = client.newTransaction()) {
+      tx.set("row1", new Column("col1"), "val1");
+      tx.set("row2", new Column("col2"), "val2");
+      tx.set("row3", new Column("col3"), "val3");
+
+      tx.commit();
+    }
+
+    try (Transaction tx = client.newTransaction()) {
+      Assert.assertEquals("val1", tx.getsAsync("row1", new 
Column("col1")).get());
+      Assert.assertEquals("val2", tx.getsAsync("row2", new Column("col2"), 
"foo").get());
+      Assert.assertEquals("val3", tx.getsAsync("row3", new 
Column("col3")).get());
+      Assert.assertEquals("val4", tx.getsAsync("row4", new Column("col4"), 
"val4").get());
+    } catch (Exception e) {
+      Assert.fail("getsAsync caused the following exception: " + e);
+    }
 
 Review comment:
   Not quite, the test immediately calls `get()` on the Future and `get()` 
blocks so its never doing more than one async operation at time. I modified one 
of the test to do the following and ran it locally, I put in the timing info to 
see make sure the getAsync calls w/o the get() were fast. 
   
   ```java
       try (Transaction tx = client.newTransaction()) {
         long t1 = System.currentTimeMillis();
         Assert.assertEquals("val1", tx.getsAsync("row1", new 
Column("col1")).get());
         Assert.assertEquals("val2", tx.getsAsync("row2", new Column("col2"), 
"foo").get());
         Assert.assertEquals("val3", tx.getsAsync("row3", new 
Column("col3")).get());
         Assert.assertEquals("val4", tx.getsAsync("row4", new Column("col4"), 
"val4").get());
         long t2 = System.currentTimeMillis();
         System.out.println(t2-t1);
       }
   
       try (Transaction tx = client.newTransaction()) {
         long t1 = System.currentTimeMillis();
         CompletableFuture<String> val1 = tx.getsAsync("row1", new 
Column("col1"));
         CompletableFuture<String> val2 = tx.getsAsync("row2", new 
Column("col2"), "foo");
         CompletableFuture<String> val3 = tx.getsAsync("row3", new 
Column("col3"));
         CompletableFuture<String> val4 = tx.getsAsync("row4", new 
Column("col4"), "val4");
   
         long t2 = System.currentTimeMillis();
   
         Assert.assertEquals("val1", val1.get());
         Assert.assertEquals("val2", val2.get());
         Assert.assertEquals("val3", val3.get());
         Assert.assertEquals("val4", val4.get());
         long t3 = System.currentTimeMillis();
   
         System.out.println((t2-t1) + " " + (t3- t2));
       }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to