CouchbaseMock icon indicating copy to clipboard operation
CouchbaseMock copied to clipboard

Create buckets automatically when server is started

Open hezjing opened this issue 9 years ago • 5 comments

Instead of creating the bucket using REST API, is there a way that we can configure CouchbaseMock to create the buckets automatically every time it is started?

hezjing avatar Mar 09 '15 09:03 hezjing

Sure, you can use the command line syntax (e.g. -buckets). See the-?` option for more details:

 $ java -jar CouchbaseMock.jar -?
Options are:
-h --host             The hostname for the REST port. Default=8091
-b --buckets          (See description below
-p --nodes            The number of nodes each bucket should contain. Default=10
-v --vbuckets         The number of vbuckets each bucket should contain. Default=1024
-R --replicas         The number of replica nodes for each bucket. Default=2
   --harakiri-monitor The host:port on which the control socket should connect to
-S --with-beer-sample Initialize the cluster with the `beer-sample` bucket active
-D --docs             Specify a ZIP file that should contain documents to be loaded
                      into the `default` bucket
-E --empty            Initialize a blank cluster without any buckets. Buckets may then
                      be later added via the REST API

=== -- bucket option ===
Buckets descriptions is a comma-separated list of {name}:{password}:{bucket type} pairs.
To allow unauthorized connections, omit password.
Third parameter could be either 'memcache' or 'couchbase' (default value is 'couchbase'). E.g.
    default:,test:,protected:secret,cache::memcache
The default is equivalent to `couchbase::

mnunberg avatar Mar 09 '15 14:03 mnunberg

Thanks, --buckets works!

But there is no similar option for creating views?

hezjing avatar Mar 10 '15 06:03 hezjing

Not at the moment. How would such an interface look like anyway? What would it accept as input? Something akin to cbdocloader?

mnunberg avatar Mar 10 '15 14:03 mnunberg

You can specify a zipfile (in the form of cbdocloader) and pass that to the -D option.

mnunberg avatar Apr 27 '15 15:04 mnunberg

What about a zip file, where each folder is the name of a bucket, each subfolder is a design document, and .js files are in each with the name of the view? Or maybe just a single JSON with stringified javascript functions?

jpike88 avatar May 15 '17 04:05 jpike88