Skip to content

Commit

Permalink
Add integration test for recreating VMs with dead agents
Browse files Browse the repository at this point in the history
Signed-off-by: Phan Le <[email protected]>
  • Loading branch information
zaksoup authored and Phan Le committed Oct 27, 2014
1 parent 2ad64ae commit 1884712
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions spec/integration/cli_cck_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
describe 'cli: cloudcheck', type: :integration do
with_reset_sandbox_before_each

let(:runner) { bosh_runner_in_work_dir(TEST_RELEASE_DIR) }

before do
target_and_login

runner = bosh_runner_in_work_dir(TEST_RELEASE_DIR)
runner.run('reset release')
runner.run('create release --force')
runner.run('upload release')
Expand All @@ -24,22 +24,26 @@
expect(runner.run('cloudcheck --report')).to match(regexp('No problems found'))
end

it 'provides resolution options for unresponsive agents' do
it 'properly resurrects VMs with dead agents' do
current_sandbox.cpi.kill_agents

cloudcheck_response = bosh_run_cck_ignore_errors(3)
cloudcheck_response = bosh_run_cck_with_resolution(3)
expect(cloudcheck_response).to_not match(regexp('No problems found'))
expect(cloudcheck_response).to match(regexp('3 unresponsive'))
expect(cloudcheck_response).to match(regexp('1. Ignore problem
2. Reboot VM
3. Recreate VM using last known apply spec
4. Delete VM reference (DANGEROUS!)'))

recreate_vm = 3
bosh_run_cck_with_resolution(3, recreate_vm)
expect(runner.run('cloudcheck --report')).to match(regexp('No problems found'))
end

it 'provides resolution options for missing VMs' do
current_sandbox.cpi.delete_vm(current_sandbox.cpi.vm_cids.first)

cloudcheck_response = bosh_run_cck_ignore_errors(1)
cloudcheck_response = bosh_run_cck_with_resolution(1)
expect(cloudcheck_response).to_not match(regexp('No problems found'))
expect(cloudcheck_response).to match(regexp('1 missing'))
expect(cloudcheck_response).to match(regexp('1. Ignore problem
Expand All @@ -49,16 +53,15 @@

it 'provides resolution options for missing disks' do
current_sandbox.cpi.delete_disk(current_sandbox.cpi.disk_cids.first)

cloudcheck_response = bosh_run_cck_ignore_errors(1)
cloudcheck_response = bosh_run_cck_with_resolution(1)
expect(cloudcheck_response).to_not match(regexp('No problems found'))
expect(cloudcheck_response).to match(regexp('1 missing'))
expect(cloudcheck_response).to match(regexp('1. Ignore problem
2. Delete disk reference (DANGEROUS!)') )
end

def bosh_run_cck_ignore_errors(num_errors)
resolution_selections = "1\n"*num_errors + "yes"
def bosh_run_cck_with_resolution(num_errors, option=1)
resolution_selections = "#{option}\n"*num_errors + "yes"
output = `echo "#{resolution_selections}" | bosh -c #{BOSH_CONFIG} cloudcheck`
if $?.exitstatus != 0
puts output
Expand Down

0 comments on commit 1884712

Please sign in to comment.