Fix calls to ruby
[puppet_vcsrepo.git] / spec / acceptance / beaker / git / shallow_clone / shallow_clone_https.rb
1 test_name 'C3480 - shallow clone repo minimal depth = 1 (https protocol)'
2
3 # Globals
4 repo_name = 'testrepo_shallow_clone'
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     install_package(host, 'git')
11     my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
12     scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
13     on(host, "cd #{tmpdir} && ./create_git_repo.sh")
14   end
15   step 'setup - start https server' do
16     https_daemon =<<-EOF
17     require 'webrick'
18     require 'webrick/https'
19     server = WEBrick::HTTPServer.new(
20     :Port               => 8443,
21     :DocumentRoot       => "#{tmpdir}",
22     :SSLEnable          => true,
23     :SSLVerifyClient    => OpenSSL::SSL::VERIFY_NONE,
24     :SSLCertificate     => OpenSSL::X509::Certificate.new(  File.open("#{tmpdir}/server.crt").read),
25     :SSLPrivateKey      => OpenSSL::PKey::RSA.new(          File.open("#{tmpdir}/server.key").read),
26     :SSLCertName        => [ [ "CN",WEBrick::Utils::getservername ] ])
27     WEBrick::Daemon.start
28     server.start
29     EOF
30     create_remote_file(host, '/tmp/https_daemon.rb', https_daemon)
31     #on(host, "#{ruby} /tmp/https_daemon.rb")
32   end
33
34   teardown do
35     on(host, "rm -fr #{tmpdir}")
36     on(host, 'ps ax | grep "#{ruby} /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh')
37   end
38
39   step 'shallow clone repo with puppet' do
40     pp = <<-EOS
41     vcsrepo { "#{tmpdir}/#{repo_name}":
42       ensure => present,
43       source => "https://github.com/johnduarte/testrepo.git",
44       provider => git,
45       depth => 1,
46     }
47     EOS
48
49     apply_manifest_on(host, pp)
50     apply_manifest_on(host, pp)
51   end
52
53   step 'verify checkout is shallow and of the correct depth' do
54     on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
55       fail_test('shallow not found') unless res.stdout.include? "shallow"
56     end
57
58     on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res|
59       fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow"
60     end
61   end
62
63 end