From a1771c43bc58c77033e203197a456059d992d28f Mon Sep 17 00:00:00 2001 From: Colin Obyrne Date: Wed, 22 Apr 2015 09:48:00 -0700 Subject: [PATCH] Fixes specs by using legacy manifest [#91451310] Signed-off-by: Jonathan Barnes --- .../errand/run_errand_failure_spec.rb | 2 +- .../errand/run_errand_success_spec.rb | 46 +++++-------------- spec/support/deployments.rb | 4 +- 3 files changed, 14 insertions(+), 38 deletions(-) diff --git a/spec/integration/errand/run_errand_failure_spec.rb b/spec/integration/errand/run_errand_failure_spec.rb index d78a5965d..487d8312d 100644 --- a/spec/integration/errand/run_errand_failure_spec.rb +++ b/spec/integration/errand/run_errand_failure_spec.rb @@ -82,7 +82,7 @@ describe 'run errand failure', type: :integration, with_tmp_dir: true do with_reset_sandbox_before_each let(:manifest_hash) do - manifest_hash = Bosh::Spec::Deployments.manifest_with_errand + manifest_hash = Bosh::Spec::Deployments.legacy_manifest_with_errand # Sleep so we have time to cancel it manifest_hash['jobs'].last['properties']['errand1']['sleep_duration_in_seconds'] = 5000 diff --git a/spec/integration/errand/run_errand_success_spec.rb b/spec/integration/errand/run_errand_success_spec.rb index 8410f0aec..ec91901b7 100644 --- a/spec/integration/errand/run_errand_success_spec.rb +++ b/spec/integration/errand/run_errand_success_spec.rb @@ -6,7 +6,7 @@ describe 'run errand success', type: :integration, with_tmp_dir: true do with_reset_sandbox_before_each let(:manifest_hash) do - manifest_hash = Bosh::Spec::Deployments.manifest_with_errand + manifest_hash = Bosh::Spec::Deployments.legacy_manifest_with_errand manifest_hash['properties'] = { 'errand1' => { 'sleep_duration_in_seconds' => 60, @@ -169,7 +169,7 @@ describe 'run errand success', type: :integration, with_tmp_dir: true do # When the errand is run, a network update will be required. # The network update will fail, by default dummy CPI will # raise NotSupported, like the aws cpi. - manifest_hash = Bosh::Spec::Deployments.manifest_with_errand + manifest_hash = Bosh::Spec::Deployments.legacy_manifest_with_errand # get rid of the non-errand job, it's not important manifest_hash['jobs'].delete(manifest_hash['jobs'][0]) @@ -254,16 +254,16 @@ describe 'run errand success', type: :integration, with_tmp_dir: true do with_tmp_dir_before_all before(:all) do - deploy_simple(manifest_hash: manifest_with_errand) - expect_errands('errand1-name') + deploy_simple(manifest_hash: Bosh::Spec::Deployments.legacy_manifest_with_errand) + expect_errands('fake-errand-name') - @output, @exit_code = bosh_runner.run("run errand errand1-name --download-logs --logs-dir #{@tmp_dir}", + @output, @exit_code = bosh_runner.run("run errand fake-errand-name --download-logs --logs-dir #{@tmp_dir}", {return_exit_code: true}) end it 'shows bin/run stdout and stderr' do - expect(@output).to include('some-stdout') - expect(@output).to include('some-stderr') + expect(@output).to include('fake-errand-stdout') + expect(@output).to include('fake-errand-stderr') end it 'shows output generated by package script which proves dependent packages are included' do @@ -271,14 +271,14 @@ describe 'run errand success', type: :integration, with_tmp_dir: true do end it 'downloads errand logs and shows downloaded location' do - expect(@output =~ /Logs saved in `(.*errand1-name\.0\..*\.tgz)'/).to_not(be_nil, @output) + expect(@output =~ /Logs saved in `(.*fake-errand-name\.0\..*\.tgz)'/).to_not(be_nil, @output) logs_file = Bosh::Spec::TarFileInspector.new($1) expect(logs_file.file_names).to match_array(%w(./errand1/stdout.log ./custom.log)) expect(logs_file.smallest_file_size).to be > 0 end it 'returns 0 as exit code from the cli and indicates that errand ran successfully' do - expect(@output).to include('Errand `errand1-name\' completed successfully (exit code 0)') + expect(@output).to include('Errand `fake-errand-name\' completed successfully (exit code 0)') expect(@exit_code).to eq(0) end end @@ -289,41 +289,17 @@ describe 'run errand success', type: :integration, with_tmp_dir: true do let(:manifest_hash) do large_property = 64.times.inject('') { |p| p << 'a'*1024 } # generates 64Kb string manifest = {'large_property' => large_property } - manifest.merge(manifest_with_errand) + manifest.merge(Bosh::Spec::Deployments.legacy_manifest_with_errand) end it 'deploys successfully' do deploy_simple(manifest_hash: manifest_hash) - _, exit_code = bosh_runner.run('run errand errand1-name', { return_exit_code: true }) + _, exit_code = bosh_runner.run('run errand fake-errand-name', { return_exit_code: true }) expect(exit_code).to eq(0) end end - def manifest_with_errand - manifest_hash = Bosh::Spec::Deployments.legacy_simple_manifest - - manifest_hash['jobs'].first['instances'] = 1 - manifest_hash['jobs'] << { - 'name' => 'errand1-name', - 'template' => 'errand1', - 'lifecycle' => 'errand', - 'resource_pool' => 'a', - 'instances' => 1, - 'networks' => [{ 'name' => 'a' }], - 'properties' => { - 'errand1' => { - 'exit_code' => 0, - 'stdout' => 'some-stdout', - 'stderr' => 'some-stderr', - 'run_package_file' => true, - }, - }, - } - - manifest_hash - end - def expect_errands(*expected_errands) output, _ = bosh_runner.run('errands') expected_errands.each do |errand| diff --git a/spec/support/deployments.rb b/spec/support/deployments.rb index 9728aedd4..19248f9c1 100644 --- a/spec/support/deployments.rb +++ b/spec/support/deployments.rb @@ -107,8 +107,8 @@ module Bosh::Spec }) end - def self.manifest_with_errand - manifest = simple_manifest.merge( + def self.legacy_manifest_with_errand + manifest = legacy_simple_manifest.merge( 'name' => 'errand' ) manifest['resource_pools'].first.delete('size') -- GitLab