Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #9 from mmb/remove_capistrano

Remove old capistrano build scripts.
  • Loading branch information...
commit b402e7b50e21367343f7cb92ebb7c9134c5e300c 2 parents d3043f1 + f3c02b2
@mmb mmb authored
Showing with 0 additions and 412 deletions.
  1. +0 −109 build/build.cap
  2. +0 −303 build/test.cap
View
109 build/build.cap
@@ -1,109 +0,0 @@
-require 'capistrano_colors'
-
-load 'deploy'
-role :build, ENV['BUILD_SERVER']
-set :user, 'pivotal'
-set :ssh_options, {:forward_agent => true}
-set :bundle_install, "(bundle check || bundle install || true)"
-set :default_shell, 'bash -l'
-
-#ssh_options[:keys] = '/var/lib/jenkins/.ssh/id_rsa'
-
-def run_commands(commands)
- run commands.join(' && ')
-end
-
-desc "rsync code to build VM."
-task :rsync_code do
- run_commands([
- 'sudo rm -rf ~pivotal/workspace/bosh/mcf'
- ])
- run_locally "rsync -e ssh -az --delete '#{ENV['WORKSPACE']}/' pivotal@#{ENV['BUILD_SERVER']}:~/workspace/"
-end
-
-desc 'Clean up build debris.'
-task :clean, role: :build do
- # TODO add /tmp
- sudo "rm -rf /var/tmp/bosh/agent-*"
- sudo "rm -rf ~pivotal/workspace/bosh/agent/mcf/*"
-end
-
-desc 'Update the bosh_cli gem.'
-task :update_gems, role: :build do
- run_commands([
- '. "$HOME/.rvm/scripts/rvm"',
- "cd ~/workspace/micro/micro",
- bundle_install,
- 'bundle exec rake assets:precompile',
-
- "cd ~/workspace/bosh/bosh_agent",
- 'gem update bosh_cli',
- bundle_install
- ])
-end
-
-desc 'Install docs'
-task :install_docs, role: :build do
- # Packages all required gems to stage app without internet
- run_commands([
- '. "$HOME/.rvm/scripts/rvm"',
- 'cd ~/workspace/micro/micro',
- 'rm -rf cf-docs',
- 'git clone git://github.com/cloudfoundry/cf-docs.git cf-docs',
- 'cd cf-docs',
- 'bundle package',
- 'cd vendor/cache',
- 'gem fetch bundler -v 1.2.1',
- 'gem fetch cf-runtime -v 0.0.2'
- ])
-end
-
-desc 'Create Micro Cloud Foundry bosh release.'
-task :create_release, role: :build do
- commands = []
- commands << "cd ~/workspace/cf-release"
- if ENV["USE_NG"]
- commands << "cp jobs/micro/monit-ng.yml jobs/micro/monit.yml"
- end
- commands << 'bosh -n create release --force --with-tarball'
- run_commands(commands)
-end
-
-desc 'Build and download the stemcell'
-task :build_stemcell, role: :build do
- build_time = Time.now.strftime('%Y%m%d.%H%M%S')
- version = "v-#{build_time}"
-
- if ENV["USE_NG"]
- manifest = '~/workspace/micro/deploy/manifest-ng.yml'
- else
- manifest = '~/workspace/micro/deploy/manifest.yml'
- end
-
- run_commands([
- '. "$HOME/.rvm/scripts/rvm"',
- "export BUILD_TIME=#{build_time}",
- "export MCF_VERSION=#{version}",
- 'export UBUNTU_ISO=~/ubuntu-10.04.4-server-amd64.iso',
- 'export UBUNTU_MIRROR=http://localhost:9999/ubuntu',
- 'LATEST_RELEASE=`ls -t ~/workspace/cf-release/dev_releases/bosh-release-*-dev.tgz | head -1`',
- 'cd ~/workspace/bosh/bosh_agent',
- "bundle exec rake stemcell:mcf[vsphere,#{manifest},$LATEST_RELEASE]"
- ])
-
- build_host = find_servers_for_task(current_task)[0]
- zip_name = File.basename("/tmp/micro-#{version}.zip")
- zip_path = "pivotal@#{build_host}:~/workspace/bosh/mcf/#{build_time}/#{zip_name}"
- run_locally "scp #{zip_path} '#{ENV['WORKSPACE']}/micro.zip'"
-end
-
-desc 'Build'
-task :build do
- rsync_code
-
- clean
- update_gems
- install_docs
- create_release
- build_stemcell
-end
View
303 build/test.cap
@@ -1,303 +0,0 @@
-require 'json'
-require 'net/ftp'
-require 'net/http'
-
-require 'capistrano_colors'
-
-load 'deploy'
-role :test, ENV['TEST_SERVER']
-set :user, 'mmb'
-ssh_options[:keys] = '/var/lib/jenkins/.ssh/id_rsa'
-
-
-def vm_ip
- attempts = 0
- micro_vm_ip = nil
-
- while micro_vm_ip == nil
- run_locally "#{vmrun} -gu root -gp #{vm_initial_password} runScriptInGuest \"#{vmx}\" /bin/sh \"/sbin/ifconfig eth0 > /tmp/ifconfig\""
- run_locally "#{vmrun} -gu root -gp #{vm_initial_password} CopyFileFromGuestToHost \"#{vmx}\" /tmp/ifconfig /tmp/ifconfig"
-
- micro_vm_ip = `cat /tmp/ifconfig`[/inet addr:(\S+) /,1]
-
- break if micro_vm_ip || attempts > 10
- attempts += 1
- sleep 2
- end
-
- p micro_vm_ip
- set :micro_vm_ip, micro_vm_ip
-end
-
-# Follow a link in the MCF API.
-def follow_link(data_in, rel, data_next=nil)
- link = data_in['_links'][rel]
- link_uri = URI(link['href'])
-
- http = Net::HTTP.new(link_uri.host, link_uri.port)
- http.open_timeout = 300
- http.read_timeout = 300
-
- if link['method'] == 'get'
- args = [link_uri.path]
- else
- data_next = data_next.to_json if data_next.is_a? Hash
- args = [link_uri.path, data_next, { 'Content-Type' => link['type'] }]
- end
-
- result = http.send(link['method'], *args)
- p [result, result.body]
- result
-end
-
-def run_commands(commands)
- run commands.join(' && ')
-end
-
-def is_release_version(filename)
- filename[/^micro-v\d+-/]
-end
-
-desc "rsync code to build VM."
-task :rsync_code do
- run_locally "rsync -e ssh -az --delete '#{ENV['WORKSPACE']}/' mmb@#{ENV['TEST_SERVER']}:~/workspace/"
-end
-
-desc 'Prepare the test VM and Micro Cloud for vcap-yeti tests.'
-task :bvt_setup, :roles => :test do
- # Set the nameserver of the test machine to the Micro Cloud VM.
- resolv_conf_backup = '~/resolv.conf.backup'
-
- run "cp /etc/resolv.conf #{resolv_conf_backup}"
- run "echo 'nameserver #{micro_vm_ip}' > /tmp/resolv.conf"
- run "#{sudo} cp /tmp/resolv.conf /etc/resolv.conf"
-
- run_commands([
- '. ~/.bash_profile',
- "vmc --trace target http://api.#{domain}/",
- "(vmc --trace register --email '#{admin_user}' --password '#{admin_password}' --verify '#{admin_password}' || true)",
- "(vmc --trace register --email '#{normal_user}' --password '#{normal_password}' --verify '#{normal_password}' || true)",
- ])
-
- run_commands([
- 'cd ~/gem_cache_warmer',
- '(vmc push -f warmer --runtime ruby19 || true)',
- '(vmc delete -f warmer || true)',
- '(vmc push -f warmer --runtime ruby18 || true)',
- '(vmc delete -f warmer || true)'
- ])
-end
-
-desc 'Run vcap-yeti tests.'
-task :bvt, :roles => :test do
- run_commands([
- '. ~/.bash_profile',
- "export VCAP_BVT_TARGET=api.#{domain}",
- "export VCAP_BVT_ADMIN_USER='#{admin_user}'",
- "export VCAP_BVT_ADMIN_USER_PASSWD='#{admin_password}'",
- "export VCAP_BVT_USER='#{normal_user}'",
- "export VCAP_BVT_USER_PASSWD='#{normal_password}'",
- "cd '~/workspace/cf-release/src/tests'",
- 'rm -rf ~/.bvt',
- 'bundle exec rake mcf' # till we can fix all yeti test, only try running a subset
- #'bundle exec rake full[1]'
- ])
-end
-
-desc 'Revert temporary changes done to the test VM.'
-task :bvt_teardown, :roles => :test do
- resolv_conf_backup = '~/resolv.conf.backup'
- run "#{sudo} cp #{resolv_conf_backup} /etc/resolv.conf"
-end
-
-desc 'Run vcap-java-client tests.'
-task :vcap_java_client_tests, :roles => :test do
- run_commands [
- "cd '~/workspace/vcap-java-client/vcap-java-client-test-apps'",
- 'mvn clean install',
- 'cd ../cloudfoundry-client-lib',
- "mvn clean test -Pintegration-test -Dcloud.version=V1 -Dtest.app.memory=256 -Dvcap.target=http://api.#{domain} -Dvcap.email=#{normal_user} -Dvcap.passwd=#{normal_password}"
- ]
-end
-
-desc 'Initial setup of the VM being tested.'
-task :initial_setup do
- root_uri = URI("http://#{micro_vm_ip}:9292/api/")
-
- micro_cloud = JSON.parse(Net::HTTP.get(root_uri))
-
- admin = JSON.parse(follow_link(micro_cloud, 'administrator').body)
- domain = JSON.parse(follow_link(micro_cloud, 'domain_name').body)
-
- follow_link(micro_cloud, 'edit', internet_connected: false)
- follow_link(admin, 'edit', email: admin_user, password: micro_password)
- follow_link(domain, 'edit', name: domain)
- follow_link(micro_cloud, 'edit', internet_connected: true)
-end
-
-desc 'Cleanup and Start VM'
-task :start_vm do
- extract_vm = "/tmp/micro"
- set :vmx, "#{extract_vm}/micro.vmx"
-
- run_locally "#{vmrun} stop #{vmx} nogui || true"
- run_locally "rm -rf #{extract_vm}"
- run_locally "unzip -o micro.zip -d /tmp"
- run_locally "#{vmrun} start #{vmx} nogui"
-end
-
-desc 'Test the latest Micro Cloud Foundry.'
-task :test_mcf do
- rsync_code
-
- start_vm
- vm_ip
- initial_setup
- bvt_setup
- bvt
- vcap_java_client_tests
- bvt_teardown
-end
-
-__END__
-################### Download
-
-desc 'Checkout the latest cf-release master on the test machine.'
-task :checkout_cf_release_master_test, :roles => :test do
- run_commands([
- 'cd ~/cf-release',
- 'git checkout master',
- './update'
- ])
-end
-
-desc 'Checkout a cf-release tag on the test machine.'
-task :checkout_cf_release_tag_test, :roles => :test do
- run_commands([
- 'cd ~/cf-release',
- 'git checkout master',
- 'git pull',
- "git branch -f #{tag}branch #{tag}",
- "git checkout #{tag}branch",
- 'git submodule update --init --recursive'
- ])
-end
-
-################### DIST
-
-# Track MCF versions that have been uploaded to the CDN.
-class VersionStore
-
- def initialize(path)
- @path = path
- @releases = []
- @nightlies = []
- @default = nil
-
- read if File.exist?(path)
- end
-
- # Read the store from disk.
- def read
- open(path) do |f|
- data = JSON.parse(f.read)
-
- @releases = data.fetch('release', [])
- @nightlies = data.fetch('nightly', [])
- @default = data.fetch('default', nil)
- end
- end
-
- # Write the contents of the store to disk in JSON.
- def write
- open(path, 'w') do |f|
- f.flock(File::LOCK_EX)
- f.write to_json
- f.flock(File::LOCK_UN)
- end
- end
-
- # Return true if the store contains a release tag.
- def has_release?(tag)
- @releases.index { |r| r[/^micro-#{tag}-/] }
- end
-
- def to_h
- {
- 'release' => @releases.uniq,
- 'nightly' => @nightlies.uniq,
- 'default' => default
- }
- end
-
- def to_json
- to_h.to_json
- end
-
- def pretty
- JSON.pretty_generate(to_h)
- end
-
- def default
- @default || releases[0]
- end
-
- attr_accessor :path
- attr_accessor :releases
- attr_accessor :nightlies
- attr_writer :default
-end
-
-desc 'Distribute a Micro Cloud zip file.'
-task :dist do
- zip_name = File.basename(zip_local_path)
-
- version_store = VersionStore.new('/var/lib/jenkins/versions.json')
-
- if is_release_version(zip_name)
- dist_release
- version_store.releases.insert(0, zip_name)
- else
- dist_nightly
- version_store.nightlies.insert(0, zip_name)
- end
-
- # Pass in default_version as a command line argument if you want to
- # set a default version that is not the latest release.
- if exists?(:default_version)
- version_store.default = default_version
- end
-
- version_store.write
-
- p "sending #{version_store.path} to CDN #{cdn_ftp_host}/micro/versions.json"
- p version_store.pretty
- Net::FTP.open(cdn_ftp_host, cdn_ftp_user, cdn_ftp_password) do |ftp|
- ftp.putbinaryfile(version_store.path, "micro/versions.json")
- end
-end
-
-desc 'Distribute a nightly version of the Micro Cloud.'
-task :dist_nightly do
- p "sending #{zip_local_path} to CDN #{cdn_ftp_host}/micro/nightly"
- zip_name = File.basename(zip_local_path)
-
- Net::FTP.open(cdn_ftp_host, cdn_ftp_user, cdn_ftp_password) do |ftp|
- ftp.putbinaryfile(zip_local_path, "micro/nightly/#{zip_name}")
- end
-
- p "http://download3.vmware.com/cloudfoundry/micro/nightly/#{zip_name}"
-end
-
-
-desc 'Distribute a release version of the Micro Cloud.'
-task :dist_release do
- p "sending #{zip_local_path} to CDN #{cdn_ftp_host}/micro/release"
- zip_name = File.basename(zip_local_path)
-
- Net::FTP.open(cdn_ftp_host, cdn_ftp_user, cdn_ftp_password) do |ftp|
- ftp.putbinaryfile(zip_local_path, "micro/release/#{zip_name}")
- end
-
- p "http://download3.vmware.com/cloudfoundry/micro/release/#{zip_name}"
-end
Please sign in to comment.
Something went wrong with that request. Please try again.