I am using the latest .Net SDK and TestContainers to do integration testing and all works perfectly until I try to use a query and then I get the following error:
Service n1ql is either not configured or cannot be reached. Check logs for details.
Code for container setup is pretty straight forward:
CouchbaseContainer = new Testcontainers.Couchbase.CouchbaseBuilder()
.WithImage("couchbase/server:latest")
.WithHostname("localhost")
.WithPortBinding(8091, 8091)
.WithPortBinding(8093, 8093)
.WithPortBinding(8094, 8094)
.Build();
await CouchbaseContainer.StartAsync();
With or without port bindings has not made a difference.
Creating a bucket if it does not exist, which is the case each time the TestContainer is run:
var bucketManager = cluster.Buckets;
var buckets = await bucketManager.GetAllBucketsAsync();
if (!buckets.ContainsKey(settings.BucketName))
{
var bucketSettings = new BucketSettings
{
Name = settings.BucketName,
BucketType = BucketType.Couchbase,
RamQuotaMB = 100,
FlushEnabled = true,
NumReplicas = 1,
ReplicaIndexes = true
};
await bucketManager.CreateBucketAsync(bucketSettings);
I am just not sure, where or how to make sure the N1QL services is setup for my bucket.
Looking at GitHub:
It seems they enable all of the required services automatically:
static CouchbaseBuilder()
{
EnabledServices.Add(CouchbaseService.Data);
EnabledServices.Add(CouchbaseService.Index);
EnabledServices.Add(CouchbaseService.Query);
EnabledServices.Add(CouchbaseService.Search);
}
Anyone else have or solve this problem?