public void OneTimeSetUp() { TestConfiguration.IgnoreIfMock(); _cluster = new Cluster(Utils.TestConfiguration.GetConfiguration("basic")); _cluster.SetupEnhancedAuth(); _clusterManager = _cluster.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword); var listbucketsResult = _clusterManager.ListBuckets(); if (listbucketsResult.Value.Any(bucket => bucket.Name == BucketName)) { var removeResult = _clusterManager.RemoveBucket(BucketName); Assert.IsTrue(removeResult.Success); } var createResult = _clusterManager.CreateBucket(BucketName, replicaNumber: ReplicaNumber.Zero, flushEnabled: true); Assert.True(createResult.Success); // Allow time for bucket to be created and configuration to propagate before beginning operations Thread.Sleep(500); _bucket = _cluster.OpenBucket(BucketName); _bucketManager = _bucket.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword); }
public void CreateBucket_DoesNotExist_Success(BucketTypeEnum bucketType) { if (!TestConfiguration.Settings.EnhancedAuth && bucketType == BucketTypeEnum.Ephemeral) { Assert.Ignore("Emphemeral buckets require CB server 5.0+"); } // Ensure the bucket doesn't already exist _clusterManager.RemoveBucket(BucketName + "_" + bucketType); Thread.Sleep(250); // Act var result = _clusterManager.CreateBucket(BucketName, bucketType: bucketType); try { // Assert Assert.NotNull(result); Assert.True(result.Success); } finally { // Cleanup Thread.Sleep(250); var removeResult = _clusterManager.RemoveBucket(BucketName); Assert.True(removeResult.Success); Thread.Sleep(250); } }
public void CreateBucket_DoesNotExist_Success() { // Arrange // Ensure the bucket doesn't already exist _clusterManager.RemoveBucket(BucketName); Thread.Sleep(250); // Act var result = _clusterManager.CreateBucket(BucketName); try { // Assert Assert.NotNull(result); Assert.True(result.Success); } finally { // Cleanup Thread.Sleep(250); var removeResult = _clusterManager.RemoveBucket(BucketName); Assert.True(removeResult.Success); Thread.Sleep(250); } }
public void OneTimeSetUp() { _cluster = new Cluster(Utils.TestConfiguration.GetConfiguration("basic")); _clusterManager = _cluster.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword); var createResult = _clusterManager.CreateBucket(BucketName, replicaNumber:ReplicaNumber.Zero, flushEnabled: true); Assert.True(createResult.Success); // Allow time for bucket to be created and configuration to propagate before beginning operations Thread.Sleep(500); _bucket = _cluster.OpenBucket(BucketName); _bucketManager = _bucket.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword); }
public void OneTimeSetUp() { _cluster = new Cluster(Utils.TestConfiguration.GetConfiguration("basic")); _clusterManager = _cluster.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword); var createResult = _clusterManager.CreateBucket(BucketName, flushEnabled: true, bucketType:BucketTypeEnum.Memcached); Console.WriteLine(createResult.Success); // Allow time for bucket to be created and configuration to propagate before beginning operations Thread.Sleep(500); _bucket = _cluster.OpenBucket(BucketName); _bucketManager = _bucket.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword); }
public void OneTimeSetUp() { _cluster = new Cluster(Utils.TestConfiguration.GetConfiguration("basic")); _clusterManager = _cluster.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword); var createResult = _clusterManager.CreateBucket(BucketName, flushEnabled: true, bucketType: BucketTypeEnum.Memcached); Console.WriteLine(createResult.Success); // Allow time for bucket to be created and configuration to propagate before beginning operations Thread.Sleep(500); _bucket = _cluster.OpenBucket(BucketName); _bucketManager = _bucket.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword); }
public void OneTimeSetUp() { _cluster = new Cluster(Utils.TestConfiguration.GetConfiguration("basic")); _clusterManager = _cluster.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword); var createResult = _clusterManager.CreateBucket(BucketName, replicaNumber: ReplicaNumber.Zero, flushEnabled: true); Assert.True(createResult.Success); // Allow time for bucket to be created and configuration to propagate before beginning operations Thread.Sleep(500); _bucket = _cluster.OpenBucket(BucketName); _bucketManager = _bucket.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword); }
private async Task InitAsync() { // Initialize a clean Couchbase bucket. cluster = new Cluster(); clusterManager = cluster.CreateManager(CouchbaseUID, CouchbasePWD); if (clusterManager.ListBuckets().Value.Count(b => b.Name == BucketName) > 0) { clusterManager.RemoveBucket(BucketName); } if (!clusterManager.CreateBucket(BucketName, 100).Success) { Assert.True(false, $"Could not create the [{BucketName}] Couchbase bucket."); } Bucket = cluster.OpenBucket(BucketName); // Crank up the sync gateway. syncGatewayProcess = Process.Start(SyncGatewayPath, $"-bucket \"{BucketName}\" -dbname \"{DatabaseName}\""); if (syncGatewayProcess.WaitForExit(2000)) { Assert.True(false, $"Could not start a Couchbase Sync Gateway. Verify that the service is not already running."); } // Initialize the sync gateway database. gateway = new Gateway( new GatewaySettings() { Host = "localhost" }); gatewayManager = gateway.CreateManager(); var databasesDeleted = false; foreach (var database in await gatewayManager.DatabaseListAsync()) { if (database == DatabaseName) { await gatewayManager.DatabaseRemoveAsync(database); databasesDeleted = true; } } if (databasesDeleted) { // Looks like the sync gateway needs some time to stablize // after deleting databases. await Task.Delay(TimeSpan.FromSeconds(5)); } await gatewayManager.DatabaseCreateAsync( new DatabaseConfiguration() { Name = DatabaseName, Bucket = BucketName, Server = "http://127.0.0.1:8091", Sync = "function (doc, oldDoc) { channel(doc.channels); }" }); }
/// <summary> /// Opens the default bucket associated with a Couchbase Cluster. /// </summary> /// <returns>An instance which implements the IBucket interface with the /// default buckets configuration.</returns> /// <remarks>Use Cluster.CloseBucket(bucket) to release resources associated with a Bucket.</remarks> public IBucket OpenBucket() { return(_clusterManager.CreateBucket(DefaultBucket)); }
private (bool, string) CreateBucket(string name) { var result = _clusterManager.CreateBucket(name); return(result.Success, result.Message); }