Follow these steps to make a contribution to any of our open source repositories:
-
Ensure that you have completed our CLA Agreement for individuals or corporations.
-
Set your name and email (these should match the information on your submitted CLA)
git config --global user.name "Firstname Lastname" git config --global user.email "[email protected]"
We assume you can install packages (brew, apt-get, or equivalent). We include Mac examples here, replace with your package manager of choice.
Bring homebrew index up-to-date:
brew update
Get mysql libraries (needed by the mysql2 gem):
brew install mysql
Get postgresql libraries (needed by the pg gem):
brew install postgresql
Install pg gem manually by specifying your architecture:
(sudo) env ARCHFLAGS="-arch x86_64" gem install pg -v '0.15.1'
Get redis:
brew install redis
Get Golang:
brew install go
Follow these steps to make a contribution to any of our open source repositories:
-
Fork the repository
-
Update submodules (
git submodule update --init
) -
Create a feature branch (
git checkout -b better_bosh
)- Run the tests to ensure that your local environment is
working
bundle && bundle exec rake
(this may take a while)
- Run the tests to ensure that your local environment is
working
-
Make changes on the branch:
- Adding a feature
- Add tests for the new feature
- Make the tests pass
- Fixing a bug
- Add a test/tests which exercises the bug
- Fix the bug, making the tests pass
- Refactoring existing functionality
- Change the implementation
- Ensure that tests still pass
- If you find yourself changing tests after a refactor, consider refactoring the tests first
- Adding a feature
-
Push to your fork (
git push origin better_bosh
) and submit a pull request selectingdevelop
as the target branch
We favor pull requests with very small, single commits with a single purpose.
Your pull request is much more likely to be accepted if:
-
Your pull request includes tests
-
Your pull request is small and focused with a clear message that conveys the intent of your change.
There are four types of tests in BOSH: unit, integration, CPI lifecycle, and acceptance. Each feature should always contain unit tests reflecting the change, and may need additional tests depending on what is changed.
Unit tests describe behavior of individual objects or methods.
Each BOSH component has its own unit tests in a spec/unit
folder.
Running individual component unit tests:
cd bosh-director # or any other component
bundle exec rspec
Running all unit tests:
bundle exec rake spec:unit
Integration tests describe communication between BOSH components.
They are in the spec/integration
folder.
Running the integration tests:
bundle exec rake spec:integration
CPI lifecycle tests describe CPI behavior and test integration with the infrastructure. Each test runs through every CPI method in a given configuration.
Running CPI lifecycle tests:
cd bosh_vsphere_cpi # or any other CPI
bundle exec rake spec:lifecycle
BATs describe BOSH behavior at the highest level. They often include infrastructure-specific behavior that is not testable at the integration level. BATs test integration between all BOSH components and an infrastructure.
All infrastructures require a stemcell to be specified.
STEMCELL_BUILD_NUMBER
(Optional) Stemcell version to look for locally in<bosh>/tmp/
(defaults to dev build '0000')CANDIDATE_BUILD_NUMBER
- (Optional) Candidate stemcell build number to fetch a remote candidate stemcell from S3 (used for testing in CI)
The BATs require an existing microbosh to be deployed, and a stemcell built (or downloaded) to test with.
To run the BATs manually, follow the steps in the bat
README after deploying a microBOSH and downloading or building a stemcell.
To automatically deploy a microBOSH for you and run the BATs on it, use the spec:system:micro
rake task.
In order to deploy microBOSH and determine which stemcell to use, set environment variables specific to your infrastructure, as described below.
Example:
bundle exec rake spec:system:micro[openstack,kvm,ubuntu,trusty,manual,go]
BOSH_OPENSTACK_NET_ID
- ID of the network on which to deploy microBOSHBOSH_OPENSTACK_MANUAL_IP
- (Optional) Static IP for microBOSH when using VLAN (should be reserved in the bat deployment spec)BOSH_OPENSTACK_VIP_DIRECTOR_IP
- Floating IP for microBOSHBOSH_OPENSTACK_AUTH_URL
- URL to the OpenStack identity serviceBOSH_OPENSTACK_USERNAME
- OpenStack usernameBOSH_OPENSTACK_API_KEY
- OpenStack passwordBOSH_OPENSTACK_TENANT
- OpenStack tenant in which to deploy microBOSHBOSH_OPENSTACK_DEFAULT_SECURITY_GROUP
- Name of the default security group for VMs deployed by microBOSHBOSH_OPENSTACK_DEFAULT_KEY_NAME
- Name of the default SSH keypair for VMs deployed by microBOSHBOSH_OPENSTACK_KEY_NAME
- (Optional) Name of the SSH keypair for deploying microBOSHBOSH_OPENSTACK_PRIVATE_KEY
- Path to the private SSH key for SSHing into VMs deployed by microBOSHBOSH_OPENSTACK_REGION
- OpenStack region in which to deploy microBOSHBOSH_OPENSTACK_REGISTRY_PORT
- (Optional) Local port on which to serve the microBOSH registry serviceBOSH_OPENSTACK_CONNECTION_TIMEOUT
- (Optional) HTTP connection timeout (in seconds) for talking to the OpenStack APIBOSH_OPENSTACK_STATE_TIMEOUT
- (Optional) Timeout (in seconds) to wait for OpenStack resources to reach the desired stateBOSH_OPENSTACK_BAT_DEPLOYMENT_SPEC
Path to the BAT deployment spec YAML (input to the BATs deployment manifest erb template)- See the
bat
README for BAT deployment spec examples. The director uuid and stemcell properties will be auto-populated by the rake task.
- See the
BOSH_VSPHERE_NET_ID
- ID of the network on which to deploy microBOSHBOSH_VSPHERE_MICROBOSH_IP
- (Optional) Static IP for microBOSH (should be reserved in the bat deployment spec)BOSH_VSPHERE_NETMASK
- Netmask for the network on which to deploy microBOSHBOSH_VSPHERE_GATEWAY
- Gateway for the network on which to deploy microBOSHBOSH_VSPHERE_DNS
- DNS server that microBOSH will use to resolve host namesBOSH_VSPHERE_NTP_SERVER
- NTP server that microBOSH will useBOSH_VSPHERE_VCENTER
- Hostname or IP of the vCenter ServerBOSH_VSPHERE_VCENTER_USER
- vSphere usernameBOSH_VSPHERE_VCENTER_PASSWORD
- vSphere passwordBOSH_VSPHERE_VCENTER_DC
- vSphere data centerBOSH_VSPHERE_VCENTER_CLUSTER
- vSphere clusterBOSH_VSPHERE_VCENTER_RESOURCE_POOL
- vSphere resource pool nameBOSH_VSPHERE_VCENTER_FOLDER_PREFIX
- Folder name prefix under which the microBOSH director stores_VMs
and_Templates
BOSH_VSPHERE_VCENTER_UBOSH_FOLDER_PREFIX
- Folder name prefix under which the microBOSH deployer stores_VMs
and_Templates
BOSH_VSPHERE_VCENTER_DATASTORE_PATTERN
- Regular expression pattern that the microBOSH director uses to find datastoresBOSH_VSPHERE_VCENTER_UBOSH_DATASTORE_PATTERN
- Regular expression pattern that the microBOSH deployer uses to find datastoresBOSH_VSPHERE_BAT_DEPLOYMENT_SPEC
Path to the BAT deployment spec YAML (input to the BATs deployment manifest erb template)- See the
bat
README for BAT deployment spec examples. The director uuid and stemcell properties will be auto-populated by the rake task.
- See the
As part of the spec:unit
task we run RuboCop,
which generally enforces the Ruby Style Guide.
We have a number of exceptions (see the various .rubocop.yml
files),
and our style is still evolving, however rake rubocop
is run by Travis
so making these pass will improve the chances that the pull request will
be accepted.