spec/unit/cf_command_spec.rb in bosh-cloudfoundry-0.5.1 vs spec/unit/cf_command_spec.rb in bosh-cloudfoundry-0.6.0
- old
+ new
@@ -41,15 +41,15 @@
it "downloads stemcell and uploads it" do
@cmd.stub!(:bosh_target).and_return("http://9.8.7.6:25555")
@cmd.stub!(:bosh_target_uuid).and_return("DIRECTOR_UUID")
@cmd.stub!(:bosh_cpi).and_return("aws")
@cmd.should_receive(:`).
- with("bosh public stemcells --tags aws | grep ' bosh-stemcell-' | awk '{ print $2 }' | sort -r | head -n 1").
+ with("bosh public stemcells --tags aws | grep ' bosh-stemcell-' | grep -v pre | awk '{ print $2 }' | sort -r | head -n 1").
and_return("bosh-stemcell-aws-0.6.7.tgz")
# FIXME default to stable stemcells when 0.8.1 is marked stable
# @cmd.should_receive(:`).
- # with("bosh public stemcells --tags aws,stable | grep ' bosh-stemcell-' | awk '{ print $2 }' | sort -r | head -n 1").
+ # with("bosh public stemcells --tags aws,stable | grep ' bosh-stemcell-' | grep -v pre | awk '{ print $2 }' | sort -r | head -n 1").
# and_return("bosh-stemcell-aws-0.6.7.tgz")
@cmd.should_receive(:sh).
with("bosh -n --color download public stemcell bosh-stemcell-aws-0.6.7.tgz")
@cmd.should_receive(:sh).
with("bosh -n --color upload stemcell #{@stemcells_dir}/bosh-stemcell-aws-0.6.7.tgz")
@@ -78,63 +78,56 @@
@cmd.add_option(:repos_dir, @repos_dir)
@cmd.add_option(:custom, true)
@cmd.upload_stemcell
end
- it "updates/creates/uploads final cf-release"
- # do
- # cf_release_dir = File.join(@releases_dir, "cf-release")
- # FileUtils.mkdir_p(cf_release_dir)
- # @cmd.system_config.cf_release_dir = cf_release_dir
- # @cmd.system_config.cf_release_branch = "staging"
- # @cmd.system_config.cf_release_branch_dir = File.join(cf_release_dir, "staging")
- #
- # @cmd.should_receive(:sh).with("git pull origin master")
- # script = <<-BASH.gsub(/^ /, '')
- # grep -rI "github.com" * .gitmodules | awk 'BEGIN {FS=":"} { print($1) }' | uniq while read file
- # do
- # echo "changing - $file"
- # sed -i 's#git://github.com#https://github.com#g' $file
- # sed -i 's#git@github.com:#https://github.com:#g' $file
- # done
- # BASH
- # @cmd.should_receive(:sh).with("sed -i 's#git@github.com:#https://github.com/#g' .gitmodules")
- # @cmd.should_receive(:sh).with("sed -i 's#git://github.com#https://github.com#g' .gitmodules")
- # @cmd.should_receive(:sh).with("git submodule update --init --recursive")
- # @cmd.should_receive(:`).with("tail -n 1 releases/index.yml | awk '{print $2}'").
- # and_return("126")
- # @cmd.should_receive(:sh).with("bosh -n --color upload release releases/appcloud-126.yml")
- # @cmd.add_option(:final, true)
- # @cmd.upload_release
- # end
+ it "updates/creates/uploads final cf-release" do
+ generate_new_system
- it "updates/creates/uploads development/edge cf-release (requires system setup)"
- # TODO turn this into a unit test for the specific methods
- # do
- # cf_release_dir = File.join(@releases_dir, "cf-release")
- # FileUtils.mkdir_p(cf_release_dir)
- # @cmd.common_config.cf_release_dir = cf_release_dir
- # @cmd.add_option(:dev, true)
- #
- # @cmd.should_receive(:sh).with("git pull origin master")
- # script = <<-BASH.gsub(/^ /, '')
- # grep -rI "github.com" * .gitmodules | awk 'BEGIN {FS=":"} { print($1) }' | uniq while read file
- # do
- # echo "changing - $file"
- # sed -i 's#git://github.com#https://github.com#g' $file
- # sed -i 's#git@github.com:#https://github.com:#g' $file
- # done
- # BASH
- # @cmd.should_receive(:sh).with("sed -i 's#git@github.com:#https://github.com/#g' .gitmodules")
- # @cmd.should_receive(:sh).with("sed -i 's#git://github.com#https://github.com#g' .gitmodules")
- # @cmd.should_receive(:sh).with("git submodule update --init --recursive")
- # @cmd.should_receive(:write_dev_config_file).with("appcloud-staging")
- # @cmd.should_receive(:sh).with("bosh create release --with-tarball --force")
- # @cmd.should_receive(:sh).with("bosh -n --color upload release")
- # @cmd.upload_release
- # end
+ cf_release_dir = File.join(@releases_dir, "cf-release")
+ @cmd.system_config.cf_release_dir = cf_release_dir
+ @cmd.system_config.cf_release_branch = "master"
+ @cmd.system_config.cf_release_branch_dir = File.join(cf_release_dir, "master")
+ FileUtils.mkdir_p(@cmd.system_config.cf_release_branch_dir)
+ @cmd.should_receive(:sh).with("git pull origin master")
+ @cmd.should_receive(:`).with("tail -n 1 releases/index.yml | awk '{print $2}'").and_return("128")
+ @cmd.should_receive(:sh).with("bosh -n --color upload release releases/appcloud-128.yml")
+
+ @cmd.add_option(:final, true)
+ @cmd.upload_release
+ end
+
+ it "updates/creates/uploads development/edge cf-release (requires system setup)" do
+ generate_new_system
+
+ cf_release_dir = File.join(@releases_dir, "cf-release")
+ @cmd.system_config.cf_release_dir = cf_release_dir
+ @cmd.system_config.cf_release_branch = "master"
+ @cmd.system_config.cf_release_branch_dir = File.join(cf_release_dir, "master")
+ FileUtils.mkdir_p(@cmd.system_config.cf_release_branch_dir)
+
+ @cmd.should_receive(:sh).with("git pull origin master")
+ script = <<-BASH.gsub(/^ /, '')
+ grep -rI "github.com" * .gitmodules | awk 'BEGIN {FS=":"} { print($1) }' | uniq while read file
+ do
+ echo "changing - $file"
+ sed -i 's#git://github.com#https://github.com#g' $file
+ sed -i 's#git@github.com:#https://github.com:#g' $file
+ done
+ BASH
+ @cmd.should_receive(:sh).with("sed -i 's#git@github.com:#https://github.com/#g' .gitmodules")
+ @cmd.should_receive(:sh).with("sed -i 's#git://github.com#https://github.com#g' .gitmodules")
+ @cmd.should_receive(:sh).with("git submodule update --init --recursive")
+ @cmd.should_receive(:write_dev_config_file).with("appcloud-master")
+ @cmd.should_receive(:sh).with("bosh -n --color create release --with-tarball --force")
+ @cmd.should_receive(:sh).with("bosh -n --color upload release")
+
+ @cmd.add_option(:branch, "master")
+ @cmd.upload_release
+ end
+
def generate_new_system(cmd = nil)
needs_initial_release_uploaded = true
cmd ||= begin
cmd = Bosh::Cli::Command::CloudFoundry.new(nil)
cmd.add_option(:non_interactive, true)
@@ -152,20 +145,26 @@
cmd.should_receive(:validate_dns_a_record).with("api.mycompany.com", '1.2.3.4').and_return(true)
cmd.should_receive(:validate_dns_a_record).with("demoapp.mycompany.com", '1.2.3.4').and_return(true)
if needs_initial_release_uploaded
cmd.should_receive(:bosh_releases).exactly(1).times.and_return([])
+
+ # TODO revert to these when appcloud-130 is released; and we go to final release
+ # cmd.should_receive(:clone_or_update_cf_release)
+ # cmd.should_receive(:upload_final_release)
+ cmd.should_receive(:set_cf_release_branch).with("master").exactly(2).times
cmd.should_receive(:clone_or_update_cf_release)
+ cmd.should_receive(:prepare_cf_release_for_dev_release)
cmd.should_receive(:create_and_upload_dev_release)
else
cmd.should_receive(:bosh_releases).exactly(1).times.and_return([
- {"name"=>"appcloud", "versions"=>["124", "126"], "in_use"=>[]},
- {"name"=>"appcloud-staging", "versions"=>["124.1-dev", "126.1-dev"], "in_use"=>[]},
+ {"name"=>"appcloud", "versions"=>["124", "126", "129"], "in_use"=>[]},
+ {"name"=>"appcloud-master", "versions"=>["124.1-dev", "126.1-dev"], "in_use"=>[]},
])
end
- cmd.should_receive(:bosh_stemcell_versions).exactly(4).times.and_return(['0.6.4'])
+ cmd.should_receive(:bosh_stemcell_versions).exactly(4).times.and_return(['0.7.0'])
cmd.should_receive(:render_system)
provider = Bosh::CloudFoundry::Providers::AWS.new
ports = {
ssh: 22, http: 80, https: 433,
@@ -194,14 +193,16 @@
it "creates new system" do
generate_new_system(@cmd)
File.basename(@cmd.system).should == "production"
end
- it "temporarily uploads latest stemcell & patched cf-release by default" do
- generate_new_system(@cmd)
- File.basename(@cmd.system).should == "production"
- @cmd.system_config.release_name.should == "appcloud-staging"
- end
+ # TODO restore when appcloud-130 released
+ it "uploads latest stemcell & final cf-release by default"
+ # do
+ # generate_new_system(@cmd)
+ # File.basename(@cmd.system).should == "production"
+ # @cmd.system_config.release_name.should == "appcloud"
+ # end
it "new system has common random password" do
generate_new_system(@cmd)
@cmd.system_config.common_password.should == "c1oudc0wc1oudc0w"
end
\ No newline at end of file