<commit_before>## Development

The release requires the Ruby gem Bundler (used by the vendoring script):

```
gem install bundler
```

With bundler installed, switch to ./src/bosh_azure_cpi and run the vendoring script:

```
./vendor_gems
```

If you are using Ubuntu 14.04, you should replace the bundle in ./vendor_gems with /usr/local/bin/bundle.

Then create the BOSH release:

```
bosh create release --force --with-tarball --name bosh-azure-cpi
```

The release is now ready for use. If everything works, commit the changes including the updated gems.

At the end of the CLI output there will be "Release tarball" path.

## Test Interfaces
After you change the CPI code, you can use `bosh_azure_console` to test your changes. Below commands are tested in Ubuntu 14.04 LTS.

```
# Install ruby 2.2.4 with rubyenv
sudo apt-get update
sudo apt-get install -y git gcc make libssl-dev libreadline-dev zlib1g-dev

cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

rbenv install 2.2.4
rbenv global 2.2.4
ruby -v

# Install postgres which bosh-registry depends on
sudo apt-get install -y postgresql postgresql-contrib libpq-dev g++ libmysqlclient-dev libsqlite3-dev

# Create database and user
cat > create_db.sql <<EOS
CREATE USER test WITH PASSWORD '<PASSWORD>';
CREATE DATABASE testdb;
GRANT ALL PRIVILEGES ON DATABASE testdb to test;
EOS
sudo su postgres
psql -f create_db.sql
exit

# Install bosh-registry which CPI depends on
gem install bundle bosh-registry pg --no-ri --no-rdoc

# Workaround for the issue https://github.com/cloudfoundry/bosh/issues/1621
sed -i -e '23s/^/#/' ~/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/bosh-registry-1.3262.24.0/lib/bosh/registry.rb

cat > ~/registry.cfg <<EOS
---
loglevel: debug

http:
  port: 25695
  user: admin
  password: <PASSWORD>

db:
  adapter: postgres<commit_msg>Upgrade dev doc to use Ruby 2.4.1<commit_after>## Development

### Before you start:

Please make sure you have installed ruby 2.1.0+ before you start. In the beginning of section `Test Interfaces` you will see how to install specific version of ruby with `rubyenv`. _FYI, the latest stable version of ruby is 2.4.1_

ruby2.0 is also required in the setup procedure. If you are using bosh devbox deployed with template in this [guidance](./get-started/via-arm-templates/deploy-bosh-via-arm-templates.md) or guidance from `bosh.io` [here](https://bosh.io/docs/init-azure.html), you should have ruby 2.0 installed already. Otherwise, please install it by:

```
sudo apt-get install -y ruby2.0
```


### Install Ruby gem Bundler (used by the vendoring script):

```
gem install bundler
```

### Run vendoring script

With bundler installed, switch to ./src/bosh_azure_cpi and run:

```
./vendor_gems
```

### Create the BOSH release:

_Please make sure you have ruby 2.0 installed before continue._

```
bosh create release --force --with-tarball --name bosh-azure-cpi
```

The release is now ready for use. If everything works, commit the changes including the updated gems.

At the end of the CLI output there will be "Release tarball" path.

## Test Interfaces
After you change the CPI code, you can use `bosh_azure_console` to test your changes. Below commands are tested in Ubuntu 14.04 LTS.

```
# Install ruby 2.4.1 with rubyenv
sudo apt-get update
sudo apt-get install -y git gcc make libssl-dev libreadline-dev zlib1g-dev

cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

rbenv install 2.4.1
rbenv global 2.4.1
ruby -v

# Install postgres which bosh-registry depends on
sudo apt-get install -y postgresql postgresql-contrib libpq-dev g++ libmysqlclient-dev libsqlite3-dev

# Create database and user
cat > create_db.sql <<EOS
CREATE USER test WITH PASSWORD '<PASSWORD>';
CREATE DATABASE testdb;
GRANT ALL PRIVILEGES ON DATABASE testdb to test;
EOS
sudo su postgres
psql -f create_db.sql
exit

# Install bosh-registry which CPI depends on
gem install bundle bosh-registry pg --no-ri --no-rdoc

# Workaround for the issue https://github.com/cloudfoundry/bosh/issues/1621
sed -i -e '23s/^/#/' ~/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bosh-registry-1.3262.24.0/lib/bosh/registry.rb

cat > ~/registry.cfg <<EOS
---
loglevel: debug

http:
  port: 25695
  user: admin
  password: <PASSWORD>

db:
  adapter: postgres
{'fraction_non_alphanumeric': 0.11770811708532282, 'fraction_numerical': 0.02096740709985468, 'mean_word_length': 3.8913705583756344, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 23, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3905338', 'n_tokens_mistral': 1771, 'n_tokens_neox': 1629, 'n_words': 576}