Skip to content

Commit

Permalink
Tests - query tests need 7.1.0 for MB-50132
Browse files Browse the repository at this point in the history
Any tests that are creating collections and require
the indexer to be aware of those collections, needs MB-50132.

Change-Id: Idabc2c4b24f8fdda954dbacc9bb1a0548fa898bf
Reviewed-on: https://review.couchbase.org/c/couchbase-jvm-clients/+/183226
Reviewed-by: Michael Reiche <michael.reiche@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>
  • Loading branch information
programmatix committed Dec 2, 2022
1 parent b113cc3 commit ccf3971
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import static com.couchbase.client.java.manager.analytics.CreateDatasetAnalyticsOptions.createDatasetAnalyticsOptions;
import static com.couchbase.client.java.manager.analytics.DropDatasetAnalyticsOptions.dropDatasetAnalyticsOptions;
import static com.couchbase.client.java.manager.analytics.DropIndexAnalyticsOptions.dropIndexAnalyticsOptions;
import static com.couchbase.client.java.manager.query.QueryIndexManagerIntegrationTest.REQUIRE_MB_50132;
import static com.couchbase.client.test.Util.waitUntilCondition;
import static java.util.Collections.singletonMap;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -65,6 +66,7 @@
*/
@IgnoreWhen(
missesCapabilities = {Capabilities.ANALYTICS, Capabilities.COLLECTIONS},
clusterVersionIsBelow = REQUIRE_MB_50132,
clusterTypes = ClusterType.CAVES
)
class AnalyticsCollectionIntegrationTest extends JavaIntegrationTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import static com.couchbase.client.core.util.CbThrowables.throwIfUnchecked;
import static com.couchbase.client.java.AsyncUtils.block;
import static com.couchbase.client.java.manager.query.QueryIndexManagerIntegrationTest.DISABLE_QUERY_TESTS_FOR_CLUSTER;
import static com.couchbase.client.java.manager.query.QueryIndexManagerIntegrationTest.REQUIRE_MB_50132;
import static com.couchbase.client.java.query.QueryOptions.queryOptions;
import static com.couchbase.client.test.Util.waitUntilCondition;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -65,10 +66,10 @@
* <p>
* @author Michael Reiche
*/
// Using SUBDOC_REVIVE_DOCUMENT as a proxy for 7.1.0 so we get fix for MB-50132
@IgnoreWhen(
missesCapabilities = { Capabilities.QUERY, Capabilities.COLLECTIONS, Capabilities.SUBDOC_REVIVE_DOCUMENT },
missesCapabilities = { Capabilities.QUERY, Capabilities.COLLECTIONS },
clusterTypes = { ClusterType.MOCKED, ClusterType.CAVES },
clusterVersionIsBelow = REQUIRE_MB_50132,
clusterVersionEquals = DISABLE_QUERY_TESTS_FOR_CLUSTER
)
class QueryCollectionIntegrationTest extends JavaIntegrationTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.util.concurrent.TimeUnit;

import static com.couchbase.client.java.manager.query.QueryIndexManagerIntegrationTest.DISABLE_QUERY_TESTS_FOR_CLUSTER;
import static com.couchbase.client.java.manager.query.QueryIndexManagerIntegrationTest.REQUIRE_MB_50132;
import static com.couchbase.client.java.query.QueryOptions.queryOptions;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All @@ -45,6 +46,7 @@
@IgnoreWhen(
missesCapabilities = Capabilities.QUERY,
clusterVersionEquals = DISABLE_QUERY_TESTS_FOR_CLUSTER,
clusterVersionIsBelow = REQUIRE_MB_50132,
clusterTypes = ClusterType.CAVES
)
class QueryConcurrencyIntegrationTest extends JavaIntegrationTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import java.util.concurrent.CompletableFuture;

import static com.couchbase.client.java.manager.query.QueryIndexManagerIntegrationTest.DISABLE_QUERY_TESTS_FOR_CLUSTER;
import static com.couchbase.client.java.manager.query.QueryIndexManagerIntegrationTest.REQUIRE_MB_50132;
import static com.couchbase.client.java.query.QueryOptions.queryOptions;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
Expand All @@ -67,6 +68,7 @@
@IgnoreWhen(
missesCapabilities = Capabilities.QUERY,
clusterVersionEquals = DISABLE_QUERY_TESTS_FOR_CLUSTER,
clusterVersionIsBelow = REQUIRE_MB_50132,
clusterTypes = ClusterType.CAVES
)
class QueryIntegrationTest extends JavaIntegrationTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import static com.couchbase.client.java.manager.query.DropPrimaryQueryIndexOptions.dropPrimaryQueryIndexOptions;
import static com.couchbase.client.java.manager.query.DropQueryIndexOptions.dropQueryIndexOptions;
import static com.couchbase.client.java.manager.query.GetAllQueryIndexesOptions.getAllQueryIndexesOptions;
import static com.couchbase.client.java.manager.query.QueryIndexManagerIntegrationTest.REQUIRE_MB_50132;
import static com.couchbase.client.java.manager.query.WatchQueryIndexesOptions.watchQueryIndexesOptions;
import static com.couchbase.client.test.Capabilities.COLLECTIONS;
import static com.couchbase.client.test.Capabilities.QUERY;
Expand All @@ -64,7 +65,9 @@
/**
* Very similar to the {@link QueryIndexManagerIntegrationTest}, but this one tests with scope and collection support.
*/
@IgnoreWhen(clusterTypes = { CAVES, MOCKED }, missesCapabilities = { QUERY, COLLECTIONS })
@IgnoreWhen(clusterTypes = { CAVES, MOCKED },
missesCapabilities = { QUERY, COLLECTIONS },
clusterVersionIsBelow = REQUIRE_MB_50132)
public class QueryCollectionsIndexManagerIntegrationTest extends JavaIntegrationTest {

// time to allow for watch operations that are expected to succeed eventually
Expand All @@ -87,9 +90,6 @@ static void setup() throws Exception {
waitForService(bucket, ServiceType.QUERY);
waitForQueryIndexerToHaveKeyspace(cluster, bucketName);

// Workaround for MB-50132
Thread.sleep(3000);

bucket.collections().createScope(scopeName);
bucket.collections().createCollection(CollectionSpec.create(collectionName, scopeName));
waitForQueryIndexerToHaveKeyspace(cluster, collectionName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import static com.couchbase.client.java.manager.query.DropQueryIndexOptions.dropQueryIndexOptions;
import static com.couchbase.client.java.manager.query.GetAllQueryIndexesOptions.getAllQueryIndexesOptions;
import static com.couchbase.client.java.manager.query.QueryIndexManagerIntegrationTest.DISABLE_QUERY_TESTS_FOR_CLUSTER;
import static com.couchbase.client.java.manager.query.QueryIndexManagerIntegrationTest.REQUIRE_MB_50132;
import static com.couchbase.client.java.manager.query.WatchQueryIndexesOptions.watchQueryIndexesOptions;
import static com.couchbase.client.test.Capabilities.QUERY;
import static com.couchbase.client.test.ClusterType.CAVES;
Expand All @@ -58,12 +59,19 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

// Disabling against 5.5 as there appear to be several query bugs (SCBC-246, SCBC-251). Hardcoding 5.5.6 as that's
// the current 5.5-release and it's unlikely to change.
@IgnoreWhen(clusterTypes = {CAVES, MOCKED}, missesCapabilities = QUERY, clusterVersionEquals = DISABLE_QUERY_TESTS_FOR_CLUSTER)
@IgnoreWhen(clusterTypes = {CAVES, MOCKED},
missesCapabilities = QUERY,
clusterVersionEquals = DISABLE_QUERY_TESTS_FOR_CLUSTER,
clusterVersionIsBelow = REQUIRE_MB_50132)
public class QueryIndexManagerIntegrationTest extends JavaIntegrationTest {
// Disabling against 5.5 as there appear to be several query bugs (SCBC-246, SCBC-251). Hardcoding 5.5.6 as that's
// the current 5.5-release and it's unlikely to change.
// This is now often redundant with REQUIRE_MB_50132 - leaving for documentation purposes.
public static final String DISABLE_QUERY_TESTS_FOR_CLUSTER = "5.5.6";

// Any tests that are creating collections and require the indexer to be aware of those collections, needs MB-50132.
public static final String REQUIRE_MB_50132 = "7.1.0";

// time to allow for watch operations that are expected to succeed eventually
private static final Duration watchTimeout = Duration.ofSeconds(15);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@ import kotlin.time.Duration.Companion.seconds
// Disabling against 5.5 as there appear to be several query bugs (SCBC-246, SCBC-251). Hardcoding 5.5.6 as that's
// the current 5.5-release and it's unlikely to change.
private const val DISABLE_QUERY_TESTS_FOR_CLUSTER = "5.5.6"
// See QueryIndexManagerIntegrationTest for explanation
private const val REQUIRE_MB_50132 = "7.1.0"
private val watchTimeout = 15.seconds

@IgnoreWhen(
clusterTypes = [ClusterType.CAVES, ClusterType.MOCKED],
missesCapabilities = [Capabilities.QUERY],
clusterVersionEquals = DISABLE_QUERY_TESTS_FOR_CLUSTER,
clusterVersionIsBelow = REQUIRE_MB_50132
)
internal class QueryIndexManagerIntegrationTest : KotlinIntegrationTest() {
private val indexes: QueryIndexManager by lazy { cluster.queryIndexes }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.couchbase.client.core.service.ServiceType
import com.couchbase.client.scala.manager.bucket.CreateBucketSettings
import com.couchbase.client.scala.manager.collection.CollectionSpec
import com.couchbase.client.scala.manager.query.{QueryIndex, QueryIndexManager}
import com.couchbase.client.scala.query.QuerySpec.RequireMB50132
import com.couchbase.client.scala.util.ScalaIntegrationTest
import com.couchbase.client.scala.{Cluster, Collection, TestUtils}
import com.couchbase.client.test._
Expand All @@ -44,7 +45,8 @@ import scala.util.{Failure, Success, Try}
@TestInstance(Lifecycle.PER_CLASS)
@IgnoreWhen(
clusterTypes = Array(ClusterType.MOCKED),
missesCapabilities = Array(Capabilities.COLLECTIONS)
missesCapabilities = Array(Capabilities.COLLECTIONS),
clusterVersionIsBelow = RequireMB50132
)
class QueryIndexManagerSpec extends ScalaIntegrationTest {
private var cluster: Cluster = _
Expand Down Expand Up @@ -458,8 +460,7 @@ class QueryIndexManagerSpec extends ScalaIntegrationTest {
assert(cluster.reactive.queryIndexes.getAllIndexes(bucketName).collectSeq().block().size == 1)
}

// Using SUBDOC_REVIVE_DOCUMENT to indicate 7.1 support as fix MB-50132 is required
@IgnoreWhen(missesCapabilities = Array(Capabilities.SUBDOC_REVIVE_DOCUMENT))
@IgnoreWhen(clusterVersionIsBelow = RequireMB50132)
@Test
def createCollectionIndex(): Unit = {
val indexName = "myCollectionIndex"
Expand Down Expand Up @@ -491,8 +492,7 @@ class QueryIndexManagerSpec extends ScalaIntegrationTest {
})
}

// Using SUBDOC_REVIVE_DOCUMENT to indicate 7.1 support as fix MB-50132 is required
@IgnoreWhen(missesCapabilities = Array(Capabilities.SUBDOC_REVIVE_DOCUMENT))
@IgnoreWhen(clusterVersionIsBelow = RequireMB50132)
@Test
def dropCollectionIndex() = {
val indexName = UUID.randomUUID().toString
Expand Down Expand Up @@ -521,8 +521,7 @@ class QueryIndexManagerSpec extends ScalaIntegrationTest {
assert(cluster.queryIndexes.getAllIndexes(config.bucketname()).get.isEmpty)
}

// Using SUBDOC_REVIVE_DOCUMENT to indicate 7.1 support as fix MB-50132 is required
@IgnoreWhen(missesCapabilities = Array(Capabilities.SUBDOC_REVIVE_DOCUMENT))
@IgnoreWhen(clusterVersionIsBelow = RequireMB50132)
@Test
def buildOneDeferredCollectionIndex() = {
val indexName = UUID.randomUUID().toString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.couchbase.client.scala.implicits.Codec
import com.couchbase.client.scala.json.JsonObject
import com.couchbase.client.scala.kv.MutationState
import com.couchbase.client.scala.query.QueryScanConsistency.ConsistentWith
import com.couchbase.client.scala.query.QuerySpec.{DisableQueryTestsForCluster, RequireMB50132}
import com.couchbase.client.scala.util.ScalaIntegrationTest
import com.couchbase.client.scala.{Cluster, Collection, TestUtils}
import com.couchbase.client.test.{Capabilities, IgnoreWhen, Util}
Expand All @@ -39,7 +40,9 @@ import scala.util.{Failure, Success}

// Disabling against 5.5. See comment on QueryIndexManagerIntegrationTest for details.
@TestInstance(Lifecycle.PER_CLASS)
@IgnoreWhen(missesCapabilities = Array(Capabilities.QUERY), clusterVersionEquals = "5.5.6")
@IgnoreWhen(missesCapabilities = Array(Capabilities.QUERY),
clusterVersionEquals = DisableQueryTestsForCluster,
clusterVersionIsBelow = RequireMB50132)
class QuerySpec extends ScalaIntegrationTest {

private var cluster: Cluster = _
Expand Down Expand Up @@ -531,3 +534,9 @@ class QuerySpec extends ScalaIntegrationTest {
assert(coll.get(docId).isFailure)
}
}

object QuerySpec {
// See QueryIndexManagerIntegrationTest.java for explanation of these.
final val DisableQueryTestsForCluster = "5.5.6"
final val RequireMB50132 = "7.1.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.couchbase.client.core.service.ServiceType
import com.couchbase.client.scala.json.JsonObject
import com.couchbase.client.scala.kv.MutationState
import com.couchbase.client.scala.manager.collection.CollectionSpec
import com.couchbase.client.scala.query.QuerySpec.RequireMB50132
import com.couchbase.client.scala.util.ScalaIntegrationTest
import com.couchbase.client.scala.{Cluster, Collection, Scope, TestUtils}
import com.couchbase.client.test.{Capabilities, Flaky, IgnoreWhen, Util}
Expand All @@ -30,7 +31,8 @@ import scala.util.{Failure, Success}

@Disabled @Flaky
@TestInstance(Lifecycle.PER_CLASS)
@IgnoreWhen(missesCapabilities = Array(Capabilities.QUERY, Capabilities.COLLECTIONS))
@IgnoreWhen(missesCapabilities = Array(Capabilities.QUERY, Capabilities.COLLECTIONS),
clusterVersionIsBelow = RequireMB50132)
class ScopeLevelQuerySpec extends ScalaIntegrationTest {

private var cluster: Cluster = _
Expand Down

0 comments on commit ccf3971

Please sign in to comment.