Skip to content

Latest commit

 

History

History
131 lines (85 loc) · 4.09 KB

BUILD.md

File metadata and controls

131 lines (85 loc) · 4.09 KB

Building From Source (via repo)

In order to build with pinned dependencies, you will need to use the the repo multi-repository tool.

Install prequisites

$ brew install repo

Bootstrap initialization -- one time step

Create a directory where you want to store the Sync Gateway source code and bundled dependencies, and change to that directory. For example:

$ mkdir ~/sync_gateway; cd ~/sync_gateway

Download the bootstrap.sh shell script and run it:

$ wget https://raw.githubusercontent.com/couchbase/sync_gateway/master/bootstrap.sh
$ chmod +x bootstrap.sh
$ ./bootstrap.sh

After it's complete, you should see a message that says Bootstrap complete! Run ./build.sh to build and ./test.sh to run tests

Note: if you want to run the bootstrap initialization and start on a particular Sync Gateway commit, you can provide the -c flag, eg ./bootstrap.sh -c y0pl33g0r425.

Build and Test

To build Sync Gateway from source and run the unit tests, run:

$ ./build.sh && ./test.sh

If you run into a gpg: Can't check signature: public key not found error, see issue 1654 for help.

Bootstrap variations: start on a different commit

To bootstrap and start with a different Sync Gateway commit:

$ ./bootstrap.sh -c commit-hash

Switch to a different sync gateway branch via snap-manifest.sh

Make sure the repo status doesn't show any uncommitted changes. For example in the output below, docs/BUILD.md is an uncommitted change:

$ repo status
project godeps/src/github.com/couchbase/sync_gateway/ branch feature/fix_snap_manifest_rebased
 -m     docs/BUILD.md
project godeps/src/github.com/couchbaselabs/sync-gateway-accel/ branch master
project godeps/src/github.com/couchbaselabs/walrus/ branch feature/sg_2418_sgbucket_interface

Once the repo status is clean, to switch to a different sync gateway commit (which must be pushed up to github):

$ ./snap-manifest.sh --sg-commit sync-gateway-commit-or-branch

Build via go get w/ dependency pinning

See the Build Extra for instructions on how to build via go get (as opposed to repo) with dependency pinning.

Cross-compiling for Linux

x86 Linux

$ ls $(go env GOROOT)/pkg && sudo chown -R $USER $(go env GOROOT)/pkg
$ GOOS=linux GOARCH=amd64 ./build.sh

ARM Linux

GOOS=linux GOARCH=arm ./build.sh

The binaries will be saved to godeps/bin/linux_amd64/ or godeps/bin/linux_arm/

Unit Testing options

Environment variables

Name Description
SG_TEST_BACKING_STORE Walrus by default, but can set to "Couchbase" to have it use http://localhost:8091
SG_TEST_COUCHBASE_SERVER_URL Uses http://localhost:8091 by default, but you can set this to any valid Couchbase Server URL
SG_TEST_USE_XATTRS Don't use Xattrs by default, but provide the test runner to specify Xattr usage
SG_TEST_USE_AUTH_HANDLER Don't use an auth handler by default, but provide a way to override

Running a single unit test against Walrus and Couchbase Server

Walrus

$ export GOPATH=`pwd`/godeps
$ go test -v -run ^TestChangesAfterChannelAdded$ github.com/couchbase/sync_gateway/...

Couchbase Server

Install Couchbase Server locally and set the Administrator username / password to match the values in base/constants.go for DefaultCouchbaseAdministrator and DefaultCouchbasePassword

$ export GOPATH=`pwd`/godeps
$ SG_TEST_BACKING_STORE=Couchbase go test -v -run ^TestChangesAfterChannelAdded$ github.com/couchbase/sync_gateway/...

Running full set of unit tests against Couchbase Server

Install Couchbase Server locally and set the Administrator username / password to match the values in base/constants.go for DefaultCouchbaseAdministrator and DefaultCouchbasePassword

$ ./test_integration.sh