This document describes the development environment and typical steps to hack on netplugin. While there are alternative ways, the steps listed here are used by a lot of developers while making incremental changes and doing frequent compilation for a quicker development cycle.
Happy hacking!
Vagarant 1.8.7 VirtualBox 5.1.x
Notes: Make sure GOPATH is set. This is a one time activity.
$ cd $GOPATH
$ mkdir -p src/github.com/contiv
$ cd src/github.com/contiv
# it is recommended that you fork the repo if you want to make contributions
$ git clone https://github.com/<your-github-id>/netplugin.git
Note: This is a one time activity
$ cd $GOPATH/src/github.com/contiv/netplugin
$ make start
Notes: This must be done inside a VM. Note that netplugin repo is mounted from the host, therefore any changes changes are saved outside VM and are not lost if VM crashes or dies or any reason
# ssh into one of the VMs
$ make ssh
# this command will change the directory to $GOPATH/src/github.com/contiv/netplugin
# make code changes here and add unit/system tests for your changes
. . .
# this command might not be needed if the directory wasn't changed
$ cd $GOPATH/src/github.com/contiv/netplugin
# compile the recently made changes. `Estimated time: 1m 20s`
$ make host-build
Note: All this is done from inside the VM. Technically the VM is the development environment including unit testing
$ cd $GOPATH/src/github.com/contiv/netplugin
# make sure to clean up any remnants from prior runs; note that cleanup may
# throw some harmless errors if things are already clean (so feel free to ignore them)
$ make host-cleanup
$ make host-unit-test
# iterate back to step 3 if tests fails or you need to make more code changes
Note: This is done outside the VMs. System tests would start the vagrant VMs if they are not already running and run the tests on three VMs
$ make system-test
Note: This is best done outside the VM using your git credentials setup on the host.
Please see here for working with godep
- Go go http://contiv-ci.ngrok.io/view/Netplugin/
- Click on
log in
button on top right corner and log in as user:guest
, password:guest
- Click on
Netplugin_OnDemand_Build
job - Click on
Build with Parameters
link on the left side - In
GIT_URL
field, enter the URL to your fork of netplugin - In
GIT_BRANCH
field, enter the branch name in your fork - Click
Build
button
This will checkout a tree from your fork and run full Jenkins CI on the branch.
Easiest way to work across multiple repos is by doing a godep restore
first and then make changes.
- SSH to vagrant VM, goto
/opt/gopath/src/github.com/contiv/netplugin
directory. - issue
godep restore
command to restore all dependent packages into$GOPATH
- go to individual repo directory, for example
github.com/contiv/ofnet
and checkout your fork of the repository. - Make changes to netplugin and ofnet and rebuild netplugin/netmaster using
cd /opt/gopath/src/github.com/contiv/netplugin; go install ./netplugin ./netmaster
- restart netplugin/netmaster using
make host-restart
- Test your code
- Repeat steps 4-6 multiple times as you need
Once you are ready to commit:
- Commit changes in ofnet/contivmodel first. Push the changes to your fork and submit pull request.
- Once the pull request is merged, checkout the latest version of ofnet/contivmodel from contiv repo.
- update netplugin's godeps using
godep update github.com/contiv/ofnet
orgodep update github.com/contiv/contivmodel
. Note that If you are godep updating ofnet, you need to update all ofnet packages in one command. E.g.godep update github.com/contiv/ofnet github.com/contiv/ofnet/ofctrl github.com/contiv/ofnet/ovsdbDriver github.com/contiv/ofnet/pqueue github.com/contiv/ofnet/rpcHub
- Build netplugin and run unit/system tests as mentioned above
- Commit netplugin changes and submit a pull request
We follow this Workflow for submitting pull requests
It is recommended that all commits in a pull requests is squashed before they can be merged. Please see here for instruction on squashing your commits
Github recently added a feature to automatically squash all merges. We are evaluating using this. Meanwhile please continue to squash all commits in a pull request.