Commit 06712f6f authored by Aaron Hurley's avatar Aaron Hurley

Merge branch 'develop' of github.com:cloudfoundry/bosh into develop

parents eae1c7f4 f4140763
......@@ -8,16 +8,16 @@ GIT
PATH
remote: agent_client
specs:
agent_client (1.2941.0)
agent_client (1.2949.0)
httpclient (= 2.4.0)
yajl-ruby (~> 1.2.0)
PATH
remote: blobstore_client
specs:
blobstore_client (1.2941.0)
blobstore_client (1.2949.0)
aws-sdk (= 1.60.2)
bosh_common (~> 1.2941.0)
bosh_common (~> 1.2949.0)
fog (~> 1.27.0)
httpclient (= 2.4.0)
multi_json (~> 1.1)
......@@ -26,7 +26,7 @@ PATH
PATH
remote: bosh-core
specs:
bosh-core (1.2941.0)
bosh-core (1.2949.0)
gibberish (~> 1.4.0)
yajl-ruby (~> 1.2.0)
......@@ -49,18 +49,18 @@ PATH
PATH
remote: bosh-director
specs:
bosh-director (1.2941.0)
bosh-director (1.2949.0)
bcrypt-ruby (~> 3.0.1)
blobstore_client (~> 1.2941.0)
bosh-core (~> 1.2941.0)
bosh-director-core (~> 1.2941.0)
bosh-template (~> 1.2941.0)
bosh_aws_cpi (~> 1.2941.0)
bosh_common (~> 1.2941.0)
bosh_cpi (~> 1.2941.0)
bosh_openstack_cpi (~> 1.2941.0)
blobstore_client (~> 1.2949.0)
bosh-core (~> 1.2949.0)
bosh-director-core (~> 1.2949.0)
bosh-template (~> 1.2949.0)
bosh_aws_cpi (~> 1.2949.0)
bosh_common (~> 1.2949.0)
bosh_cpi (~> 1.2949.0)
bosh_openstack_cpi (~> 1.2949.0)
bosh_vcloud_cpi (~> 0.7.3)
bosh_vsphere_cpi (~> 1.2941.0)
bosh_vsphere_cpi (~> 1.2949.0)
cf-uaa-lib (~> 3.2.1)
eventmachine (~> 1.0.0)
fog (~> 1.27.0)
......@@ -85,14 +85,14 @@ PATH
PATH
remote: bosh-director-core
specs:
bosh-director-core (1.2941.0)
bosh-template (~> 1.2941.0)
bosh_common (~> 1.2941.0)
bosh-director-core (1.2949.0)
bosh-template (~> 1.2949.0)
bosh_common (~> 1.2949.0)
PATH
remote: bosh-monitor
specs:
bosh-monitor (1.2941.0)
bosh-monitor (1.2949.0)
aws-sdk (= 1.60.2)
dogapi (~> 1.6.0)
em-http-request (~> 0.3.0)
......@@ -106,9 +106,9 @@ PATH
PATH
remote: bosh-registry
specs:
bosh-registry (1.2941.0)
bosh-registry (1.2949.0)
aws-sdk (= 1.60.2)
bosh_cpi (~> 1.2941.0)
bosh_cpi (~> 1.2949.0)
fog (~> 1.27.0)
sequel (~> 3.43.0)
sinatra (~> 1.4.2)
......@@ -118,45 +118,45 @@ PATH
PATH
remote: bosh-release
specs:
bosh-release (1.2941.0)
agent_client (~> 1.2941.0)
blobstore_client (~> 1.2941.0)
bosh-template (~> 1.2941.0)
bosh_common (~> 1.2941.0)
bosh-release (1.2949.0)
agent_client (~> 1.2949.0)
blobstore_client (~> 1.2949.0)
bosh-template (~> 1.2949.0)
bosh_common (~> 1.2949.0)
trollop (~> 1.16)
yajl-ruby (~> 1.2.0)
PATH
remote: bosh-stemcell
specs:
bosh-stemcell (1.2941.0)
bosh-core (~> 1.2941.0)
bosh_aws_cpi (~> 1.2941.0)
bosh-stemcell (1.2949.0)
bosh-core (~> 1.2949.0)
bosh_aws_cpi (~> 1.2949.0)
PATH
remote: bosh-template
specs:
bosh-template (1.2941.0)
bosh-template (1.2949.0)
semi_semantic (~> 1.1.0)
PATH
remote: bosh_aws_cpi
specs:
bosh_aws_cpi (1.2941.0)
bosh_aws_cpi (1.2949.0)
aws-sdk (= 1.60.2)
bosh-registry (~> 1.2941.0)
bosh_common (~> 1.2941.0)
bosh_cpi (~> 1.2941.0)
bosh-registry (~> 1.2949.0)
bosh_common (~> 1.2949.0)
bosh_cpi (~> 1.2949.0)
httpclient (= 2.4.0)
yajl-ruby (>= 0.8.2)
PATH
remote: bosh_cli
specs:
bosh_cli (1.2941.0)
blobstore_client (~> 1.2941.0)
bosh-template (~> 1.2941.0)
bosh_common (~> 1.2941.0)
bosh_cli (1.2949.0)
blobstore_client (~> 1.2949.0)
bosh-template (~> 1.2949.0)
bosh_common (~> 1.2949.0)
cf-uaa-lib (~> 3.2.1)
highline (~> 1.6.2)
httpclient (= 2.4.0)
......@@ -172,54 +172,54 @@ PATH
PATH
remote: bosh_cli_plugin_aws
specs:
bosh_cli_plugin_aws (1.2941.0)
bosh-core (~> 1.2941.0)
bosh-stemcell (~> 1.2941.0)
bosh_aws_cpi (~> 1.2941.0)
bosh_cli (~> 1.2941.0)
bosh_cli_plugin_micro (~> 1.2941.0)
bosh_cli_plugin_aws (1.2949.0)
bosh-core (~> 1.2949.0)
bosh-stemcell (~> 1.2949.0)
bosh_aws_cpi (~> 1.2949.0)
bosh_cli (~> 1.2949.0)
bosh_cli_plugin_micro (~> 1.2949.0)
PATH
remote: bosh_cli_plugin_micro
specs:
bosh_cli_plugin_micro (1.2941.0)
agent_client (~> 1.2941.0)
blobstore_client (~> 1.2941.0)
bosh-core (~> 1.2941.0)
bosh-director-core (~> 1.2941.0)
bosh-registry (~> 1.2941.0)
bosh-stemcell (~> 1.2941.0)
bosh_aws_cpi (~> 1.2941.0)
bosh_cli (~> 1.2941.0)
bosh_cpi (~> 1.2941.0)
bosh_openstack_cpi (~> 1.2941.0)
bosh_cli_plugin_micro (1.2949.0)
agent_client (~> 1.2949.0)
blobstore_client (~> 1.2949.0)
bosh-core (~> 1.2949.0)
bosh-director-core (~> 1.2949.0)
bosh-registry (~> 1.2949.0)
bosh-stemcell (~> 1.2949.0)
bosh_aws_cpi (~> 1.2949.0)
bosh_cli (~> 1.2949.0)
bosh_cpi (~> 1.2949.0)
bosh_openstack_cpi (~> 1.2949.0)
bosh_vcloud_cpi (~> 0.7.3)
bosh_vsphere_cpi (~> 1.2941.0)
bosh_vsphere_cpi (~> 1.2949.0)
mono_logger (~> 1.1.0)
sqlite3 (~> 1.3.7)
PATH
remote: bosh_common
specs:
bosh_common (1.2941.0)
bosh_common (1.2949.0)
logging (~> 1.8.2)
semi_semantic (~> 1.1.0)
PATH
remote: bosh_cpi
specs:
bosh_cpi (1.2941.0)
bosh_common (~> 1.2941.0)
bosh_cpi (1.2949.0)
bosh_common (~> 1.2949.0)
logging (~> 1.8.2)
membrane (~> 1.1.0)
PATH
remote: bosh_openstack_cpi
specs:
bosh_openstack_cpi (1.2941.0)
bosh-registry (~> 1.2941.0)
bosh_common (~> 1.2941.0)
bosh_cpi (~> 1.2941.0)
bosh_openstack_cpi (1.2949.0)
bosh-registry (~> 1.2949.0)
bosh_common (~> 1.2949.0)
bosh_cpi (~> 1.2949.0)
fog (~> 1.27.0)
httpclient (= 2.4.0)
membrane (~> 1.1.0)
......@@ -228,9 +228,9 @@ PATH
PATH
remote: bosh_vsphere_cpi
specs:
bosh_vsphere_cpi (1.2941.0)
bosh_common (~> 1.2941.0)
bosh_cpi (~> 1.2941.0)
bosh_vsphere_cpi (1.2949.0)
bosh_common (~> 1.2949.0)
bosh_cpi (~> 1.2949.0)
builder (~> 3.1.4)
httpclient (= 2.4.0)
membrane (~> 1.1.0)
......@@ -240,7 +240,7 @@ PATH
PATH
remote: simple_blobstore_server
specs:
simple_blobstore_server (1.2941.0)
simple_blobstore_server (1.2949.0)
sinatra (~> 1.4.2)
thin (~> 1.5.0)
......
module Bosh
module Agent
class Client
VERSION = '1.2941.0'
VERSION = '1.2949.0'
end
end
end
module Bosh
module Blobstore
class Client
VERSION = '1.2941.0'
VERSION = '1.2949.0'
end
end
end
module Bosh
module Core
VERSION = '1.2941.0'
VERSION = '1.2949.0'
end
end
#!/usr/bin/env ruby
require "socket"
class ConnectionProxy
def initialize(remote_host, remote_port, listen_port)
@max_threads = 32
@threads = []
@server_sockets = {}
@remote_host = remote_host
@remote_port = remote_port
@listen_port = listen_port
end
# This method is inspired by an example found at
# http://blog.bitmelt.com/2010/01/transparent-tcp-proxy-in-ruby-jruby.html
def start
puts "Starting to proxy connections from localhost:#{@listen_port} -> #{@remote_host}:#{@remote_port}"
server = TCPServer.new(nil, @listen_port)
while true
# Start a new thread for every client connection.
begin
socket = server.accept
@threads << Thread.new(socket) do |client_socket|
proxy_single_connection(client_socket)
end
rescue Interrupt => i
server.close
ensure
# Clean up the dead threads, and wait until we have available threads.
@threads = @threads.select { |t| t.alive? ? true : (t.join; false) }
while @threads.size >= @max_threads
puts "Too many ConnectionProxy threads in use! Sleeping until some exit."
sleep 1
@threads = @threads.select { |t| t.alive? ? true : (t.join; false) }
end
end
end
end
def proxy_single_connection(client_socket)
begin
begin
server_socket = TCPSocket.new(@remote_host, @remote_port)
@server_sockets[Thread.current] = server_socket
rescue Errno::ECONNREFUSED
client_socket.close
raise
end
while true
# Wait for data to be available on either socket.
(ready_sockets, dummy, dummy) = IO.select([client_socket, server_socket])
begin
ready_sockets.each do |socket|
data = socket.readpartial(4096)
if socket == client_socket
# Read from client, write to server.
server_socket.write data
server_socket.flush
else
# Read from server, write to client.
client_socket.write data
client_socket.flush
end
end
rescue EOFError
break
end
end
rescue StandardError => e
# this happens when we get EOF on the client or server socket
end
@server_sockets.delete(Thread.current)
server_socket.close rescue StandardError
client_socket.close rescue StandardError
end
end
cp = ConnectionProxy.new(ARGV[0], ARGV[1].to_i, ARGV[2].to_i)
cp.start
......@@ -11,6 +11,7 @@ require 'bosh/dev/sandbox/director_config'
require 'bosh/dev/sandbox/port_provider'
require 'bosh/dev/sandbox/services/director_service'
require 'bosh/dev/sandbox/services/nginx_service'
require 'bosh/dev/sandbox/services/connection_proxy_service'
require 'cloud/dummy'
require 'logging'
......@@ -41,6 +42,8 @@ module Bosh::Dev::Sandbox
attr_reader :director_service
attr_reader :port_provider
attr_reader :postgres_proxy
alias_method :db_name, :name
attr_reader :blobstore_storage_dir
......@@ -84,6 +87,9 @@ module Bosh::Dev::Sandbox
@nginx_service = NginxService.new(sandbox_root, director_port, director_ruby_port, uaa_port, @logger)
# all postgres connections go through this proxy (for testing automatic reconnect)
@postgres_proxy = ConnectionProxyService.new("127.0.0.1", 5432, @port_provider.get_port(:postgres), @logger)
director_config = sandbox_path(DirectorService::DIRECTOR_CONFIG)
director_tmp_path = sandbox_path('boshdir')
@director_service = DirectorService.new(director_ruby_port, redis_port, base_log_path, director_tmp_path, director_config, @logger)
......@@ -123,6 +129,8 @@ module Bosh::Dev::Sandbox
FileUtils.rm_rf(logs_path)
FileUtils.mkdir_p(logs_path)
@postgres_proxy.start
@redis_process.start
@redis_socket_connector.try_to_connect
......@@ -192,6 +200,8 @@ module Bosh::Dev::Sandbox
@uaa_process.stop
@database.drop_db
@postgres_proxy.stop
FileUtils.rm_f(dns_db_path)
FileUtils.rm_rf(agent_tmp_path)
FileUtils.rm_rf(blobstore_storage_dir)
......@@ -339,7 +349,7 @@ module Bosh::Dev::Sandbox
if db_opts[:type] == 'mysql'
@database = Mysql.new(@name, @logger, db_opts[:user], db_opts[:password])
else
@database = Postgresql.new(@name, @logger)
@database = Postgresql.new(@name, @logger, @port_provider.get_port(:postgres))
end
end
......
......@@ -5,14 +5,14 @@ module Bosh::Dev::Sandbox
class Postgresql
attr_reader :db_name, :username, :password, :adapter, :port
def initialize(db_name, logger, runner = Bosh::Core::Shell.new)
def initialize(db_name, logger, port, runner = Bosh::Core::Shell.new)
@db_name = db_name
@logger = logger
@runner = runner
@username = 'postgres'
@password = ''
@adapter = 'postgres'
@port = 5432
@port = port
end
# Assumption is that user running tests can
......
module Bosh::Dev::Sandbox
class ConnectionProxyService
REPO_ROOT = File.expand_path('../../../../../../', File.dirname(__FILE__))
ASSETS_DIR = File.expand_path('bosh-dev/assets/sandbox', REPO_ROOT)
TCP_PROXY = File.join(ASSETS_DIR, 'proxy/tcp-proxy')
def initialize(forward_to_host, forward_to_port, listen_port, logger)
@logger = logger
@process = Service.new(%W[#{TCP_PROXY} #{forward_to_host} #{forward_to_port} #{listen_port}], {}, logger)
@socket_connector = SocketConnector.new("proxy #{listen_port} -> #{forward_to_host}:#{forward_to_port}", 'localhost', listen_port, logger)
end
def start
@process.start
@socket_connector.try_to_connect
end
def stop
@process.stop
end
end
end
......@@ -45,7 +45,7 @@ namespace :spec do
if spec_path
"https_proxy= http_proxy= bundle exec rspec #{spec_path}"
else
"https_proxy= http_proxy= bundle exec parallel_test '#{test_path}'#{count}#{group} --group-by filesize --type rspec"
"https_proxy= http_proxy= bundle exec parallel_test '#{test_path}'#{count}#{group} --group-by filesize --type rspec -o '--format documentation'"
end
end
puts command
......
......@@ -3,7 +3,7 @@ require 'bosh/dev/sandbox/postgresql'
module Bosh::Dev::Sandbox
describe Postgresql do
subject(:postgresql) { described_class.new('fake_db_name', logger, runner) }
subject(:postgresql) { described_class.new('fake_db_name', logger, 9922, runner) }
let(:runner) { instance_double('Bosh::Core::Shell') }
describe '#create_db' do
......@@ -48,7 +48,7 @@ module Bosh::Dev::Sandbox
describe '#port' do
it 'has the correct port' do
expect(subject.port).to eq(5432)
expect(subject.port).to eq(9922)
end
end
end
......
module Bosh
module Director
module Core
VERSION = '1.2941.0'
VERSION = '1.2949.0'
end
end
end
......@@ -168,6 +168,8 @@ module Bosh::Director
db_config = db_config.merge(connection_options)
db = Sequel.connect(db_config)
db.extension :connection_validator
db.pool.connection_validation_timeout = -1
if logger
db.logger = logger
db.sql_log_level = :debug
......
......@@ -335,7 +335,9 @@ module Bosh::Director
def persistent_disk_changed?
new_disk_size = @job.persistent_disk_pool ? @job.persistent_disk_pool.disk_size : 0
new_disk_cloud_properties = @job.persistent_disk_pool ? @job.persistent_disk_pool.cloud_properties : {}
new_disk_size != disk_size || new_disk_cloud_properties != disk_cloud_properties
return true if new_disk_size != disk_size
new_disk_size != 0 && new_disk_cloud_properties != disk_cloud_properties
end
##
......
module Bosh
module Director
VERSION = '1.2941.0'
VERSION = '1.2949.0'
end
end
......@@ -17,12 +17,21 @@ module Bosh::Director::DeploymentPlan
network: net,
})
end
let(:job) { instance_double('Bosh::Director::DeploymentPlan::Job', resource_pool: resource_pool, deployment: plan, name: 'fake-job') }
let(:resource_pool) { instance_double('Bosh::Director::DeploymentPlan::ResourcePool', network: net) }
let(:job) do
instance_double('Bosh::Director::DeploymentPlan::Job',
resource_pool: resource_pool,
deployment: plan,
name: 'fake-job',
persistent_disk_pool: disk_pool,
)
end
let(:resource_pool) { instance_double('Bosh::Director::DeploymentPlan::ResourcePool', network: net, name: 'fake-resource-pool') }
let(:disk_pool) { nil }
let(:net) { instance_double('Bosh::Director::DeploymentPlan::Network', name: 'net_a') }
let(:vm) { Vm.new(resource_pool) }
before do
allow(resource_pool).to receive(:allocate_vm).and_return(vm)
allow(resource_pool).to receive(:add_allocated_vm).and_return(vm)
allow(job).to receive(:instance_state).with(0).and_return('started')
end
......@@ -72,7 +81,6 @@ module Bosh::Director::DeploymentPlan
network: network,
})
end
before { allow(resource_pool).to receive(:add_allocated_vm).and_return(vm) }
let(:vm) do
instance_double('Bosh::Director::DeploymentPlan::Vm', {
......@@ -796,6 +804,28 @@ module Bosh::Director::DeploymentPlan
end
end
describe 'persistent_disk_changed?' do
context 'when disk pool with size 0 is used' do
let(:disk_pool) do
Bosh::Director::DeploymentPlan::DiskPool.parse(
{
'name' => 'fake-name',
'disk_size' => 0,
'cloud_properties' => {'type' => 'fake-type'},
}
)
end
before { instance.bind_existing_instance(instance_model, {}, {}) }
context 'when disk_size is still 0' do
it 'returns false' do
expect(instance.persistent_disk_changed?).to be(false)
end
end
end
end
describe '#spec' do
let(:job_spec) { {name: 'job', release: 'release', templates: []} }
let(:release_spec) { {name: 'release', version: '1.1-dev'} }
......
module Bosh
module Monitor
VERSION = '1.2941.0'
VERSION = '1.2949.0'
end
end
module Bosh
module Registry
VERSION = '1.2941.0'
VERSION = '1.2949.0'
end
end
module Bosh
module Release
VERSION = '1.2941.0'
VERSION = '1.2949.0'
end
end
module Bosh
module Stemcell
VERSION = '1.2941.0'
VERSION = '1.2949.0'
end
end
module Bosh
module Template
VERSION = '1.2941.0'
VERSION = '1.2949.0'
end
end
module Bosh
module AwsCloud
VERSION = '1.2941.0'
VERSION = '1.2949.0'
end
end
module Bosh
module Cli
VERSION = '1.2941.0'
VERSION = '1.2949.0'
end
end
module Bosh
module Aws
VERSION = '1.2941.0'
VERSION = '1.2949.0'
end
end