Debian Codegraph @

spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb

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