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());
}
}
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);
}
}
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);
}
}
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"));
}
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"));
}
Aggregations