Debian Codegraph @

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

raw
1 test_name 'C3453 - checkout a revision (ssh protocol, scp syntax)'
2
3 # Globals
4 repo_name = 'testrepo_revision_checkout'
5
6 hosts.each do |host|
7 tmpdir = host.tmpdir('vcsrepo')
8 step 'setup - create repo' do
9 git_pkg = 'git'
10 if host['platform'] =~ /ubuntu-10/
11 git_pkg = 'git-core'
12 end
13 install_package(host, git_pkg)
14 my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
15 scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
16 on(host, "cd #{tmpdir} && ./create_git_repo.sh")
17 end
18 step 'setup - establish ssh keys' do
19 # create ssh keys
20 on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
21
22 # copy public key to authorized_keys
23 on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
24 on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
25 on(host, 'chown -R root:root /root/.ssh')
26 end
27
28 teardown do
29 on(host, "rm -fr #{tmpdir}")
30 apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
31 apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
32 end
33
34 step 'get revision sha from repo' do
35 on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res|
36 @sha = res.stdout.chomp
37 end
38 end
39
40 step 'checkout a revision with puppet (scp syntax)' do
41 pp = <<-EOS
42 vcsrepo { "#{tmpdir}/#{repo_name}":
43 ensure => present,
44 source => "root@#{host}:#{tmpdir}/testrepo.git",
45 provider => git,
46 revision => '#{@sha}',
47 }
48 EOS
49
50 apply_manifest_on(host, pp, :catch_failures => true)
51 apply_manifest_on(host, pp, :catch_changes => true)
52 end
53
54 step "verify checkout is set to revision #{@sha}" do
55 on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
56 fail_test('checkout not found') unless res.stdout.include? "HEAD"
57 end
58
59 on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
60 fail_test('revision not found') unless res.stdout.include? "#{@sha}"
61 end
62 end
63
64 end