Skip to content
Snippets Groups Projects
Commit c353f712 authored by nygard_89's avatar nygard_89
Browse files

[travis] Reverted to original version, just added riak as service.

[riak] Configured RiakKVClientTest.java to work with default bucket-type instead of creating a new one.
parent d4d251a0
No related branches found
No related tags found
No related merge requests found
...@@ -21,21 +21,17 @@ language: java ...@@ -21,21 +21,17 @@ language: java
jdk: jdk:
- oraclejdk7 - oraclejdk7
- openjdk7 - openjdk7
install: mvn install -q -DskipTests=true install: mvn install -q -DskipTests=true
script: mvn test -q script: mvn test -q
# Bucket-type to activate before running Riak KV tests.
before_script:
- sudo riak-admin bucket-type create ycsb '{"props":{"allow_mult":"false"}}'
- sudo riak-admin bucket-type activate ycsb
# Services to start for tests. # Services to start for tests.
services: services:
- mongodb - mongodb
- riak - riak
# Sudo required for Riak KV test.
sudo: required # Use the Container based infrastructure.
sudo: false
\ No newline at end of file
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
package com.yahoo.ycsb.db.riak; package com.yahoo.ycsb.db.riak;
import com.basho.riak.client.api.commands.buckets.StoreBucketProperties;
import com.basho.riak.client.api.commands.kv.UpdateValue; import com.basho.riak.client.api.commands.kv.UpdateValue;
import com.basho.riak.client.core.RiakFuture; import com.basho.riak.client.core.RiakFuture;
import com.yahoo.ycsb.*; import com.yahoo.ycsb.*;
...@@ -548,4 +549,22 @@ public final class RiakKVClient extends DB { ...@@ -548,4 +549,22 @@ public final class RiakKVClient extends DB {
throw new DBException(e); throw new DBException(e);
} }
} }
/**
* Auxiliary function needed for testing. It configures the default bucket-type to take care of the consistency
* problem by disallowing the siblings creation. Moreover, it disables strong consistency, as the scan transaction
* test would otherwise fail.
*
* @param bucket The bucket name.
* @throws Exception Thrown if something bad happens.
*/
void setTestEnvironment(String bucket) throws Exception {
bucketType = "default";
strongConsistency = false;
Namespace ns = new Namespace(bucketType, bucket);
StoreBucketProperties newBucketProperties = new StoreBucketProperties.Builder(ns).withAllowMulti(false).build();
riakClient.execute(newBucketProperties);
}
} }
...@@ -29,8 +29,8 @@ import org.junit.BeforeClass; ...@@ -29,8 +29,8 @@ import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assume.assumeNoException;
import static org.junit.Assume.assumeThat; import static org.junit.Assume.assumeThat;
/** /**
...@@ -57,10 +57,17 @@ public class RiakKVClientTest { ...@@ -57,10 +57,17 @@ public class RiakKVClientTest {
riakClient = new RiakKVClient(); riakClient = new RiakKVClient();
riakClient.init(); riakClient.init();
// Set the test bucket environment with the appropriate parameters.
try {
riakClient.setTestEnvironment(bucket);
} catch(Exception e) {
assumeNoException("Unable to configure Riak KV for test, aborting.", e);
}
// Just add some records to work on... // Just add some records to work on...
for (int i = 0; i < recordsToInsert; i++) { for (int i = 0; i < recordsToInsert; i++) {
// Abort the entire test whenever the dataset population operation fails. // Abort the entire test whenever the dataset population operation fails.
assumeThat("Riak KV is NOT RUNNING, aborting test!", assumeThat("Riak KV is NOT RUNNING, aborting test.",
riakClient.insert(bucket, keyPrefix + String.valueOf(i), StringByteIterator.getByteIteratorMap( riakClient.insert(bucket, keyPrefix + String.valueOf(i), StringByteIterator.getByteIteratorMap(
createExpectedHashMap(i))), createExpectedHashMap(i))),
is(Status.OK)); is(Status.OK));
...@@ -129,18 +136,11 @@ public class RiakKVClientTest { ...@@ -129,18 +136,11 @@ public class RiakKVClientTest {
// Prepare a HashMap vector to store the scan transaction results. // Prepare a HashMap vector to store the scan transaction results.
Vector<HashMap<String, ByteIterator>> scannedValues = new Vector<>(); Vector<HashMap<String, ByteIterator>> scannedValues = new Vector<>();
// If strong consistency is to be used, then it is not possible to perform a scan transaction (check // Check whether the scan transaction is correctly performed or not.
// RiakKVClient.java for further info).
Status status = riakClient.scan(bucket, keyPrefix + Integer.toString(startScanKeyNumber), recordsToScan, null,
scannedValues);
assumeThat("Scan transaction NOT SUPPORTED when using strong consistency. Test skipped.",
status,
not(Status.NOT_IMPLEMENTED));
assertEquals("Scan transaction FAILED.", assertEquals("Scan transaction FAILED.",
Status.OK, Status.OK,
status); riakClient.scan(bucket, keyPrefix + Integer.toString(startScanKeyNumber), recordsToScan, null,
scannedValues));
// After the scan transaction completes, compare the obtained results with the expected ones. // After the scan transaction completes, compare the obtained results with the expected ones.
for (int i = 0; i < recordsToScan; i++) { for (int i = 0; i < recordsToScan; i++) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment