| 1 |
test_name 'C3478 - shallow clone repo minimal depth = 1 (ssh protocol, scp syntax)' |
| 2 |
|
| 3 |
# Globals |
| 4 |
repo_name = 'testrepo_shallow_clone' |
| 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 'shallow clone repo with puppet (scp syntax)' do |
| 35 |
pp = <<-EOS |
| 36 |
vcsrepo { "#{tmpdir}/#{repo_name}": |
| 37 |
ensure => present, |
| 38 |
source => "root@#{host}:#{tmpdir}/testrepo.git", |
| 39 |
provider => git, |
| 40 |
depth => 1, |
| 41 |
} |
| 42 |
EOS |
| 43 |
|
| 44 |
apply_manifest_on(host, pp, :catch_failures => true) |
| 45 |
apply_manifest_on(host, pp, :catch_changes => true) |
| 46 |
end |
| 47 |
|
| 48 |
step 'verify checkout is shallow and of the correct depth' do |
| 49 |
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| |
| 50 |
fail_test('shallow not found') unless res.stdout.include? "shallow" |
| 51 |
end |
| 52 |
|
| 53 |
on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| |
| 54 |
fail_test('shallow not found') unless res.stdout.include? "1 #{tmpdir}/#{repo_name}/.git/shallow" |
| 55 |
end |
| 56 |
end |
| 57 |
|
| 58 |
end |