[GitHub] [gora] sneceesay77 commented on a change in pull request #179: GORA-532: Apache Gora Benchmark initial pull request for review and comments

2019-08-18 Thread GitBox
sneceesay77 commented on a change in pull request #179: GORA-532: Apache Gora 
Benchmark initial pull request for review and comments
URL: https://github.com/apache/gora/pull/179#discussion_r315010693
 
 

 ##
 File path: 
gora-benchmark/src/test/java/org/apache/gora/benchmark/GoraClientTest.java
 ##
 @@ -0,0 +1,195 @@
+/**
+ * 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.gora.benchmark;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.Vector;
+import org.apache.gora.benchmark.generated.User;
+import org.apache.gora.util.GoraException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import com.yahoo.ycsb.ByteIterator;
+import com.yahoo.ycsb.Status;
+import com.yahoo.ycsb.StringByteIterator;
+import com.yahoo.ycsb.workloads.CoreWorkload;
+
+/**
+ * The Class GoraClientTest.
+ */
+public class GoraClientTest {
+
+  private static final String TABLE = "users";
+  private GoraBenchmarkClient client;
+  private static HashMap DATA_TO_INSERT;
+  private static HashMap DATA_TO_UPDATE;
+  private static final int NUMBER_OF_FIELDS = 10;
+  private GoraBenchmarkUtils bmutils = new GoraBenchmarkUtils();
+
+  /**
+   * Sets the up.
+   *
+   * Setup is executed before each test. Use @BeforeClass if you want to 
execute
+   * a code block just once.
+   * 
+   * @throws Exception
+   *   the exceptionfiles are auto-generated. I have the code to add 
the license file accordingly
+   */
+  @Before
+  public void setUp() throws Exception {
+DATA_TO_INSERT = new HashMap<>();
+DATA_TO_UPDATE = new HashMap<>();
+for (int i = 0; i < NUMBER_OF_FIELDS; i++) {
+  DATA_TO_INSERT.put("field" + i, new StringByteIterator("value" + i));
+  DATA_TO_UPDATE.put("field" + i, new StringByteIterator("updated" + i));
+}
+Properties p = new Properties();
+p.setProperty("key.class", "java.lang.String");
+p.setProperty("persistent.class", 
"org.apache.gora.benchmark.generated.User");
+p.setProperty(CoreWorkload.FIELD_COUNT_PROPERTY, NUMBER_OF_FIELDS + "");
+client = new GoraBenchmarkClient();
+client.setProperties(p);
+client.init();
+  }
+
+  /**
+   * Clean up.
+   *
+   * @throws Exception
+   *   the exception
+   */
+  @After
+  public void cleanUp() throws Exception {
+if (client != null)
+  client.cleanup();
+client = null;
+  }
+
+  /**
+   * Read record.
+   *
+   * @param key
+   *  the key
+   * @return the user
+   * @throws GoraException
+   *   the gora exception
+   */
+  private User readRecord(String key) throws GoraException {
+User u = client.dataStore.get(key);
+return u;
+  }
+
+  /**
+   * Test client initialisation.
+   */
+  @Test
+  public void testClientInitialisation() {
+assertNotNull(client.dataStore);
+  }
+
+  /**files are auto-generated. I have the code to add the license file 
accordingly
+   * Test insert.
+   *
+   * @throws GoraException
+   *   the gora exception
+   */
+  @Test
+  public void testInsert() throws GoraException {
+Status result1 = client.insert(TABLE, "key1", DATA_TO_INSERT);
+Status result2 = client.insert(TABLE, "key2", DATA_TO_INSERT);
+Status result3 = client.insert(TABLE, "key3", DATA_TO_INSERT);
+assertEquals(Status.OK, result1);
+assertEquals(Status.OK, result2);
+assertEquals(Status.OK, result3);
+  }
+
+  /**
+   * Test read.
+   */
+  @Test
+  public void testRead() {
+HashMap results = new HashMap<>();
+Set fields = new HashSet<>();// this could be null as well
+// fields.add("field0");
+Status result = client.read(TABLE, "key1", fields, results);
+assertEquals(Status.OK, result);
+assertEquals(DATA_TO_INSERT.size(), results.size());
+assertEquals(DATA_TO_INSERT.get("field0").toString(), 
results.get("field0").toString());
+assertEquals(DATA_TO_INSERT.get("field0").toString(), "value0");
+  }
+
+  /**
+   * Test scan.
+   */
+  @Test
+  public void testScan() {
+Vector> 

[GitHub] [gora] sneceesay77 commented on issue #179: GORA-532: Apache Gora Benchmark initial pull request for review and comments

2019-08-18 Thread GitBox
sneceesay77 commented on issue #179: GORA-532: Apache Gora Benchmark initial 
pull request for review and comments
URL: https://github.com/apache/gora/pull/179#issuecomment-522379871
 
 
   @lewismc and @djkevincr, I have addressed most of the comments in this 
updated PR. It seems there is a lot to do in this final week of GSoC. It 
includes evaluations, submission of a link that hosts the project files.
   
   @lewismc, since we are in the last week of GSoC, what options do we have if 
YCSB maven issue is not resolved? It seems it is not progressing well for now 
and I am not sure if it going to be resolved before the submission of the final 
evaluation. 
   


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


Week 12 Report

2019-08-18 Thread Sheriffo Ceesay
All,

Week 12 report is available at
https://cwiki.apache.org/confluence/display/GORA/%5BGORA-532%5D+Apache+Gora+Benchmark+Module+Weekly+Report

I have resolved almost all the comments by @Lewis John Mcgibbney
 and @Kevin Ratnasekera
 except
for a few where I may need clarification or guidance.

We are still waiting on the folks from YCSB to proceed with this issue (
https://github.com/brianfrankcooper/YCSB/issues/1340

)

If the above issue is resolved then it will be simpler to test the
benchmark module. Currently, the readme file has some guidlines on how to
compile and run the module.


**Sheriffo Ceesay**


[GitHub] [gora] sneceesay77 commented on a change in pull request #179: GORA-532: Apache Gora Benchmark initial pull request for review and comments

2019-08-18 Thread GitBox
sneceesay77 commented on a change in pull request #179: GORA-532: Apache Gora 
Benchmark initial pull request for review and comments
URL: https://github.com/apache/gora/pull/179#discussion_r315010843
 
 

 ##
 File path: 
gora-benchmark/src/test/java/org/apache/gora/benchmark/GoraClientTest.java
 ##
 @@ -0,0 +1,195 @@
+/**
+ * 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.gora.benchmark;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.Vector;
+import org.apache.gora.benchmark.generated.User;
+import org.apache.gora.util.GoraException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import com.yahoo.ycsb.ByteIterator;
+import com.yahoo.ycsb.Status;
+import com.yahoo.ycsb.StringByteIterator;
+import com.yahoo.ycsb.workloads.CoreWorkload;
+
+/**
+ * The Class GoraClientTest.
+ */
+public class GoraClientTest {
 
 Review comment:
   I have updated the test to auto-provision MongoDB cluster without having to 
run a local copy. I have just added a simple method to this. I haven't used the 
test-jar or the file you have attached.  


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [gora] sneceesay77 commented on a change in pull request #179: GORA-532: Apache Gora Benchmark initial pull request for review and comments

2019-08-18 Thread GitBox
sneceesay77 commented on a change in pull request #179: GORA-532: Apache Gora 
Benchmark initial pull request for review and comments
URL: https://github.com/apache/gora/pull/179#discussion_r315010693
 
 

 ##
 File path: 
gora-benchmark/src/test/java/org/apache/gora/benchmark/GoraClientTest.java
 ##
 @@ -0,0 +1,195 @@
+/**
+ * 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.gora.benchmark;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.Vector;
+import org.apache.gora.benchmark.generated.User;
+import org.apache.gora.util.GoraException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import com.yahoo.ycsb.ByteIterator;
+import com.yahoo.ycsb.Status;
+import com.yahoo.ycsb.StringByteIterator;
+import com.yahoo.ycsb.workloads.CoreWorkload;
+
+/**
+ * The Class GoraClientTest.
+ */
+public class GoraClientTest {
+
+  private static final String TABLE = "users";
+  private GoraBenchmarkClient client;
+  private static HashMap DATA_TO_INSERT;
+  private static HashMap DATA_TO_UPDATE;
+  private static final int NUMBER_OF_FIELDS = 10;
+  private GoraBenchmarkUtils bmutils = new GoraBenchmarkUtils();
+
+  /**
+   * Sets the up.
+   *
+   * Setup is executed before each test. Use @BeforeClass if you want to 
execute
+   * a code block just once.
+   * 
+   * @throws Exception
+   *   the exceptionfiles are auto-generated. I have the code to add 
the license file accordingly
+   */
+  @Before
+  public void setUp() throws Exception {
+DATA_TO_INSERT = new HashMap<>();
+DATA_TO_UPDATE = new HashMap<>();
+for (int i = 0; i < NUMBER_OF_FIELDS; i++) {
+  DATA_TO_INSERT.put("field" + i, new StringByteIterator("value" + i));
+  DATA_TO_UPDATE.put("field" + i, new StringByteIterator("updated" + i));
+}
+Properties p = new Properties();
+p.setProperty("key.class", "java.lang.String");
+p.setProperty("persistent.class", 
"org.apache.gora.benchmark.generated.User");
+p.setProperty(CoreWorkload.FIELD_COUNT_PROPERTY, NUMBER_OF_FIELDS + "");
+client = new GoraBenchmarkClient();
+client.setProperties(p);
+client.init();
+  }
+
+  /**
+   * Clean up.
+   *
+   * @throws Exception
+   *   the exception
+   */
+  @After
+  public void cleanUp() throws Exception {
+if (client != null)
+  client.cleanup();
+client = null;
+  }
+
+  /**
+   * Read record.
+   *
+   * @param key
+   *  the key
+   * @return the user
+   * @throws GoraException
+   *   the gora exception
+   */
+  private User readRecord(String key) throws GoraException {
+User u = client.dataStore.get(key);
+return u;
+  }
+
+  /**
+   * Test client initialisation.
+   */
+  @Test
+  public void testClientInitialisation() {
+assertNotNull(client.dataStore);
+  }
+
+  /**files are auto-generated. I have the code to add the license file 
accordingly
+   * Test insert.
+   *
+   * @throws GoraException
+   *   the gora exception
+   */
+  @Test
+  public void testInsert() throws GoraException {
+Status result1 = client.insert(TABLE, "key1", DATA_TO_INSERT);
+Status result2 = client.insert(TABLE, "key2", DATA_TO_INSERT);
+Status result3 = client.insert(TABLE, "key3", DATA_TO_INSERT);
+assertEquals(Status.OK, result1);
+assertEquals(Status.OK, result2);
+assertEquals(Status.OK, result3);
+  }
+
+  /**
+   * Test read.
+   */
+  @Test
+  public void testRead() {
+HashMap results = new HashMap<>();
+Set fields = new HashSet<>();// this could be null as well
+// fields.add("field0");
+Status result = client.read(TABLE, "key1", fields, results);
+assertEquals(Status.OK, result);
+assertEquals(DATA_TO_INSERT.size(), results.size());
+assertEquals(DATA_TO_INSERT.get("field0").toString(), 
results.get("field0").toString());
+assertEquals(DATA_TO_INSERT.get("field0").toString(), "value0");
+  }
+
+  /**
+   * Test scan.
+   */
+  @Test
+  public void testScan() {
+Vector>