Skip to content
This repository has been archived by the owner on Nov 29, 2017. It is now read-only.

Commit

Permalink
Default "prepare system" uploads patched HEAD release [closes #89]
Browse files Browse the repository at this point in the history
  • Loading branch information
drnic committed Feb 6, 2013
1 parent b8d51c4 commit fd3e3d5
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 33 deletions.
2 changes: 1 addition & 1 deletion lib/bosh-cloudfoundry/bosh_release_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def latest_dev_release_filename
def create_and_upload_dev_release(release_name=default_dev_release_name)
chdir(cf_release_dir) do
write_dev_config_file(release_name)
sh "bosh create release --with-tarball --force"
sh "bosh -n create release --with-tarball --force"
sh "bosh -n --color upload release"
end
@bosh_releases = nil # reset cache
Expand Down
15 changes: 10 additions & 5 deletions lib/bosh/cli/commands/cf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,18 @@ def upload_stemcell

usage "cf upload release"
desc "fetch & upload latest public cloudfoundry release to BOSH"
option "--dev", "Create development release from very latest cf-release commits"
# option "--dev", "Create development release from very latest cf-release commits & specific patches"
option "--final", "Upload latest final release from very latest cf-release commits"
def upload_release
clone_or_update_cf_release
if options.delete(:dev)
create_and_upload_dev_release
else
if options.delete(:final)
upload_final_release
else
# FUTURE once all patches from https://github.com/StarkAndWayne/bosh-cloudfoundry/issues/42
# are merged into cf-release, then no more gerrit merging required
options[:dev] = true
merge_gerrit(*%w[37/13137/4 84/13084/4 09/13609/2])
# create_and_upload_dev_release
end
end

Expand All @@ -157,7 +162,7 @@ def merge_gerrit(*gerrit_changes)
end
end
apply_gerrit_patches
create_and_upload_dev_release
create_and_upload_dev_release(release_name)
end

usage "cf deploy"
Expand Down
66 changes: 39 additions & 27 deletions spec/unit/cf_command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,34 +96,38 @@
@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 development/edge cf-release" 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-dev")
@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
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-dev")
# @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

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)
Expand All @@ -138,12 +142,20 @@ def generate_new_system(cmd = nil)
cmd.stub!(:bosh_target_uuid).and_return("DIRECTOR_UUID")
cmd.stub!(:bosh_cpi).and_return("aws")
cmd.should_receive(:generate_common_password).and_return('c1oudc0wc1oudc0w')
cmd.should_receive(:bosh_releases).exactly(1).times.and_return([
{"name"=>"appcloud", "versions"=>["124", "126"], "in_use"=>[]},
{"name"=>"appcloud-dev", "versions"=>["124.1-dev", "126.1-dev"], "in_use"=>[]},
])
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([])
cmd.should_receive(:clone_or_update_cf_release)
cmd.should_receive(:merge_gerrit).with(*%w[37/13137/4 84/13084/4 09/13609/2])
else
cmd.should_receive(:bosh_releases).exactly(1).times.and_return([
{"name"=>"appcloud", "versions"=>["124", "126"], "in_use"=>[]},
{"name"=>"appcloud-dev", "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(:render_system)

Expand Down

0 comments on commit fd3e3d5

Please sign in to comment.