Search in sources :

Example 6 with IgnoreWhen

use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.

the class SubdocMutateIntegrationTest method createAsDeletedCanAccess.

@Test
@IgnoreWhen(missesCapabilities = Capabilities.CREATE_AS_DELETED, clusterTypes = ClusterType.CAVES)
void createAsDeletedCanAccess() {
    String docId = docId();
    try {
        coll.mutateIn(docId, Collections.singletonList(MutateInSpec.insert("foo", "bar").xattr()), MutateInOptions.mutateInOptions().createAsDeleted(true).storeSemantics(StoreSemantics.INSERT));
        assertThrows(DocumentNotFoundException.class, () -> coll.get(docId));
        assertThrows(DocumentNotFoundException.class, () -> coll.lookupIn(docId, Collections.singletonList(LookupInSpec.get("foo").xattr())));
        LookupInResult result = coll.lookupIn(docId, Collections.singletonList(LookupInSpec.get("foo").xattr()), LookupInOptions.lookupInOptions().accessDeleted(true));
        assertEquals("bar", result.contentAs(0, String.class));
    } catch (CouchbaseException err) {
        // createAsDeleted flag only supported in 6.5.1+
        assertEquals(ResponseStatus.INVALID_REQUEST, err.context().responseStatus());
    }
}
Also used : LookupInResult(com.couchbase.client.java.kv.LookupInResult) CouchbaseException(com.couchbase.client.core.error.CouchbaseException) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 7 with IgnoreWhen

use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.

the class RateLimitingIntegrationTest method queryRateLimitIngress.

@Test
@IgnoreWhen(missesCapabilities = Capabilities.QUERY)
void queryRateLimitIngress() throws Exception {
    String username = "queryRateLimitIngress";
    Limits limits = new Limits();
    limits.queryLimits = new QueryLimits(10000, 10000, 1, 10);
    createRateLimitedUser(username, limits);
    Cluster cluster = createTestCluster(username);
    try {
        cluster.waitUntilReady(Duration.ofSeconds(10));
        RateLimitedException ex = assertThrows(RateLimitedException.class, () -> {
            for (int i = 0; i < 5; i++) {
                String content = repeatString(1024 * 1024 * 5, "a");
                cluster.query("UPSERT INTO `" + config().bucketname() + "` (KEY,VALUE) VALUES (\"key1\", \"" + content + "\")", // Can take a while
                QueryOptions.queryOptions().timeout(Duration.ofSeconds(30)));
            }
        });
        assertTrue(ex.getMessage().contains("User has exceeded input network traffic limit"));
    } finally {
        cluster.disconnect();
        adminCluster.users().dropUser(username);
    }
}
Also used : RateLimitedException(com.couchbase.client.core.error.RateLimitedException) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 8 with IgnoreWhen

use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.

the class RateLimitingIntegrationTest method queryRateLimitEgress.

@Test
@IgnoreWhen(missesCapabilities = Capabilities.QUERY)
void queryRateLimitEgress() throws Exception {
    String username = "queryRateLimitEgress";
    Limits limits = new Limits();
    limits.queryLimits = new QueryLimits(10000, 10000, 10, 1);
    createRateLimitedUser(username, limits);
    Cluster cluster = createTestCluster(username);
    try {
        cluster.waitUntilReady(Duration.ofSeconds(10));
        String content = repeatString(1024 * 1024, "a");
        Collection collection = cluster.bucket(config().bucketname()).defaultCollection();
        collection.upsert("key1", content, UpsertOptions.upsertOptions().timeout(Duration.ofSeconds(5)));
        RateLimitedException ex = assertThrows(RateLimitedException.class, () -> {
            for (int i = 0; i < 50; i++) {
                cluster.query("SELECT * FROM `" + config().bucketname() + "` USE KEYS [\"key1\"]", QueryOptions.queryOptions().timeout(Duration.ofSeconds(15)));
            }
        });
        assertTrue(ex.getMessage().contains("User has exceeded results size limit"));
    } finally {
        cluster.disconnect();
        adminCluster.users().dropUser(username);
    }
}
Also used : RateLimitedException(com.couchbase.client.core.error.RateLimitedException) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 9 with IgnoreWhen

use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.

the class SubdocMutateIntegrationTest method counterMinusXattrCreatePath.

@Test
@IgnoreWhen(clusterTypes = ClusterType.CAVES)
void counterMinusXattrCreatePath() {
    JsonObject updatedContent = checkSingleOpSuccessXattr(JsonObject.create(), Arrays.asList(MutateInSpec.decrement("x.foo", 3).xattr().createPath()));
    assertEquals(-3, (int) updatedContent.getInt("foo"));
}
Also used : JsonObject(com.couchbase.client.java.json.JsonObject) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 10 with IgnoreWhen

use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.

the class SubdocMutateIntegrationTest method counterAddCreatePath.

// TODO failing with bad input server error
// @Test
// public void arrayInsertCreatePath() {
// JsonObject updatedContent = checkSingleOpSuccess(JsonObject.create(),
// Arrays.asList(MutateInSpec.arrayInsert("foo[0]", "cruel", true));
// assertEquals(JsonArray.from("cruel"), updatedContent.getArray("foo"));
// }
// 
// @Test
// public void arrayInsertUniqueDoesNotExistCreatePath() {
// JsonObject updatedContent = checkSingleOpSuccess(JsonObject.create(),
// Arrays.asList(MutateInSpec.arrayAddUnique("foo", "cruel", true));
// assertEquals(JsonArray.from("hello", "world", "cruel"), updatedContent.getArray("foo"));
// }
@Test
@IgnoreWhen(clusterTypes = ClusterType.CAVES)
void counterAddCreatePath() {
    JsonObject updatedContent = checkSingleOpSuccess(JsonObject.create(), Arrays.asList(MutateInSpec.increment("foo", 5).createPath()));
    assertEquals(5, (int) updatedContent.getInt("foo"));
}
Also used : JsonObject(com.couchbase.client.java.json.JsonObject) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

IgnoreWhen (com.couchbase.client.test.IgnoreWhen)79 Test (org.junit.jupiter.api.Test)78 JavaIntegrationTest (com.couchbase.client.java.util.JavaIntegrationTest)70 JsonObject (com.couchbase.client.java.json.JsonObject)41 GetResult (com.couchbase.client.java.kv.GetResult)15 MutationResult (com.couchbase.client.java.kv.MutationResult)13 CoreIntegrationTest (com.couchbase.client.core.util.CoreIntegrationTest)9 RateLimitedException (com.couchbase.client.core.error.RateLimitedException)8 TimeoutException (com.couchbase.client.core.error.TimeoutException)7 LookupInResult (com.couchbase.client.java.kv.LookupInResult)7 CouchbaseException (com.couchbase.client.core.error.CouchbaseException)6 ReplaceBodyWithXattr (com.couchbase.client.java.kv.ReplaceBodyWithXattr)6 SearchIndex (com.couchbase.client.java.manager.search.SearchIndex)5 CasMismatchException (com.couchbase.client.core.error.CasMismatchException)4 MutateInResult (com.couchbase.client.java.kv.MutateInResult)4 TestNodeConfig (com.couchbase.client.test.TestNodeConfig)4 DocumentNotFoundException (com.couchbase.client.core.error.DocumentNotFoundException)3 FeatureNotAvailableException (com.couchbase.client.core.error.FeatureNotAvailableException)3 UnambiguousTimeoutException (com.couchbase.client.core.error.UnambiguousTimeoutException)3 Core (com.couchbase.client.core.Core)2