Skip to content

Setup for Dev and Test

Sea Yo edited this page Jan 7, 2016 · 25 revisions

Prerequisites

    gvm install go1.4
    gvm use go1.4
    export GOROOT_BOOTSTRAP=$GOROOT
    gvm install go1.5.1
    gvm use go1.5.1

Download the project repo

Clone the repository to your src tree of your $GOPATH

	mkdir -p $GOPATH/src/github.com/vivowares
	git clone [email protected]:vivowares/octopus.git $GOPATH/src/github.com/vivowares/octopus

Build the project

	cd $GOPATH/src/github.com/vivowares/octopus
	go build -a

Set OCTOPUS_HOME environment variable

	export OCTOPUS_HOME=$GOPATH/src/github.com/vivowares/octopus

You may want to add this environment variable to your bash profile.

Run the migration for sqlite db

	cd tasks
	go run migration.go

By default, Octopus creates db file under at $OCTOPUS_HOME/db/octopus_development.db for development mode and $OCTOPUS_HOME/db/octopus_test.db for test mode.

You can change the default db location in configs/octopus_development.yml and configs/octopus_test.yml and then build the entire project again. We will refer to these two files as configuration files from going onwards.

Setup ES mappings for Octopus

	cd tasks
	go run setup_es.go

If you ran into the problem connecting to Elasticsearch, check if your ES server is running at port 9200. If not you can modify the ES host and port in the configuration files.

Start Octopus

Now that you have most of dependencies ready, you can start Octopus by doing:

	./octopus

And Octopus should be listening to your port 8080 for http requests and 8081 for websocket requests by default. Hoo-Yah!

Run the tests

There are two parts of the tests, unit tests and integration tests. You can use the normal way to start unit tests:

	go test -v ./...

Ignore anything outputted from tasks directory, they are not part of the tests.

Running the integration test requires to run the Octopus server first. So we recommend to run all the test via the auto_test.sh script.

For example:

	./auto_test.sh -v -n 4

Run all the unit tests for 4 times in verbose mode. All log outputs will be generated into auto_test.log, and will be overridden next time you run the tests.

	./auto_test.sh -vi -n 4

Run both unit tests and integration tests for 4 times in verbose mode.

There are a bunch of tests for testing race conditions. If you are interested in running the tests util if fails, you can do:

	./auto_test.sh -vif -n 1000

It will run the tests for no more than 1000 times or util if fails. Or if you are more aggressive to run it endlessly util something fails. Do:

	./auto_test.sh -vif -n 0

You can read ./auto_test.sh -h for more details.

Clone this wiki locally