Skip to content

Commit

Permalink
Merge pull request #657 from basho/make-integration-tests-great-again
Browse files Browse the repository at this point in the history
Ready: Make integration tests great again
  • Loading branch information
alexmoore authored Aug 17, 2016
2 parents 9b700f0 + 8833f86 commit f3d931d
Show file tree
Hide file tree
Showing 32 changed files with 332 additions and 225 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ compile:

test: unit-test integration-test

test-ts: unit-test integration-test-timeseries

unit-test:
mvn test

integration-test:
mvn -Pitest,default -Dcom.basho.riak.2i=true -Dcom.basho.riak.yokozuna=true -Dcom.basho.riak.buckettype=true -Dcom.basho.riak.crdt=true -Dcom.basho.riak.lifecycle=true -Dcom.basho.riak.pbcport=$(RIAK_PORT) verify
mvn -Pitest,default -Dcom.basho.riak.pbcport=$(RIAK_PORT) verify

integration-test-timeseries:
mvn -Pitest,default -Dcom.basho.riak.buckettype=true -Dcom.basho.riak.crdt=true -Dcom.basho.riak.lifecycle=true -Dcom.basho.riak.timeseries=true -Dcom.basho.riak.pbcport=$(RIAK_PORT) verify
mvn -Pitest,default -Dcom.basho.riak.timeseries=true -Dcom.basho.riak.pbcport=$(RIAK_PORT) verify

integration-test-security:
mvn -Pitest,default -Dcom.basho.riak.security=true -Dcom.basho.riak.security.clientcert=true -Dcom.basho.riak.pbcport=$(RIAK_PORT) test-compile failsafe:integration-test
Expand Down
6 changes: 5 additions & 1 deletion buildbot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ test: test-normal test-security

test-normal:
$(RIAK_ADMIN) security disable
@cd ..; mvn -Pitest,default -Dcom.basho.riak.2i=true -Dcom.basho.riak.yokozuna=true -Dcom.basho.riak.buckettype=true -Dcom.basho.riak.crdt=true -Dcom.basho.riak.lifecycle=true verify
@cd ..; mvn -Pitest,default verify

test-timeseries:
$(RIAK_ADMIN) security disable
mvn -Pitest,default -Dcom.basho.riak.timeseries=true verify

test-security:
$(RIAK_ADMIN) security enable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
public abstract class CoreFutureAdapter<T2,S2,T,S> extends ListenableFuture<T2,S2> implements RiakFutureListener<T,S>
{
private final RiakFuture<T,S> coreFuture;

public CoreFutureAdapter(RiakFuture<T,S> coreFuture)
{
this.coreFuture = coreFuture;
}

@Override
public boolean cancel(boolean mayInterruptIfRunning)
{
Expand Down Expand Up @@ -71,7 +71,7 @@ public T2 getNow()
return null;
}
}

@Override
public boolean isCancelled()
{
Expand All @@ -91,9 +91,9 @@ public void await() throws InterruptedException
}

@Override
public void await(long timeout, TimeUnit unit) throws InterruptedException
public boolean await(long timeout, TimeUnit unit) throws InterruptedException
{
coreFuture.await(timeout, unit);
return coreFuture.await(timeout, unit);
}

@Override
Expand All @@ -113,13 +113,13 @@ public S2 getQueryInfo()
{
return convertQueryInfo(coreFuture.getQueryInfo());
}

@Override
public void handle(RiakFuture<T,S> f)
{
notifyListeners();
}

protected abstract T2 convertResponse(T coreResponse);
protected abstract S2 convertQueryInfo(S coreQueryInfo);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
* <script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script>
* <p>
* A BigIntIndexQuery is used when you are using integers for your 2i keys. The
* parameters are provided as BigInteger values. Use this query if your
* 2i key values exceed that
* which can be stored in a (64 bit) long,
* parameters are provided as BigInteger values. Use this query if your
* 2i key values exceed that
* which can be stored in a (64 bit) long,
* </p>
* <pre class="prettyprint">
* {@code
Expand All @@ -54,7 +54,7 @@ protected IndexConverter<BigInteger> getConverter()
{
return converter;
}

protected BigIntIndexQuery(Init<BigInteger,?> builder)
{
super(builder);
Expand All @@ -78,19 +78,19 @@ public BinaryValue convert(BigInteger input)
}
};
}

@Override
protected RiakFuture<Response, BigIntIndexQuery> executeAsync(RiakCluster cluster)
{
RiakFuture<SecondaryIndexQueryOperation.Response, SecondaryIndexQueryOperation.Query> coreFuture =
executeCoreAsync(cluster);

BigIntQueryFuture future = new BigIntQueryFuture(coreFuture);
coreFuture.addListener(future);
return future;

}

protected final class BigIntQueryFuture extends CoreFutureAdapter<Response, BigIntIndexQuery, SecondaryIndexQueryOperation.Response, SecondaryIndexQueryOperation.Query>
{
public BigIntQueryFuture(RiakFuture<SecondaryIndexQueryOperation.Response, SecondaryIndexQueryOperation.Query> coreFuture)
Expand All @@ -110,7 +110,7 @@ protected BigIntIndexQuery convertQueryInfo(SecondaryIndexQueryOperation.Query c
return BigIntIndexQuery.this;
}
}

protected static abstract class Init<S, T extends Init<S,T>> extends SecondaryIndexQuery.Init<S,T>
{

Expand All @@ -135,7 +135,7 @@ public T withRegexTermFilter(String filter)
throw new IllegalArgumentException("Cannot use term filter with _int query");
}
}

/**
* Builder used to construct a BigIntIndexQuery.
*/
Expand All @@ -151,7 +151,7 @@ public static class Builder extends Init<BigInteger, Builder>
* @param indexName The name of the index in Riak.
* @param coverContext cover context.
*/
public Builder(Namespace namespace, String indexName, byte[] coverContext)
public Builder(Namespace namespace, String indexName, byte[] coverContext)
{
super(namespace, indexName, coverContext);
}
Expand All @@ -160,7 +160,7 @@ public Builder(Namespace namespace, String indexName, byte[] coverContext)
* Construct a Builder for a BigIntIndexQuery with a range.
* <p>
* Note that your index name should not include the Riak {@literal _int} or
* {@literal _bin} extension.
* {@literal _bin} extension.
* <p>
* @param namespace The namespace in Riak to query.
* @param indexName The name of the index in Riak.
Expand All @@ -176,7 +176,7 @@ public Builder(Namespace namespace, String indexName, BigInteger start, BigInteg
* Construct a Builder for a BigIntIndexQuery with a single 2i key.
* <p>
* Note that your index name should not include the Riak {@literal _int} or
* {@literal _bin} extension.
* {@literal _bin} extension.
* <p>
* @param namespace The namespace in Riak to query.
* @param indexName The name of the index in Riak.
Expand All @@ -202,14 +202,14 @@ public BigIntIndexQuery build()
return new BigIntIndexQuery(this);
}
}

public static class Response extends SecondaryIndexQuery.Response<BigInteger>
{
protected Response(Namespace queryLocation, SecondaryIndexQueryOperation.Response coreResponse, IndexConverter<BigInteger> converter)
{
super(queryLocation, coreResponse, converter);
}

@Override
public List<Entry> getEntries()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.basho.riak.client.core.operations.SecondaryIndexQueryOperation;
import com.basho.riak.client.core.query.Location;
import com.basho.riak.client.core.query.Namespace;
import com.basho.riak.client.core.query.indexes.IndexNames;
import com.basho.riak.client.core.util.BinaryValue;
import com.basho.riak.client.core.util.DefaultCharset;

Expand Down Expand Up @@ -120,17 +121,28 @@ protected static abstract class Init<S, T extends Init<S, T>> extends SecondaryI

public Init(Namespace namespace, String indexName, S start, S end)
{
super(namespace, indexName + Type._BIN, start, end);
super(namespace, generateIndexName(indexName), start, end);
}

public Init(Namespace namespace, String indexName, S match)
{
super(namespace, indexName + Type._BIN, match);
super(namespace, generateIndexName(indexName), match);
}

public Init(Namespace namespace, String indexName, byte[] coverContext)
{
super(namespace, indexName + Type._BIN, coverContext);
super(namespace, generateIndexName(indexName), coverContext);
}

private static String generateIndexName(String baseIndexName)
{
if(IndexNames.BUCKET.equalsIgnoreCase(baseIndexName) ||
IndexNames.KEY.equalsIgnoreCase(baseIndexName))
{
return baseIndexName;
}

return baseIndexName + Type._BIN;
}

T withCharacterSet(Charset charset)
Expand Down Expand Up @@ -278,6 +290,10 @@ public String convert(BinaryValue input)
@Override
public BinaryValue convert(String input)
{
if (input == null )
{
return null;
}
return BinaryValue.create(input, charset);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.basho.riak.client.core.operations.SecondaryIndexQueryOperation;
import com.basho.riak.client.core.query.Namespace;
import com.basho.riak.client.core.query.indexes.IndexNames;
import com.basho.riak.client.core.util.BinaryValue;

/**
Expand All @@ -19,18 +20,23 @@
* @author Alex Moore <amoore at basho dot com>
* @since 2.0.7
*/
public class BucketIndexQuery extends RawIndexQuery
public class BucketIndexQuery extends BinIndexQuery
{
private BucketIndexQuery(Init<BinaryValue, Builder> builder)
private BucketIndexQuery(Init<String, Builder> builder)
{
super(builder);
}

public static class Builder extends SecondaryIndexQuery.Init<BinaryValue, Builder>
public static class Builder extends BinIndexQuery.Init<String, Builder>
{
public Builder(Namespace namespace)
{
super(namespace, "$bucket", namespace.getBucketName());
super(namespace, IndexNames.BUCKET, namespace.getBucketName().toStringUtf8());
}

public Builder(Namespace namespace, byte[] coverContext)
{
super(namespace, IndexNames.BUCKET, coverContext);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ protected RiakFuture<Response, IntIndexQuery> executeAsync(RiakCluster cluster)
{
RiakFuture<SecondaryIndexQueryOperation.Response, SecondaryIndexQueryOperation.Query> coreFuture =
executeCoreAsync(cluster);

IntQueryFuture future = new IntQueryFuture(coreFuture);
coreFuture.addListener(future);
return future;

}

protected final class IntQueryFuture extends CoreFutureAdapter<Response, IntIndexQuery, SecondaryIndexQueryOperation.Response, SecondaryIndexQueryOperation.Query>
Expand All @@ -96,7 +96,7 @@ public IntQueryFuture(RiakFuture<SecondaryIndexQueryOperation.Response, Secondar
{
super(coreFuture);
}

@Override
protected Response convertResponse(SecondaryIndexQueryOperation.Response coreResponse)
{
Expand All @@ -109,7 +109,7 @@ protected IntIndexQuery convertQueryInfo(SecondaryIndexQueryOperation.Query core
return IntIndexQuery.this;
}
}

protected static abstract class Init<S, T extends Init<S,T>> extends SecondaryIndexQuery.Init<S,T>
{

Expand All @@ -127,7 +127,7 @@ public Init(Namespace namespace, String indexName, S match)
{
super(namespace, indexName + Type._INT, match);
}

@Override
public T withRegexTermFilter(String filter)
{
Expand Down Expand Up @@ -160,7 +160,7 @@ public Builder(Namespace namespace, String indexName, byte[] coverContext)
* Construct a Builder for a IntIndexQuery with a range.
* <p>
* Note that your index name should not include the Riak {@literal _int} or
* {@literal _bin} extension.
* {@literal _bin} extension.
* <p>
* @param namespace The namespace in Riak to query.
* @param indexName The name of the index in Riak.
Expand All @@ -176,7 +176,7 @@ public Builder(Namespace namespace, String indexName, Long start, Long end)
* Construct a Builder for a IntIndexQuery with a single 2i key.
* <p>
* Note that your index name should not include the Riak {@literal _int} or
* {@literal _bin} extension.
* {@literal _bin} extension.
* <p>
* @param namespace The namespace in Riak to query.
* @param indexName The name of the index in Riak.
Expand All @@ -202,14 +202,14 @@ public IntIndexQuery build()
return new IntIndexQuery(this);
}
}

public static class Response extends SecondaryIndexQuery.Response<Long>
{
protected Response(Namespace queryLocation, SecondaryIndexQueryOperation.Response coreResponse, IndexConverter<Long> converter)
{
super(queryLocation, coreResponse, converter);
}

@Override
public List<Entry> getEntries()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.basho.riak.client.core.operations.SecondaryIndexQueryOperation;
import com.basho.riak.client.core.query.Namespace;
import com.basho.riak.client.core.query.indexes.IndexNames;
import com.basho.riak.client.core.util.BinaryValue;
import com.basho.riak.client.core.util.DefaultCharset;

Expand Down Expand Up @@ -39,7 +40,7 @@ public Builder(Namespace namespace, String start, String end)

public Builder(Namespace namespace, BinaryValue start, BinaryValue end)
{
super(namespace, "$key", start, end);
super(namespace, IndexNames.KEY, start, end);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ public abstract static class Response<T>
final protected IndexConverter<T> converter;
final protected SecondaryIndexQueryOperation.Response coreResponse;
final protected Namespace queryLocation;

protected Response(Namespace queryLocation,
SecondaryIndexQueryOperation.Response coreResponse,
IndexConverter<T> converter)
Expand Down
Loading

0 comments on commit f3d931d

Please sign in to comment.