testcontainers-java icon indicating copy to clipboard operation
testcontainers-java copied to clipboard

[couchbase] Add support for scopes and collections.

Open daschl opened this issue 4 years ago • 3 comments

This changeset allows to specify scopes and collections to be automatically created, which is available with Couchbase Server 7.0 and later.

The BucketDefinition is expanded to take a ScopeDefinition which itself
can be configured with CollectionDefinitions. During startup, after the
bucket is created, the scopes and collections are stored on the server.

Note that as a nice "bonus", similar to a primary index being automatically
created on a bucket by default (can be turned off), this change also
automatically adds a primary index for each collection created, as long
as the query service is also enabled.

If the server does not support it, a descriptive error message is shown.

Further Reviewer notes:

 - The primary index creation and keyspace checks have been refactored
   into their own methods since they are now called from two places: once
   for the bucket only and once for bucket, scope and collection triple.
 - A test case has been added to verify using custom scopes and collections.
   To make this work, the enterprise image has been bumped to 7.0 from 6.6.
   The community image is left at 6.6 - we could bump it too, but this gives
   us a little more test coverage on server versions (pre and post collection
   support) for free.

daschl avatar Dec 29 '21 07:12 daschl

This change needs to be rebased after the service quota change is merged, since I built it on top to avoid having to rework it quite a bit.

daschl avatar Dec 29 '21 07:12 daschl

Since this only works since version 7.0, do you think you could make use of ComparableVersion and report incompatibility once a user tries to set scopes or collections?

kiview avatar Jan 03 '22 17:01 kiview

Since this only works since version 7.0, do you think you could make use of ComparableVersion and report incompatibility once a user tries to set scopes or collections?

yes, that's doable - I'll add that

daschl avatar Jan 05 '22 08:01 daschl