use of com.couchbase.client.java.manager.collection.CollectionManager in project couchbase-jvm-clients by couchbase.
the class RateLimitingIntegrationTest method scopeQuotaLimitExceedMaxCollections.
@Test
void scopeQuotaLimitExceedMaxCollections() throws Exception {
String scopeName = "exceedMaxCollections";
ScopeRateLimits limits = new ScopeRateLimits();
limits.clusterManager = new ClusterManagerScopeRateLimit(1);
createLimitedScope(scopeName, config().bucketname(), limits);
CollectionManager collectionManager = adminCluster.bucket(config().bucketname()).collections();
try {
collectionManager.createCollection(CollectionSpec.create("collection1", scopeName));
assertThrows(QuotaLimitedException.class, () -> collectionManager.createCollection(CollectionSpec.create("collection2", scopeName)));
} finally {
collectionManager.dropScope(scopeName);
}
}
use of com.couchbase.client.java.manager.collection.CollectionManager in project couchbase-jvm-clients by couchbase.
the class RateLimitingIntegrationTest method kvQuotaLimitScopesDataSize.
@Test
void kvQuotaLimitScopesDataSize() throws Exception {
String scopeName = "ratelimitDataSize2";
ScopeRateLimits limits = new ScopeRateLimits();
limits.kv = new KeyValueScopeRateLimit(1024 * 1024);
createLimitedScope(scopeName, config().bucketname(), limits);
CollectionManager collectionManager = adminCluster.bucket(config().bucketname()).collections();
collectionManager.createCollection(CollectionSpec.create(scopeName, scopeName));
Collection collection = adminCluster.bucket(config().bucketname()).scope(scopeName).collection(scopeName);
try {
collection.upsert("ratelimitkvscope", randomString(512));
assertThrows(QuotaLimitedException.class, () -> collection.upsert("ratelimitkvscope", randomString(2048)));
} finally {
collectionManager.dropScope(scopeName);
}
}
use of com.couchbase.client.java.manager.collection.CollectionManager in project spring-data-couchbase by spring-projects.
the class CollectionAwareIntegrationTests method beforeAll.
@BeforeAll
public static void beforeAll() {
callSuperBeforeAll(new Object() {
});
ClusterEnvironment environment = environment().build();
Cluster cluster = Cluster.connect(seedNodes(), ClusterOptions.clusterOptions(authenticator()).environment(environment));
Bucket bucket = cluster.bucket(config().bucketname());
bucket.waitUntilReady(Duration.ofSeconds(5));
waitForService(bucket, ServiceType.QUERY);
waitForQueryIndexerToHaveBucket(cluster, config().bucketname());
CollectionManager collectionManager = bucket.collections();
setupScopeCollection(cluster, scopeName, collectionName, collectionManager);
setupScopeCollection(cluster, scopeName, collectionName2, collectionManager);
if (otherScope != null || otherCollection != null) {
// afterAll should be undoing the creation of scope etc
setupScopeCollection(cluster, otherScope, otherCollection, collectionManager);
}
try {
// needs an index for this N1ql Join
// create index ix2 on my_bucket(parent_id) where `_class` = 'org.springframework.data.couchbase.domain.Address';
List<String> fieldList = new ArrayList<>();
fieldList.add("parentId");
cluster.query("CREATE INDEX `parent_idx` ON default:" + bucketName() + "." + scopeName + "." + collectionName2 + "(parentId)");
} catch (IndexExistsException ife) {
LOGGER.warn("IndexFailureException occurred - ignoring: ", ife.toString());
}
Config.setScopeName(scopeName);
ApplicationContext ac = new AnnotationConfigApplicationContext(Config.class);
// the Config class has been modified, these need to be loaded again
couchbaseTemplate = (CouchbaseTemplate) ac.getBean(COUCHBASE_TEMPLATE);
reactiveCouchbaseTemplate = (ReactiveCouchbaseTemplate) ac.getBean(REACTIVE_COUCHBASE_TEMPLATE);
}
use of com.couchbase.client.java.manager.collection.CollectionManager in project couchbase-jvm-clients by couchbase.
the class RateLimitingIntegrationTest method searchQuotaLimitScopesMaxIndexes.
@Test
@IgnoreWhen(missesCapabilities = Capabilities.SEARCH)
void searchQuotaLimitScopesMaxIndexes() throws Exception {
String scopeName = "ratelimitSearch";
String collectionName = "searchCollection";
ScopeRateLimits limits = new ScopeRateLimits();
limits.fts = new SearchScopeRateLimit(1);
createLimitedScope(scopeName, config().bucketname(), limits);
CollectionManager collectionManager = adminCluster.bucket(config().bucketname()).collections();
Map<String, Object> params = mapOf("mapping", mapOf("types", mapOf(scopeName + "." + collectionName, mapOf("enabled", true, "dynamic", true)), "default_mapping", mapOf("enabled", false), "default_type", "_default", "default_analyzer", "standard", "default_field", "_all"), "doc_config", mapOf("mode", "scope.collection.type_field", "type_field", "type"));
try {
CollectionSpec collectionSpec = CollectionSpec.create(collectionName, scopeName);
collectionManager.createCollection(collectionSpec);
waitUntilCondition(() -> collectionExists(collectionManager, collectionSpec));
waitForService(adminCluster.bucket(config().bucketname()), ServiceType.SEARCH);
adminCluster.searchIndexes().upsertIndex(new SearchIndex("ratelimits1", config().bucketname()).params(params));
QuotaLimitedException ex = assertThrows(QuotaLimitedException.class, () -> adminCluster.searchIndexes().upsertIndex(new SearchIndex("ratelimits2", config().bucketname()).params(params)));
} finally {
collectionManager.dropScope(scopeName);
}
}
Aggregations