Debian Codegraph @

spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb

raw
1 test_name 'C3441 - checkout a branch (http protocol)'
2
3 # Globals
4 repo_name = 'testrepo_branch_checkout'
5 branch = 'a_branch'
6
7 hosts.each do |host|
8 ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
9 tmpdir = host.tmpdir('vcsrepo')
10 step 'setup - create repo' do
11 git_pkg = 'git'
12 if host['platform'] =~ /ubuntu-10/
13 git_pkg = 'git-core'
14 end
15 install_package(host, git_pkg)
16 my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
17 scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
18 on(host, "cd #{tmpdir} && ./create_git_repo.sh")
19 end
20
21 step 'setup - start http server' do
22 http_daemon =<<-EOF
23 require 'webrick'
24 server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}")
25 WEBrick::Daemon.start
26 server.start
27 EOF
28 create_remote_file(host, '/tmp/http_daemon.rb', http_daemon)
29 on(host, "#{ruby} /tmp/http_daemon.rb")
30 end
31
32 teardown do
33 on(host, "rm -fr #{tmpdir}")
34 on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
35 end
36
37 step 'checkout a branch with puppet' do
38 pp = <<-EOS
39 vcsrepo { "#{tmpdir}/#{repo_name}":
40 ensure => present,
41 source => "http://#{host}:8000/testrepo.git",
42 provider => git,
43 revision => '#{branch}',
44 }
45 EOS
46
47 apply_manifest_on(host, pp, :catch_failures => true)
48 apply_manifest_on(host, pp, :catch_changes => true)
49 end
50
51 step "verify checkout is on the #{branch} branch" do
52 on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
53 fail_test('checkout not found') unless res.stdout.include? "HEAD"
54 end
55
56 on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
57 fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}"
58 end
59 end
60
61 end