From 411111b5ff88b682d7e9cc54a47573bccc3e3edc Mon Sep 17 00:00:00 2001 From: John Iacona Date: Wed, 28 Aug 2013 14:32:05 -0400 Subject: update git provider to handle checking out into an existing (empty) dir --- lib/puppet/provider/vcsrepo.rb | 5 +++++ lib/puppet/provider/vcsrepo/git.rb | 2 +- spec/unit/puppet/provider/vcsrepo/git_spec.rb | 6 ++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/puppet/provider/vcsrepo.rb b/lib/puppet/provider/vcsrepo.rb index 2c026ba..05b92f8 100644 --- a/lib/puppet/provider/vcsrepo.rb +++ b/lib/puppet/provider/vcsrepo.rb @@ -17,6 +17,11 @@ class Puppet::Provider::Vcsrepo < Puppet::Provider File.directory?(@resource.value(:path)) end + def path_empty? + # Path is empty if the only entries are '.' and '..' + Dir.entries(@resource.value(:path)).size == 2 + end + # Note: We don't rely on Dir.chdir's behavior of automatically returning the # value of the last statement -- for easier stubbing. def at_path(&block) #:nodoc: diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 58330f6..47e84d2 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -147,7 +147,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) end def check_force - if path_exists? + if path_exists? and not path_empty? if @resource.value(:force) notice "Removing %s to replace with vcsrepo." % @resource.value(:path) destroy diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index 68b6c0a..1a6d008 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -74,9 +74,10 @@ describe_provider :vcsrepo, :git, :resource => {:path => '/tmp/vcsrepo'} do end end - context "when the path is not a repository" do + context "when the path is not empty and not a repository" do it "should raise an exception" do provider.expects(:path_exists?).returns(true) + provider.expects(:path_empty?).returns(false) proc { provider.create }.should raise_error(Puppet::Error) end end @@ -102,9 +103,10 @@ describe_provider :vcsrepo, :git, :resource => {:path => '/tmp/vcsrepo'} do end end - context "when the path is not a repository" do + context "when the path is not empty and not a repository" do it "should raise an exception" do expects_directory?(true) + provider.expects(:path_empty?).returns(false) proc { provider.create }.should raise_error(Puppet::Error) end end -- cgit v1.2.3 From e69c6eac89fbbbd5c459388eef30b1320ab9d826 Mon Sep 17 00:00:00 2001 From: John Iacona Date: Wed, 28 Aug 2013 16:34:57 -0400 Subject: change path_empty? to not do full directory listing --- lib/puppet/provider/vcsrepo.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/puppet/provider/vcsrepo.rb b/lib/puppet/provider/vcsrepo.rb index 05b92f8..8793e63 100644 --- a/lib/puppet/provider/vcsrepo.rb +++ b/lib/puppet/provider/vcsrepo.rb @@ -19,7 +19,10 @@ class Puppet::Provider::Vcsrepo < Puppet::Provider def path_empty? # Path is empty if the only entries are '.' and '..' - Dir.entries(@resource.value(:path)).size == 2 + d = Dir.new(@resource.value(:path)) + d.read # should return '.' + d.read # should return '..' + d.read.nil? end # Note: We don't rely on Dir.chdir's behavior of automatically returning the -- cgit v1.2.3 From 7b2084afba9a0ca76fce75f479f88390d6204bca Mon Sep 17 00:00:00 2001 From: Mark Leighton Fisher Date: Wed, 4 Sep 2013 10:24:38 -0400 Subject: Documented the "module" attribute. --- README.CVS.markdown | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.CVS.markdown b/README.CVS.markdown index 10121a7..3bdd59d 100644 --- a/README.CVS.markdown +++ b/README.CVS.markdown @@ -21,6 +21,16 @@ To get the current mainline: provider => cvs, source => ":pserver:anonymous@example.com:/sources/myproj" } + +To get a specific module on the current mainline: + + vcsrepo {"/vagrant/lockss-daemon-source": + ensure => present, + provider => cvs, + source => ":pserver:anonymous@lockss.cvs.sourceforge.net:/cvsroot/lockss", + module => "lockss-daemon", + } + You can use the `compression` parameter (it works like CVS `-z`): -- cgit v1.2.3 From aeb3ea63ec561440c02f9d4c4d4c0ac3a1d096c9 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Wed, 18 Sep 2013 15:59:44 -0400 Subject: Overhaul the spec tests to work in rspec2. This work gets rid of the provider_example_group and reworks everything to work properly against rspec2. I don't know if I'd consider the style "better" but it works. --- Gemfile | 25 +- Rakefile | 14 +- spec/spec_helper.rb | 30 +-- spec/support/provider_example_group.rb | 80 ------ spec/unit/puppet/provider/vcsrepo/bzr_spec.rb | 73 +++-- spec/unit/puppet/provider/vcsrepo/cvs_spec.rb | 67 +++-- spec/unit/puppet/provider/vcsrepo/dummy_spec.rb | 17 -- spec/unit/puppet/provider/vcsrepo/git_spec.rb | 336 +++++++++++++----------- spec/unit/puppet/provider/vcsrepo/hg_spec.rb | 52 ++-- spec/unit/puppet/provider/vcsrepo/svn_spec.rb | 95 ++++--- 10 files changed, 388 insertions(+), 401 deletions(-) delete mode 100644 spec/support/provider_example_group.rb delete mode 100644 spec/unit/puppet/provider/vcsrepo/dummy_spec.rb diff --git a/Gemfile b/Gemfile index e6e114d..5def829 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,22 @@ source 'https://rubygems.org' -gem 'rake', '~> 0.8.7' -gem 'rspec', '~> 1.3' -gem 'mocha', '~> 0.12.9', :require => false -gem 'puppet', "~> #{ENV['PUPPET_VERSION'] || '2.7.22'}" + +group :development, :test do + gem 'rake', :require => false + gem 'rspec-puppet', :require => false + gem 'puppetlabs_spec_helper', :require => false + gem 'rspec-system', :require => false + gem 'rspec-system-puppet', :require => false + gem 'rspec-system-serverspec', :require => false + gem 'serverspec', :require => false + gem 'puppet-lint', :require => false + gem 'pry', :require => false + gem 'simplecov', :require => false +end + +if puppetversion = ENV['PUPPET_GEM_VERSION'] + gem 'puppet', puppetversion, :require => false +else + gem 'puppet', :require => false +end + +# vim:ft=ruby diff --git a/Rakefile b/Rakefile index 3e005ff..cd3d379 100644 --- a/Rakefile +++ b/Rakefile @@ -1,13 +1 @@ -require 'spec/rake/spectask' -Spec::Rake::SpecTask.new(:spec) do |spec| - spec.libs << 'lib' << 'spec' - spec.spec_files = FileList['spec/**/*_spec.rb'] -end - -Spec::Rake::SpecTask.new(:rcov) do |spec| - spec.libs << 'lib' << 'spec' - spec.pattern = 'spec/**/*_spec.rb' - spec.rcov = true -end - -task :default => :spec +require 'puppetlabs_spec_helper/rake_tasks' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3bac650..acfae0c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,25 +1,13 @@ -require 'pathname' -dir = Pathname.new(__FILE__).parent -$LOAD_PATH.unshift(dir, dir + 'lib', dir + '../lib') +require 'puppetlabs_spec_helper/module_spec_helper' +require 'simplecov' +require 'support/filesystem_helpers' +require 'support/fixture_helpers' -require 'test/unit' -require 'mocha' -require 'puppet' -gem 'rspec', '>= 1.2.9' -require 'spec/autorun' - -Dir[File.join(File.dirname(__FILE__), 'support', '*.rb')].each do |support_file| - require support_file -end - -Spec::Runner.configure do |config| - config.mock_with :mocha - config.include(FixtureHelpers) - config.include(FilesystemHelpers) +SimpleCov.start do + add_filter "/spec/" end -# We need this because the RAL uses 'should' as a method. This -# allows us the same behaviour but with a different method name. -class Object - alias :must :should +RSpec.configure do |c| + c.include FilesystemHelpers + c.include FixtureHelpers end diff --git a/spec/support/provider_example_group.rb b/spec/support/provider_example_group.rb deleted file mode 100644 index 1431f78..0000000 --- a/spec/support/provider_example_group.rb +++ /dev/null @@ -1,80 +0,0 @@ -class ProviderExampleGroup < Spec::Example::ExampleGroup - - # Allow access to the current resource - attr_reader :resource - - # Build up the values for the resource in this scope - before :each do - resource_hash = example_group_hierarchy.inject({}) do |memo, klass| - memo.merge(klass.options[:resource] || {}) - end - full_hash = resource_hash.merge(:provider => described_class.name) - @resource = described_class.resource_type.new(full_hash) - end - - # Build the provider - subject { described_class.new(@resource) } - - # Allow access to it via +provider+ - alias :provider :subject - - # Generate a context for a provider operating on a resource with: - # - # call-seq: - # - # # A parameter/property set (when the value isn't important) - # resource_with :source do - # # ... - # end - # - # # A parameter/property set to a specific value - # resource_with :source => 'a-specific-value' do - # # ... - # end - # - # Note: Choose one or the other (mixing will create two separate contexts) - # - def self.resource_with(*params, &block) - params_with_values = params.last.is_a?(Hash) ? params.pop : {} - build_value_context(params_with_values, &block) - build_existence_context(*params, &block) - end - - def self.build_existence_context(*params, &block) #:nodoc: - unless params.empty? - text = params.join(', ') - placeholders = params.inject({}) { |memo, key| memo.merge(key => 'an-unimportant-value') } - context("and with a #{text}", {:resource => placeholders}, &block) - end - end - - def self.build_value_context(params = {}, &block) #:nodoc: - unless params.empty? - text = params.map { |k, v| "#{k} => #{v.inspect}" }.join(' and with ') - context("and with #{text}", {:resource => params}, &block) - end - end - - - # Generate a context for a provider operating on a resource without - # a given parameter/property. - # - # call-seq: - # - # resource_without :source do - # # ... - # end - # - def self.resource_without(field, &block) - context("and without a #{field}", &block) - end - -end - -Spec::Example::ExampleGroupFactory.register(:provider, ProviderExampleGroup) - -# Outside wrapper to lookup a provider and start the spec using ProviderExampleGroup -def describe_provider(type_name, provider_name, options = {}, &block) - provider_class = Puppet::Type.type(type_name).provider(provider_name) - describe(provider_class, options.merge(:type => :provider), &block) -end diff --git a/spec/unit/puppet/provider/vcsrepo/bzr_spec.rb b/spec/unit/puppet/provider/vcsrepo/bzr_spec.rb index c0231e9..488ddc0 100644 --- a/spec/unit/puppet/provider/vcsrepo/bzr_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/bzr_spec.rb @@ -1,24 +1,41 @@ require 'spec_helper' -describe_provider :vcsrepo, :bzr, :resource => {:path => '/tmp/vcsrepo'} do +describe Puppet::Type.type(:vcsrepo).provider(:bzr_provider) do + + let(:resource) { Puppet::Type.type(:vcsrepo).new({ + :name => 'test', + :ensure => :present, + :provider => :bzr, + :revision => '2634', + :source => 'lp:do', + :path => '/tmp/test', + })} + + let(:provider) { resource.provider } + + before :each do + Puppet::Util.stubs(:which).with('bzr').returns('/usr/bin/bzr') + end describe 'creating' do - resource_with :source do - resource_with :revision do - it "should execute 'bzr clone -r' with the revision" do - provider.expects(:bzr).with('branch', '-r', resource.value(:revision), resource.value(:source), resource.value(:path)) - provider.create - end + context 'with defaults' do + it "should execute 'bzr clone -r' with the revision" do + provider.expects(:bzr).with('branch', '-r', resource.value(:revision), resource.value(:source), resource.value(:path)) + provider.create end - resource_without :revision do - it "should just execute 'bzr clone' without a revision" do - provider.expects(:bzr).with('branch', resource.value(:source), resource.value(:path)) - provider.create - end + end + + context 'without revision' do + it "should just execute 'bzr clone' without a revision" do + resource.delete(:revision) + provider.expects(:bzr).with('branch', resource.value(:source), resource.value(:path)) + provider.create end end - resource_without :source do + + context 'without source' do it "should execute 'bzr init'" do + resource.delete(:source) provider.expects(:bzr).with('init', resource.value(:path)) provider.create end @@ -27,14 +44,13 @@ describe_provider :vcsrepo, :bzr, :resource => {:path => '/tmp/vcsrepo'} do describe 'destroying' do it "it should remove the directory" do - expects_rm_rf provider.destroy end end describe "checking existence" do it "should check for the directory" do - expects_directory?(true, File.join(resource.value(:path), '.bzr')) + File.expects(:directory?).with(File.join(resource.value(:path), '.bzr')).returns(true) provider.exists? end end @@ -42,46 +58,49 @@ describe_provider :vcsrepo, :bzr, :resource => {:path => '/tmp/vcsrepo'} do describe "checking the revision property" do before do expects_chdir - provider.expects(:bzr).with('version-info').returns(fixture(:bzr_version_info)) + provider.expects(:bzr).with('version-info').returns(File.read(fixtures('bzr_version_info.txt'))) @current_revid = 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x' end - context "when given a non-revid as the resource revision", :resource => {:revision => '2634'} do + + context "when given a non-revid as the resource revision" do context "when its revid is not different than the current revid" do - before do - provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("#{resource.value(:revision)} menesis@pov.lt-20100309191856-4wmfqzc803fj300x\n") - end it "should return the ref" do + resource[:revision] = '2634' + provider.expects(:bzr).with('revision-info', '2634').returns("2634 menesis@pov.lt-20100309191856-4wmfqzc803fj300x\n") provider.revision.should == resource.value(:revision) end end - context "when its revid is different than the current revid", :resource => {:revision => '2636'} do + context "when its revid is different than the current revid" do it "should return the current revid" do + resource[:revision] = '2636' provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("2635 foo\n") provider.revision.should == @current_revid end end end + context "when given a revid as the resource revision" do - context "when it is the same as the current revid", :resource => {:revision => 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x'} do - before do - provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("1234 #{resource.value(:revision)}\n") - end + context "when it is the same as the current revid" do it "should return it" do + resource[:revision] = 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x' + provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("1234 #{resource.value(:revision)}\n") provider.revision.should == resource.value(:revision) end end - context "when it is not the same as the current revid", :resource => {:revision => 'menesis@pov.lt-20100309191856-4wmfqzc803fj300y'} do + context "when it is not the same as the current revid" do it "should return the current revid" do + resource[:revision] = 'menesis@pov.lt-20100309191856-4wmfqzc803fj300y' provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("2636 foo\n") provider.revision.should == @current_revid end end + end end describe "setting the revision property" do it "should use 'bzr update -r' with the revision" do - expects_chdir + Dir.expects(:chdir).with('/tmp/test').at_least_once.yields provider.expects(:bzr).with('update', '-r', 'somerev') provider.revision = 'somerev' end diff --git a/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb b/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb index aad54cc..efa4b33 100644 --- a/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb @@ -1,27 +1,44 @@ require 'spec_helper' -describe_provider :vcsrepo, :cvs, :resource => {:path => '/tmp/vcsrepo'} do +describe Puppet::Type.type(:vcsrepo).provider(:cvs_provider) do + + let(:resource) { Puppet::Type.type(:vcsrepo).new({ + :name => 'test', + :ensure => :present, + :provider => :cvs, + :revision => '2634', + :source => 'lp:do', + :path => '/tmp/test', + })} + + let(:provider) { resource.provider } + + before :each do + Puppet::Util.stubs(:which).with('cvs').returns('/usr/bin/cvs') + end describe 'creating' do - context "with a source", :resource => {:source => ':ext:source@example.com:/foo/bar'} do - resource_with :revision do - it "should execute 'cvs checkout' and 'cvs update -r'" do - provider.expects(:cvs).with('-d', resource.value(:source), 'checkout', '-r', 'an-unimportant-value', '-d', 'vcsrepo', 'bar') - expects_chdir(File.dirname(resource.value(:path))) - #provider.expects(:cvs).with('update', '-r', resource.value(:revision), '.') - provider.create - end + context "with a source" do + it "should execute 'cvs checkout'" do + resource[:source] = ':ext:source@example.com:/foo/bar' + resource[:revision] = 'an-unimportant-value' + expects_chdir('/tmp') + provider.expects(:cvs).with('-d', resource.value(:source), 'checkout', '-r', 'an-unimportant-value', '-d', 'test', 'bar') + provider.create end - resource_without :revision do - it "should just execute 'cvs checkout' without a revision" do - provider.expects(:cvs).with('-d', resource.value(:source), 'checkout', '-d', File.basename(resource.value(:path)), File.basename(resource.value(:source))) - provider.create - end + it "should just execute 'cvs checkout' without a revision" do + resource[:source] = ':ext:source@example.com:/foo/bar' + resource.delete(:revision) + provider.expects(:cvs).with('-d', resource.value(:source), 'checkout', '-d', File.basename(resource.value(:path)), File.basename(resource.value(:source))) + provider.create end - context "with a compression", :resource => {:compression => '3'} do + context "with a compression" do it "should just execute 'cvs checkout' without a revision" do + resource[:source] = ':ext:source@example.com:/foo/bar' + resource[:compression] = '3' + resource.delete(:revision) provider.expects(:cvs).with('-d', resource.value(:source), '-z', '3', 'checkout', '-d', File.basename(resource.value(:path)), File.basename(resource.value(:source))) provider.create end @@ -30,6 +47,7 @@ describe_provider :vcsrepo, :cvs, :resource => {:path => '/tmp/vcsrepo'} do context "when a source is not given" do it "should execute 'cvs init'" do + resource.delete(:source) provider.expects(:cvs).with('-d', resource.value(:path), 'init') provider.create end @@ -38,24 +56,21 @@ describe_provider :vcsrepo, :cvs, :resource => {:path => '/tmp/vcsrepo'} do describe 'destroying' do it "it should remove the directory" do - expects_rm_rf provider.destroy end end describe "checking existence" do - resource_with :source do - it "should check for the CVS directory" do - File.expects(:directory?).with(File.join(resource.value(:path), 'CVS')) - provider.exists? - end + it "should check for the CVS directory with source" do + resource[:source] = ':ext:source@example.com:/foo/bar' + File.expects(:directory?).with(File.join(resource.value(:path), 'CVS')) + provider.exists? end - resource_without :source do - it "should check for the CVSROOT directory" do - File.expects(:directory?).with(File.join(resource.value(:path), 'CVSROOT')) - provider.exists? - end + it "should check for the CVSROOT directory without source" do + resource.delete(:source) + File.expects(:directory?).with(File.join(resource.value(:path), 'CVSROOT')) + provider.exists? end end diff --git a/spec/unit/puppet/provider/vcsrepo/dummy_spec.rb b/spec/unit/puppet/provider/vcsrepo/dummy_spec.rb deleted file mode 100644 index a945888..0000000 --- a/spec/unit/puppet/provider/vcsrepo/dummy_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'spec_helper' - -describe_provider :vcsrepo, :dummy, :resource => {:path => '/tmp/vcsrepo'} do - - context 'dummy' do - resource_with :source do - resource_with :ensure => :present do - context "with nothing doing", :resource => {:revision => 'foo'} do - it "should raise an exception" do - proc { provider.working_copy_exists? }.should raise_error(RuntimeError) - end - end - end - end - end - -end diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index 1a6d008..d2769ae 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -1,192 +1,212 @@ require 'spec_helper' -describe_provider :vcsrepo, :git, :resource => {:path => '/tmp/vcsrepo'} do +describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do + + let(:resource) { Puppet::Type.type(:vcsrepo).new({ + :name => 'test', + :ensure => :present, + :provider => :git, + :revision => '2634', + :source => 'git@repo', + :path => '/tmp/test', + })} + + let(:provider) { resource.provider } + + before :each do + Puppet::Util.stubs(:which).with('git').returns('/usr/bin/git') + end context 'creating' do - resource_with :source do - resource_with :ensure => :present do - context "with a revision that is a remote branch", :resource => {:revision => 'only/remote'} do - it "should execute 'git clone' and 'git checkout -b'" do - provider.expects(:git).with('clone', resource.value(:source), resource.value(:path)) - expects_chdir('/') - expects_chdir - provider.expects(:update_submodules) - provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) - provider.expects(:git).with('checkout', '--force', resource.value(:revision)) - provider.create - end - end - context "with a revision that is not a remote branch", :resource => {:revision => 'a-commit-or-tag'} do - it "should execute 'git clone' and 'git reset --hard'" do - provider.expects(:git).with('clone', resource.value(:source), resource.value(:path)) - expects_chdir('/') - expects_chdir - provider.expects(:update_submodules) - provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) - provider.expects(:git).with('checkout', '--force', resource.value(:revision)) - provider.create - end - end - resource_without :revision do - it "should execute 'git clone' and submodule commands" do - provider.expects(:git).with('clone', resource.value(:source), resource.value(:path)) - provider.expects(:update_submodules) - provider.create - end - end + context "with a revision that is a remote branch" do + it "should execute 'git clone' and 'git checkout -b'" do + resource[:revision] = 'only/remote' + Dir.expects(:chdir).with('/').at_least_once.yields + Dir.expects(:chdir).with('/tmp/test').at_least_once.yields + provider.expects(:git).with('clone', resource.value(:source), resource.value(:path)) + provider.expects(:update_submodules) + provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) + provider.expects(:git).with('checkout', '--force', resource.value(:revision)) + provider.create end + end - resource_with :ensure => :bare do - resource_with :revision do - it "should just execute 'git clone --bare'" do - provider.expects(:git).with('clone', '--bare', resource.value(:source), resource.value(:path)) - provider.create - end - end + context "with a revision that is not a remote branch" do + it "should execute 'git clone' and 'git reset --hard'" do + resource[:revision] = 'a-commit-or-tag' + Dir.expects(:chdir).with('/').at_least_once.yields + Dir.expects(:chdir).with('/tmp/test').at_least_once.yields + provider.expects(:git).with('clone', resource.value(:source), resource.value(:path)) + provider.expects(:update_submodules) + provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) + provider.expects(:git).with('checkout', '--force', resource.value(:revision)) + provider.create + end + + it "should execute 'git clone' and submodule commands" do + resource.delete(:revision) + provider.expects(:git).with('clone', resource.value(:source), resource.value(:path)) + provider.expects(:update_submodules) + provider.create + end + end - resource_without :revision do - it "should just execute 'git clone --bare'" do - provider.expects(:git).with('clone', '--bare', resource.value(:source), resource.value(:path)) - provider.create - end + context "with an ensure of bare" do + context "with revision" do + it "should just execute 'git clone --bare'" do + resource[:ensure] = :bare + provider.expects(:git).with('clone', '--bare', resource.value(:source), resource.value(:path)) + provider.create + end + end + context "without revision" do + it "should just execute 'git clone --bare'" do + resource[:ensure] = :bare + resource.delete(:revision) + provider.expects(:git).with('clone', '--bare', resource.value(:source), resource.value(:path)) + provider.create end end end context "when a source is not given" do - resource_with :ensure => :present do - context "when the path does not exist" do - it "should execute 'git init'" do - expects_mkdir - expects_chdir - expects_directory?(false) - provider.expects(:bare_exists?).returns(false) - provider.expects(:git).with('init') - provider.create - end - end + context "when the path does not exist" do + it "should execute 'git init'" do + resource[:ensure] = :present + resource.delete(:source) + expects_mkdir + expects_chdir + expects_directory?(false) - context "when the path is a bare repository" do - it "should convert it to a working copy" do - provider.expects(:bare_exists?).returns(true) - provider.expects(:convert_bare_to_working_copy) - provider.create - end + provider.expects(:bare_exists?).returns(false) + provider.expects(:git).with('init') + provider.create end + end - context "when the path is not empty and not a repository" do - it "should raise an exception" do - provider.expects(:path_exists?).returns(true) - provider.expects(:path_empty?).returns(false) - proc { provider.create }.should raise_error(Puppet::Error) - end + context "when the path is a bare repository" do + it "should convert it to a working copy" do + resource[:ensure] = :present + resource.delete(:source) + provider.expects(:bare_exists?).returns(true) + provider.expects(:convert_bare_to_working_copy) + provider.create end end - resource_with :ensure => :bare do - context "when the path does not exist" do - it "should execute 'git init --bare'" do - expects_chdir - expects_mkdir - expects_directory?(false) - provider.expects(:working_copy_exists?).returns(false) - provider.expects(:git).with('init', '--bare') - provider.create - end + context "when the path is not empty and not a repository" do + it "should raise an exception" do + provider.expects(:path_exists?).returns(true) + provider.expects(:path_empty?).returns(false) + proc { provider.create }.should raise_error(Puppet::Error) end + end + end - context "when the path is a working copy repository" do - it "should convert it to a bare repository" do - provider.expects(:working_copy_exists?).returns(true) - provider.expects(:convert_working_copy_to_bare) - provider.create - end - end + context "when the path does not exist" do + it "should execute 'git init --bare'" do + resource[:ensure] = :bare + resource.delete(:source) + expects_chdir + expects_mkdir + expects_directory?(false) + provider.expects(:working_copy_exists?).returns(false) + provider.expects(:git).with('init', '--bare') + provider.create + end + end - context "when the path is not empty and not a repository" do - it "should raise an exception" do - expects_directory?(true) - provider.expects(:path_empty?).returns(false) - proc { provider.create }.should raise_error(Puppet::Error) - end - end + context "when the path is a working copy repository" do + it "should convert it to a bare repository" do + resource[:ensure] = :bare + resource.delete(:source) + provider.expects(:working_copy_exists?).returns(true) + provider.expects(:convert_working_copy_to_bare) + provider.create end end + context "when the path is not empty and not a repository" do + it "should raise an exception" do + expects_directory?(true) + provider.expects(:path_empty?).returns(false) + proc { provider.create }.should raise_error(Puppet::Error) + end + end end + context 'destroying' do it "it should remove the directory" do - expects_rm_rf + #expects_rm_rf provider.destroy end end context "checking the revision property" do - resource_with :revision do - before do - expects_chdir - provider.expects(:git).with('rev-parse', 'HEAD').returns('currentsha') - end + before do + expects_chdir('/tmp/test') + resource[:revision] = 'currentsha' + resource.delete(:source) + provider.expects(:git).with('rev-parse', 'HEAD').returns('currentsha') + end - context "when its SHA is not different than the current SHA" do - it "should return the ref" do - provider.expects(:git).with('config', 'remote.origin.url').returns('') - provider.expects(:git).with('fetch', 'origin') # FIXME - provider.expects(:git).with('fetch', '--tags', 'origin') - provider.expects(:git).with('rev-parse', '--revs-only', resource.value(:revision)).returns('currentsha') - provider.expects(:git).with('tag', '-l').returns("Hello") - provider.revision.should == resource.value(:revision) - end + context "when its SHA is not different than the current SHA" do + it "should return the ref" do + provider.expects(:git).with('config', 'remote.origin.url').returns('') + provider.expects(:git).with('fetch', 'origin') # FIXME + provider.expects(:git).with('fetch', '--tags', 'origin') + provider.expects(:git).with('rev-parse', '--revs-only', resource.value(:revision)).returns('currentsha') + provider.expects(:git).with('tag', '-l').returns("Hello") + provider.revision.should == resource.value(:revision) end + end - context "when its SHA is different than the current SHA" do - it "should return the current SHA" do - provider.expects(:git).with('config', 'remote.origin.url').returns('') - provider.expects(:git).with('fetch', 'origin') # FIXME - provider.expects(:git).with('fetch', '--tags', 'origin') - provider.expects(:git).with('rev-parse', '--revs-only', resource.value(:revision)).returns('othersha') - provider.expects(:git).with('tag', '-l').returns("Hello") - provider.revision.should == 'currentsha' - end + context "when its SHA is different than the current SHA" do + it "should return the current SHA" do + provider.expects(:git).with('config', 'remote.origin.url').returns('') + provider.expects(:git).with('fetch', 'origin') # FIXME + provider.expects(:git).with('fetch', '--tags', 'origin') + provider.expects(:git).with('rev-parse', '--revs-only', resource.value(:revision)).returns('othersha') + provider.expects(:git).with('tag', '-l').returns("Hello") + provider.revision.should == 'currentsha' end + end - context "when its a ref to a remote head" do - it "should return the revision" do - provider.expects(:git).with('config', 'remote.origin.url').returns('') - provider.expects(:git).with('fetch', 'origin') # FIXME - provider.expects(:git).with('fetch', '--tags', 'origin') - provider.expects(:git).with('tag', '-l').returns("Hello") - provider.expects(:git).with('rev-parse', '--revs-only', resource.value(:revision)).returns('') - provider.expects(:git).with('ls-remote', '--heads', '--tags', 'origin', resource.value(:revision)).returns("newsha refs/heads/#{resource.value(:revision)}") - provider.revision.should == 'currentsha' - end + context "when its a ref to a remote head" do + it "should return the revision" do + provider.expects(:git).with('config', 'remote.origin.url').returns('') + provider.expects(:git).with('fetch', 'origin') # FIXME + provider.expects(:git).with('fetch', '--tags', 'origin') + provider.expects(:git).with('tag', '-l').returns("Hello") + provider.expects(:git).with('rev-parse', '--revs-only', resource.value(:revision)).returns('') + provider.expects(:git).with('ls-remote', '--heads', '--tags', 'origin', resource.value(:revision)).returns("newsha refs/heads/#{resource.value(:revision)}") + provider.revision.should == 'currentsha' end + end - context "when its a ref to non existant remote head" do - it "should fail" do - provider.expects(:git).with('config', 'remote.origin.url').returns('') - provider.expects(:git).with('fetch', 'origin') # FIXME - provider.expects(:git).with('fetch', '--tags', 'origin') - provider.expects(:git).with('tag', '-l').returns("Hello") - provider.expects(:git).with('rev-parse', '--revs-only', resource.value(:revision)).returns('') - provider.expects(:git).with('ls-remote', '--heads', '--tags', 'origin', resource.value(:revision)).returns('') - expect { provider.revision }.should raise_error(Puppet::Error, /not a local or remote ref$/) - end + context "when its a ref to non existant remote head" do + it "should fail" do + provider.expects(:git).with('config', 'remote.origin.url').returns('') + provider.expects(:git).with('fetch', 'origin') # FIXME + provider.expects(:git).with('fetch', '--tags', 'origin') + provider.expects(:git).with('tag', '-l').returns("Hello") + provider.expects(:git).with('rev-parse', '--revs-only', resource.value(:revision)).returns('') + provider.expects(:git).with('ls-remote', '--heads', '--tags', 'origin', resource.value(:revision)).returns('') + expect { provider.revision }.to raise_error(Puppet::Error, /not a local or remote ref$/) end + end - context "when the source is modified" do - resource_with :source => 'git://git@foo.com/bar.git' do - it "should update the origin url" do - provider.expects(:git).with('config', 'remote.origin.url').returns('old') - provider.expects(:git).with('config', 'remote.origin.url', 'git://git@foo.com/bar.git') - provider.expects(:git).with('fetch', 'origin') # FIXME - provider.expects(:git).with('fetch', '--tags', 'origin') - provider.expects(:git).with('rev-parse', '--revs-only', resource.value(:revision)).returns('currentsha') - provider.expects(:git).with('tag', '-l').returns("Hello") - provider.revision.should == resource.value(:revision) - end - end + context "when the source is modified" do + it "should update the origin url" do + resource[:source] = 'git://git@foo.com/bar.git' + provider.expects(:git).with('config', 'remote.origin.url').returns('old') + provider.expects(:git).with('config', 'remote.origin.url', 'git://git@foo.com/bar.git') + provider.expects(:git).with('fetch', 'origin') # FIXME + provider.expects(:git).with('fetch', '--tags', 'origin') + provider.expects(:git).with('rev-parse', '--revs-only', resource.value(:revision)).returns('currentsha') + provider.expects(:git).with('tag', '-l').returns("Hello") + provider.revision.should == resource.value(:revision) end end end @@ -195,8 +215,9 @@ describe_provider :vcsrepo, :git, :resource => {:path => '/tmp/vcsrepo'} do before do expects_chdir end - context "when it's an existing local branch", :resource => {:revision => 'feature/foo'} do + context "when it's an existing local branch" do it "should use 'git fetch' and 'git reset'" do + resource[:revision] = 'feature/foo' provider.expects(:update_submodules) provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) @@ -205,8 +226,9 @@ describe_provider :vcsrepo, :git, :resource => {:path => '/tmp/vcsrepo'} do provider.revision = resource.value(:revision) end end - context "when it's a remote branch", :resource => {:revision => 'only/remote'} do + context "when it's a remote branch" do it "should use 'git fetch' and 'git reset'" do + resource[:revision] = 'only/remote' provider.expects(:update_submodules) provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) @@ -215,8 +237,9 @@ describe_provider :vcsrepo, :git, :resource => {:path => '/tmp/vcsrepo'} do provider.revision = resource.value(:revision) end end - context "when it's a commit or tag", :resource => {:revision => 'a-commit-or-tag'} do + context "when it's a commit or tag" do it "should use 'git fetch' and 'git reset'" do + resource[:revision] = 'a-commit-or-tag' provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a)) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a)) @@ -229,6 +252,7 @@ describe_provider :vcsrepo, :git, :resource => {:path => '/tmp/vcsrepo'} do context "updating references" do it "should use 'git fetch --tags'" do + resource.delete(:source) expects_chdir provider.expects(:git).with('config', 'remote.origin.url').returns('') provider.expects(:git).with('fetch', 'origin') @@ -243,25 +267,29 @@ describe_provider :vcsrepo, :git, :resource => {:path => '/tmp/vcsrepo'} do provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a)) end context "is a local branch" do - context "when it's listed in 'git branch -a'", :resource => {:revision => 'feature/foo'} do + context "when it's listed in 'git branch -a'" do it "should return true" do + resource[:revision] = 'feature/foo' provider.should be_local_branch_revision end end - context "when it's not listed in 'git branch -a'" , :resource => {:revision => 'feature/notexist'}do + context "when it's not listed in 'git branch -a'" do it "should return false" do + resource[:revision] = 'feature/notexist' provider.should_not be_local_branch_revision end end end context "is a remote branch" do - context "when it's listed in 'git branch -a' with an 'origin/' prefix", :resource => {:revision => 'only/remote'} do + context "when it's listed in 'git branch -a' with an 'origin/' prefix" do it "should return true" do + resource[:revision] = 'only/remote' provider.should be_remote_branch_revision end end - context "when it's not listed in 'git branch -a' with an 'origin/' prefix" , :resource => {:revision => 'only/local'}do + context "when it's not listed in 'git branch -a' with an 'origin/' prefix" do it "should return false" do + resource[:revision] = 'only/local' provider.should_not be_remote_branch_revision end end diff --git a/spec/unit/puppet/provider/vcsrepo/hg_spec.rb b/spec/unit/puppet/provider/vcsrepo/hg_spec.rb index f17aa2f..7fd5348 100644 --- a/spec/unit/puppet/provider/vcsrepo/hg_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/hg_spec.rb @@ -1,24 +1,38 @@ require 'spec_helper' -describe_provider :vcsrepo, :hg, :resource => {:path => '/tmp/vcsrepo'} do +describe Puppet::Type.type(:vcsrepo).provider(:hg) do + + let(:resource) { Puppet::Type.type(:vcsrepo).new({ + :name => 'test', + :ensure => :present, + :provider => :hg, + :path => '/tmp/vcsrepo', + })} + + let(:provider) { resource.provider } + + before :each do + Puppet::Util.stubs(:which).with('hg').returns('/usr/bin/hg') + end describe 'creating' do - resource_with :source do - resource_with :revision do - it "should execute 'hg clone -u' with the revision" do - provider.expects(:hg).with('clone', '-u', - resource.value(:revision), - resource.value(:source), - resource.value(:path)) - provider.create - end + context 'with source and revision' do + it "should execute 'hg clone -u' with the revision" do + resource[:source] = 'something' + resource[:revision] = '1' + provider.expects(:hg).with('clone', '-u', + resource.value(:revision), + resource.value(:source), + resource.value(:path)) + provider.create end + end - resource_without :revision do - it "should just execute 'hg clone' without a revision" do - provider.expects(:hg).with('clone', resource.value(:source), resource.value(:path)) - provider.create - end + context 'without revision' do + it "should just execute 'hg clone' without a revision" do + resource[:source] = 'something' + provider.expects(:hg).with('clone', resource.value(:source), resource.value(:path)) + provider.create end end @@ -55,14 +69,16 @@ describe_provider :vcsrepo, :hg, :resource => {:path => '/tmp/vcsrepo'} do provider.expects(:hg).with('tags').returns(fixture(:hg_tags)) end - context "when its SHA is not different than the current SHA", :resource => {:revision => '0.6'} do + context "when its SHA is not different than the current SHA" do it "should return the ref" do + resource[:revision] = '0.6' provider.revision.should == '0.6' end end - context "when its SHA is different than the current SHA", :resource => {:revision => '0.5.3'} do + context "when its SHA is different than the current SHA" do it "should return the current SHA" do + resource[:revision] = '0.5.3' provider.revision.should == '34e6012c783a' end end @@ -74,6 +90,7 @@ describe_provider :vcsrepo, :hg, :resource => {:path => '/tmp/vcsrepo'} do context "when it is the same as the current SHA", :resource => {:revision => '34e6012c783a'} do it "should return it" do + resource[:revision] = '34e6012c783a' provider.expects(:hg).with('tags').returns(fixture(:hg_tags)) provider.revision.should == resource.value(:revision) end @@ -81,6 +98,7 @@ describe_provider :vcsrepo, :hg, :resource => {:path => '/tmp/vcsrepo'} do context "when it is not the same as the current SHA", :resource => {:revision => 'not-the-same'} do it "should return the current SHA" do + resource[:revision] = 'not-the-same' provider.expects(:hg).with('tags').returns(fixture(:hg_tags)) provider.revision.should == '34e6012c783a' end diff --git a/spec/unit/puppet/provider/vcsrepo/svn_spec.rb b/spec/unit/puppet/provider/vcsrepo/svn_spec.rb index 5c03327..f44e314 100644 --- a/spec/unit/puppet/provider/vcsrepo/svn_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/svn_spec.rb @@ -1,41 +1,55 @@ require 'spec_helper' -describe_provider :vcsrepo, :svn, :resource => {:path => '/tmp/vcsrepo'} do +describe Puppet::Type.type(:vcsrepo).provider(:svn) do + + let(:resource) { Puppet::Type.type(:vcsrepo).new({ + :name => 'test', + :ensure => :present, + :provider => :svn, + :path => '/tmp/vcsrepo', + })} + + let(:provider) { resource.provider } + + before :each do + Puppet::Util.stubs(:which).with('git').returns('/usr/bin/git') + end describe 'creating' do - resource_with :source do - resource_with :revision do - it "should execute 'svn checkout' with a revision" do - provider.expects(:svn).with('--non-interactive', 'checkout', '-r', - resource.value(:revision), - resource.value(:source), - resource.value(:path)) - provider.create - end + context 'with source and revision' do + it "should execute 'svn checkout' with a revision" do + resource[:source] = 'exists' + resource[:revision] = '1' + provider.expects(:svn).with('--non-interactive', 'checkout', '-r', + resource.value(:revision), + resource.value(:source), + resource.value(:path)) + provider.create end - resource_without :revision do - it "should just execute 'svn checkout' without a revision" do - provider.expects(:svn).with('--non-interactive', 'checkout', - resource.value(:source), - resource.value(:path)) - provider.create - end + end + context 'with source' do + it "should just execute 'svn checkout' without a revision" do + resource[:source] = 'exists' + provider.expects(:svn).with('--non-interactive', 'checkout', + resource.value(:source), + resource.value(:path)) + provider.create end end - resource_without :source do - resource_with :fstype do - it "should execute 'svnadmin create' with an '--fs-type' option" do - provider.expects(:svnadmin).with('create', '--fs-type', - resource.value(:fstype), - resource.value(:path)) - provider.create - end + + context 'with fstype' do + it "should execute 'svnadmin create' with an '--fs-type' option" do + resource[:fstype] = 'ext4' + provider.expects(:svnadmin).with('create', '--fs-type', + resource.value(:fstype), + resource.value(:path)) + provider.create end - resource_without :fstype do - it "should execute 'svnadmin create' without an '--fs-type' option" do - provider.expects(:svnadmin).with('create', resource.value(:path)) - provider.create - end + end + context 'without fstype' do + it "should execute 'svnadmin create' without an '--fs-type' option" do + provider.expects(:svnadmin).with('create', resource.value(:path)) + provider.create end end end @@ -69,12 +83,10 @@ describe_provider :vcsrepo, :svn, :resource => {:path => '/tmp/vcsrepo'} do before do @revision = '30' end - resource_without :source do - it "should use 'svn update'" do - expects_chdir - provider.expects(:svn).with('--non-interactive', 'update', '-r', @revision) - provider.revision = @revision - end + it "should use 'svn update'" do + expects_chdir + provider.expects(:svn).with('--non-interactive', 'update', '-r', @revision) + provider.revision = @revision end end @@ -82,12 +94,11 @@ describe_provider :vcsrepo, :svn, :resource => {:path => '/tmp/vcsrepo'} do before do @revision = '30' end - resource_with :source do - it "should use 'svn switch'" do - expects_chdir - provider.expects(:svn).with('--non-interactive', 'switch', '-r', @revision, 'an-unimportant-value') - provider.revision = @revision - end + it "should use 'svn switch'" do + resource[:source] = 'an-unimportant-value' + expects_chdir + provider.expects(:svn).with('--non-interactive', 'switch', '-r', @revision, 'an-unimportant-value') + provider.revision = @revision end end -- cgit v1.2.3 From c92ede74bedda8b43df17abfe7528d3ddffe951a Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Wed, 18 Sep 2013 18:01:13 -0400 Subject: Add test for latest? Also add some fixtures for previous tests. --- spec/fixtures/git_branch_feature_bar.txt | 14 ++++++++++++++ spec/fixtures/git_branch_none.txt | 15 +++++++++++++++ spec/unit/puppet/provider/vcsrepo/git_spec.rb | 21 +++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 spec/fixtures/git_branch_feature_bar.txt create mode 100644 spec/fixtures/git_branch_none.txt diff --git a/spec/fixtures/git_branch_feature_bar.txt b/spec/fixtures/git_branch_feature_bar.txt new file mode 100644 index 0000000..72d5e20 --- /dev/null +++ b/spec/fixtures/git_branch_feature_bar.txt @@ -0,0 +1,14 @@ + feature/foo +* feature/bar + feature/baz + feature/quux + only/local + master + refactor/foo + origin/HEAD + origin/feature/foo + origin/feature/bar + origin/feature/baz + origin/feature/quux + origin/only/remote + origin/master diff --git a/spec/fixtures/git_branch_none.txt b/spec/fixtures/git_branch_none.txt new file mode 100644 index 0000000..7207c37 --- /dev/null +++ b/spec/fixtures/git_branch_none.txt @@ -0,0 +1,15 @@ + feature/foo + feature/bar + feature/baz + feature/quux + only/local + master +* (no branch) + refactor/foo + origin/HEAD + origin/feature/foo + origin/feature/bar + origin/feature/baz + origin/feature/quux + origin/only/remote + origin/master diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index d2769ae..cc369d9 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -296,4 +296,25 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do end end + describe 'latest?' do + before do + expects_chdir('/tmp/test') + end + context 'when true' do + it do + provider.expects(:revision).returns('testrev') + provider.expects(:latest).returns('testrev') + provider.latest?.should be_true + end + end + context 'when false' do + it do + provider.expects(:revision).returns('master') + provider.expects(:latest).returns('testrev') + provider.latest?.should be_false + end + end + end + + end -- cgit v1.2.3 From a3d888f1fdd0a4cbd423b8b47f546c2d1decead7 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Wed, 18 Sep 2013 18:16:39 -0400 Subject: Add latest tests. --- spec/unit/puppet/provider/vcsrepo/git_spec.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index cc369d9..1e4704f 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -316,5 +316,30 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do end end + describe 'latest' do + before do + provider.expects(:get_revision).returns('master') + expects_chdir + end + context 'on master' do + it do + provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a)) + provider.latest.should == 'master' + end + end + context 'no branch' do + it do + provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_none)) + provider.latest.should == 'master' + end + end + context 'feature/bar' do + it do + provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_feature_bar)) + provider.latest.should == 'master' + end + end + end + end -- cgit v1.2.3 From 33c492e0e6b04c6829b8ce4650f5e45012b770dc Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Wed, 18 Sep 2013 18:20:29 -0400 Subject: Add tests for convert_working_copy_to_bare and convert_bare_to_working_copy --- spec/unit/puppet/provider/vcsrepo/git_spec.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index 1e4704f..33117f2 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -341,5 +341,26 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do end end + describe 'convert_working_copy_to_bare' do + it do + FileUtils.expects(:mv) + FileUtils.expects(:rm_rf) + FileUtils.expects(:mv) + + provider.instance_eval { convert_working_copy_to_bare } + end + end + + describe 'convert_bare_to_working_copy' do + it do + FileUtils.expects(:mv) + FileUtils.expects(:mkdir) + FileUtils.expects(:mv) + provider.expects(:commits_in?).returns(true) + expects_chdir + + provider.instance_eval { convert_bare_to_working_copy } + end + end end -- cgit v1.2.3 From d163d5059b910de9d2c086a29c72e7a228090465 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Wed, 18 Sep 2013 18:48:47 -0400 Subject: Add convert_working_copy_to_bear and convert_bare_to_working_copy tests. --- spec/unit/puppet/provider/vcsrepo/git_spec.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index 33117f2..15fee53 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -343,9 +343,9 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do describe 'convert_working_copy_to_bare' do it do - FileUtils.expects(:mv) - FileUtils.expects(:rm_rf) - FileUtils.expects(:mv) + FileUtils.expects(:mv).returns(true) + FileUtils.expects(:rm_rf).returns(true) + FileUtils.expects(:mv).returns(true) provider.instance_eval { convert_working_copy_to_bare } end @@ -353,11 +353,14 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do describe 'convert_bare_to_working_copy' do it do - FileUtils.expects(:mv) - FileUtils.expects(:mkdir) - FileUtils.expects(:mv) + FileUtils.expects(:mv).returns(true) + FileUtils.expects(:mkdir).returns(true) + FileUtils.expects(:mv).returns(true) provider.expects(:commits_in?).returns(true) - expects_chdir + # If you forget to stub these out you lose 3 hours of rspec work. + provider.expects(:reset).with('HEAD').returns(true) + provider.expects(:git_with_identity).returns(true) + provider.expects(:update_owner_and_excludes).returns(true) provider.instance_eval { convert_bare_to_working_copy } end -- cgit v1.2.3 From b9da4c4cea9a04b1d97e3a82fc4211b8f8b62260 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Tue, 1 Oct 2013 12:51:13 -0400 Subject: Modifications to .travis.yml to test appropriately. --- .travis.yml | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5e3f744..1c5e71b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,25 +1,20 @@ ---- branches: only: - - master -notifications: - email: false + - master language: ruby -script: -- 'bundle exec gem list' -- 'bundle exec rake spec' +bundler_args: --without development +script: "bundle exec rake spec SPEC_OPTS='--format documentation'" after_success: -- git clone -q git://github.com/puppetlabs/ghpublisher.git .forge-releng -- .forge-releng/publish + - git clone -q git://github.com/puppetlabs/ghpublisher.git .forge-release + - .forge-release/publish rvm: -- 1.8.7 -- 1.9.3 -- 2.0.0 + - 1.8.7 + - 1.9.3 + - 2.0.0 env: matrix: - - PUPPET_VERSION=2.6.18 - - PUPPET_VERSION=2.7.22 - - PUPPET_VERSION=3.2.1 + - PUPPET_GEM_VERSION="~> 2.7.0" + - PUPPET_GEM_VERSION="~> 3.3.0" global: - PUBLISHER_LOGIN=puppetlabs - secure: |- @@ -28,7 +23,9 @@ env: IJBDl1MADKA4i1+jAZPpz4mTvTtKS4pWKErgCSmhSfsY1hs7n6c= matrix: exclude: - - rvm: 1.9.3 - env: PUPPET_VERSION=2.6.18 - - rvm: 2.0.0 - env: PUPPET_VERSION=2.6.18 + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 2.7.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 2.7.0" +notifications: + email: false -- cgit v1.2.3 From 300d51cae5b15afacd50fee26a1a891565af90de Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Mon, 7 Oct 2013 13:20:47 -0700 Subject: FM-103: Add metadata.json to all modules. --- metadata.json | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 metadata.json diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..84551e5 --- /dev/null +++ b/metadata.json @@ -0,0 +1,24 @@ +{ + "name": "puppetlabs/vcsrepo", + "version": "0.1.2", + "summary": "Manage repositories from various version control systems", + "source": "git@github.com/puppetlabs/puppetlabs-vcsrepo.git", + "project_page": "http://github.com/puppetlabs/puppetlabs-vcsrepo", + "author": "Puppet Labs", + "license": "Apache-2.0", + "operatingsystem_support": [ + "RedHat", + "OpenSUSE", + "SLES", + "SLED", + "Debian", + "Ubuntu" + ], + "puppet_version": [ + 2.7, + 3.0, + 3.1, + 3.2, + 3.3 + ] +} -- cgit v1.2.3 From 120268f3d2142be0be346b6a04c4e709a20ed4f4 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Tue, 8 Oct 2013 15:21:14 -0700 Subject: Add a blank dependencies section and stringify versions. --- metadata.json | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/metadata.json b/metadata.json index 84551e5..5862ca8 100644 --- a/metadata.json +++ b/metadata.json @@ -15,10 +15,11 @@ "Ubuntu" ], "puppet_version": [ - 2.7, - 3.0, - 3.1, - 3.2, - 3.3 - ] + "2.7", + "3.0", + "3.1", + "3.2", + "3.3" + ], + "dependencies": [] } -- cgit v1.2.3 From 2b190756260346931b8f9a0dda8afc0c815710d6 Mon Sep 17 00:00:00 2001 From: Reid Vandewiele Date: Sun, 20 Oct 2013 22:19:34 -0700 Subject: Add autorequire for Package['git'] If the git package is being managed, it stands to reason that the git package should be installed before trying to potentially manage git repositories using vcsrepo resources. This commit adds an autorequire to the vcsrepo type that reflects the above premise. --- lib/puppet/type/vcsrepo.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/puppet/type/vcsrepo.rb b/lib/puppet/type/vcsrepo.rb index 8225721..ad90ced 100644 --- a/lib/puppet/type/vcsrepo.rb +++ b/lib/puppet/type/vcsrepo.rb @@ -191,4 +191,8 @@ Puppet::Type.newtype(:vcsrepo) do desc "The value to be used for the CVS_RSH environment variable." end + autorequire(:package) do + ['git', 'git-core'] + end + end -- cgit v1.2.3 From 6dfdc0f1c38ce9371aa8ce5f91dd9799e625a3f7 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Wed, 13 Nov 2013 12:44:24 -0500 Subject: Prepare 0.2.0 release. --- CHANGELOG | 41 +++++++++++++++++++++++++++++++++++++++++ Modulefile | 2 +- metadata.json | 25 ------------------------- 3 files changed, 42 insertions(+), 26 deletions(-) create mode 100644 CHANGELOG delete mode 100644 metadata.json diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..8142f5d --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,41 @@ +2013-11-13 - Version 0.2.0 + +Summary: + +This release mainly focuses on a number of bugfixes, which should +significantly improve the reliability of Git and SVN. Thanks to +our many contributors for all of these fixes! + +Features: +- Git: + - Add autorequire for Package['git'] +- HG: + - Allow user and identity properties. +- Bzr: + - "ensure => latest" support. +- SVN: + - Added configuration parameter. + - Add support for master svn repositories. +- CVS: + - Allow for setting the CVS_RSH environment variable. + +Fixes: +- Handle Puppet::Util[::Execution].withenv for 2.x and 3.x properly. +- Change path_empty? to not do full directory listing. +- Overhaul spec tests to work with rspec2. +- Git: + - Improve Git SSH usage documentation. + - Add ssh session timeouts to prevent network issues from blocking runs. + - Fix git provider checkout of a remote ref on an existing repo. + - Allow unlimited submodules (thanks to --recursive). + - Use git checkout --force instead of short -f everywhere. + - Update git provider to handle checking out into an existing (empty) dir. +- SVN: + - Handle force property. for svn. + - Adds support for changing upstream repo url. + - Check that the URL of the WC matches the URL from the manifest. + - Changed from using "update" to "switch". + - Handle revision update without source switch. + - Fix svn provider to look for '^Revision:' instead of '^Last Changed Rev:'. +- CVS: + - Documented the "module" attribute. diff --git a/Modulefile b/Modulefile index 5d95183..d2bbe92 100644 --- a/Modulefile +++ b/Modulefile @@ -1,4 +1,4 @@ name 'puppetlabs/vcsrepo' -version '0.1.2' +version '0.2.0' summary 'Manage repositories from various version control systems' description 'Manage repositories from various version control systems' diff --git a/metadata.json b/metadata.json deleted file mode 100644 index 5862ca8..0000000 --- a/metadata.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "puppetlabs/vcsrepo", - "version": "0.1.2", - "summary": "Manage repositories from various version control systems", - "source": "git@github.com/puppetlabs/puppetlabs-vcsrepo.git", - "project_page": "http://github.com/puppetlabs/puppetlabs-vcsrepo", - "author": "Puppet Labs", - "license": "Apache-2.0", - "operatingsystem_support": [ - "RedHat", - "OpenSUSE", - "SLES", - "SLED", - "Debian", - "Ubuntu" - ], - "puppet_version": [ - "2.7", - "3.0", - "3.1", - "3.2", - "3.3" - ], - "dependencies": [] -} -- cgit v1.2.3 From c9c6d96554e546f70a289522df3f24261674cc1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=E1=BA=BDl=20Can=C3=A9vet?= Date: Sun, 24 Nov 2013 10:44:37 +0100 Subject: Don't 'su' if passed user is current user --- lib/puppet/provider/vcsrepo/git.rb | 2 +- lib/puppet/provider/vcsrepo/hg.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 47e84d2..442ea61 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -314,7 +314,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) return ret end - elsif @resource.value(:user) + elsif @resource.value(:user) and @resource.value(:user) != Facter['id'].value su(@resource.value(:user), '-c', "git #{args.join(' ')}" ) else git(*args) diff --git a/lib/puppet/provider/vcsrepo/hg.rb b/lib/puppet/provider/vcsrepo/hg.rb index 4886b7a..33f1e6a 100644 --- a/lib/puppet/provider/vcsrepo/hg.rb +++ b/lib/puppet/provider/vcsrepo/hg.rb @@ -105,7 +105,7 @@ Puppet::Type.type(:vcsrepo).provide(:hg, :parent => Puppet::Provider::Vcsrepo) d if @resource.value(:identity) args += ["--ssh", "ssh -oStrictHostKeyChecking=no -oPasswordAuthentication=no -oKbdInteractiveAuthentication=no -oChallengeResponseAuthentication=no -i #{@resource.value(:identity)}"] end - if @resource.value(:user) + if @resource.value(:user) and @resource.value(:user) != Facter['id'].value args.map! { |a| if a =~ /\s/ then "'#{a}'" else a end } # Adds quotes to arguments with whitespaces. su(@resource.value(:user), '-c', "hg #{args.join(' ')}") else -- cgit v1.2.3 From 4689c514a12764933a9cb1e2858343f0ba5923b3 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Mon, 2 Dec 2013 11:24:15 -0500 Subject: origin/HEAD is not valid; use origin/master for latest when branch == 'master' --- lib/puppet/provider/vcsrepo/git.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 47e84d2..6bc1c3d 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -39,9 +39,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) def latest branch = on_branch? - if branch == 'master' - return get_revision("#{@resource.value(:remote)}/HEAD") - elsif branch == '(no branch)' + if branch == '(no branch)' return get_revision('HEAD') else return get_revision("#{@resource.value(:remote)}/%s" % branch) -- cgit v1.2.3 From 8837be29ff114228f86d67c59337119120690e44 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Mon, 2 Dec 2013 11:38:56 -0500 Subject: Using rev-parse to determine branch name of HEAD for on_branch? method --- lib/puppet/provider/vcsrepo/git.rb | 4 ++-- spec/unit/puppet/provider/vcsrepo/git_spec.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 6bc1c3d..17275c4 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -39,7 +39,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) def latest branch = on_branch? - if branch == '(no branch)' + if branch == '' return get_revision('HEAD') else return get_revision("#{@resource.value(:remote)}/%s" % branch) @@ -253,7 +253,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) end def on_branch? - at_path { git_with_identity('branch', '-a') }.split(/\n/).grep(/\*/).first.to_s.gsub('*', '').strip + at_path { git_with_identity('rev-parse', '--abbrev-ref', 'HEAD') } end def tags diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index 15fee53..f3d9dd3 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -323,19 +323,19 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do end context 'on master' do it do - provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a)) + provider.expects(:git).with('rev-parse', '--abbrev-ref', 'HEAD').returns(fixture(:git_branch_a)) provider.latest.should == 'master' end end context 'no branch' do it do - provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_none)) + provider.expects(:git).with('rev-parse', '--abbrev-ref', 'HEAD').returns(fixture(:git_branch_none)) provider.latest.should == 'master' end end context 'feature/bar' do it do - provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_feature_bar)) + provider.expects(:git).with('rev-parse', '--abbrev-ref', 'HEAD').returns(fixture(:git_branch_feature_bar)) provider.latest.should == 'master' end end -- cgit v1.2.3 From 69b93cefcdcd4a80d241dc71d5e6de90842faf11 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Tue, 3 Dec 2013 09:54:21 -0500 Subject: Stripping git on_branch? return value; contains trailing newline This commit also contains git provider `latest' method formatting changes; squashed by request. --- lib/puppet/provider/vcsrepo/git.rb | 6 +++--- spec/unit/puppet/provider/vcsrepo/git_spec.rb | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 17275c4..d488271 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -39,10 +39,10 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) def latest branch = on_branch? - if branch == '' + if !branch return get_revision('HEAD') else - return get_revision("#{@resource.value(:remote)}/%s" % branch) + return get_revision("#{@resource.value(:remote)}/#{branch}") end end @@ -253,7 +253,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) end def on_branch? - at_path { git_with_identity('rev-parse', '--abbrev-ref', 'HEAD') } + at_path { git_with_identity('rev-parse', '--abbrev-ref', 'HEAD').chomp } end def tags diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index f3d9dd3..554645b 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -296,6 +296,18 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do end end + context "retrieving the current revision" do + before do + expects_chdir + provider.expects(:git).with('rev-parse', '--abbrev-ref', 'HEAD').returns("foo\n") + end + + it "will strip trailing newlines" do + provider.expects(:get_revision).with('origin/foo') + provider.latest + end + end + describe 'latest?' do before do expects_chdir('/tmp/test') -- cgit v1.2.3 From e4eb8ab551d41c6d4d96cc3d0c4bc3186d4ed74d Mon Sep 17 00:00:00 2001 From: Aaron Stone Date: Tue, 7 Jan 2014 10:35:17 -0800 Subject: Temporary workaround for broken Rubygems on Travis --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 1c5e71b..ed1b75c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,3 +29,7 @@ matrix: env: PUPPET_GEM_VERSION="~> 2.7.0" notifications: email: false +# Temporary workaround for broken Rubygems on Travis +before_install: + - gem update --system 2.1.11 + - gem --version -- cgit v1.2.3 From 0ea16bba47cf177dc17fa14f20d54d0091a09865 Mon Sep 17 00:00:00 2001 From: Felipe Reyes Date: Thu, 2 Jan 2014 18:13:40 -0300 Subject: Add the option to shallow clones with git The new parameter used to indicate that you want a shallow clone is `:depth` --- lib/puppet/provider/vcsrepo/git.rb | 5 ++++- lib/puppet/type/vcsrepo.rb | 7 +++++++ spec/unit/puppet/provider/vcsrepo/git_spec.rb | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index d488271..af38a59 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -6,7 +6,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) ##TODO modify the commands below so that the su - is included optional_commands :git => 'git', :su => 'su' - has_features :bare_repositories, :reference_tracking, :ssh_identity, :multiple_remotes, :user + has_features :bare_repositories, :reference_tracking, :ssh_identity, :multiple_remotes, :user, :depth def create if !@resource.value(:source) @@ -131,6 +131,9 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) def clone_repository(source, path) check_force args = ['clone'] + if @resource.value(:depth) and @resource.value(:depth).to_i > 0 + args.push('--depth', @resource.value(:depth).to_s) + end if @resource.value(:ensure) == :bare args << '--bare' end diff --git a/lib/puppet/type/vcsrepo.rb b/lib/puppet/type/vcsrepo.rb index ad90ced..1dab2b9 100644 --- a/lib/puppet/type/vcsrepo.rb +++ b/lib/puppet/type/vcsrepo.rb @@ -37,6 +37,9 @@ Puppet::Type.newtype(:vcsrepo) do feature :cvs_rsh, "The provider understands the CVS_RSH environment variable" + feature :depth, + "The provider can do shallow clones" + ensurable do attr_accessor :latest @@ -191,6 +194,10 @@ Puppet::Type.newtype(:vcsrepo) do desc "The value to be used for the CVS_RSH environment variable." end + newparam :depth, :required_features => [:depth] do + desc "The value to be used to do a shallow clone." + end + autorequire(:package) do ['git', 'git-core'] end diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index 554645b..c40388f 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -31,6 +31,20 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do end end + context "with shallow clone enable" do + it "should execute 'git clone --depth 1'" do + resource[:revision] = 'only/remote' + resource[:depth] = 1 + Dir.expects(:chdir).with('/').at_least_once.yields + Dir.expects(:chdir).with('/tmp/test').at_least_once.yields + provider.expects(:git).with('clone', '--depth', '1', resource.value(:source), resource.value(:path)) + provider.expects(:update_submodules) + provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) + provider.expects(:git).with('checkout', '--force', resource.value(:revision)) + provider.create + end + end + context "with a revision that is not a remote branch" do it "should execute 'git clone' and 'git reset --hard'" do resource[:revision] = 'a-commit-or-tag' -- cgit v1.2.3 From 7845ea132b0b40a83d3e9284723cbf63e2b61a82 Mon Sep 17 00:00:00 2001 From: Miguel Di Ciurcio Filho Date: Sat, 11 Jan 2014 15:25:28 -0200 Subject: git: actually use the remote parameter When using the following sample, the provider does not use the value of remote when cloning a repository: vcsrepo {'/path/to/repo': ensure => 'present', provider => 'git', remote => 'test', source => 'git@somerepo:repo.git', } $ git remote origin This commit makes sure that the new repository has a remote with the supplied value. Closes #MODULES-430 --- lib/puppet/provider/vcsrepo/git.rb | 7 +++++-- spec/unit/puppet/provider/vcsrepo/git_spec.rb | 13 +++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index af38a59..cdae459 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -105,10 +105,10 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) end def update_remote_origin_url - current = git_with_identity('config', 'remote.origin.url') + current = git_with_identity('config', "remote.#{@resource.value(:remote)}.url") unless @resource.value(:source).nil? if current.nil? or current.strip != @resource.value(:source) - git_with_identity('config', 'remote.origin.url', @resource.value(:source)) + git_with_identity('config', "remote.#{@resource.value(:remote)}.url", @resource.value(:source)) end end end @@ -137,6 +137,9 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) if @resource.value(:ensure) == :bare args << '--bare' end + if @resource.value(:remote) != 'origin' + args.push('--origin', @resource.value(:remote)) + end if !File.exist?(File.join(@resource.value(:path), '.git')) args.push(source, path) Dir.chdir("/") do diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index c40388f..96c4f19 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -31,6 +31,19 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do end end + context "with a remote not named 'origin'" do + it "should execute 'git clone --origin not_origin" do + resource[:remote] = 'not_origin' + Dir.expects(:chdir).with('/').at_least_once.yields + Dir.expects(:chdir).with('/tmp/test').at_least_once.yields + provider.expects(:git).with('clone', '--origin', 'not_origin', resource.value(:source), resource.value(:path)) + provider.expects(:update_submodules) + provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) + provider.expects(:git).with('checkout', '--force', resource.value(:revision)) + provider.create + end + end + context "with shallow clone enable" do it "should execute 'git clone --depth 1'" do resource[:revision] = 'only/remote' -- cgit v1.2.3 From 93b73f6877f9bdfdd291e2dd5ff5b8f6247d833d Mon Sep 17 00:00:00 2001 From: jonoterc Date: Tue, 14 Jan 2014 12:31:26 -0500 Subject: fix svnlook behavior with plain directories svnlook expects a sub-directory within a repository called "format"; when using svnlook within a non-repository directory this causes it to throw an error. Adding a test for that directory before executing svnlook. --- lib/puppet/provider/vcsrepo/svn.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/puppet/provider/vcsrepo/svn.rb b/lib/puppet/provider/vcsrepo/svn.rb index e0d5b21..7856acd 100644 --- a/lib/puppet/provider/vcsrepo/svn.rb +++ b/lib/puppet/provider/vcsrepo/svn.rb @@ -24,8 +24,10 @@ Puppet::Type.type(:vcsrepo).provide(:svn, :parent => Puppet::Provider::Vcsrepo) if File.directory?(@resource.value(:path)) # :path is an svn checkout return true if File.directory?(File.join(@resource.value(:path), '.svn')) - # :path is an svn server - return true if svnlook('uuid', @resource.value(:path)) + if File.directory?(File.join(@resource.value(:path), 'format')) + # :path is an svn server + return true if svnlook('uuid', @resource.value(:path)) + end end false end -- cgit v1.2.3 From 9c873e1c56f1147a8fcdd01b804f744deebb53f6 Mon Sep 17 00:00:00 2001 From: Huan Du Date: Wed, 12 Feb 2014 22:40:56 +0800 Subject: use `git rev-parse` to get tag canonical revision. --- lib/puppet/provider/vcsrepo/git.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index c96095b..b2e893b 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -52,7 +52,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) return current unless @resource.value(:revision) if tag_revision?(@resource.value(:revision)) - canonical = at_path { git_with_identity('show', @resource.value(:revision)).scan(/^commit (.*)/).to_s } + canonical = at_path { git_with_identity('rev-parse', @resource.value(:revision)).chomp } else # if it's not a tag, look for it as a local ref canonical = at_path { git_with_identity('rev-parse', '--revs-only', @resource.value(:revision)).chomp } -- cgit v1.2.3 From 744f3cc4094062ef1f6a80c644d82b6284d2f7fc Mon Sep 17 00:00:00 2001 From: Felix Krull Date: Fri, 14 Feb 2014 22:12:42 +0100 Subject: Only add ssh options to commands that actually talk to the network. At least in Mercurial 2.8.2, --ssh seems to be a command-specific parameter in contrast to a global one. As a result, local commands error when seeing a --ssh parameter. This change passes --ssh only for commands that actually talk to the network ('incoming', 'pull' and 'clone' here). --- lib/puppet/provider/vcsrepo/hg.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/puppet/provider/vcsrepo/hg.rb b/lib/puppet/provider/vcsrepo/hg.rb index 33f1e6a..6c6f936 100644 --- a/lib/puppet/provider/vcsrepo/hg.rb +++ b/lib/puppet/provider/vcsrepo/hg.rb @@ -37,7 +37,7 @@ Puppet::Type.type(:vcsrepo).provide(:hg, :parent => Puppet::Provider::Vcsrepo) d def latest at_path do begin - hg_wrapper('incoming', '--branch', '.', '--newest-first', '--limit', '1')[/^changeset:\s+(?:-?\d+):(\S+)/m, 1] + hg_wrapper('incoming', '--branch', '.', '--newest-first', '--limit', '1', { :remote => true })[/^changeset:\s+(?:-?\d+):(\S+)/m, 1] rescue Puppet::ExecutionFailure # If there are no new changesets, return the current nodeid self.revision @@ -66,7 +66,7 @@ Puppet::Type.type(:vcsrepo).provide(:hg, :parent => Puppet::Provider::Vcsrepo) d def revision=(desired) at_path do begin - hg_wrapper('pull') + hg_wrapper('pull', { :remote => true }) rescue end begin @@ -92,6 +92,7 @@ Puppet::Type.type(:vcsrepo).provide(:hg, :parent => Puppet::Provider::Vcsrepo) d end args.push(@resource.value(:source), @resource.value(:path)) + args.push({ :remote => true }) hg_wrapper(*args) end @@ -102,7 +103,11 @@ Puppet::Type.type(:vcsrepo).provide(:hg, :parent => Puppet::Provider::Vcsrepo) d end def hg_wrapper(*args) - if @resource.value(:identity) + options = { :remote => false } + if args.length > 0 and args[-1].is_a? Hash + options.merge!(args.pop) + end + if options[:remote] and @resource.value(:identity) args += ["--ssh", "ssh -oStrictHostKeyChecking=no -oPasswordAuthentication=no -oKbdInteractiveAuthentication=no -oChallengeResponseAuthentication=no -i #{@resource.value(:identity)}"] end if @resource.value(:user) and @resource.value(:user) != Facter['id'].value -- cgit v1.2.3 From e4be0ab189aa32967bb732a8183c142e01942e4b Mon Sep 17 00:00:00 2001 From: Aaron Stone Date: Tue, 3 Dec 2013 01:30:51 -0600 Subject: Call set_ownership from the bzr provider --- lib/puppet/provider/vcsrepo/bzr.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/puppet/provider/vcsrepo/bzr.rb b/lib/puppet/provider/vcsrepo/bzr.rb index 6688ce8..80b18ed 100644 --- a/lib/puppet/provider/vcsrepo/bzr.rb +++ b/lib/puppet/provider/vcsrepo/bzr.rb @@ -52,6 +52,7 @@ Puppet::Type.type(:vcsrepo).provide(:bzr, :parent => Puppet::Provider::Vcsrepo) bzr('update', '-r', desired, ':parent') end end + update_owner end def latest @@ -70,6 +71,7 @@ Puppet::Type.type(:vcsrepo).provide(:bzr, :parent => Puppet::Provider::Vcsrepo) def create_repository(path) bzr('init', path) + update_owner end def clone_repository(revision) @@ -80,6 +82,12 @@ Puppet::Type.type(:vcsrepo).provide(:bzr, :parent => Puppet::Provider::Vcsrepo) args.push(@resource.value(:source), @resource.value(:path)) bzr(*args) + update_owner end + def update_owner + if @resource.value(:owner) or @resource.value(:group) + set_ownership + end + end end -- cgit v1.2.3 From 1ebe52ef9963391f13b406c843c8f475668f173c Mon Sep 17 00:00:00 2001 From: Phil Pham Date: Fri, 14 Feb 2014 11:16:15 -0800 Subject: add beaker-rspec support This adds support for beaker-rspec as well as basic test coverage for git --- Gemfile | 2 + spec/acceptance/clone_repo_spec.rb | 443 +++++++++++++++++++++ spec/acceptance/create_repo_spec.rb | 77 ++++ spec/acceptance/files/create_git_repo.sh | 36 ++ spec/acceptance/nodesets/centos-64-x64.yml | 10 + spec/acceptance/nodesets/debian-607-x64.yml | 10 + spec/acceptance/nodesets/debian-73-x64.yml | 10 + spec/acceptance/nodesets/default.yml | 10 + .../nodesets/ubuntu-server-10044-x64.yml | 10 + .../nodesets/ubuntu-server-12042-x64.yml | 10 + spec/acceptance/remove_repo_spec.rb | 30 ++ spec/spec_helper_acceptance.rb | 39 ++ 12 files changed, 687 insertions(+) create mode 100644 spec/acceptance/clone_repo_spec.rb create mode 100644 spec/acceptance/create_repo_spec.rb create mode 100755 spec/acceptance/files/create_git_repo.sh create mode 100644 spec/acceptance/nodesets/centos-64-x64.yml create mode 100644 spec/acceptance/nodesets/debian-607-x64.yml create mode 100644 spec/acceptance/nodesets/debian-73-x64.yml create mode 100644 spec/acceptance/nodesets/default.yml create mode 100644 spec/acceptance/nodesets/ubuntu-server-10044-x64.yml create mode 100644 spec/acceptance/nodesets/ubuntu-server-12042-x64.yml create mode 100644 spec/acceptance/remove_repo_spec.rb create mode 100644 spec/spec_helper_acceptance.rb diff --git a/Gemfile b/Gemfile index 5def829..ad7f34e 100644 --- a/Gemfile +++ b/Gemfile @@ -10,6 +10,8 @@ group :development, :test do gem 'serverspec', :require => false gem 'puppet-lint', :require => false gem 'pry', :require => false + gem 'beaker', :require => false + gem 'beaker-rspec', :require => false gem 'simplecov', :require => false end diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb new file mode 100644 index 0000000..4e2db19 --- /dev/null +++ b/spec/acceptance/clone_repo_spec.rb @@ -0,0 +1,443 @@ +require 'spec_helper_acceptance' + +tmpdir = default.tmpdir('vcsrepo') + +describe 'clones a remote repo' do + before(:all) do + my_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + shell("mkdir -p #{tmpdir}") # win test + scp_to(default, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + shell("cd #{tmpdir} && ./create_git_repo.sh") + end + + after(:all) do + shell("rm -rf #{tmpdir}/testrepo.git") + end + + context 'get the current master HEAD' do + it 'clones a repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo/.git") do + it { should be_directory } + end + + describe file("#{tmpdir}/testrepo/.git/HEAD") do + it { should contain 'ref: refs/heads/master' } + end + end + + context 'using a commit SHA' do + let (:sha) do + shell("git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1").stdout.chomp + end + + after(:all) do + shell("rm -rf #{tmpdir}/testrepo_sha") + end + + it 'clones a repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_sha": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + revision => "#{sha}", + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo_sha/.git") do + it { should be_directory } + end + + describe file("#{tmpdir}/testrepo_sha/.git/HEAD") do + it { should contain sha } + end + end + + context 'using a tag' do + it 'clones a repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_tag": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + revision => '0.0.2', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo_tag/.git") do + it { should be_directory } + end + + it 'should have the tag as the HEAD' do + shell("git --git-dir=#{tmpdir}/testrepo_tag/.git name-rev HEAD | grep '0.0.2'") + end + end + + context 'using a branch name' do + it 'clones a repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_branch": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + revision => 'a_branch', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo_branch/.git") do + it { should be_directory } + end + + describe file("#{tmpdir}/testrepo_branch/.git/HEAD") do + it { should contain 'ref: refs/heads/a_branch' } + end + end + + context 'ensure latest' do + it 'clones a repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_latest": + ensure => latest, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + revision => 'master', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + it 'verifies the HEAD commit SHA on remote and local match' do + remote_commit = shell("git ls-remote file://#{tmpdir}/testrepo_latest HEAD | head -1").stdout + local_commit = shell("git --git-dir=#{tmpdir}/testrepo_latest/.git rev-parse HEAD").stdout.chomp + expect(remote_commit).to include(local_commit) + end + end + + context 'with shallow clone' do + it 'does a shallow clone' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_shallow": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + depth => '1', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo_shallow/.git/shallow") do + it { should be_file } + end + end + + context 'path is not empty and not a repository' do + before(:all) do + shell("mkdir #{tmpdir}/not_a_repo", :acceptable_exit_codes => [0,1]) + shell("touch #{tmpdir}/not_a_repo/file1.txt", :acceptable_exit_codes => [0,1]) + end + + it 'should raise an exception' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/not_a_repo": + ensure => present, + provider => git + source => "file://#{tmpdir}/testrepo.git", + } + EOS + apply_manifest(pp, :expect_failures => true) + end + end + + context 'with an owner' do + it 'clones a repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_owner": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + owner => 'vagrant', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo_owner") do + it { should be_directory } + it { should be_owned_by 'vagrant' } + end + end + + context 'with a group' do + it 'clones a repo' do + pp = <<-EOS + vcsrepo { "/#{tmpdir}/testrepo_group": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + group => 'vagrant', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo_group") do + it { should be_directory } + it { should be_grouped_into 'vagrant' } + end + end + + context 'with excludes' do + it 'clones a repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_excludes": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + excludes => ['exclude1.txt', 'exclude2.txt'], + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo_excludes/.git/info/exclude") do + its(:content) { should match /exclude1.txt/ } + its(:content) { should match /exclude2.txt/ } + end + end + + context 'with force' do + before(:all) do + shell("mkdir -p #{tmpdir}/testrepo_force/folder") + shell("touch #{tmpdir}/testrepo_force/temp.txt") + end + + it 'applies the manifest' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_force": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + force => true, + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo_force/folder") do + it { should_not be_directory } + end + + describe file("#{tmpdir}/testrepo_force/temp.txt") do + it { should_not be_file } + end + + describe file("#{tmpdir}/testrepo_force/.git") do + it { should be_directory } + end + end + + context 'as a user' do + before(:all) do + shell("chmod 707 #{tmpdir}") + pp = <<-EOS + user { 'testuser': + ensure => present, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'applies the manifest' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_user": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + user => 'testuser', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo_user") do + it { should be_directory } + it { should be_owned_by 'testuser' } + end + + describe file("#{tmpdir}/testrepo_user") do + it { should be_directory } + it { should be_grouped_into 'testuser' } + end + end + + context 'non-origin remote name' do + it 'applies the manifest' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_remote": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + remote => 'testorigin', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + it 'remote name is "testorigin"' do + shell("git --git-dir=#{tmpdir}/testrepo_remote/.git remote | grep 'testorigin'") + end + + after(:all) do + pp = 'user { "testuser": ensure => absent }' + apply_manifest(pp, :catch_failures => true) + end + end + + context 'as a user with ssh' do + before(:all) do + # create user + pp = <<-EOS + user { 'testuser-ssh': + ensure => present, + managehome => true, + } + EOS + apply_manifest(pp, :catch_failures => true) + + # create ssh keys + shell('mkdir -p /home/testuser-ssh/.ssh') + shell('ssh-keygen -q -t rsa -f /home/testuser-ssh/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + shell('cat /home/testuser-ssh/.ssh/id_rsa.pub > /home/testuser-ssh/.ssh/authorized_keys') + shell('echo -e "Host localhost\n\tStrictHostKeyChecking no\n" > /home/testuser-ssh/.ssh/config') + shell('chown -R testuser-ssh:testuser-ssh /home/testuser-ssh/.ssh') + end + + it 'applies the manifest' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_user_ssh": + ensure => present, + provider => git, + source => "testuser-ssh@localhost:#{tmpdir}/testrepo.git", + user => 'testuser-ssh', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + after(:all) do + pp = <<-EOS + user { 'testuser-ssh': + ensure => absent, + managehome => true, + } + EOS + apply_manifest(pp, :catch_failures => true) + end + end + + context 'using an identity file' do + before(:all) do + # create user + pp = <<-EOS + user { 'testuser-ssh': + ensure => present, + managehome => true, + } + EOS + apply_manifest(pp, :catch_failures => true) + + # create ssh keys + shell('mkdir -p /home/testuser-ssh/.ssh') + shell('ssh-keygen -q -t rsa -f /home/testuser-ssh/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + shell('cat /home/testuser-ssh/.ssh/id_rsa.pub > /home/testuser-ssh/.ssh/authorized_keys') + shell('echo -e "Host localhost\n\tStrictHostKeyChecking no\n" > /home/testuser-ssh/.ssh/config') + shell('chown -R testuser-ssh:testuser-ssh /home/testuser-ssh/.ssh') + end + + it 'applies the manifest' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_user_ssh_id": + ensure => present, + provider => git, + source => "testuser-ssh@localhost:#{tmpdir}/testrepo.git", + identity => '/home/testuser-ssh/.ssh/id_rsa', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + after(:all) do + pp = <<-EOS + user { 'testuser-ssh': + ensure => absent, + managehome => true, + } + EOS + apply_manifest(pp, :catch_failures => true) + end + end +end diff --git a/spec/acceptance/create_repo_spec.rb b/spec/acceptance/create_repo_spec.rb new file mode 100644 index 0000000..675517e --- /dev/null +++ b/spec/acceptance/create_repo_spec.rb @@ -0,0 +1,77 @@ +require 'spec_helper_acceptance' + +tmpdir = default.tmpdir('vcsrepo') + +describe 'create a repo' do + context 'without a source' do + it 'creates a blank repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_blank_repo": + ensure => present, + provider => git, + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo_blank_repo/") do + it 'should have zero files' do + shell("ls -1 #{tmpdir}/testrepo_blank_repo | wc -l") do |r| + expect(r.stdout).to match(/^0\n$/) + end + end + end + + describe file("#{tmpdir}/testrepo_blank_repo/.git") do + it { should be_directory } + end + end + + context 'bare repo' do + it 'creates a bare repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_bare_repo": + ensure => bare, + provider => git, + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo_bare_repo/config") do + it { should contain 'bare = true' } + end + + describe file("#{tmpdir}/testrepo_bare_repo/.git") do + it { should_not be_directory } + end + end + + context 'bare repo with a revision' do + it 'creates a bare repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_bare_repo_rev": + ensure => bare, + provider => git, + revision => 'master', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{tmpdir}/testrepo_bare_repo_rev/config") do + it { should contain 'bare = true' } + end + + describe file("#{tmpdir}/testrepo_bare_repo_rev/.git") do + it { should_not be_directory } + end + end +end diff --git a/spec/acceptance/files/create_git_repo.sh b/spec/acceptance/files/create_git_repo.sh new file mode 100755 index 0000000..03c4f44 --- /dev/null +++ b/spec/acceptance/files/create_git_repo.sh @@ -0,0 +1,36 @@ +#!/bin/bash +mkdir testrepo +cd testrepo + +touch file1.txt file2.txt file3.txt +git init +echo 'change 1' > file1.txt +git add file1.txt +git tag 0.0.1 +git commit -m 'add file1' +echo 'change 2' > file2.txt +git add file2.txt +git tag 0.0.2 +git commit -m 'add file2' +echo 'change 3' > file3.txt +git add file3.txt +git commit -m 'add file3' +git tag 0.0.3 + +git checkout -b a_branch +echo 'change 4' > file4.txt +git add file4.txt +git commit -m 'add file4' +echo 'change 5' > file5.txt +git add file5.txt +git commit -m 'add file5' +echo 'change 6' > file6.txt +git add file6.txt +git commit -m 'add file6' + +git checkout master +cd .. + +git --git-dir=testrepo/.git config core.bare true +cp -r testrepo/.git testrepo.git +rm -rf testrepo diff --git a/spec/acceptance/nodesets/centos-64-x64.yml b/spec/acceptance/nodesets/centos-64-x64.yml new file mode 100644 index 0000000..05540ed --- /dev/null +++ b/spec/acceptance/nodesets/centos-64-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-64-x64: + roles: + - master + platform: el-6-x86_64 + box : centos-64-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/spec/acceptance/nodesets/debian-607-x64.yml b/spec/acceptance/nodesets/debian-607-x64.yml new file mode 100644 index 0000000..43df6a5 --- /dev/null +++ b/spec/acceptance/nodesets/debian-607-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + debian-607-x64: + roles: + - master + platform: debian-6-amd64 + box : debian-607-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-607-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/spec/acceptance/nodesets/debian-73-x64.yml b/spec/acceptance/nodesets/debian-73-x64.yml new file mode 100644 index 0000000..5b87870 --- /dev/null +++ b/spec/acceptance/nodesets/debian-73-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + debian-73-x64: + roles: + - master + platform: debian-7-amd64 + box : debian-73-x64-virtualbox-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml new file mode 100644 index 0000000..05540ed --- /dev/null +++ b/spec/acceptance/nodesets/default.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-64-x64: + roles: + - master + platform: el-6-x86_64 + box : centos-64-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml b/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml new file mode 100644 index 0000000..5ca1514 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + ubuntu-server-10044-x64: + roles: + - master + platform: ubuntu-10.04-amd64 + box : ubuntu-server-10044-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml b/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml new file mode 100644 index 0000000..d065b30 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + ubuntu-server-12042-x64: + roles: + - master + platform: ubuntu-12.04-amd64 + box : ubuntu-server-12042-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/spec/acceptance/remove_repo_spec.rb b/spec/acceptance/remove_repo_spec.rb new file mode 100644 index 0000000..d22d9db --- /dev/null +++ b/spec/acceptance/remove_repo_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper_acceptance' + +tmpdir = default.tmpdir('vcsrepo') + +describe 'remove a repo' do + it 'creates a blank repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_deleted": + ensure => present, + provider => git, + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + it 'removes a repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_deleted": + ensure => absent, + provider => git, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{tmpdir}/testrepo_deleted") do + it { should_not be_directory } + end +end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb new file mode 100644 index 0000000..dec9331 --- /dev/null +++ b/spec/spec_helper_acceptance.rb @@ -0,0 +1,39 @@ +require 'beaker-rspec' + +unless ENV['RS_PROVISION'] == 'no' + hosts.each do |host| + # Install Puppet + if host.is_pe? + install_pe + else + install_puppet + end + end +end + +RSpec.configure do |c| + # Project root + proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + + # Readable test descriptions + c.formatter = :documentation + + # Configure all nodes in nodeset + c.before :suite do + # Install module and dependencies + puppet_module_install(:source => proj_root, :module_name => 'vcsrepo') + hosts.each do |host| + case fact('osfamily') + when 'RedHat' + install_package(host, 'git') + when 'Debian' + install_package(host, 'git-core') + else + if !check_for_package(host, 'git') + puts "Git package is required for this module" + exit + end + end + end + end +end -- cgit v1.2.3 From 51063851095f3482c644f699ba57ffab3f830263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Gali=C4=87?= Date: Thu, 3 Apr 2014 14:28:33 +0200 Subject: fix tabbing in vcsrepo test --- spec/unit/puppet/provider/vcsrepo/git_spec.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index 96c4f19..ba726fa 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -32,16 +32,16 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do end context "with a remote not named 'origin'" do - it "should execute 'git clone --origin not_origin" do - resource[:remote] = 'not_origin' - Dir.expects(:chdir).with('/').at_least_once.yields - Dir.expects(:chdir).with('/tmp/test').at_least_once.yields - provider.expects(:git).with('clone', '--origin', 'not_origin', resource.value(:source), resource.value(:path)) - provider.expects(:update_submodules) - provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) - provider.expects(:git).with('checkout', '--force', resource.value(:revision)) - provider.create - end + it "should execute 'git clone --origin not_origin" do + resource[:remote] = 'not_origin' + Dir.expects(:chdir).with('/').at_least_once.yields + Dir.expects(:chdir).with('/tmp/test').at_least_once.yields + provider.expects(:git).with('clone', '--origin', 'not_origin', resource.value(:source), resource.value(:path)) + provider.expects(:update_submodules) + provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) + provider.expects(:git).with('checkout', '--force', resource.value(:revision)) + provider.create + end end context "with shallow clone enable" do -- cgit v1.2.3 From 2a57379e669a6920766548927b08e9ef4ede521e Mon Sep 17 00:00:00 2001 From: John Duarte Date: Mon, 5 May 2014 14:02:51 -0700 Subject: Add acceptance tests for git protocols using clone The git_clone_protocols_spec.rb will be used to enumerate over the available protocols for git to use to clone to disk. Support key files are also included for https/ssl use. Protocols tested * file protocol (raw filepath) * file protocol (file://) * git protocol (git://) * http protocol (http://) * https protocol (https://) * ssh protocol (ssh://user@host) TODO: Currently, the ssl cert is not added to the CA on the host. This causes the git clone to fail because the cert is not trusted and the client does not proceed with a non-trusted ssl connection. --- spec/acceptance/files/create_git_repo.sh | 3 + spec/acceptance/files/server.crt | 13 ++ spec/acceptance/files/server.key | 15 ++ spec/acceptance/git_clone_protocols_spec.rb | 230 ++++++++++++++++++++++++++++ 4 files changed, 261 insertions(+) create mode 100644 spec/acceptance/files/server.crt create mode 100644 spec/acceptance/files/server.key create mode 100644 spec/acceptance/git_clone_protocols_spec.rb diff --git a/spec/acceptance/files/create_git_repo.sh b/spec/acceptance/files/create_git_repo.sh index 03c4f44..40f341a 100755 --- a/spec/acceptance/files/create_git_repo.sh +++ b/spec/acceptance/files/create_git_repo.sh @@ -34,3 +34,6 @@ cd .. git --git-dir=testrepo/.git config core.bare true cp -r testrepo/.git testrepo.git rm -rf testrepo +cd testrepo.git +touch git-daemon-export-ok +git update-server-info diff --git a/spec/acceptance/files/server.crt b/spec/acceptance/files/server.crt new file mode 100644 index 0000000..ef1de5a --- /dev/null +++ b/spec/acceptance/files/server.crt @@ -0,0 +1,13 @@ +-----BEGIN CERTIFICATE----- +MIICATCCAWoCCQCS3fQotV10LzANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJB +VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0 +cyBQdHkgTHRkMB4XDTE0MDQyMzIyMzEyM1oXDTE1MDQyMzIyMzEyM1owRTELMAkG +A1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0 +IFdpZGdpdHMgUHR5IEx0ZDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAyRTv +uX6328aQ5Auc8PI+xNaCiE0UZNYcs+xq3AEkR/Tnz0HGXdx3+PnFG7MIRSS65hXA +VGenZk3wP4vNIe9gu+G9jtOFTJOgoOBUnJ/Hcs79Zgcmz3cAWQpqww+CZpyngUDS +msZ5HoEbNS+qaIron3IrYCgPsy1BHFs5ze7JrtcCAwEAATANBgkqhkiG9w0BAQUF +AAOBgQA2uLvdc1cf+nt7d8Lmu0SdaoIsCzh6DjVscCpFJKXdDjGT2Ys40iKbLRnY +Tt98wa6uRzEhSKfx+zVi8n3PSkQHlER7jzKFXMVx8NEt2/O/APKXVizmLFjk5WcT +FvGmmbkqX+Nj9TUTuSRZEmF776r5k8U5ABu/VarxvAzyoXAhqA== +-----END CERTIFICATE----- diff --git a/spec/acceptance/files/server.key b/spec/acceptance/files/server.key new file mode 100644 index 0000000..b594f13 --- /dev/null +++ b/spec/acceptance/files/server.key @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXQIBAAKBgQDJFO+5frfbxpDkC5zw8j7E1oKITRRk1hyz7GrcASRH9OfPQcZd +3Hf4+cUbswhFJLrmFcBUZ6dmTfA/i80h72C74b2O04VMk6Cg4FScn8dyzv1mBybP +dwBZCmrDD4JmnKeBQNKaxnkegRs1L6poiuifcitgKA+zLUEcWznN7smu1wIDAQAB +AoGAQPnD8OOyk5DZVuctwmn0wHQ0X8jQczkAs18MtKSlzZ6knUM6zy+jkM9c0vOK +E5Wn0xtqN5v66sL6g/4vvex1DA5Q6YsXvZ48VpVliZXXK/1pdTv0qwMyHdlBhmgJ +MhnZbyNy61QHdOTsWDR1YrELpDyFMJ9cZZD0NOnsuhd2DbECQQDq7W/zlJBZPWNR +ab2dP+HLpm/PiEBT13SuEEskh3GEEfZlwz/cGu0Z8DHA4E3Z60KFjwgnc92GNFMg +m0t3hHtpAkEA2x5PsDxBk9sWwdIvu57vjQLdotvAfyb+W9puIaZS1JRSVLTsUVEj +Y0KxgsPHtcjrVoN//zGymn4ePxWOzlrQPwJBAN5thEuZY7o6dyiD9zVFYKGSqdZS +aKV5H04Wuy6Q1pd28lWTMYlSLR8b3d+B//PN3SPbMps4BoukSvhaUG+OjdECQFzF +KZIBAPa7pJftCH6UHPIDy5ifF5H+DWUQRt6CT8FnBrCMZR1MkAH/g65Me6pwZYsc +Y73E6cxVJzMoSmz9r/sCQQCOhPflFCxZ23ocsuRBo9O/mMUDaLoHZXWuJ2DqAUN2 +mS6UUR/lpyc7Cmy0VOyhS8783D7MUfji5ddfVxb5tWgm +-----END RSA PRIVATE KEY----- diff --git a/spec/acceptance/git_clone_protocols_spec.rb b/spec/acceptance/git_clone_protocols_spec.rb new file mode 100644 index 0000000..f59644e --- /dev/null +++ b/spec/acceptance/git_clone_protocols_spec.rb @@ -0,0 +1,230 @@ +require 'spec_helper_acceptance' + +hosts.each do |host| + + describe 'clones a repo with git' do + tmpdir = host.tmpdir('vcsrepo') + + before(:all) do + # {{{ setup + on(host,apply_manifest("user{'testuser': ensure => present, managehome => true }")) + on(host,apply_manifest("user{'vagrant': ensure => present, }")) + # install git + install_package(host, 'git') + install_package(host, 'git-daemon') + # create ssh keys + host.execute('mkdir -p /home/testuser/.ssh') + host.execute('ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + host.execute('cat /root/.ssh/id_rsa.pub >> /home/testuser/.ssh/authorized_keys') + host.execute('echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /home/testuser/.ssh/config') + host.execute('echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') + host.execute('chown -R testuser:testuser /home/testuser/.ssh') + host.execute('chown -R root:root /root/.ssh') + + # create git repo + my_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + host.execute("cd #{tmpdir} && ./create_git_repo.sh") + + # copy ssl keys + scp_to(host, "#{my_root}/acceptance/files/server.crt", tmpdir) + scp_to(host, "#{my_root}/acceptance/files/server.key", tmpdir) + # }}} + end + + after(:all) do + # {{{ teardown + on(host,apply_manifest("user{'testuser': ensure => absent, managehome => true }")) + on(host,apply_manifest("file{'/root/.ssh/id_rsa': ensure => absent, force => true }")) + on(host,apply_manifest("file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }")) + # }}} + end + + + #--------------- TESTS ----------------------# + + context 'using local protocol (file URL)' do + before(:all) do + on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + end + + it 'should have HEAD pointing to master' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + } + EOS + + # Run it twice and test for idempotency + on(host,apply_manifest(pp, :catch_failures => true)) + on(host,apply_manifest(pp, :catch_changes => true)) + end + + describe file("#{tmpdir}/testrepo/.git/HEAD") do + it { should contain 'ref: refs/heads/master' } + end + + end + + context 'using local protocol (file path)' do + before(:all) do + on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + end + + it 'should have HEAD pointing to master' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo": + ensure => present, + provider => git, + source => "#{tmpdir}/testrepo.git", + } + EOS + + # Run it twice and test for idempotency + on(host,apply_manifest(pp, :catch_failures => true)) + on(host,apply_manifest(pp, :catch_changes => true)) + end + + describe file("#{tmpdir}/testrepo/.git/HEAD") do + it { should contain 'ref: refs/heads/master' } + end + + end + + context 'using git protocol' do + before(:all) do + on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + host.execute("nohup git daemon --detach --base-path=/#{tmpdir}") + end + + it 'should have HEAD pointing to master' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo": + ensure => present, + provider => git, + source => "git://#{host}/testrepo.git", + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + describe file("#{tmpdir}/testrepo/.git/HEAD") do + it { should contain 'ref: refs/heads/master' } + end + + after(:all) do + host.execute('pkill -9 git') + end + end + + context 'using http protocol' do + before(:all) do + on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + daemon =<<-EOF + require 'webrick' + server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/daemon.rb', daemon) + on(host, "ruby /tmp/daemon.rb") + end + + it 'should have HEAD pointing to master' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo": + ensure => present, + provider => git, + source => "http://#{host}:8000/testrepo.git", + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + describe file("#{tmpdir}/testrepo/.git/HEAD") do + it { should contain 'ref: refs/heads/master' } + end + + after(:all) do + host.execute('pkill -9 ruby') + end + end + + context 'using https protocol' do + before(:all) do + on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + daemon =<<-EOF + require 'webrick' + require 'webrick/https' + server = WEBrick::HTTPServer.new( + :Port => 8443, + :DocumentRoot => "#{tmpdir}", + :SSLEnable => true, + :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, + :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), + :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), + :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/daemon.rb', daemon) + on(host, "ruby /tmp/daemon.rb") + end + + it 'should have HEAD pointing to master' do + # howto whitelist ssl cert + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo": + ensure => present, + provider => git, + source => "https://#{host}:8443/testrepo.git", + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo/.git/HEAD") do + it { should contain 'ref: refs/heads/master' } + end + + after(:all) do + host.execute('pkill -9 ruby') + end + end + + context 'using ssh protocol' do + before(:all) do + on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + end + it 'should have HEAD pointing to master' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo": + ensure => present, + provider => git, + source => "ssh://root@#{host}#{tmpdir}/testrepo.git", + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo/.git/HEAD") do + it { should contain 'ref: refs/heads/master' } + end + end + + end +end -- cgit v1.2.3 From d0c2026b64b796482d2e410b336331dc493589d0 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Thu, 8 May 2014 11:55:58 -0700 Subject: Change apply syntax to apply_manifest_on --- spec/acceptance/git_clone_protocols_spec.rb | 46 ++++++++++++++--------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/spec/acceptance/git_clone_protocols_spec.rb b/spec/acceptance/git_clone_protocols_spec.rb index f59644e..6c9114d 100644 --- a/spec/acceptance/git_clone_protocols_spec.rb +++ b/spec/acceptance/git_clone_protocols_spec.rb @@ -7,8 +7,8 @@ hosts.each do |host| before(:all) do # {{{ setup - on(host,apply_manifest("user{'testuser': ensure => present, managehome => true }")) - on(host,apply_manifest("user{'vagrant': ensure => present, }")) + apply_manifest_on(host, "user{'testuser': ensure => present, managehome => true }") + apply_manifest_on(host, "user{'vagrant': ensure => present, }") # install git install_package(host, 'git') install_package(host, 'git-daemon') @@ -36,9 +36,9 @@ hosts.each do |host| after(:all) do # {{{ teardown - on(host,apply_manifest("user{'testuser': ensure => absent, managehome => true }")) - on(host,apply_manifest("file{'/root/.ssh/id_rsa': ensure => absent, force => true }")) - on(host,apply_manifest("file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }")) + apply_manifest_on(host, "user{'testuser': ensure => absent, managehome => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") # }}} end @@ -47,7 +47,7 @@ hosts.each do |host| context 'using local protocol (file URL)' do before(:all) do - on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") end it 'should have HEAD pointing to master' do @@ -60,8 +60,8 @@ hosts.each do |host| EOS # Run it twice and test for idempotency - on(host,apply_manifest(pp, :catch_failures => true)) - on(host,apply_manifest(pp, :catch_changes => true)) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end describe file("#{tmpdir}/testrepo/.git/HEAD") do @@ -72,7 +72,7 @@ hosts.each do |host| context 'using local protocol (file path)' do before(:all) do - on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") end it 'should have HEAD pointing to master' do @@ -85,8 +85,8 @@ hosts.each do |host| EOS # Run it twice and test for idempotency - on(host,apply_manifest(pp, :catch_failures => true)) - on(host,apply_manifest(pp, :catch_changes => true)) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end describe file("#{tmpdir}/testrepo/.git/HEAD") do @@ -97,7 +97,7 @@ hosts.each do |host| context 'using git protocol' do before(:all) do - on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") host.execute("nohup git daemon --detach --base-path=/#{tmpdir}") end @@ -111,8 +111,8 @@ hosts.each do |host| EOS # Run it twice and test for idempotency - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end describe file("#{tmpdir}/testrepo/.git/HEAD") do it { should contain 'ref: refs/heads/master' } @@ -125,7 +125,7 @@ hosts.each do |host| context 'using http protocol' do before(:all) do - on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") daemon =<<-EOF require 'webrick' server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") @@ -146,8 +146,8 @@ hosts.each do |host| EOS # Run it twice and test for idempotency - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end describe file("#{tmpdir}/testrepo/.git/HEAD") do it { should contain 'ref: refs/heads/master' } @@ -160,7 +160,7 @@ hosts.each do |host| context 'using https protocol' do before(:all) do - on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") daemon =<<-EOF require 'webrick' require 'webrick/https' @@ -190,8 +190,8 @@ hosts.each do |host| EOS # Run it twice and test for idempotency - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end describe file("#{tmpdir}/testrepo/.git/HEAD") do @@ -205,7 +205,7 @@ hosts.each do |host| context 'using ssh protocol' do before(:all) do - on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") end it 'should have HEAD pointing to master' do pp = <<-EOS @@ -217,8 +217,8 @@ hosts.each do |host| EOS # Run it twice and test for idempotency - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end describe file("#{tmpdir}/testrepo/.git/HEAD") do -- cgit v1.2.3 From f703b923a4e40d1d7db424bca77cd3a1459e6600 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Thu, 8 May 2014 13:40:44 -0700 Subject: Use on(host, '') rather than host.execute('') syntax --- spec/acceptance/git_clone_protocols_spec.rb | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/spec/acceptance/git_clone_protocols_spec.rb b/spec/acceptance/git_clone_protocols_spec.rb index 6c9114d..4d9129e 100644 --- a/spec/acceptance/git_clone_protocols_spec.rb +++ b/spec/acceptance/git_clone_protocols_spec.rb @@ -13,20 +13,20 @@ hosts.each do |host| install_package(host, 'git') install_package(host, 'git-daemon') # create ssh keys - host.execute('mkdir -p /home/testuser/.ssh') - host.execute('ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + on(host, 'mkdir -p /home/testuser/.ssh') + on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') # copy public key to authorized_keys - host.execute('cat /root/.ssh/id_rsa.pub >> /home/testuser/.ssh/authorized_keys') - host.execute('echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /home/testuser/.ssh/config') - host.execute('echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') - host.execute('chown -R testuser:testuser /home/testuser/.ssh') - host.execute('chown -R root:root /root/.ssh') + on(host, 'cat /root/.ssh/id_rsa.pub >> /home/testuser/.ssh/authorized_keys') + on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /home/testuser/.ssh/config') + on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') + on(host, 'chown -R testuser:testuser /home/testuser/.ssh') + on(host, 'chown -R root:root /root/.ssh') # create git repo my_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - host.execute("cd #{tmpdir} && ./create_git_repo.sh") + on(host, "cd #{tmpdir} && ./create_git_repo.sh") # copy ssl keys scp_to(host, "#{my_root}/acceptance/files/server.crt", tmpdir) @@ -98,7 +98,7 @@ hosts.each do |host| context 'using git protocol' do before(:all) do apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") - host.execute("nohup git daemon --detach --base-path=/#{tmpdir}") + on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") end it 'should have HEAD pointing to master' do @@ -119,7 +119,7 @@ hosts.each do |host| end after(:all) do - host.execute('pkill -9 git') + on(host, 'pkill -9 git') end end @@ -154,7 +154,7 @@ hosts.each do |host| end after(:all) do - host.execute('pkill -9 ruby') + on(host, 'pkill -9 ruby') end end @@ -199,7 +199,7 @@ hosts.each do |host| end after(:all) do - host.execute('pkill -9 ruby') + on(host, 'pkill -9 ruby') end end -- cgit v1.2.3 From 35ba3c859c83df6c725579986b8681d3aaa3813f Mon Sep 17 00:00:00 2001 From: John Duarte Date: Mon, 12 May 2014 14:58:35 -0700 Subject: Add test for ensure latest with branch specified --- spec/acceptance/clone_repo_spec.rb | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb index 4e2db19..3ebbcfa 100644 --- a/spec/acceptance/clone_repo_spec.rb +++ b/spec/acceptance/clone_repo_spec.rb @@ -121,14 +121,36 @@ describe 'clones a remote repo' do end end - context 'ensure latest' do + context 'ensure latest with branch specified' do + it 'clones a repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_latest": + ensure => latest, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + revision => 'a_branch', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + it 'verifies the HEAD commit SHA on remote and local match' do + remote_commit = shell("git ls-remote file://#{tmpdir}/testrepo_latest HEAD | head -1").stdout + local_commit = shell("git --git-dir=#{tmpdir}/testrepo_latest/.git rev-parse HEAD").stdout.chomp + expect(remote_commit).to include(local_commit) + end + end + + context 'ensure latest with branch unspecified' do it 'clones a repo' do pp = <<-EOS vcsrepo { "#{tmpdir}/testrepo_latest": ensure => latest, provider => git, source => "file://#{tmpdir}/testrepo.git", - revision => 'master', } EOS -- cgit v1.2.3 From cfcd03a7c59eaa6b81de8c767bbd91e6d278c0f2 Mon Sep 17 00:00:00 2001 From: Travis Fields Date: Tue, 13 May 2014 11:27:02 -0700 Subject: Fix issue where force=>true was not destroying repository then recreating --- lib/puppet/provider/vcsrepo/git.rb | 5 ++++- lib/puppet/type/vcsrepo.rb | 8 +++++++- spec/unit/puppet/provider/vcsrepo/git_spec.rb | 19 +++++++++++++++++-- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index b2e893b..fafe4bf 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -140,7 +140,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) if @resource.value(:remote) != 'origin' args.push('--origin', @resource.value(:remote)) end - if !File.exist?(File.join(@resource.value(:path), '.git')) + if !working_copy_exists? args.push(source, path) Dir.chdir("/") do git_with_identity(*args) @@ -271,6 +271,9 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) end def get_revision(rev) + if @resource.value(:force) && working_copy_exists? + create + end if !working_copy_exists? create end diff --git a/lib/puppet/type/vcsrepo.rb b/lib/puppet/type/vcsrepo.rb index 1dab2b9..3dd7bc6 100644 --- a/lib/puppet/type/vcsrepo.rb +++ b/lib/puppet/type/vcsrepo.rb @@ -76,7 +76,7 @@ Puppet::Type.newtype(:vcsrepo) do end newvalue :latest, :required_features => [:reference_tracking] do - if provider.exists? + if provider.exists? && !@resource.value(:force) if provider.respond_to?(:update_references) provider.update_references end @@ -97,6 +97,12 @@ Puppet::Type.newtype(:vcsrepo) do prov = @resource.provider if prov if prov.working_copy_exists? + if @resource.value(:force) + notice "Deleting current repository before recloning" + prov.destroy + notice "Create repository from latest" + prov.create + end (@should.include?(:latest) && prov.latest?) ? :latest : :present elsif prov.class.feature?(:bare_repositories) and prov.bare_exists? :bare diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index ba726fa..ad6ed08 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -9,6 +9,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do :revision => '2634', :source => 'git@repo', :path => '/tmp/test', + :force => false })} let(:provider) { resource.provider } @@ -151,12 +152,26 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do provider.expects(:convert_working_copy_to_bare) provider.create end + it "should clone overtop it using force" do + resource[:force] = true + Dir.expects(:chdir).with('/').at_least_once.yields + Dir.expects(:chdir).with('/tmp/test').at_least_once.yields + provider.expects(:path_exists?).returns(true) + provider.expects(:path_empty?).returns(false) + provider.destroy + provider.expects(:git).with('clone',resource.value(:source), resource.value(:path)) + provider.expects(:update_submodules) + provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) + provider.expects(:git).with('checkout', '--force', resource.value(:revision)) + provider.create + end end context "when the path is not empty and not a repository" do it "should raise an exception" do - expects_directory?(true) + provider.expects(:path_exists?).returns(true) provider.expects(:path_empty?).returns(false) + provider.expects(:working_copy_exists?).returns(false) proc { provider.create }.should raise_error(Puppet::Error) end end @@ -390,7 +405,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do end end - describe 'convert_bare_to_working_copy' do + describe 'convert_bare_to_working_copy' do it do FileUtils.expects(:mv).returns(true) FileUtils.expects(:mkdir).returns(true) -- cgit v1.2.3 From a213d71ec8d3e75bef909cc5c3f11aaea8b4e94d Mon Sep 17 00:00:00 2001 From: Travis Fields Date: Thu, 15 May 2014 16:47:24 -0700 Subject: Fix detached head state --- lib/puppet/provider/vcsrepo/git.rb | 21 ++++++++++++++++++--- spec/unit/puppet/provider/vcsrepo/git_spec.rb | 11 +++++++---- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index fafe4bf..b4bafbf 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -79,12 +79,18 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) def revision=(desired) checkout(desired) - if local_branch_revision?(desired) + if local_branch_revision? # reset instead of pull to avoid merge conflicts. assuming remote is # authoritative. # might be worthwhile to have an allow_local_changes param to decide # whether to reset or pull when we're ensuring latest. - at_path { git_with_identity('reset', '--hard', "#{@resource.value(:remote)}/#{desired}") } + at_path { + git_with_identity('reset', '--hard', "#{@resource.value(:remote)}/#{@resource.value(:revision)}") + if detached? + git_with_identity('checkout', "#{@resource.value(:revision)}") + git_with_identity('pull') + end + } end if @resource.value(:ensure) != :bare update_submodules @@ -259,7 +265,16 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) end def on_branch? - at_path { git_with_identity('rev-parse', '--abbrev-ref', 'HEAD').chomp } + at_path { + matches = git_with_identity('branch', '--list').match /\*\s+(.*)/ + matches[1] unless matches[1].match /detached/ + } + end + + def detached? + at_path { + git_with_identity('branch', '--list').match /\*\s+\(detached from.*\)/ + } end def tags diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index ad6ed08..20aa084 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -261,6 +261,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do it "should use 'git fetch' and 'git reset'" do resource[:revision] = 'feature/foo' provider.expects(:update_submodules) + provider.expects(:git).with('branch','--list').returns("* master") provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) @@ -272,6 +273,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do it "should use 'git fetch' and 'git reset'" do resource[:revision] = 'only/remote' provider.expects(:update_submodules) + provider.expects(:git).with('branch','--list').returns("* master") provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) @@ -341,7 +343,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do context "retrieving the current revision" do before do expects_chdir - provider.expects(:git).with('rev-parse', '--abbrev-ref', 'HEAD').returns("foo\n") + provider.expects(:git).with('branch','--list').returns("* foo") end it "will strip trailing newlines" do @@ -377,19 +379,20 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do end context 'on master' do it do - provider.expects(:git).with('rev-parse', '--abbrev-ref', 'HEAD').returns(fixture(:git_branch_a)) + provider.expects(:git).with('branch','--list').returns("* master") provider.latest.should == 'master' end end context 'no branch' do it do - provider.expects(:git).with('rev-parse', '--abbrev-ref', 'HEAD').returns(fixture(:git_branch_none)) + provider.expects(:git).with('branch','--list').returns("* master") + provider.latest.should == 'master' end end context 'feature/bar' do it do - provider.expects(:git).with('rev-parse', '--abbrev-ref', 'HEAD').returns(fixture(:git_branch_feature_bar)) + provider.expects(:git).with('branch','--list').returns("* master") provider.latest.should == 'master' end end -- cgit v1.2.3 From a909fe74c71e7e214087c3c95bb21e6dfd90c940 Mon Sep 17 00:00:00 2001 From: Travis Fields Date: Thu, 15 May 2014 22:00:14 -0700 Subject: update to use -a and desired for hard reset --- lib/puppet/provider/vcsrepo/git.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index b4bafbf..61044e0 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -85,7 +85,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) # might be worthwhile to have an allow_local_changes param to decide # whether to reset or pull when we're ensuring latest. at_path { - git_with_identity('reset', '--hard', "#{@resource.value(:remote)}/#{@resource.value(:revision)}") + git_with_identity('reset', '--hard', "#{@resource.value(:remote)}/#{desired}") if detached? git_with_identity('checkout', "#{@resource.value(:revision)}") git_with_identity('pull') @@ -266,14 +266,14 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) def on_branch? at_path { - matches = git_with_identity('branch', '--list').match /\*\s+(.*)/ + matches = git_with_identity('branch', '-a').match /\*\s+(.*)/ matches[1] unless matches[1].match /detached/ } end def detached? at_path { - git_with_identity('branch', '--list').match /\*\s+\(detached from.*\)/ + git_with_identity('branch', '-a').match /\*\s+\(detached from.*\)/ } end -- cgit v1.2.3 From 2458aba1401ad6336137653f87086e7656625bf7 Mon Sep 17 00:00:00 2001 From: Travis Fields Date: Thu, 15 May 2014 22:32:47 -0700 Subject: Fix spec tests --- spec/unit/puppet/provider/vcsrepo/git_spec.rb | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index 20aa084..8e296ef 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -261,10 +261,8 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do it "should use 'git fetch' and 'git reset'" do resource[:revision] = 'feature/foo' provider.expects(:update_submodules) - provider.expects(:git).with('branch','--list').returns("* master") - provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) + provider.expects(:git).with('branch', '-a').at_least_once.returns(resource.value(:revision)) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) - provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) provider.expects(:git).with('reset', '--hard', "origin/#{resource.value(:revision)}") provider.revision = resource.value(:revision) end @@ -273,10 +271,8 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do it "should use 'git fetch' and 'git reset'" do resource[:revision] = 'only/remote' provider.expects(:update_submodules) - provider.expects(:git).with('branch','--list').returns("* master") - provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) + provider.expects(:git).with('branch', '-a').at_least_once.returns(resource.value(:revision)) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) - provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) provider.expects(:git).with('reset', '--hard', "origin/#{resource.value(:revision)}") provider.revision = resource.value(:revision) end @@ -343,7 +339,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do context "retrieving the current revision" do before do expects_chdir - provider.expects(:git).with('branch','--list').returns("* foo") + provider.expects(:git).with('branch','-a').returns("* foo") end it "will strip trailing newlines" do @@ -379,20 +375,20 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do end context 'on master' do it do - provider.expects(:git).with('branch','--list').returns("* master") + provider.expects(:git).with('branch','-a').returns("* master") provider.latest.should == 'master' end end context 'no branch' do it do - provider.expects(:git).with('branch','--list').returns("* master") + provider.expects(:git).with('branch','-a').returns("* master") provider.latest.should == 'master' end end context 'feature/bar' do it do - provider.expects(:git).with('branch','--list').returns("* master") + provider.expects(:git).with('branch','-a').returns("* master") provider.latest.should == 'master' end end -- cgit v1.2.3 From 79c4a4e6e9638aa4b5f3e7366ada7c3ddbafb8a3 Mon Sep 17 00:00:00 2001 From: Travis Fields Date: Fri, 16 May 2014 12:37:39 -0700 Subject: Add rake tasks to test both beaker and beaker-rspec in one go --- Rakefile | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) mode change 100644 => 100755 Rakefile diff --git a/Rakefile b/Rakefile old mode 100644 new mode 100755 index cd3d379..3ccf664 --- a/Rakefile +++ b/Rakefile @@ -1 +1,58 @@ require 'puppetlabs_spec_helper/rake_tasks' +require 'rake' + +task 'beaker:test',[:host,:type] => :set_beaker_variables do |t,args| + + Rake::Task['beaker-rspec:test'].invoke(args) + + if File.exists?('./acceptance') + Dir.chdir('./acceptance') + exec(build_beaker_command args) + Dir.chdir('../') + else + puts "No acceptance directory found, not running beaker tests" + end + +end + +desc "Run beaker rspec tasks against pe" +RSpec::Core::RakeTask.new('beaker-rspec:test',[:host,:type]=>:set_beaker_variables) do |t,args| + t.pattern = 'spec/acceptance' + t.rspec_opts = '--color' + t.verbose = true +end + +desc "Run beaker and beaker-rspec tasks" +task 'beaker:test:pe',:host do |t,args| + args.with_defaults(:type=> 'pe') + Rake::Task['beaker:test'].invoke(args[:host],args[:type]) +end + +task 'beaker:test:git',:host do |t,args| + args.with_defaults({:type=> 'git'}) + Rake::Task['beaker:test'].invoke(args[:host],args[:type]) +end + +task :set_beaker_variables do |t,args| + puts 'Setting environment variables for testing' + if args[:host] + ENV['BEAKER_set'] = args[:host] + puts "Host to test #{ENV['BEAKER_set']}" + end + ENV['BEAKER_IS_PE'] = args[:type] == 'pe'? "true": "false" +end + +def build_beaker_command(args) + cmd = ["beaker"] + cmd << "--type #{args[:type]}" unless !args[:type] + if File.exists?("./.beaker-#{args[:type]}.cfg") + cmd << "--options-file ./.beaker-#{args[:type]}.cfg" + end + if File.exists?("config/#{args[:host]}.cfg") + cmd << "--hosts config/#{args[:host]}.cfg" + end + if File.exists?("./tests") + cmd << "--tests ./tests" + end + cmd.join(" ") +end -- cgit v1.2.3 From 4613e93e35551271651bb7b1102d3b97a3f5b40d Mon Sep 17 00:00:00 2001 From: Travis Fields Date: Fri, 16 May 2014 16:30:58 -0700 Subject: Added multiline parsing tests for branch -a --- .gitignore | 6 ++++++ spec/unit/puppet/provider/vcsrepo/git_spec.rb | 23 ++++++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index ddd2d45..44e004c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,9 @@ coverage .DS_Store .#* \#* +Gemfile.lock +log + +#Intellij +.idea +*.iml diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index 8e296ef..daec038 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -1,7 +1,16 @@ require 'spec_helper' describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do + def branch_a_list(include_branch) + < 'test', :ensure => :present, @@ -26,7 +35,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do Dir.expects(:chdir).with('/tmp/test').at_least_once.yields provider.expects(:git).with('clone', resource.value(:source), resource.value(:path)) provider.expects(:update_submodules) - provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) + provider.expects(:git).with('branch', '-a').returns(branch_a_list(resource.value(:revision))) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) provider.create end @@ -39,7 +48,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do Dir.expects(:chdir).with('/tmp/test').at_least_once.yields provider.expects(:git).with('clone', '--origin', 'not_origin', resource.value(:source), resource.value(:path)) provider.expects(:update_submodules) - provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) + provider.expects(:git).with('branch', '-a').returns(branch_a_list(resource.value(:revision))) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) provider.create end @@ -53,7 +62,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do Dir.expects(:chdir).with('/tmp/test').at_least_once.yields provider.expects(:git).with('clone', '--depth', '1', resource.value(:source), resource.value(:path)) provider.expects(:update_submodules) - provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) + provider.expects(:git).with('branch', '-a').returns(branch_a_list(resource.value(:revision))) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) provider.create end @@ -66,7 +75,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do Dir.expects(:chdir).with('/tmp/test').at_least_once.yields provider.expects(:git).with('clone', resource.value(:source), resource.value(:path)) provider.expects(:update_submodules) - provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) + provider.expects(:git).with('branch', '-a').returns(branch_a_list(resource.value(:revision))) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) provider.create end @@ -161,7 +170,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do provider.destroy provider.expects(:git).with('clone',resource.value(:source), resource.value(:path)) provider.expects(:update_submodules) - provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) + provider.expects(:git).with('branch', '-a').returns(branch_a_list(resource.value(:revision))) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) provider.create end @@ -261,7 +270,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do it "should use 'git fetch' and 'git reset'" do resource[:revision] = 'feature/foo' provider.expects(:update_submodules) - provider.expects(:git).with('branch', '-a').at_least_once.returns(resource.value(:revision)) + provider.expects(:git).with('branch', '-a').at_least_once.returns(branch_a_list(resource.value(:revision))) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) provider.expects(:git).with('reset', '--hard', "origin/#{resource.value(:revision)}") provider.revision = resource.value(:revision) @@ -280,7 +289,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do context "when it's a commit or tag" do it "should use 'git fetch' and 'git reset'" do resource[:revision] = 'a-commit-or-tag' - provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a)) + provider.expects(:git).with('branch', '-a').at_least_once.returns(fixture(:git_branch_a)) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a)) provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a)) -- cgit v1.2.3 From bca6ff5c480d4aa129766ccac4cb385aef092fd9 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Mon, 5 May 2014 14:02:51 -0700 Subject: Add spec for clone protocols skeleton The git_clone_protocols_spec.rb will be used to enumerate over the available protocols for git to use to clone to disk. The initial skeleton includes the 'file://' protocol test as well as support key files to be used later. --- spec/acceptance/files/create_git_repo.sh | 1 + spec/acceptance/files/server.crt | 13 ++++ spec/acceptance/files/server.key | 15 +++++ spec/acceptance/git_clone_protocols_spec.rb | 94 +++++++++++++++++++++++++++++ 4 files changed, 123 insertions(+) create mode 100644 spec/acceptance/files/server.crt create mode 100644 spec/acceptance/files/server.key create mode 100644 spec/acceptance/git_clone_protocols_spec.rb diff --git a/spec/acceptance/files/create_git_repo.sh b/spec/acceptance/files/create_git_repo.sh index 03c4f44..87b00a4 100755 --- a/spec/acceptance/files/create_git_repo.sh +++ b/spec/acceptance/files/create_git_repo.sh @@ -34,3 +34,4 @@ cd .. git --git-dir=testrepo/.git config core.bare true cp -r testrepo/.git testrepo.git rm -rf testrepo +touch testrepo.git/git-daemon-export-ok diff --git a/spec/acceptance/files/server.crt b/spec/acceptance/files/server.crt new file mode 100644 index 0000000..ef1de5a --- /dev/null +++ b/spec/acceptance/files/server.crt @@ -0,0 +1,13 @@ +-----BEGIN CERTIFICATE----- +MIICATCCAWoCCQCS3fQotV10LzANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJB +VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0 +cyBQdHkgTHRkMB4XDTE0MDQyMzIyMzEyM1oXDTE1MDQyMzIyMzEyM1owRTELMAkG +A1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0 +IFdpZGdpdHMgUHR5IEx0ZDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAyRTv +uX6328aQ5Auc8PI+xNaCiE0UZNYcs+xq3AEkR/Tnz0HGXdx3+PnFG7MIRSS65hXA +VGenZk3wP4vNIe9gu+G9jtOFTJOgoOBUnJ/Hcs79Zgcmz3cAWQpqww+CZpyngUDS +msZ5HoEbNS+qaIron3IrYCgPsy1BHFs5ze7JrtcCAwEAATANBgkqhkiG9w0BAQUF +AAOBgQA2uLvdc1cf+nt7d8Lmu0SdaoIsCzh6DjVscCpFJKXdDjGT2Ys40iKbLRnY +Tt98wa6uRzEhSKfx+zVi8n3PSkQHlER7jzKFXMVx8NEt2/O/APKXVizmLFjk5WcT +FvGmmbkqX+Nj9TUTuSRZEmF776r5k8U5ABu/VarxvAzyoXAhqA== +-----END CERTIFICATE----- diff --git a/spec/acceptance/files/server.key b/spec/acceptance/files/server.key new file mode 100644 index 0000000..b594f13 --- /dev/null +++ b/spec/acceptance/files/server.key @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXQIBAAKBgQDJFO+5frfbxpDkC5zw8j7E1oKITRRk1hyz7GrcASRH9OfPQcZd +3Hf4+cUbswhFJLrmFcBUZ6dmTfA/i80h72C74b2O04VMk6Cg4FScn8dyzv1mBybP +dwBZCmrDD4JmnKeBQNKaxnkegRs1L6poiuifcitgKA+zLUEcWznN7smu1wIDAQAB +AoGAQPnD8OOyk5DZVuctwmn0wHQ0X8jQczkAs18MtKSlzZ6knUM6zy+jkM9c0vOK +E5Wn0xtqN5v66sL6g/4vvex1DA5Q6YsXvZ48VpVliZXXK/1pdTv0qwMyHdlBhmgJ +MhnZbyNy61QHdOTsWDR1YrELpDyFMJ9cZZD0NOnsuhd2DbECQQDq7W/zlJBZPWNR +ab2dP+HLpm/PiEBT13SuEEskh3GEEfZlwz/cGu0Z8DHA4E3Z60KFjwgnc92GNFMg +m0t3hHtpAkEA2x5PsDxBk9sWwdIvu57vjQLdotvAfyb+W9puIaZS1JRSVLTsUVEj +Y0KxgsPHtcjrVoN//zGymn4ePxWOzlrQPwJBAN5thEuZY7o6dyiD9zVFYKGSqdZS +aKV5H04Wuy6Q1pd28lWTMYlSLR8b3d+B//PN3SPbMps4BoukSvhaUG+OjdECQFzF +KZIBAPa7pJftCH6UHPIDy5ifF5H+DWUQRt6CT8FnBrCMZR1MkAH/g65Me6pwZYsc +Y73E6cxVJzMoSmz9r/sCQQCOhPflFCxZ23ocsuRBo9O/mMUDaLoHZXWuJ2DqAUN2 +mS6UUR/lpyc7Cmy0VOyhS8783D7MUfji5ddfVxb5tWgm +-----END RSA PRIVATE KEY----- diff --git a/spec/acceptance/git_clone_protocols_spec.rb b/spec/acceptance/git_clone_protocols_spec.rb new file mode 100644 index 0000000..9663889 --- /dev/null +++ b/spec/acceptance/git_clone_protocols_spec.rb @@ -0,0 +1,94 @@ +require 'spec_helper_acceptance' + +hosts.each do |host| + +describe 'clones a repo with git' do + tmpdir = host.tmpdir('vcsrepo') + before(:all) do + pp = <<-EOS + user { 'testuser': + ensure => absent, + managehome => true, + } + EOS + on(host,apply_manifest(pp, :catch_failures => true)) + on(host,apply_manifest("file {'#{tmpdir}': ensure => absent}", :catch_failures => true)) + # {{{ setup + # install git + install_package(host, 'git') + + # create git repo + my_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + #shell("mkdir -p #{tmpdir}") # win test + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + host.execute("cd #{tmpdir} && ./create_git_repo.sh") + + # copy ssl keys + scp_to(host, "#{my_root}/acceptance/files/server.crt", tmpdir) + scp_to(host, "#{my_root}/acceptance/files/server.key", tmpdir) + + # hack for non-vagrant deploys (deleteme) + on(host,apply_manifest("user{'vagrant': ensure => present, }")) + + # create user + pp = <<-EOS + user { 'testuser': + ensure => present, + managehome => true, + } + EOS + on(host,apply_manifest(pp, :catch_failures => true)) + + # create ssh keys + host.execute('mkdir -p /home/testuser/.ssh') + host.execute('ssh-keygen -q -t rsa -f /home/testuser/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + host.execute('cat /home/testuser/.ssh/id_rsa.pub > /home/testuser/.ssh/authorized_keys') + host.execute('echo -e "Host localhost\n\tStrictHostKeyChecking no\n" > /home/testuser/.ssh/config') + host.execute('chown -R testuser:testuser /home/testuser/.ssh') + # }}} + end + + after(:all) do + # {{{ teardown + pp = <<-EOS + user { 'testuser': + ensure => absent, + managehome => true, + } + EOS + on(host,apply_manifest(pp, :catch_failures => true)) + on(host,apply_manifest("file {'#{tmpdir}': ensure => absent}", :catch_failures => true)) + # }}} + end + + after(:each) do + on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => absent}", :catch_failures => true)) + end + + #--------------- TESTS ----------------------# + + context 'using local protocol (file URL)' do + it 'should have HEAD pointing to master' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + } + EOS + + # Run it twice and test for idempotency + on(host,apply_manifest(pp, :catch_failures => true)) + on(host,apply_manifest(pp, :catch_changes => true)) + end + + describe file("#{tmpdir}/testrepo/.git/HEAD") do + it { should contain 'ref: refs/heads/master' } + end + + end + +end +end -- cgit v1.2.3 From 30aa7738146921f0fb34e61ace82eed8dae1fc97 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Mon, 5 May 2014 17:54:22 -0700 Subject: Add test for clone using git protocol --- spec/acceptance/git_clone_protocols_spec.rb | 164 ++++++++++++++-------------- 1 file changed, 83 insertions(+), 81 deletions(-) diff --git a/spec/acceptance/git_clone_protocols_spec.rb b/spec/acceptance/git_clone_protocols_spec.rb index 9663889..ec56625 100644 --- a/spec/acceptance/git_clone_protocols_spec.rb +++ b/spec/acceptance/git_clone_protocols_spec.rb @@ -2,93 +2,95 @@ require 'spec_helper_acceptance' hosts.each do |host| -describe 'clones a repo with git' do - tmpdir = host.tmpdir('vcsrepo') - before(:all) do - pp = <<-EOS - user { 'testuser': - ensure => absent, - managehome => true, - } - EOS - on(host,apply_manifest(pp, :catch_failures => true)) - on(host,apply_manifest("file {'#{tmpdir}': ensure => absent}", :catch_failures => true)) - # {{{ setup - # install git - install_package(host, 'git') - - # create git repo - my_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) - #shell("mkdir -p #{tmpdir}") # win test - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - host.execute("cd #{tmpdir} && ./create_git_repo.sh") - - # copy ssl keys - scp_to(host, "#{my_root}/acceptance/files/server.crt", tmpdir) - scp_to(host, "#{my_root}/acceptance/files/server.key", tmpdir) - - # hack for non-vagrant deploys (deleteme) - on(host,apply_manifest("user{'vagrant': ensure => present, }")) - - # create user - pp = <<-EOS - user { 'testuser': - ensure => present, - managehome => true, - } - EOS - on(host,apply_manifest(pp, :catch_failures => true)) - - # create ssh keys - host.execute('mkdir -p /home/testuser/.ssh') - host.execute('ssh-keygen -q -t rsa -f /home/testuser/.ssh/id_rsa -N ""') - - # copy public key to authorized_keys - host.execute('cat /home/testuser/.ssh/id_rsa.pub > /home/testuser/.ssh/authorized_keys') - host.execute('echo -e "Host localhost\n\tStrictHostKeyChecking no\n" > /home/testuser/.ssh/config') - host.execute('chown -R testuser:testuser /home/testuser/.ssh') - # }}} - end + describe 'clones a repo with git' do + tmpdir = host.tmpdir('vcsrepo') + + before(:all) do + # {{{ setup + on(host,apply_manifest("user{'testuser': ensure => present, }")) + on(host,apply_manifest("user{'vagrant': ensure => present, }")) + # install git + install_package(host, 'git') + install_package(host, 'git-daemon') + # create ssh keys + host.execute('mkdir -p /home/testuser/.ssh') + host.execute('ssh-keygen -q -t rsa -f /home/testuser/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + host.execute('cat /home/testuser/.ssh/id_rsa.pub > /home/testuser/.ssh/authorized_keys') + host.execute('echo -e "Host localhost\n\tStrictHostKeyChecking no\n" > /home/testuser/.ssh/config') + host.execute('chown -R testuser:testuser /home/testuser/.ssh') + + # create git repo + my_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + host.execute("cd #{tmpdir} && ./create_git_repo.sh") + + # copy ssl keys + scp_to(host, "#{my_root}/acceptance/files/server.crt", tmpdir) + scp_to(host, "#{my_root}/acceptance/files/server.key", tmpdir) + + host.execute("nohup git daemon --detach --base-path=/#{tmpdir}") + # }}} + end - after(:all) do - # {{{ teardown - pp = <<-EOS - user { 'testuser': - ensure => absent, - managehome => true, - } - EOS - on(host,apply_manifest(pp, :catch_failures => true)) - on(host,apply_manifest("file {'#{tmpdir}': ensure => absent}", :catch_failures => true)) - # }}} - end + after(:all) do + # {{{ teardown + on(host,apply_manifest("user{'testuser': ensure => absent,}")) + # }}} + end - after(:each) do - on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => absent}", :catch_failures => true)) - end - #--------------- TESTS ----------------------# - - context 'using local protocol (file URL)' do - it 'should have HEAD pointing to master' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/testrepo": - ensure => present, - provider => git, - source => "file://#{tmpdir}/testrepo.git", - } - EOS - - # Run it twice and test for idempotency - on(host,apply_manifest(pp, :catch_failures => true)) - on(host,apply_manifest(pp, :catch_changes => true)) + #--------------- TESTS ----------------------# + + context 'using local protocol (file URL)' do + before(:all) do + on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + end + + it 'should have HEAD pointing to master' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + } + EOS + + # Run it twice and test for idempotency + on(host,apply_manifest(pp, :catch_failures => true)) + on(host,apply_manifest(pp, :catch_changes => true)) + end + + describe file("#{tmpdir}/testrepo/.git/HEAD") do + it { should contain 'ref: refs/heads/master' } + end + end - describe file("#{tmpdir}/testrepo/.git/HEAD") do - it { should contain 'ref: refs/heads/master' } + context 'using git protocol' do + before(:all) do + on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + end + + it 'should have HEAD pointing to master' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo": + ensure => present, + provider => git, + source => "git://#{host}/testrepo.git", + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + describe file("#{tmpdir}/testrepo/.git/HEAD") do + it { should contain 'ref: refs/heads/master' } + end + end end - -end end -- cgit v1.2.3 From 3c41c39e19b63d76001fe980a2b8281221e6175e Mon Sep 17 00:00:00 2001 From: John Duarte Date: Mon, 5 May 2014 21:04:24 -0700 Subject: Add test for git clone using file path --- spec/acceptance/git_clone_protocols_spec.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/spec/acceptance/git_clone_protocols_spec.rb b/spec/acceptance/git_clone_protocols_spec.rb index ec56625..ec99629 100644 --- a/spec/acceptance/git_clone_protocols_spec.rb +++ b/spec/acceptance/git_clone_protocols_spec.rb @@ -68,6 +68,31 @@ hosts.each do |host| end + context 'using local protocol (file path)' do + before(:all) do + on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + end + + it 'should have HEAD pointing to master' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo": + ensure => present, + provider => git, + source => "#{tmpdir}/testrepo.git", + } + EOS + + # Run it twice and test for idempotency + on(host,apply_manifest(pp, :catch_failures => true)) + on(host,apply_manifest(pp, :catch_changes => true)) + end + + describe file("#{tmpdir}/testrepo/.git/HEAD") do + it { should contain 'ref: refs/heads/master' } + end + + end + context 'using git protocol' do before(:all) do on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) -- cgit v1.2.3 From fc8c177fbbe0f3cecfb1f984725bf4cbcfbeb54d Mon Sep 17 00:00:00 2001 From: John Duarte Date: Tue, 6 May 2014 08:52:20 -0700 Subject: Move git daemon setup/teardown into context block In order to ensure that the git daemon is running for the proper test, the setup and teardown calls for git daemon hav been moved into the context block for testing the git protocol. --- spec/acceptance/git_clone_protocols_spec.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/acceptance/git_clone_protocols_spec.rb b/spec/acceptance/git_clone_protocols_spec.rb index ec99629..77a1adb 100644 --- a/spec/acceptance/git_clone_protocols_spec.rb +++ b/spec/acceptance/git_clone_protocols_spec.rb @@ -29,8 +29,6 @@ hosts.each do |host| # copy ssl keys scp_to(host, "#{my_root}/acceptance/files/server.crt", tmpdir) scp_to(host, "#{my_root}/acceptance/files/server.key", tmpdir) - - host.execute("nohup git daemon --detach --base-path=/#{tmpdir}") # }}} end @@ -96,6 +94,7 @@ hosts.each do |host| context 'using git protocol' do before(:all) do on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + host.execute("nohup git daemon --detach --base-path=/#{tmpdir}") end it 'should have HEAD pointing to master' do @@ -115,6 +114,9 @@ hosts.each do |host| it { should contain 'ref: refs/heads/master' } end + after(:all) do + host.execute('pkill -9 git') + end end end -- cgit v1.2.3 From 6c284f23696eb5d036537acab9a6d564b700d78a Mon Sep 17 00:00:00 2001 From: John Duarte Date: Tue, 6 May 2014 08:54:48 -0700 Subject: Add managehome to testuser In order to make sure that the home directory for the test user is created and destroyed, add managehome to the setup and teardown manifests for the testuser. --- spec/acceptance/git_clone_protocols_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/acceptance/git_clone_protocols_spec.rb b/spec/acceptance/git_clone_protocols_spec.rb index 77a1adb..a3f897a 100644 --- a/spec/acceptance/git_clone_protocols_spec.rb +++ b/spec/acceptance/git_clone_protocols_spec.rb @@ -7,7 +7,7 @@ hosts.each do |host| before(:all) do # {{{ setup - on(host,apply_manifest("user{'testuser': ensure => present, }")) + on(host,apply_manifest("user{'testuser': ensure => present, managehome => true }")) on(host,apply_manifest("user{'vagrant': ensure => present, }")) # install git install_package(host, 'git') @@ -34,7 +34,7 @@ hosts.each do |host| after(:all) do # {{{ teardown - on(host,apply_manifest("user{'testuser': ensure => absent,}")) + on(host,apply_manifest("user{'testuser': ensure => absent, managehome => true }")) # }}} end -- cgit v1.2.3 From 2e8cc51403ead784e9764bb25d15d8a30d8d6475 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Tue, 6 May 2014 08:55:51 -0700 Subject: Add test for git clone using http --- spec/acceptance/files/create_git_repo.sh | 4 +++- spec/acceptance/git_clone_protocols_spec.rb | 35 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/spec/acceptance/files/create_git_repo.sh b/spec/acceptance/files/create_git_repo.sh index 87b00a4..40f341a 100755 --- a/spec/acceptance/files/create_git_repo.sh +++ b/spec/acceptance/files/create_git_repo.sh @@ -34,4 +34,6 @@ cd .. git --git-dir=testrepo/.git config core.bare true cp -r testrepo/.git testrepo.git rm -rf testrepo -touch testrepo.git/git-daemon-export-ok +cd testrepo.git +touch git-daemon-export-ok +git update-server-info diff --git a/spec/acceptance/git_clone_protocols_spec.rb b/spec/acceptance/git_clone_protocols_spec.rb index a3f897a..96afe56 100644 --- a/spec/acceptance/git_clone_protocols_spec.rb +++ b/spec/acceptance/git_clone_protocols_spec.rb @@ -119,5 +119,40 @@ hosts.each do |host| end end + context 'using http protocol' do + before(:all) do + on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + daemon =<<-EOF + require 'webrick' + server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/daemon.rb', daemon) + on(host, "ruby /tmp/daemon.rb") + end + + it 'should have HEAD pointing to master' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo": + ensure => present, + provider => git, + source => "http://#{host}:8000/testrepo.git", + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + describe file("#{tmpdir}/testrepo/.git/HEAD") do + it { should contain 'ref: refs/heads/master' } + end + + after(:all) do + host.execute('pkill -9 ruby') + end + end + end end -- cgit v1.2.3 From ff1dcfde8b337a95022a03947a84f148ff65badc Mon Sep 17 00:00:00 2001 From: John Duarte Date: Tue, 6 May 2014 11:11:25 -0700 Subject: Add test for git clone using https --- spec/acceptance/git_clone_protocols_spec.rb | 45 +++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/spec/acceptance/git_clone_protocols_spec.rb b/spec/acceptance/git_clone_protocols_spec.rb index 96afe56..21f29a6 100644 --- a/spec/acceptance/git_clone_protocols_spec.rb +++ b/spec/acceptance/git_clone_protocols_spec.rb @@ -154,5 +154,50 @@ hosts.each do |host| end end + context 'using https protocol' do + before(:all) do + on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + daemon =<<-EOF + require 'webrick' + require 'webrick/https' + server = WEBrick::HTTPServer.new( + :Port => 8443, + :DocumentRoot => "#{tmpdir}", + :SSLEnable => true, + :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, + :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), + :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), + :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/daemon.rb', daemon) + on(host, "ruby /tmp/daemon.rb") + end + + it 'should have HEAD pointing to master' do + # howto whitelist ssl cert + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo": + ensure => present, + provider => git, + source => "https://#{host}:8443/testrepo.git", + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo/.git/HEAD") do + it { should contain 'ref: refs/heads/master' } + end + + after(:all) do + host.execute('pkill -9 ruby') + end + end + end end -- cgit v1.2.3 From b6d724bb656939f7b6c95fbe86a42442193b2938 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Tue, 6 May 2014 17:50:06 -0700 Subject: Add test for git clone using ssh --- spec/acceptance/git_clone_protocols_spec.rb | 33 ++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/spec/acceptance/git_clone_protocols_spec.rb b/spec/acceptance/git_clone_protocols_spec.rb index 21f29a6..f59644e 100644 --- a/spec/acceptance/git_clone_protocols_spec.rb +++ b/spec/acceptance/git_clone_protocols_spec.rb @@ -14,12 +14,14 @@ hosts.each do |host| install_package(host, 'git-daemon') # create ssh keys host.execute('mkdir -p /home/testuser/.ssh') - host.execute('ssh-keygen -q -t rsa -f /home/testuser/.ssh/id_rsa -N ""') + host.execute('ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') # copy public key to authorized_keys - host.execute('cat /home/testuser/.ssh/id_rsa.pub > /home/testuser/.ssh/authorized_keys') - host.execute('echo -e "Host localhost\n\tStrictHostKeyChecking no\n" > /home/testuser/.ssh/config') + host.execute('cat /root/.ssh/id_rsa.pub >> /home/testuser/.ssh/authorized_keys') + host.execute('echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /home/testuser/.ssh/config') + host.execute('echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') host.execute('chown -R testuser:testuser /home/testuser/.ssh') + host.execute('chown -R root:root /root/.ssh') # create git repo my_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) @@ -35,6 +37,8 @@ hosts.each do |host| after(:all) do # {{{ teardown on(host,apply_manifest("user{'testuser': ensure => absent, managehome => true }")) + on(host,apply_manifest("file{'/root/.ssh/id_rsa': ensure => absent, force => true }")) + on(host,apply_manifest("file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }")) # }}} end @@ -199,5 +203,28 @@ hosts.each do |host| end end + context 'using ssh protocol' do + before(:all) do + on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + end + it 'should have HEAD pointing to master' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo": + ensure => present, + provider => git, + source => "ssh://root@#{host}#{tmpdir}/testrepo.git", + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo/.git/HEAD") do + it { should contain 'ref: refs/heads/master' } + end + end + end end -- cgit v1.2.3 From 4a18465e7dc957a586b58fd3237e4312afb5fd5f Mon Sep 17 00:00:00 2001 From: John Duarte Date: Thu, 8 May 2014 11:55:58 -0700 Subject: Change apply syntax to apply_manifest_on --- spec/acceptance/git_clone_protocols_spec.rb | 46 ++++++++++++++--------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/spec/acceptance/git_clone_protocols_spec.rb b/spec/acceptance/git_clone_protocols_spec.rb index f59644e..6c9114d 100644 --- a/spec/acceptance/git_clone_protocols_spec.rb +++ b/spec/acceptance/git_clone_protocols_spec.rb @@ -7,8 +7,8 @@ hosts.each do |host| before(:all) do # {{{ setup - on(host,apply_manifest("user{'testuser': ensure => present, managehome => true }")) - on(host,apply_manifest("user{'vagrant': ensure => present, }")) + apply_manifest_on(host, "user{'testuser': ensure => present, managehome => true }") + apply_manifest_on(host, "user{'vagrant': ensure => present, }") # install git install_package(host, 'git') install_package(host, 'git-daemon') @@ -36,9 +36,9 @@ hosts.each do |host| after(:all) do # {{{ teardown - on(host,apply_manifest("user{'testuser': ensure => absent, managehome => true }")) - on(host,apply_manifest("file{'/root/.ssh/id_rsa': ensure => absent, force => true }")) - on(host,apply_manifest("file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }")) + apply_manifest_on(host, "user{'testuser': ensure => absent, managehome => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") # }}} end @@ -47,7 +47,7 @@ hosts.each do |host| context 'using local protocol (file URL)' do before(:all) do - on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") end it 'should have HEAD pointing to master' do @@ -60,8 +60,8 @@ hosts.each do |host| EOS # Run it twice and test for idempotency - on(host,apply_manifest(pp, :catch_failures => true)) - on(host,apply_manifest(pp, :catch_changes => true)) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end describe file("#{tmpdir}/testrepo/.git/HEAD") do @@ -72,7 +72,7 @@ hosts.each do |host| context 'using local protocol (file path)' do before(:all) do - on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") end it 'should have HEAD pointing to master' do @@ -85,8 +85,8 @@ hosts.each do |host| EOS # Run it twice and test for idempotency - on(host,apply_manifest(pp, :catch_failures => true)) - on(host,apply_manifest(pp, :catch_changes => true)) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end describe file("#{tmpdir}/testrepo/.git/HEAD") do @@ -97,7 +97,7 @@ hosts.each do |host| context 'using git protocol' do before(:all) do - on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") host.execute("nohup git daemon --detach --base-path=/#{tmpdir}") end @@ -111,8 +111,8 @@ hosts.each do |host| EOS # Run it twice and test for idempotency - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end describe file("#{tmpdir}/testrepo/.git/HEAD") do it { should contain 'ref: refs/heads/master' } @@ -125,7 +125,7 @@ hosts.each do |host| context 'using http protocol' do before(:all) do - on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") daemon =<<-EOF require 'webrick' server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") @@ -146,8 +146,8 @@ hosts.each do |host| EOS # Run it twice and test for idempotency - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end describe file("#{tmpdir}/testrepo/.git/HEAD") do it { should contain 'ref: refs/heads/master' } @@ -160,7 +160,7 @@ hosts.each do |host| context 'using https protocol' do before(:all) do - on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") daemon =<<-EOF require 'webrick' require 'webrick/https' @@ -190,8 +190,8 @@ hosts.each do |host| EOS # Run it twice and test for idempotency - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end describe file("#{tmpdir}/testrepo/.git/HEAD") do @@ -205,7 +205,7 @@ hosts.each do |host| context 'using ssh protocol' do before(:all) do - on(host,apply_manifest("file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }")) + apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") end it 'should have HEAD pointing to master' do pp = <<-EOS @@ -217,8 +217,8 @@ hosts.each do |host| EOS # Run it twice and test for idempotency - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end describe file("#{tmpdir}/testrepo/.git/HEAD") do -- cgit v1.2.3 From 85073a856bc69d7b63ebc3993ab1cda6fcba482c Mon Sep 17 00:00:00 2001 From: John Duarte Date: Thu, 8 May 2014 13:40:44 -0700 Subject: Use on(host, '') rather than host.execute('') syntax --- spec/acceptance/git_clone_protocols_spec.rb | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/spec/acceptance/git_clone_protocols_spec.rb b/spec/acceptance/git_clone_protocols_spec.rb index 6c9114d..4d9129e 100644 --- a/spec/acceptance/git_clone_protocols_spec.rb +++ b/spec/acceptance/git_clone_protocols_spec.rb @@ -13,20 +13,20 @@ hosts.each do |host| install_package(host, 'git') install_package(host, 'git-daemon') # create ssh keys - host.execute('mkdir -p /home/testuser/.ssh') - host.execute('ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + on(host, 'mkdir -p /home/testuser/.ssh') + on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') # copy public key to authorized_keys - host.execute('cat /root/.ssh/id_rsa.pub >> /home/testuser/.ssh/authorized_keys') - host.execute('echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /home/testuser/.ssh/config') - host.execute('echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') - host.execute('chown -R testuser:testuser /home/testuser/.ssh') - host.execute('chown -R root:root /root/.ssh') + on(host, 'cat /root/.ssh/id_rsa.pub >> /home/testuser/.ssh/authorized_keys') + on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /home/testuser/.ssh/config') + on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') + on(host, 'chown -R testuser:testuser /home/testuser/.ssh') + on(host, 'chown -R root:root /root/.ssh') # create git repo my_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - host.execute("cd #{tmpdir} && ./create_git_repo.sh") + on(host, "cd #{tmpdir} && ./create_git_repo.sh") # copy ssl keys scp_to(host, "#{my_root}/acceptance/files/server.crt", tmpdir) @@ -98,7 +98,7 @@ hosts.each do |host| context 'using git protocol' do before(:all) do apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") - host.execute("nohup git daemon --detach --base-path=/#{tmpdir}") + on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") end it 'should have HEAD pointing to master' do @@ -119,7 +119,7 @@ hosts.each do |host| end after(:all) do - host.execute('pkill -9 git') + on(host, 'pkill -9 git') end end @@ -154,7 +154,7 @@ hosts.each do |host| end after(:all) do - host.execute('pkill -9 ruby') + on(host, 'pkill -9 ruby') end end @@ -199,7 +199,7 @@ hosts.each do |host| end after(:all) do - host.execute('pkill -9 ruby') + on(host, 'pkill -9 ruby') end end -- cgit v1.2.3 From 60d5e83205a38f714ae678142e14a0d223076028 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Fri, 9 May 2014 11:13:40 -0700 Subject: Add beaker tests for git clone --- ...clone_over_different_exiting_repo_with_force.rb | 44 ++++++++++++++++++++++ .../clone/clone_repo_with_excludes_in_repo.rb | 42 +++++++++++++++++++++ .../clone/clone_repo_with_excludes_not_in_repo.rb | 42 +++++++++++++++++++++ .../negative/clone_over_different_exiting_repo.rb | 43 +++++++++++++++++++++ .../negative/clone_repo_with_hostile_excludes.rb | 40 ++++++++++++++++++++ 5 files changed, 211 insertions(+) create mode 100644 spec/acceptance/beaker/clone/clone_over_different_exiting_repo_with_force.rb create mode 100644 spec/acceptance/beaker/clone/clone_repo_with_excludes_in_repo.rb create mode 100644 spec/acceptance/beaker/clone/clone_repo_with_excludes_not_in_repo.rb create mode 100644 spec/acceptance/beaker/clone/negative/clone_over_different_exiting_repo.rb create mode 100644 spec/acceptance/beaker/clone/negative/clone_repo_with_hostile_excludes.rb diff --git a/spec/acceptance/beaker/clone/clone_over_different_exiting_repo_with_force.rb b/spec/acceptance/beaker/clone/clone_over_different_exiting_repo_with_force.rb new file mode 100644 index 0000000..2d755fc --- /dev/null +++ b/spec/acceptance/beaker/clone/clone_over_different_exiting_repo_with_force.rb @@ -0,0 +1,44 @@ +test_name 'C3511 - clone over an existing repo with force' + +# Globals +repo_name = 'testrepo_already_exists' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + on(host, "mkdir #{tmpdir}/#{repo_name}") + on(host, "cd #{tmpdir}/#{repo_name} && git init") + on(host, "cd #{tmpdir}/#{repo_name} && touch a && git add a && git commit -m 'a'") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'clone over existing repo with force using puppet' do + on(host, "cd #{tmpdir}/#{repo_name} && git log --pretty=format:\"%h\"") do |res| + @existing_sha = res.stdout + end + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + force => true, + } + EOS + + apply_manifest_on(host, pp) + end + + step 'verify new repo has replaced old one' do + on(host, "cd #{tmpdir}/#{repo_name} && git log --pretty=format:\"%h\"") do |res| + fail_test('original repo not replaced by force') if res.stdout.include? "#{@existing_sha}" + end + end + +end diff --git a/spec/acceptance/beaker/clone/clone_repo_with_excludes_in_repo.rb b/spec/acceptance/beaker/clone/clone_repo_with_excludes_in_repo.rb new file mode 100644 index 0000000..1252e3b --- /dev/null +++ b/spec/acceptance/beaker/clone/clone_repo_with_excludes_in_repo.rb @@ -0,0 +1,42 @@ +test_name 'C3507 - clone repo with excludes in repo' + +# Globals +repo_name = 'testrepo_with_excludes_in_repo' +exclude1 = 'file1.txt' +exclude2 ='file2.txt' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'clone repo with excludes in repo with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + excludes => [ '#{exclude1}', '#{exclude2}' ], + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify exludes are known to git' do + on(host, "cat #{tmpdir}/#{repo_name}/.git/info/exclude") do |res| + fail_test('exclude not found') unless res.stdout.include? "#{exclude1}" + fail_test('exclude not found') unless res.stdout.include? "#{exclude2}" + end + end + +end diff --git a/spec/acceptance/beaker/clone/clone_repo_with_excludes_not_in_repo.rb b/spec/acceptance/beaker/clone/clone_repo_with_excludes_not_in_repo.rb new file mode 100644 index 0000000..ce173fd --- /dev/null +++ b/spec/acceptance/beaker/clone/clone_repo_with_excludes_not_in_repo.rb @@ -0,0 +1,42 @@ +test_name 'C3508 - clone repo with excludes not in repo' + +# Globals +repo_name = 'testrepo_with_excludes_not_in_repo' +exclude1 = 'worh02o' +exclude2 ='ho398b' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'clone repo with excludes not in repo with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + excludes => [ '#{exclude1}', '#{exclude2}' ], + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify exludes are known to git' do + on(host, "cat #{tmpdir}/#{repo_name}/.git/info/exclude") do |res| + fail_test('exclude not found') unless res.stdout.include? "#{exclude1}" + fail_test('exclude not found') unless res.stdout.include? "#{exclude2}" + end + end + +end diff --git a/spec/acceptance/beaker/clone/negative/clone_over_different_exiting_repo.rb b/spec/acceptance/beaker/clone/negative/clone_over_different_exiting_repo.rb new file mode 100644 index 0000000..7821ce2 --- /dev/null +++ b/spec/acceptance/beaker/clone/negative/clone_over_different_exiting_repo.rb @@ -0,0 +1,43 @@ +test_name 'C3482 - clone over an existing repo' + +# Globals +repo_name = 'testrepo_already_exists' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + on(host, "mkdir #{tmpdir}/#{repo_name}") + on(host, "cd #{tmpdir}/#{repo_name} && git init") + on(host, "cd #{tmpdir}/#{repo_name} && touch a && git add a && git commit -m 'a'") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'clone over existing repo using puppet' do + on(host, "cd #{tmpdir}/#{repo_name} && git log --pretty=format:\"%h\"") do |res| + @existing_sha = res.stdout + end + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + } + EOS + + apply_manifest_on(host, pp) + end + + step 'verify original repo was not replaced' do + on(host, "cd #{tmpdir}/#{repo_name} && git log --pretty=format:\"%h\"") do |res| + fail_test('original repo was replaced without force') unless res.stdout.include? "#{@existing_sha}" + end + end + +end diff --git a/spec/acceptance/beaker/clone/negative/clone_repo_with_hostile_excludes.rb b/spec/acceptance/beaker/clone/negative/clone_repo_with_hostile_excludes.rb new file mode 100644 index 0000000..4e04c78 --- /dev/null +++ b/spec/acceptance/beaker/clone/negative/clone_repo_with_hostile_excludes.rb @@ -0,0 +1,40 @@ +test_name 'C3509 - clone repo with excludes not in repo' + +# Globals +repo_name = 'testrepo_with_excludes_not_in_repo' +exclude1 = 'rm -rf /tmp' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'clone repo with excludes not in repo with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + excludes => [ '#{exclude1}' ], + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify excludes are known to git' do + on(host, "cat #{tmpdir}/#{repo_name}/.git/info/exclude") do |res| + fail_test('exclude not found') unless res.stdout.include? "#{exclude1}" + end + end + +end -- cgit v1.2.3 From 35fd8b137fa83d34eb90df400ccd1da78a947b18 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Sat, 10 May 2014 09:36:26 -0700 Subject: Add beaker tests for git create --- .../create/create_bare_repo_that_already_exists.rb | 35 ++++++++++++++++++++ .../create/create_repo_that_already_exists.rb | 37 ++++++++++++++++++++++ .../create_bare_repo_specifying_revision.rb | 34 ++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 spec/acceptance/beaker/create/create_bare_repo_that_already_exists.rb create mode 100644 spec/acceptance/beaker/create/create_repo_that_already_exists.rb create mode 100644 spec/acceptance/beaker/create/negative/create_bare_repo_specifying_revision.rb diff --git a/spec/acceptance/beaker/create/create_bare_repo_that_already_exists.rb b/spec/acceptance/beaker/create/create_bare_repo_that_already_exists.rb new file mode 100644 index 0000000..663c758 --- /dev/null +++ b/spec/acceptance/beaker/create/create_bare_repo_that_already_exists.rb @@ -0,0 +1,35 @@ +test_name 'C3472 - create bare repo that already exists' + +# Globals +repo_name = 'testrepo_bare_repo_already_exists.git' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create bare repo' do + install_package(host, 'git') + on(host, "mkdir #{tmpdir}/#{repo_name}") + on(host, "cd #{tmpdir}/#{repo_name} && git --bare init") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'create bare repo that already exists using puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => bare, + provider => git, + } + EOS + + apply_manifest_on(host, pp) + end + + step 'verify repo does not contain .git directory' do + on(host, "ls -al #{tmpdir}/#{repo_name}") do |res| + fail_test "found .git for #{repo_name}" if res.stdout.include? ".git" + end + end + +end diff --git a/spec/acceptance/beaker/create/create_repo_that_already_exists.rb b/spec/acceptance/beaker/create/create_repo_that_already_exists.rb new file mode 100644 index 0000000..7c28998 --- /dev/null +++ b/spec/acceptance/beaker/create/create_repo_that_already_exists.rb @@ -0,0 +1,37 @@ +test_name 'C3470 - create repo that already exists' + +# Globals +repo_name = 'testrepo_already_exists' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + on(host, "cd #{tmpdir} && git clone file://#{tmpdir}/testrepo.git #{repo_name}") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'create repo that already exists using puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + provider => git, + } + EOS + + apply_manifest_on(host, pp) + end + + step 'verify repo is on master branch' do + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + assert_match(/ref: refs\/heads\/master/, stdout, "Git checkout not on master on #{host}") + end + end + +end diff --git a/spec/acceptance/beaker/create/negative/create_bare_repo_specifying_revision.rb b/spec/acceptance/beaker/create/negative/create_bare_repo_specifying_revision.rb new file mode 100644 index 0000000..6a12c8c --- /dev/null +++ b/spec/acceptance/beaker/create/negative/create_bare_repo_specifying_revision.rb @@ -0,0 +1,34 @@ +test_name 'C3473 - create bare repo specifying revision' + +# Globals +repo_name = 'testrepo_bare.git' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup' do + install_package(host, 'git') + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'create bare repo specifying revision using puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => bare, + revision => master, + provider => git, + } + EOS + + apply_manifest_on(host, pp, :acceptable_exit_codes => [1]) + end + + step 'verify repo was NOT created' do + on(host, "ls -al #{tmpdir}") do |res| + fail_test "found #{repo_name}" if res.stdout.include? "#{repo_name}" + end + end + +end -- cgit v1.2.3 From cd553d04e8a456cf7b76dba5f6a047242d09c03e Mon Sep 17 00:00:00 2001 From: John Duarte Date: Sat, 10 May 2014 10:00:28 -0700 Subject: Add beaker test for git branch checkout --- .../beaker/branch_checkout/branch_checkout_file.rb | 44 +++++++++++++++ .../branch_checkout/branch_checkout_file_path.rb | 44 +++++++++++++++ .../beaker/branch_checkout/branch_checkout_git.rb | 49 +++++++++++++++++ .../beaker/branch_checkout/branch_checkout_http.rb | 56 +++++++++++++++++++ .../branch_checkout/branch_checkout_https.rb | 63 ++++++++++++++++++++++ .../beaker/branch_checkout/branch_checkout_ssh.rb | 54 +++++++++++++++++++ .../negative/branch_checkout_not_exists.rb | 43 +++++++++++++++ 7 files changed, 353 insertions(+) create mode 100644 spec/acceptance/beaker/branch_checkout/branch_checkout_file.rb create mode 100644 spec/acceptance/beaker/branch_checkout/branch_checkout_file_path.rb create mode 100644 spec/acceptance/beaker/branch_checkout/branch_checkout_git.rb create mode 100644 spec/acceptance/beaker/branch_checkout/branch_checkout_http.rb create mode 100644 spec/acceptance/beaker/branch_checkout/branch_checkout_https.rb create mode 100644 spec/acceptance/beaker/branch_checkout/branch_checkout_ssh.rb create mode 100644 spec/acceptance/beaker/branch_checkout/negative/branch_checkout_not_exists.rb diff --git a/spec/acceptance/beaker/branch_checkout/branch_checkout_file.rb b/spec/acceptance/beaker/branch_checkout/branch_checkout_file.rb new file mode 100644 index 0000000..e78e374 --- /dev/null +++ b/spec/acceptance/beaker/branch_checkout/branch_checkout_file.rb @@ -0,0 +1,44 @@ +test_name 'C3438 - checkout a branch (file protocol)' + +# Globals +repo_name = 'testrepo_branch_checkout' +branch = 'a_branch' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout a branch with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + revision => '#{branch}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the #{branch} branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}" + end + end + +end diff --git a/spec/acceptance/beaker/branch_checkout/branch_checkout_file_path.rb b/spec/acceptance/beaker/branch_checkout/branch_checkout_file_path.rb new file mode 100644 index 0000000..9870daa --- /dev/null +++ b/spec/acceptance/beaker/branch_checkout/branch_checkout_file_path.rb @@ -0,0 +1,44 @@ +test_name 'C3437 - checkout a branch (file path)' + +# Globals +repo_name = 'testrepo_branch_checkout' +branch = 'a_branch' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout a branch with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "#{tmpdir}/testrepo.git", + provider => git, + revision => '#{branch}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the #{branch} branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}" + end + end + +end diff --git a/spec/acceptance/beaker/branch_checkout/branch_checkout_git.rb b/spec/acceptance/beaker/branch_checkout/branch_checkout_git.rb new file mode 100644 index 0000000..a319b7d --- /dev/null +++ b/spec/acceptance/beaker/branch_checkout/branch_checkout_git.rb @@ -0,0 +1,49 @@ +test_name 'C3436 - checkout a branch (git protocol)' + +# Globals +repo_name = 'testrepo_branch_checkout' +branch = 'a_branch' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start git daemon' do + install_package(host, 'git-daemon') + on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'pkill -9 git-daemon') + end + + step 'checkout a branch with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "git://#{host}/testrepo.git", + provider => git, + revision => '#{branch}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the #{branch} branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}" + end + end + +end diff --git a/spec/acceptance/beaker/branch_checkout/branch_checkout_http.rb b/spec/acceptance/beaker/branch_checkout/branch_checkout_http.rb new file mode 100644 index 0000000..ddfaff5 --- /dev/null +++ b/spec/acceptance/beaker/branch_checkout/branch_checkout_http.rb @@ -0,0 +1,56 @@ +test_name 'C3441 - checkout a branch (http protocol)' + +# Globals +repo_name = 'testrepo_branch_checkout' +branch = 'a_branch' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - start http server' do + http_daemon =<<-EOF + require 'webrick' + server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) + on(host, "ruby /tmp/http_daemon.rb") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + end + + step 'checkout a branch with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "http://#{host}:8000/testrepo.git", + provider => git, + revision => '#{branch}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the #{branch} branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}" + end + end + +end diff --git a/spec/acceptance/beaker/branch_checkout/branch_checkout_https.rb b/spec/acceptance/beaker/branch_checkout/branch_checkout_https.rb new file mode 100644 index 0000000..024daaa --- /dev/null +++ b/spec/acceptance/beaker/branch_checkout/branch_checkout_https.rb @@ -0,0 +1,63 @@ +test_name 'C3442 - checkout a branch (https protocol)' + +# Globals +repo_name = 'testrepo_branch_checkout' +branch = 'a_branch' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start https server' do + https_daemon =<<-EOF + require 'webrick' + require 'webrick/https' + server = WEBrick::HTTPServer.new( + :Port => 8443, + :DocumentRoot => "#{tmpdir}", + :SSLEnable => true, + :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, + :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), + :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), + :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) + #on(host, "ruby /tmp/https_daemon.rb") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + end + + step 'checkout a branch with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "https://github.com/johnduarte/testrepo.git", + provider => git, + revision => '#{branch}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the #{branch} branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}" + end + end + +end diff --git a/spec/acceptance/beaker/branch_checkout/branch_checkout_ssh.rb b/spec/acceptance/beaker/branch_checkout/branch_checkout_ssh.rb new file mode 100644 index 0000000..8eabd98 --- /dev/null +++ b/spec/acceptance/beaker/branch_checkout/branch_checkout_ssh.rb @@ -0,0 +1,54 @@ +test_name 'C3440 - checkout a branch (ssh protocol)' + +# Globals +repo_name = 'testrepo_branch_checkout' +branch = 'a_branch' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - establish ssh keys' do + # create ssh keys + on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') + on(host, 'chown -R root:root /root/.ssh') + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + end + + step 'checkout a branch with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "ssh://root@#{host}#{tmpdir}/testrepo.git", + provider => git, + revision => '#{branch}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the #{branch} branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}" + end + end + +end diff --git a/spec/acceptance/beaker/branch_checkout/negative/branch_checkout_not_exists.rb b/spec/acceptance/beaker/branch_checkout/negative/branch_checkout_not_exists.rb new file mode 100644 index 0000000..5168ac7 --- /dev/null +++ b/spec/acceptance/beaker/branch_checkout/negative/branch_checkout_not_exists.rb @@ -0,0 +1,43 @@ +test_name 'C3609 - checkout a branch that does not exist' + +# Globals +repo_name = 'testrepo_branch_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout branch that does not exist with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + revision => 'non_existent_branch', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify that master branch is checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/master" + end + end + +end -- cgit v1.2.3 From 961896256d771596b6e8359baa59e9f8a73b5b83 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Sat, 10 May 2014 10:12:55 -0700 Subject: Add beaker tests for git compression checkouts --- .../beaker/compression/compression_0_checkout.rb | 39 ++++++++++++++++++++++ .../beaker/compression/compression_1_checkout.rb | 39 ++++++++++++++++++++++ .../beaker/compression/compression_2_checkout.rb | 39 ++++++++++++++++++++++ .../beaker/compression/compression_3_checkout.rb | 39 ++++++++++++++++++++++ .../beaker/compression/compression_4_checkout.rb | 39 ++++++++++++++++++++++ .../beaker/compression/compression_5_checkout.rb | 39 ++++++++++++++++++++++ .../beaker/compression/compression_6_checkout.rb | 39 ++++++++++++++++++++++ .../compression/negative/compression_7_checkout.rb | 39 ++++++++++++++++++++++ .../negative/compression_alpha_checkout.rb | 39 ++++++++++++++++++++++ .../negative/compression_eval_checkout.rb | 39 ++++++++++++++++++++++ .../negative/compression_exec_checkout.rb | 39 ++++++++++++++++++++++ .../negative/compression_negative_checkout.rb | 39 ++++++++++++++++++++++ 12 files changed, 468 insertions(+) create mode 100644 spec/acceptance/beaker/compression/compression_0_checkout.rb create mode 100644 spec/acceptance/beaker/compression/compression_1_checkout.rb create mode 100644 spec/acceptance/beaker/compression/compression_2_checkout.rb create mode 100644 spec/acceptance/beaker/compression/compression_3_checkout.rb create mode 100644 spec/acceptance/beaker/compression/compression_4_checkout.rb create mode 100644 spec/acceptance/beaker/compression/compression_5_checkout.rb create mode 100644 spec/acceptance/beaker/compression/compression_6_checkout.rb create mode 100644 spec/acceptance/beaker/compression/negative/compression_7_checkout.rb create mode 100644 spec/acceptance/beaker/compression/negative/compression_alpha_checkout.rb create mode 100644 spec/acceptance/beaker/compression/negative/compression_eval_checkout.rb create mode 100644 spec/acceptance/beaker/compression/negative/compression_exec_checkout.rb create mode 100644 spec/acceptance/beaker/compression/negative/compression_negative_checkout.rb diff --git a/spec/acceptance/beaker/compression/compression_0_checkout.rb b/spec/acceptance/beaker/compression/compression_0_checkout.rb new file mode 100644 index 0000000..fc62d4a --- /dev/null +++ b/spec/acceptance/beaker/compression/compression_0_checkout.rb @@ -0,0 +1,39 @@ +test_name 'C3495 - checkout with compression 0' + +# Globals +repo_name = 'testrepo_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout with compression 0 with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + compression => 0, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify git repo was checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/compression/compression_1_checkout.rb b/spec/acceptance/beaker/compression/compression_1_checkout.rb new file mode 100644 index 0000000..c1ec2f2 --- /dev/null +++ b/spec/acceptance/beaker/compression/compression_1_checkout.rb @@ -0,0 +1,39 @@ +test_name 'C3496 - checkout with compression 1' + +# Globals +repo_name = 'testrepo_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout with compression 1 with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + compression => 1, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify git repo was checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/compression/compression_2_checkout.rb b/spec/acceptance/beaker/compression/compression_2_checkout.rb new file mode 100644 index 0000000..c92a878 --- /dev/null +++ b/spec/acceptance/beaker/compression/compression_2_checkout.rb @@ -0,0 +1,39 @@ +test_name 'C3497 - checkout with compression 2' + +# Globals +repo_name = 'testrepo_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout with compression 2 with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + compression => 2, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify git repo was checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/compression/compression_3_checkout.rb b/spec/acceptance/beaker/compression/compression_3_checkout.rb new file mode 100644 index 0000000..8cba272 --- /dev/null +++ b/spec/acceptance/beaker/compression/compression_3_checkout.rb @@ -0,0 +1,39 @@ +test_name 'C3498 - checkout with compression 3' + +# Globals +repo_name = 'testrepo_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout with compression 3 with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + compression => 3, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify git repo was checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/compression/compression_4_checkout.rb b/spec/acceptance/beaker/compression/compression_4_checkout.rb new file mode 100644 index 0000000..c5c12a6 --- /dev/null +++ b/spec/acceptance/beaker/compression/compression_4_checkout.rb @@ -0,0 +1,39 @@ +test_name 'C3499 - checkout with compression 4' + +# Globals +repo_name = 'testrepo_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout with compression 4 with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + compression => 4, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify git repo was checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/compression/compression_5_checkout.rb b/spec/acceptance/beaker/compression/compression_5_checkout.rb new file mode 100644 index 0000000..474b62f --- /dev/null +++ b/spec/acceptance/beaker/compression/compression_5_checkout.rb @@ -0,0 +1,39 @@ +test_name 'C3500 - checkout with compression 5' + +# Globals +repo_name = 'testrepo_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout with compression 5 with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + compression => 5, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify git repo was checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/compression/compression_6_checkout.rb b/spec/acceptance/beaker/compression/compression_6_checkout.rb new file mode 100644 index 0000000..b3fb71b --- /dev/null +++ b/spec/acceptance/beaker/compression/compression_6_checkout.rb @@ -0,0 +1,39 @@ +test_name 'C3501 - checkout with compression 6' + +# Globals +repo_name = 'testrepo_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout with compression 6 with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + compression => 6, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify git repo was checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/compression/negative/compression_7_checkout.rb b/spec/acceptance/beaker/compression/negative/compression_7_checkout.rb new file mode 100644 index 0000000..b7af79a --- /dev/null +++ b/spec/acceptance/beaker/compression/negative/compression_7_checkout.rb @@ -0,0 +1,39 @@ +test_name 'C3503 - checkout with compression 7' + +# Globals +repo_name = 'testrepo_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout with compression 7 with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + compression => 7, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify git repo was checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/compression/negative/compression_alpha_checkout.rb b/spec/acceptance/beaker/compression/negative/compression_alpha_checkout.rb new file mode 100644 index 0000000..06a0a01 --- /dev/null +++ b/spec/acceptance/beaker/compression/negative/compression_alpha_checkout.rb @@ -0,0 +1,39 @@ +test_name 'C3505 - checkout with compression alpha' + +# Globals +repo_name = 'testrepo_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout with compression alpha with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + compression => abcde, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify git repo was checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/compression/negative/compression_eval_checkout.rb b/spec/acceptance/beaker/compression/negative/compression_eval_checkout.rb new file mode 100644 index 0000000..d66996e --- /dev/null +++ b/spec/acceptance/beaker/compression/negative/compression_eval_checkout.rb @@ -0,0 +1,39 @@ +test_name 'C3504 - checkout with compression 10-5' + +# Globals +repo_name = 'testrepo_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout with compression 10-5 with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + compression => 10-5, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify git repo was checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/compression/negative/compression_exec_checkout.rb b/spec/acceptance/beaker/compression/negative/compression_exec_checkout.rb new file mode 100644 index 0000000..46e730d --- /dev/null +++ b/spec/acceptance/beaker/compression/negative/compression_exec_checkout.rb @@ -0,0 +1,39 @@ +test_name 'C3506 - checkout with compression exec' + +# Globals +repo_name = 'testrepo_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout with compression exec with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + compression => `exec rm -rf /tmp`, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify git repo was checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/compression/negative/compression_negative_checkout.rb b/spec/acceptance/beaker/compression/negative/compression_negative_checkout.rb new file mode 100644 index 0000000..ee98057 --- /dev/null +++ b/spec/acceptance/beaker/compression/negative/compression_negative_checkout.rb @@ -0,0 +1,39 @@ +test_name 'C3502 - checkout with compression -1' + +# Globals +repo_name = 'testrepo_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout with compression -1 with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + compression => -1, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify git repo was checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end -- cgit v1.2.3 From ffa656904cf617cc7de319afca1bd94d0d64a5c0 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Sat, 10 May 2014 10:24:00 -0700 Subject: Add beaker tests for git checkout for group --- .../beaker/group_checkout/group_checkout_file.rb | 49 ++++++++++++++++ .../group_checkout/group_checkout_file_path.rb | 49 ++++++++++++++++ .../beaker/group_checkout/group_checkout_git.rb | 54 +++++++++++++++++ .../beaker/group_checkout/group_checkout_http.rb | 61 +++++++++++++++++++ .../beaker/group_checkout/group_checkout_https.rb | 68 ++++++++++++++++++++++ .../beaker/group_checkout/group_checkout_ssh.rb | 59 +++++++++++++++++++ .../group_checkout_file_non_existent_group.rb | 48 +++++++++++++++ 7 files changed, 388 insertions(+) create mode 100644 spec/acceptance/beaker/group_checkout/group_checkout_file.rb create mode 100644 spec/acceptance/beaker/group_checkout/group_checkout_file_path.rb create mode 100644 spec/acceptance/beaker/group_checkout/group_checkout_git.rb create mode 100644 spec/acceptance/beaker/group_checkout/group_checkout_http.rb create mode 100644 spec/acceptance/beaker/group_checkout/group_checkout_https.rb create mode 100644 spec/acceptance/beaker/group_checkout/group_checkout_ssh.rb create mode 100644 spec/acceptance/beaker/group_checkout/negative/group_checkout_file_non_existent_group.rb diff --git a/spec/acceptance/beaker/group_checkout/group_checkout_file.rb b/spec/acceptance/beaker/group_checkout/group_checkout_file.rb new file mode 100644 index 0000000..469fb07 --- /dev/null +++ b/spec/acceptance/beaker/group_checkout/group_checkout_file.rb @@ -0,0 +1,49 @@ +test_name 'C3487 - checkout as a group (file protocol)' + +# Globals +repo_name = 'testrepo_group_checkout' +group = 'mygroup' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - create group' do + apply_manifest_on(host, "group { '#{group}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "group { '#{group}': ensure => absent, }") + end + + step 'checkout as a group with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + group => '#{group}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is own by group #{group}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}" + end + end + +end diff --git a/spec/acceptance/beaker/group_checkout/group_checkout_file_path.rb b/spec/acceptance/beaker/group_checkout/group_checkout_file_path.rb new file mode 100644 index 0000000..07510e1 --- /dev/null +++ b/spec/acceptance/beaker/group_checkout/group_checkout_file_path.rb @@ -0,0 +1,49 @@ +test_name 'C3486 - checkout as a group (file path)' + +# Globals +repo_name = 'testrepo_group_checkout' +group = 'mygroup' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - create group' do + apply_manifest_on(host, "group { '#{group}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "group { '#{group}': ensure => absent, }") + end + + step 'checkout a group with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "#{tmpdir}/testrepo.git", + provider => git, + group => '#{group}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is own by group #{group}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}" + end + end + +end diff --git a/spec/acceptance/beaker/group_checkout/group_checkout_git.rb b/spec/acceptance/beaker/group_checkout/group_checkout_git.rb new file mode 100644 index 0000000..df7ec09 --- /dev/null +++ b/spec/acceptance/beaker/group_checkout/group_checkout_git.rb @@ -0,0 +1,54 @@ +test_name 'C3485 - checkout as a group (git protocol)' + +# Globals +repo_name = 'testrepo_group_checkout' +group = 'mygroup' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start git daemon' do + install_package(host, 'git-daemon') + on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") + end + + step 'setup - create group' do + apply_manifest_on(host, "group { '#{group}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'pkill -9 git-daemon') + apply_manifest_on(host, "group { '#{group}': ensure => absent, }") + end + + step 'checkout a group with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "git://#{host}/testrepo.git", + provider => git, + group => '#{group}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is own by group #{group}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}" + end + end + +end diff --git a/spec/acceptance/beaker/group_checkout/group_checkout_http.rb b/spec/acceptance/beaker/group_checkout/group_checkout_http.rb new file mode 100644 index 0000000..96e0205 --- /dev/null +++ b/spec/acceptance/beaker/group_checkout/group_checkout_http.rb @@ -0,0 +1,61 @@ +test_name 'C3490 - checkout as a group (http protocol)' + +# Globals +repo_name = 'testrepo_group_checkout' +group = 'mygroup' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - start http server' do + http_daemon =<<-EOF + require 'webrick' + server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) + on(host, "ruby /tmp/http_daemon.rb") + end + + step 'setup - create group' do + apply_manifest_on(host, "group { '#{group}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + apply_manifest_on(host, "group { '#{group}': ensure => absent, }") + end + + step 'checkout a group with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "http://#{host}:8000/testrepo.git", + provider => git, + group => '#{group}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is own by group #{group}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}" + end + end + +end diff --git a/spec/acceptance/beaker/group_checkout/group_checkout_https.rb b/spec/acceptance/beaker/group_checkout/group_checkout_https.rb new file mode 100644 index 0000000..7fe4e96 --- /dev/null +++ b/spec/acceptance/beaker/group_checkout/group_checkout_https.rb @@ -0,0 +1,68 @@ +test_name 'C3491 - checkout as a group (https protocol)' + +# Globals +repo_name = 'testrepo_group_checkout' +group = 'mygroup' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start https server' do + https_daemon =<<-EOF + require 'webrick' + require 'webrick/https' + server = WEBrick::HTTPServer.new( + :Port => 8443, + :DocumentRoot => "#{tmpdir}", + :SSLEnable => true, + :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, + :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), + :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), + :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) + #on(host, "ruby /tmp/https_daemon.rb") + end + + step 'setup - create group' do + apply_manifest_on(host, "group { '#{group}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + apply_manifest_on(host, "group { '#{group}': ensure => absent, }") + end + + step 'checkout as a group with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "https://github.com/johnduarte/testrepo.git", + provider => git, + group => '#{group}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is own by group #{group}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}" + end + end + +end diff --git a/spec/acceptance/beaker/group_checkout/group_checkout_ssh.rb b/spec/acceptance/beaker/group_checkout/group_checkout_ssh.rb new file mode 100644 index 0000000..2ede1ef --- /dev/null +++ b/spec/acceptance/beaker/group_checkout/group_checkout_ssh.rb @@ -0,0 +1,59 @@ +test_name 'C3489 - checkout as a group (ssh protocol)' + +# Globals +repo_name = 'testrepo_group_checkout' +group = 'mygroup' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - establish ssh keys' do + # create ssh keys + on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') + on(host, 'chown -R root:root /root/.ssh') + end + + step 'setup - create group' do + apply_manifest_on(host, "group { '#{group}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + apply_manifest_on(host, "group { '#{group}': ensure => absent, }") + end + + step 'checkout as a group with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "ssh://root@#{host}#{tmpdir}/testrepo.git", + provider => git, + group => '#{group}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is own by group #{group}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}" + end + end + +end diff --git a/spec/acceptance/beaker/group_checkout/negative/group_checkout_file_non_existent_group.rb b/spec/acceptance/beaker/group_checkout/negative/group_checkout_file_non_existent_group.rb new file mode 100644 index 0000000..85757aa --- /dev/null +++ b/spec/acceptance/beaker/group_checkout/negative/group_checkout_file_non_existent_group.rb @@ -0,0 +1,48 @@ +test_name 'C3484 - checkout as a group that is not on system' + +# Globals +repo_name = 'testrepo_group_checkout' +group = 'mygroup' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - delete group' do + apply_manifest_on(host, "group { '#{group}': ensure => absent, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout as a group with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + group => '#{group}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is NOT owned by group #{group}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by group') if res.stdout.include? ":#{group}" + end + end + +end -- cgit v1.2.3 From 275f975d7b12612820b38dff41722c89cb4ed3ae Mon Sep 17 00:00:00 2001 From: John Duarte Date: Sat, 10 May 2014 16:55:09 -0700 Subject: Add beaker tests for git checkout for specified revision --- .../negative/revision_checkout_not_exists.rb | 43 ++++++++++++++ .../revision_checkout/revision_checkout_file.rb | 49 +++++++++++++++ .../revision_checkout_file_path.rb | 49 +++++++++++++++ .../revision_checkout/revision_checkout_git.rb | 54 +++++++++++++++++ .../revision_checkout/revision_checkout_http.rb | 61 +++++++++++++++++++ .../revision_checkout/revision_checkout_https.rb | 69 ++++++++++++++++++++++ .../revision_checkout/revision_checkout_ssh.rb | 59 ++++++++++++++++++ 7 files changed, 384 insertions(+) create mode 100644 spec/acceptance/beaker/revision_checkout/negative/revision_checkout_not_exists.rb create mode 100644 spec/acceptance/beaker/revision_checkout/revision_checkout_file.rb create mode 100644 spec/acceptance/beaker/revision_checkout/revision_checkout_file_path.rb create mode 100644 spec/acceptance/beaker/revision_checkout/revision_checkout_git.rb create mode 100644 spec/acceptance/beaker/revision_checkout/revision_checkout_http.rb create mode 100644 spec/acceptance/beaker/revision_checkout/revision_checkout_https.rb create mode 100644 spec/acceptance/beaker/revision_checkout/revision_checkout_ssh.rb diff --git a/spec/acceptance/beaker/revision_checkout/negative/revision_checkout_not_exists.rb b/spec/acceptance/beaker/revision_checkout/negative/revision_checkout_not_exists.rb new file mode 100644 index 0000000..e4af1b2 --- /dev/null +++ b/spec/acceptance/beaker/revision_checkout/negative/revision_checkout_not_exists.rb @@ -0,0 +1,43 @@ +test_name 'C3614 - checkout a revision that does not exist' + +# Globals +repo_name = 'testrepo_revision_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout revision that does not exist with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + revision => '11111111111111111', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify that master revision is checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('revision not found') unless res.stdout.include? "ref: refs/heads/master" + end + end + +end diff --git a/spec/acceptance/beaker/revision_checkout/revision_checkout_file.rb b/spec/acceptance/beaker/revision_checkout/revision_checkout_file.rb new file mode 100644 index 0000000..70af031 --- /dev/null +++ b/spec/acceptance/beaker/revision_checkout/revision_checkout_file.rb @@ -0,0 +1,49 @@ +test_name 'C3452 - checkout a revision (file protocol)' + +# Globals +repo_name = 'testrepo_revision_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'get revision sha from repo' do + on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| + @sha = res.stdout.chomp + end + end + + step 'checkout a revision with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + revision => '#{@sha}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + stop "verify repo is checked out to revision #{sha}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('revision not found') unless res.stdout.include? "#{@sha}" + end + end + +end diff --git a/spec/acceptance/beaker/revision_checkout/revision_checkout_file_path.rb b/spec/acceptance/beaker/revision_checkout/revision_checkout_file_path.rb new file mode 100644 index 0000000..b5fd70a --- /dev/null +++ b/spec/acceptance/beaker/revision_checkout/revision_checkout_file_path.rb @@ -0,0 +1,49 @@ +test_name 'C3451 - checkout a revision (file path)' + +# Globals +repo_name = 'testrepo_revision_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'get revision sha from repo' do + on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| + @sha = res.stdout.chomp + end + end + + step 'checkout a revision with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "#{tmpdir}/testrepo.git", + provider => git, + revision => '#{@sha}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + stop "verify repo is checked out to revision #{sha}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('revision not found') unless res.stdout.include? "#{@sha}" + end + end + +end diff --git a/spec/acceptance/beaker/revision_checkout/revision_checkout_git.rb b/spec/acceptance/beaker/revision_checkout/revision_checkout_git.rb new file mode 100644 index 0000000..b34dfdc --- /dev/null +++ b/spec/acceptance/beaker/revision_checkout/revision_checkout_git.rb @@ -0,0 +1,54 @@ +test_name 'C3450 - checkout a revision (git protocol)' + +# Globals +repo_name = 'testrepo_revision_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start git daemon' do + install_package(host, 'git-daemon') + on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'pkill -9 git-daemon') + end + + step 'get revision sha from repo' do + on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| + @sha = res.stdout.chomp + end + end + + step 'checkout a revision with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "git://#{host}/testrepo.git", + provider => git, + revision => '#{@sha}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is set to revision #{@sha}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('revision not found') unless res.stdout.include? "#{@sha}" + end + end + +end diff --git a/spec/acceptance/beaker/revision_checkout/revision_checkout_http.rb b/spec/acceptance/beaker/revision_checkout/revision_checkout_http.rb new file mode 100644 index 0000000..debbb01 --- /dev/null +++ b/spec/acceptance/beaker/revision_checkout/revision_checkout_http.rb @@ -0,0 +1,61 @@ +test_name 'C3455 - checkout a revision (http protocol)' + +# Globals +repo_name = 'testrepo_revision_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - start http server' do + http_daemon =<<-EOF + require 'webrick' + server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) + on(host, "ruby /tmp/http_daemon.rb") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + end + + step 'get revision sha from repo' do + on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| + @sha = res.stdout.chomp + end + end + + step 'checkout a revision with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "http://#{host}:8000/testrepo.git", + provider => git, + revision => '#{@sha}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is set to revision #{@sha}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('revision not found') unless res.stdout.include? "#{@sha}" + end + end + +end diff --git a/spec/acceptance/beaker/revision_checkout/revision_checkout_https.rb b/spec/acceptance/beaker/revision_checkout/revision_checkout_https.rb new file mode 100644 index 0000000..c062316 --- /dev/null +++ b/spec/acceptance/beaker/revision_checkout/revision_checkout_https.rb @@ -0,0 +1,69 @@ +test_name 'C3456 - checkout a revision (https protocol)' + +# Globals +repo_name = 'testrepo_revision_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start https server' do + https_daemon =<<-EOF + require 'webrick' + require 'webrick/https' + server = WEBrick::HTTPServer.new( + :Port => 8443, + :DocumentRoot => "#{tmpdir}", + :SSLEnable => true, + :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, + :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), + :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), + :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) + #on(host, "ruby /tmp/https_daemon.rb") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + end + + step 'get revision sha from repo' do + on(host, "git clone https://github.com/johnduarte/testrepo.git #{tmpdir}/foo") + on(host, "git --git-dir=#{tmpdir}/foo/.git rev-list HEAD | tail -1") do |res| + @sha = res.stdout.chomp + end + end + + step 'checkout a revision with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "https://github.com/johnduarte/testrepo.git", + provider => git, + revision => '#{@sha}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is set to revision #{@sha}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('revision not found') unless res.stdout.include? "#{@sha}" + end + end + +end diff --git a/spec/acceptance/beaker/revision_checkout/revision_checkout_ssh.rb b/spec/acceptance/beaker/revision_checkout/revision_checkout_ssh.rb new file mode 100644 index 0000000..7a0991c --- /dev/null +++ b/spec/acceptance/beaker/revision_checkout/revision_checkout_ssh.rb @@ -0,0 +1,59 @@ +test_name 'C3454 - checkout a revision (ssh protocol)' + +# Globals +repo_name = 'testrepo_revision_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - establish ssh keys' do + # create ssh keys + on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') + on(host, 'chown -R root:root /root/.ssh') + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + end + + step 'get revision sha from repo' do + on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| + @sha = res.stdout.chomp + end + end + + step 'checkout a revision with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "ssh://root@#{host}#{tmpdir}/testrepo.git", + provider => git, + revision => '#{@sha}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is set to revision #{@sha}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('revision not found') unless res.stdout.include? "#{@sha}" + end + end + +end -- cgit v1.2.3 From 4a3392310e0e85c216e28cded17df4833a771a3b Mon Sep 17 00:00:00 2001 From: John Duarte Date: Sat, 10 May 2014 17:19:58 -0700 Subject: Add beaker tests for git shallow clone --- .../negative/shallow_clone_hostile_depth.rb | 39 ++++++++++++++ .../negative/shallow_clone_negative_depth.rb | 39 ++++++++++++++ .../negative/shallow_clone_overflow_depth.rb | 39 ++++++++++++++ .../beaker/shallow_clone/shallow_clone_file.rb | 43 +++++++++++++++ .../shallow_clone/shallow_clone_file_path.rb | 43 +++++++++++++++ .../beaker/shallow_clone/shallow_clone_git.rb | 48 +++++++++++++++++ .../beaker/shallow_clone/shallow_clone_http.rb | 55 +++++++++++++++++++ .../beaker/shallow_clone/shallow_clone_https.rb | 62 ++++++++++++++++++++++ .../beaker/shallow_clone/shallow_clone_ssh.rb | 53 ++++++++++++++++++ .../shallow_clone/shallow_clone_zero_depth.rb | 39 ++++++++++++++ 10 files changed, 460 insertions(+) create mode 100644 spec/acceptance/beaker/shallow_clone/negative/shallow_clone_hostile_depth.rb create mode 100644 spec/acceptance/beaker/shallow_clone/negative/shallow_clone_negative_depth.rb create mode 100644 spec/acceptance/beaker/shallow_clone/negative/shallow_clone_overflow_depth.rb create mode 100644 spec/acceptance/beaker/shallow_clone/shallow_clone_file.rb create mode 100644 spec/acceptance/beaker/shallow_clone/shallow_clone_file_path.rb create mode 100644 spec/acceptance/beaker/shallow_clone/shallow_clone_git.rb create mode 100644 spec/acceptance/beaker/shallow_clone/shallow_clone_http.rb create mode 100644 spec/acceptance/beaker/shallow_clone/shallow_clone_https.rb create mode 100644 spec/acceptance/beaker/shallow_clone/shallow_clone_ssh.rb create mode 100644 spec/acceptance/beaker/shallow_clone/shallow_clone_zero_depth.rb diff --git a/spec/acceptance/beaker/shallow_clone/negative/shallow_clone_hostile_depth.rb b/spec/acceptance/beaker/shallow_clone/negative/shallow_clone_hostile_depth.rb new file mode 100644 index 0000000..9c63716 --- /dev/null +++ b/spec/acceptance/beaker/shallow_clone/negative/shallow_clone_hostile_depth.rb @@ -0,0 +1,39 @@ +test_name 'C3608 - shallow clone repo depth hostile input' + +# Globals +repo_name = 'testrepo_shallow_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'shallow clone repo with puppet (bad input ignored, full clone checkedout)' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + depth => 'rm -rf /tmp', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify checkout is NOT shallow' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('shallow not found') if res.stdout.include? "shallow" + end + end + +end diff --git a/spec/acceptance/beaker/shallow_clone/negative/shallow_clone_negative_depth.rb b/spec/acceptance/beaker/shallow_clone/negative/shallow_clone_negative_depth.rb new file mode 100644 index 0000000..10b0559 --- /dev/null +++ b/spec/acceptance/beaker/shallow_clone/negative/shallow_clone_negative_depth.rb @@ -0,0 +1,39 @@ +test_name 'C3607 - shallow clone repo depth = -1' + +# Globals +repo_name = 'testrepo_shallow_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'shallow clone repo with puppet (bad input ignored, full clone checkedout)' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + depth => -1, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify checkout is NOT shallow' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('shallow not found') if res.stdout.include? "shallow" + end + end + +end diff --git a/spec/acceptance/beaker/shallow_clone/negative/shallow_clone_overflow_depth.rb b/spec/acceptance/beaker/shallow_clone/negative/shallow_clone_overflow_depth.rb new file mode 100644 index 0000000..6b34f5d --- /dev/null +++ b/spec/acceptance/beaker/shallow_clone/negative/shallow_clone_overflow_depth.rb @@ -0,0 +1,39 @@ +test_name 'C3606 - shallow clone repo depth overflow 64bit integer' + +# Globals +repo_name = 'testrepo_shallow_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'shallow clone repo with puppet (bad input ignored, full clone checkedout)' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + depth => 18446744073709551616, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify checkout is NOT shallow' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('shallow not found') if res.stdout.include? "shallow" + end + end + +end diff --git a/spec/acceptance/beaker/shallow_clone/shallow_clone_file.rb b/spec/acceptance/beaker/shallow_clone/shallow_clone_file.rb new file mode 100644 index 0000000..7e6f3a1 --- /dev/null +++ b/spec/acceptance/beaker/shallow_clone/shallow_clone_file.rb @@ -0,0 +1,43 @@ +test_name 'C3476 - shallow clone repo minimal depth = 1 (file protocol)' + +# Globals +repo_name = 'testrepo_shallow_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'shallow clone repo with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + depth => 1, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify checkout is shallow and of the correct depth' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('shallow not found') unless res.stdout.include? "shallow" + end + + on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| + fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" + end + end + +end diff --git a/spec/acceptance/beaker/shallow_clone/shallow_clone_file_path.rb b/spec/acceptance/beaker/shallow_clone/shallow_clone_file_path.rb new file mode 100644 index 0000000..fa3e278 --- /dev/null +++ b/spec/acceptance/beaker/shallow_clone/shallow_clone_file_path.rb @@ -0,0 +1,43 @@ +test_name 'C3475 - shallow clone repo minimal depth = 1 (file path protocol)' + +# Globals +repo_name = 'testrepo_shallow_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'shallow clone repo with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "#{tmpdir}/testrepo.git", + provider => git, + depth => 1, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify checkout is shallow and of the correct depth' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('shallow not found') unless res.stdout.include? "shallow" + end + + on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| + fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" + end + end + +end diff --git a/spec/acceptance/beaker/shallow_clone/shallow_clone_git.rb b/spec/acceptance/beaker/shallow_clone/shallow_clone_git.rb new file mode 100644 index 0000000..a95716f --- /dev/null +++ b/spec/acceptance/beaker/shallow_clone/shallow_clone_git.rb @@ -0,0 +1,48 @@ +test_name 'C3474 - shallow clone repo minimal depth = 1 (git protocol)' + +# Globals +repo_name = 'testrepo_shallow_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start git daemon' do + install_package(host, 'git-daemon') + on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'pkill -9 git-daemon') + end + + step 'shallow clone repo with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "git://#{host}/testrepo.git", + provider => git, + depth => 1, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify checkout is shallow and of the correct depth' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('shallow not found') unless res.stdout.include? "shallow" + end + + on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| + fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" + end + end + +end diff --git a/spec/acceptance/beaker/shallow_clone/shallow_clone_http.rb b/spec/acceptance/beaker/shallow_clone/shallow_clone_http.rb new file mode 100644 index 0000000..b43e232 --- /dev/null +++ b/spec/acceptance/beaker/shallow_clone/shallow_clone_http.rb @@ -0,0 +1,55 @@ +test_name 'C3479 - shallow clone repo minimal depth = 1 (http protocol)' + +# Globals +repo_name = 'testrepo_shallow_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - start http server' do + http_daemon =<<-EOF + require 'webrick' + server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) + on(host, "ruby /tmp/http_daemon.rb") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + end + + step 'shallow clone repo with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "http://#{host}:8000/testrepo.git", + provider => git, + depth => 1, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify checkout is shallow and of the correct depth' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('shallow not found') unless res.stdout.include? "shallow" + end + + on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| + fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" + end + end + +end diff --git a/spec/acceptance/beaker/shallow_clone/shallow_clone_https.rb b/spec/acceptance/beaker/shallow_clone/shallow_clone_https.rb new file mode 100644 index 0000000..723c979 --- /dev/null +++ b/spec/acceptance/beaker/shallow_clone/shallow_clone_https.rb @@ -0,0 +1,62 @@ +test_name 'C3480 - shallow clone repo minimal depth = 1 (https protocol)' + +# Globals +repo_name = 'testrepo_shallow_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start https server' do + https_daemon =<<-EOF + require 'webrick' + require 'webrick/https' + server = WEBrick::HTTPServer.new( + :Port => 8443, + :DocumentRoot => "#{tmpdir}", + :SSLEnable => true, + :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, + :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), + :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), + :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) + #on(host, "ruby /tmp/https_daemon.rb") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + end + + step 'shallow clone repo with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "https://github.com/johnduarte/testrepo.git", + provider => git, + depth => 1, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify checkout is shallow and of the correct depth' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('shallow not found') unless res.stdout.include? "shallow" + end + + on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| + fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" + end + end + +end diff --git a/spec/acceptance/beaker/shallow_clone/shallow_clone_ssh.rb b/spec/acceptance/beaker/shallow_clone/shallow_clone_ssh.rb new file mode 100644 index 0000000..96f1973 --- /dev/null +++ b/spec/acceptance/beaker/shallow_clone/shallow_clone_ssh.rb @@ -0,0 +1,53 @@ +test_name 'C3477 - shallow clone repo minimal depth = 1 (ssh protocol)' + +# Globals +repo_name = 'testrepo_shallow_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - establish ssh keys' do + # create ssh keys + on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') + on(host, 'chown -R root:root /root/.ssh') + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + end + + step 'shallow clone repo with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "ssh://root@#{host}#{tmpdir}/testrepo.git", + provider => git, + depth => 1, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify checkout is shallow and of the correct depth' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('shallow not found') unless res.stdout.include? "shallow" + end + + on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| + fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" + end + end + +end diff --git a/spec/acceptance/beaker/shallow_clone/shallow_clone_zero_depth.rb b/spec/acceptance/beaker/shallow_clone/shallow_clone_zero_depth.rb new file mode 100644 index 0000000..264bcfc --- /dev/null +++ b/spec/acceptance/beaker/shallow_clone/shallow_clone_zero_depth.rb @@ -0,0 +1,39 @@ +test_name 'C3404 - shallow clone repo depth = 0 non shallow' + +# Globals +repo_name = 'testrepo_shallow_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'shallow clone repo with puppet (zero depth means not shallow)' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + depth => 0, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify checkout is NOT shallow' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('shallow found') if res.stdout.include? "shallow" + end + end + +end -- cgit v1.2.3 From 51e4f4f5a5288740561b2c3d1decd592430c7358 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Sat, 10 May 2014 17:32:57 -0700 Subject: Add beaker tests for git checkout for specified tag --- .../negative/tag_checkout_not_exists.rb | 43 ++++++++++++++ .../beaker/tag_checkout/tag_checkout_file.rb | 44 ++++++++++++++ .../beaker/tag_checkout/tag_checkout_file_path.rb | 44 ++++++++++++++ .../beaker/tag_checkout/tag_checkout_git.rb | 55 +++++++++++++++++ .../beaker/tag_checkout/tag_checkout_http.rb | 62 +++++++++++++++++++ .../beaker/tag_checkout/tag_checkout_https.rb | 69 ++++++++++++++++++++++ .../beaker/tag_checkout/tag_checkout_ssh.rb | 60 +++++++++++++++++++ 7 files changed, 377 insertions(+) create mode 100644 spec/acceptance/beaker/tag_checkout/negative/tag_checkout_not_exists.rb create mode 100644 spec/acceptance/beaker/tag_checkout/tag_checkout_file.rb create mode 100644 spec/acceptance/beaker/tag_checkout/tag_checkout_file_path.rb create mode 100644 spec/acceptance/beaker/tag_checkout/tag_checkout_git.rb create mode 100644 spec/acceptance/beaker/tag_checkout/tag_checkout_http.rb create mode 100644 spec/acceptance/beaker/tag_checkout/tag_checkout_https.rb create mode 100644 spec/acceptance/beaker/tag_checkout/tag_checkout_ssh.rb diff --git a/spec/acceptance/beaker/tag_checkout/negative/tag_checkout_not_exists.rb b/spec/acceptance/beaker/tag_checkout/negative/tag_checkout_not_exists.rb new file mode 100644 index 0000000..28dd107 --- /dev/null +++ b/spec/acceptance/beaker/tag_checkout/negative/tag_checkout_not_exists.rb @@ -0,0 +1,43 @@ +test_name 'C3612 - checkout a tag that does not exist' + +# Globals +repo_name = 'testrepo_tag_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout tag that does not exist with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + tag => '11111111111111111', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify that master tag is checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('tag not found') unless res.stdout.include? "ref: refs/heads/master" + end + end + +end diff --git a/spec/acceptance/beaker/tag_checkout/tag_checkout_file.rb b/spec/acceptance/beaker/tag_checkout/tag_checkout_file.rb new file mode 100644 index 0000000..6d39a62 --- /dev/null +++ b/spec/acceptance/beaker/tag_checkout/tag_checkout_file.rb @@ -0,0 +1,44 @@ +test_name 'C3445 - checkout a tag (file protocol)' + +# Globals +repo_name = 'testrepo_tag_checkout' +tag = '0.0.2' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout a tag with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + revision => '#{tag}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout out tag is #{tag}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res| + fail_test('tag not found') unless res.stdout.include? "#{tag}" + end + end + +end diff --git a/spec/acceptance/beaker/tag_checkout/tag_checkout_file_path.rb b/spec/acceptance/beaker/tag_checkout/tag_checkout_file_path.rb new file mode 100644 index 0000000..ec0ac9a --- /dev/null +++ b/spec/acceptance/beaker/tag_checkout/tag_checkout_file_path.rb @@ -0,0 +1,44 @@ +test_name 'C3444 - checkout a tag (file path)' + +# Globals +repo_name = 'testrepo_tag_checkout' +tag = '0.0.2' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout a tag with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "#{tmpdir}/testrepo.git", + provider => git, + revision => '#{tag}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout out tag is #{tag}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res| + fail_test('tag not found') unless res.stdout.include? "#{tag}" + end + end + +end diff --git a/spec/acceptance/beaker/tag_checkout/tag_checkout_git.rb b/spec/acceptance/beaker/tag_checkout/tag_checkout_git.rb new file mode 100644 index 0000000..dc83ad1 --- /dev/null +++ b/spec/acceptance/beaker/tag_checkout/tag_checkout_git.rb @@ -0,0 +1,55 @@ +test_name 'C3443 - checkout a tag (git protocol)' + +# Globals +repo_name = 'testrepo_tag_checkout' +tag = '0.0.2' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start git daemon' do + install_package(host, 'git-daemon') + on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'pkill -9 git-daemon') + end + + step 'get tag sha from repo' do + on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| + @sha = res.stdout.chomp + end + end + + step 'checkout a tag with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "git://#{host}/testrepo.git", + provider => git, + revision => '#{tag}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout out tag is #{tag}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res| + fail_test('tag not found') unless res.stdout.include? "#{tag}" + end + end + +end diff --git a/spec/acceptance/beaker/tag_checkout/tag_checkout_http.rb b/spec/acceptance/beaker/tag_checkout/tag_checkout_http.rb new file mode 100644 index 0000000..5db0035 --- /dev/null +++ b/spec/acceptance/beaker/tag_checkout/tag_checkout_http.rb @@ -0,0 +1,62 @@ +test_name 'C3448 - checkout a tag (http protocol)' + +# Globals +repo_name = 'testrepo_tag_checkout' +tag = '0.0.2' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - start http server' do + http_daemon =<<-EOF + require 'webrick' + server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) + on(host, "ruby /tmp/http_daemon.rb") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + end + + step 'get tag sha from repo' do + on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| + @sha = res.stdout.chomp + end + end + + step 'checkout a tag with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "http://#{host}:8000/testrepo.git", + provider => git, + revision => '#{tag}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout out tag is #{tag}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res| + fail_test('tag not found') unless res.stdout.include? "#{tag}" + end + end + +end diff --git a/spec/acceptance/beaker/tag_checkout/tag_checkout_https.rb b/spec/acceptance/beaker/tag_checkout/tag_checkout_https.rb new file mode 100644 index 0000000..b4d1a2f --- /dev/null +++ b/spec/acceptance/beaker/tag_checkout/tag_checkout_https.rb @@ -0,0 +1,69 @@ +test_name 'C3449 - checkout a tag (https protocol)' + +# Globals +repo_name = 'testrepo_tag_checkout' +tag = '0.0.2' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start https server' do + https_daemon =<<-EOF + require 'webrick' + require 'webrick/https' + server = WEBrick::HTTPServer.new( + :Port => 8443, + :DocumentRoot => "#{tmpdir}", + :SSLEnable => true, + :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, + :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), + :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), + :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) + #on(host, "ruby /tmp/https_daemon.rb") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + end + + step 'get tag sha from repo' do + on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| + @sha = res.stdout.chomp + end + end + + step 'checkout a tag with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "https://github.com/johnduarte/testrepo.git", + provider => git, + revision => '#{tag}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout out tag is #{tag}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res| + fail_test('tag not found') unless res.stdout.include? "#{tag}" + end + end + +end diff --git a/spec/acceptance/beaker/tag_checkout/tag_checkout_ssh.rb b/spec/acceptance/beaker/tag_checkout/tag_checkout_ssh.rb new file mode 100644 index 0000000..a92c7d4 --- /dev/null +++ b/spec/acceptance/beaker/tag_checkout/tag_checkout_ssh.rb @@ -0,0 +1,60 @@ +test_name 'C3447 - checkout a tag (ssh protocol)' + +# Globals +repo_name = 'testrepo_tag_checkout' +tag = '0.0.2' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - establish ssh keys' do + # create ssh keys + on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') + on(host, 'chown -R root:root /root/.ssh') + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + end + + step 'get tag sha from repo' do + on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| + @sha = res.stdout.chomp + end + end + + step 'checkout a tag with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "ssh://root@#{host}#{tmpdir}/testrepo.git", + provider => git, + revision => '#{tag}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout out tag is #{tag}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res| + fail_test('tag not found') unless res.stdout.include? "#{tag}" + end + end + +end -- cgit v1.2.3 From 23a4cf03cc9c666323371c3aaacf73e5a058cead Mon Sep 17 00:00:00 2001 From: John Duarte Date: Sat, 10 May 2014 17:48:54 -0700 Subject: Add beaker tests for git checkout for user --- .../user_checkout_file_non_existent_user.rb | 48 +++++++++++++++ .../beaker/user_checkout/user_checkout_file.rb | 49 ++++++++++++++++ .../user_checkout/user_checkout_file_path.rb | 49 ++++++++++++++++ .../beaker/user_checkout/user_checkout_git.rb | 54 +++++++++++++++++ .../beaker/user_checkout/user_checkout_http.rb | 61 +++++++++++++++++++ .../beaker/user_checkout/user_checkout_https.rb | 68 ++++++++++++++++++++++ .../beaker/user_checkout/user_checkout_ssh.rb | 59 +++++++++++++++++++ 7 files changed, 388 insertions(+) create mode 100644 spec/acceptance/beaker/user_checkout/negative/user_checkout_file_non_existent_user.rb create mode 100644 spec/acceptance/beaker/user_checkout/user_checkout_file.rb create mode 100644 spec/acceptance/beaker/user_checkout/user_checkout_file_path.rb create mode 100644 spec/acceptance/beaker/user_checkout/user_checkout_git.rb create mode 100644 spec/acceptance/beaker/user_checkout/user_checkout_http.rb create mode 100644 spec/acceptance/beaker/user_checkout/user_checkout_https.rb create mode 100644 spec/acceptance/beaker/user_checkout/user_checkout_ssh.rb diff --git a/spec/acceptance/beaker/user_checkout/negative/user_checkout_file_non_existent_user.rb b/spec/acceptance/beaker/user_checkout/negative/user_checkout_file_non_existent_user.rb new file mode 100644 index 0000000..f4c301d --- /dev/null +++ b/spec/acceptance/beaker/user_checkout/negative/user_checkout_file_non_existent_user.rb @@ -0,0 +1,48 @@ +test_name 'C3483 - checkout as a user that is not on system' + +# Globals +repo_name = 'testrepo_user_checkout' +user = 'myuser' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - delete user' do + apply_manifest_on(host, "user { '#{user}': ensure => absent, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout as a user with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + owner => '#{user}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is NOT owned by user #{user}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by user') if res.stdout.include? "#{user}:" + end + end + +end diff --git a/spec/acceptance/beaker/user_checkout/user_checkout_file.rb b/spec/acceptance/beaker/user_checkout/user_checkout_file.rb new file mode 100644 index 0000000..e2b9582 --- /dev/null +++ b/spec/acceptance/beaker/user_checkout/user_checkout_file.rb @@ -0,0 +1,49 @@ +test_name 'C3459 - checkout as a user (file protocol)' + +# Globals +repo_name = 'testrepo_user_checkout' +user = 'myuser' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - create user' do + apply_manifest_on(host, "user { '#{user}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "user { '#{user}': ensure => absent, }") + end + + step 'checkout as a user with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + owner => '#{user}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is owned by user #{user}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:" + end + end + +end diff --git a/spec/acceptance/beaker/user_checkout/user_checkout_file_path.rb b/spec/acceptance/beaker/user_checkout/user_checkout_file_path.rb new file mode 100644 index 0000000..50592a2 --- /dev/null +++ b/spec/acceptance/beaker/user_checkout/user_checkout_file_path.rb @@ -0,0 +1,49 @@ +test_name 'C3458 - checkout as a user (file path)' + +# Globals +repo_name = 'testrepo_user_checkout' +user = 'myuser' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - create user' do + apply_manifest_on(host, "user { '#{user}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "user { '#{user}': ensure => absent, }") + end + + step 'checkout a user with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "#{tmpdir}/testrepo.git", + provider => git, + owner => '#{user}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is owned by user #{user}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:" + end + end + +end diff --git a/spec/acceptance/beaker/user_checkout/user_checkout_git.rb b/spec/acceptance/beaker/user_checkout/user_checkout_git.rb new file mode 100644 index 0000000..a7ddfd0 --- /dev/null +++ b/spec/acceptance/beaker/user_checkout/user_checkout_git.rb @@ -0,0 +1,54 @@ +test_name 'C3457 - checkout as a user (git protocol)' + +# Globals +repo_name = 'testrepo_user_checkout' +user = 'myuser' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start git daemon' do + install_package(host, 'git-daemon') + on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") + end + + step 'setup - create user' do + apply_manifest_on(host, "user { '#{user}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'pkill -9 git-daemon') + apply_manifest_on(host, "user { '#{user}': ensure => absent, }") + end + + step 'checkout a user with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "git://#{host}/testrepo.git", + provider => git, + owner => '#{user}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is owned by user #{user}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:" + end + end + +end diff --git a/spec/acceptance/beaker/user_checkout/user_checkout_http.rb b/spec/acceptance/beaker/user_checkout/user_checkout_http.rb new file mode 100644 index 0000000..3ffb377 --- /dev/null +++ b/spec/acceptance/beaker/user_checkout/user_checkout_http.rb @@ -0,0 +1,61 @@ +test_name 'C3462 - checkout as a user (http protocol)' + +# Globals +repo_name = 'testrepo_user_checkout' +user = 'myuser' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - start http server' do + http_daemon =<<-EOF + require 'webrick' + server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) + on(host, "ruby /tmp/http_daemon.rb") + end + + step 'setup - create user' do + apply_manifest_on(host, "user { '#{user}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + apply_manifest_on(host, "user { '#{user}': ensure => absent, }") + end + + step 'checkout a user with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "http://#{host}:8000/testrepo.git", + provider => git, + owner => '#{user}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is owned by user #{user}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:" + end + end + +end diff --git a/spec/acceptance/beaker/user_checkout/user_checkout_https.rb b/spec/acceptance/beaker/user_checkout/user_checkout_https.rb new file mode 100644 index 0000000..e76a93d --- /dev/null +++ b/spec/acceptance/beaker/user_checkout/user_checkout_https.rb @@ -0,0 +1,68 @@ +test_name 'C3463 - checkout as a user (https protocol)' + +# Globals +repo_name = 'testrepo_user_checkout' +user = 'myuser' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start https server' do + https_daemon =<<-EOF + require 'webrick' + require 'webrick/https' + server = WEBrick::HTTPServer.new( + :Port => 8443, + :DocumentRoot => "#{tmpdir}", + :SSLEnable => true, + :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, + :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), + :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), + :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) + #on(host, "ruby /tmp/https_daemon.rb") + end + + step 'setup - create user' do + apply_manifest_on(host, "user { '#{user}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + apply_manifest_on(host, "user { '#{user}': ensure => absent, }") + end + + step 'checkout as a user with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "https://github.com/johnduarte/testrepo.git", + provider => git, + owner => '#{user}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is owned by user #{user}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:" + end + end + +end diff --git a/spec/acceptance/beaker/user_checkout/user_checkout_ssh.rb b/spec/acceptance/beaker/user_checkout/user_checkout_ssh.rb new file mode 100644 index 0000000..8de2bc3 --- /dev/null +++ b/spec/acceptance/beaker/user_checkout/user_checkout_ssh.rb @@ -0,0 +1,59 @@ +test_name 'C3461 - checkout as a user (ssh protocol)' + +# Globals +repo_name = 'testrepo_user_checkout' +user = 'myuser' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - establish ssh keys' do + # create ssh keys + on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') + on(host, 'chown -R root:root /root/.ssh') + end + + step 'setup - create user' do + apply_manifest_on(host, "user { '#{user}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + apply_manifest_on(host, "user { '#{user}': ensure => absent, }") + end + + step 'checkout as a user with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "ssh://root@#{host}#{tmpdir}/testrepo.git", + provider => git, + owner => '#{user}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is owned by user #{user}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:" + end + end + +end -- cgit v1.2.3 From 591725e0f2a0dd0dd31b0086dbd4068bd302b0e1 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Sat, 10 May 2014 21:13:03 -0700 Subject: Move git tests into sub-directory --- .../beaker/branch_checkout/branch_checkout_file.rb | 44 -------------- .../branch_checkout/branch_checkout_file_path.rb | 44 -------------- .../beaker/branch_checkout/branch_checkout_git.rb | 49 --------------- .../beaker/branch_checkout/branch_checkout_http.rb | 56 ------------------ .../branch_checkout/branch_checkout_https.rb | 63 -------------------- .../beaker/branch_checkout/branch_checkout_ssh.rb | 54 ----------------- .../negative/branch_checkout_not_exists.rb | 43 -------------- ...clone_over_different_exiting_repo_with_force.rb | 44 -------------- .../clone/clone_repo_with_excludes_in_repo.rb | 42 ------------- .../clone/clone_repo_with_excludes_not_in_repo.rb | 42 ------------- .../negative/clone_over_different_exiting_repo.rb | 43 -------------- .../negative/clone_repo_with_hostile_excludes.rb | 40 ------------- .../beaker/compression/compression_0_checkout.rb | 39 ------------ .../beaker/compression/compression_1_checkout.rb | 39 ------------ .../beaker/compression/compression_2_checkout.rb | 39 ------------ .../beaker/compression/compression_3_checkout.rb | 39 ------------ .../beaker/compression/compression_4_checkout.rb | 39 ------------ .../beaker/compression/compression_5_checkout.rb | 39 ------------ .../beaker/compression/compression_6_checkout.rb | 39 ------------ .../compression/negative/compression_7_checkout.rb | 39 ------------ .../negative/compression_alpha_checkout.rb | 39 ------------ .../negative/compression_eval_checkout.rb | 39 ------------ .../negative/compression_exec_checkout.rb | 39 ------------ .../negative/compression_negative_checkout.rb | 39 ------------ .../create/create_bare_repo_that_already_exists.rb | 35 ----------- .../create/create_repo_that_already_exists.rb | 37 ------------ .../create_bare_repo_specifying_revision.rb | 34 ----------- .../git/branch_checkout/branch_checkout_file.rb | 44 ++++++++++++++ .../branch_checkout/branch_checkout_file_path.rb | 44 ++++++++++++++ .../git/branch_checkout/branch_checkout_git.rb | 49 +++++++++++++++ .../git/branch_checkout/branch_checkout_http.rb | 56 ++++++++++++++++++ .../git/branch_checkout/branch_checkout_https.rb | 63 ++++++++++++++++++++ .../git/branch_checkout/branch_checkout_ssh.rb | 54 +++++++++++++++++ .../negative/branch_checkout_not_exists.rb | 43 ++++++++++++++ ...clone_over_different_exiting_repo_with_force.rb | 44 ++++++++++++++ .../git/clone/clone_repo_with_excludes_in_repo.rb | 42 +++++++++++++ .../clone/clone_repo_with_excludes_not_in_repo.rb | 42 +++++++++++++ .../negative/clone_over_different_exiting_repo.rb | 43 ++++++++++++++ .../negative/clone_repo_with_hostile_excludes.rb | 40 +++++++++++++ .../git/compression/compression_0_checkout.rb | 39 ++++++++++++ .../git/compression/compression_1_checkout.rb | 39 ++++++++++++ .../git/compression/compression_2_checkout.rb | 39 ++++++++++++ .../git/compression/compression_3_checkout.rb | 39 ++++++++++++ .../git/compression/compression_4_checkout.rb | 39 ++++++++++++ .../git/compression/compression_5_checkout.rb | 39 ++++++++++++ .../git/compression/compression_6_checkout.rb | 39 ++++++++++++ .../compression/negative/compression_7_checkout.rb | 39 ++++++++++++ .../negative/compression_alpha_checkout.rb | 39 ++++++++++++ .../negative/compression_eval_checkout.rb | 39 ++++++++++++ .../negative/compression_exec_checkout.rb | 39 ++++++++++++ .../negative/compression_negative_checkout.rb | 39 ++++++++++++ .../create/create_bare_repo_that_already_exists.rb | 35 +++++++++++ .../git/create/create_repo_that_already_exists.rb | 37 ++++++++++++ .../create_bare_repo_specifying_revision.rb | 34 +++++++++++ .../git/group_checkout/group_checkout_file.rb | 49 +++++++++++++++ .../git/group_checkout/group_checkout_file_path.rb | 49 +++++++++++++++ .../git/group_checkout/group_checkout_git.rb | 54 +++++++++++++++++ .../git/group_checkout/group_checkout_http.rb | 61 +++++++++++++++++++ .../git/group_checkout/group_checkout_https.rb | 68 +++++++++++++++++++++ .../git/group_checkout/group_checkout_ssh.rb | 59 ++++++++++++++++++ .../group_checkout_file_non_existent_group.rb | 48 +++++++++++++++ .../negative/revision_checkout_not_exists.rb | 43 ++++++++++++++ .../revision_checkout/revision_checkout_file.rb | 49 +++++++++++++++ .../revision_checkout_file_path.rb | 49 +++++++++++++++ .../git/revision_checkout/revision_checkout_git.rb | 54 +++++++++++++++++ .../revision_checkout/revision_checkout_http.rb | 61 +++++++++++++++++++ .../revision_checkout/revision_checkout_https.rb | 69 ++++++++++++++++++++++ .../git/revision_checkout/revision_checkout_ssh.rb | 59 ++++++++++++++++++ .../negative/shallow_clone_hostile_depth.rb | 39 ++++++++++++ .../negative/shallow_clone_negative_depth.rb | 39 ++++++++++++ .../negative/shallow_clone_overflow_depth.rb | 39 ++++++++++++ .../beaker/git/shallow_clone/shallow_clone_file.rb | 43 ++++++++++++++ .../git/shallow_clone/shallow_clone_file_path.rb | 43 ++++++++++++++ .../beaker/git/shallow_clone/shallow_clone_git.rb | 48 +++++++++++++++ .../beaker/git/shallow_clone/shallow_clone_http.rb | 55 +++++++++++++++++ .../git/shallow_clone/shallow_clone_https.rb | 62 +++++++++++++++++++ .../beaker/git/shallow_clone/shallow_clone_ssh.rb | 53 +++++++++++++++++ .../git/shallow_clone/shallow_clone_zero_depth.rb | 39 ++++++++++++ .../negative/tag_checkout_not_exists.rb | 43 ++++++++++++++ .../beaker/git/tag_checkout/tag_checkout_file.rb | 44 ++++++++++++++ .../git/tag_checkout/tag_checkout_file_path.rb | 44 ++++++++++++++ .../beaker/git/tag_checkout/tag_checkout_git.rb | 55 +++++++++++++++++ .../beaker/git/tag_checkout/tag_checkout_http.rb | 62 +++++++++++++++++++ .../beaker/git/tag_checkout/tag_checkout_https.rb | 69 ++++++++++++++++++++++ .../beaker/git/tag_checkout/tag_checkout_ssh.rb | 60 +++++++++++++++++++ .../user_checkout_file_non_existent_user.rb | 48 +++++++++++++++ .../beaker/git/user_checkout/user_checkout_file.rb | 49 +++++++++++++++ .../git/user_checkout/user_checkout_file_path.rb | 49 +++++++++++++++ .../beaker/git/user_checkout/user_checkout_git.rb | 54 +++++++++++++++++ .../beaker/git/user_checkout/user_checkout_http.rb | 61 +++++++++++++++++++ .../git/user_checkout/user_checkout_https.rb | 68 +++++++++++++++++++++ .../beaker/git/user_checkout/user_checkout_ssh.rb | 59 ++++++++++++++++++ .../beaker/group_checkout/group_checkout_file.rb | 49 --------------- .../group_checkout/group_checkout_file_path.rb | 49 --------------- .../beaker/group_checkout/group_checkout_git.rb | 54 ----------------- .../beaker/group_checkout/group_checkout_http.rb | 61 ------------------- .../beaker/group_checkout/group_checkout_https.rb | 68 --------------------- .../beaker/group_checkout/group_checkout_ssh.rb | 59 ------------------ .../group_checkout_file_non_existent_group.rb | 48 --------------- .../negative/revision_checkout_not_exists.rb | 43 -------------- .../revision_checkout/revision_checkout_file.rb | 49 --------------- .../revision_checkout_file_path.rb | 49 --------------- .../revision_checkout/revision_checkout_git.rb | 54 ----------------- .../revision_checkout/revision_checkout_http.rb | 61 ------------------- .../revision_checkout/revision_checkout_https.rb | 69 ---------------------- .../revision_checkout/revision_checkout_ssh.rb | 59 ------------------ .../negative/shallow_clone_hostile_depth.rb | 39 ------------ .../negative/shallow_clone_negative_depth.rb | 39 ------------ .../negative/shallow_clone_overflow_depth.rb | 39 ------------ .../beaker/shallow_clone/shallow_clone_file.rb | 43 -------------- .../shallow_clone/shallow_clone_file_path.rb | 43 -------------- .../beaker/shallow_clone/shallow_clone_git.rb | 48 --------------- .../beaker/shallow_clone/shallow_clone_http.rb | 55 ----------------- .../beaker/shallow_clone/shallow_clone_https.rb | 62 ------------------- .../beaker/shallow_clone/shallow_clone_ssh.rb | 53 ----------------- .../shallow_clone/shallow_clone_zero_depth.rb | 39 ------------ .../negative/tag_checkout_not_exists.rb | 43 -------------- .../beaker/tag_checkout/tag_checkout_file.rb | 44 -------------- .../beaker/tag_checkout/tag_checkout_file_path.rb | 44 -------------- .../beaker/tag_checkout/tag_checkout_git.rb | 55 ----------------- .../beaker/tag_checkout/tag_checkout_http.rb | 62 ------------------- .../beaker/tag_checkout/tag_checkout_https.rb | 69 ---------------------- .../beaker/tag_checkout/tag_checkout_ssh.rb | 60 ------------------- .../user_checkout_file_non_existent_user.rb | 48 --------------- .../beaker/user_checkout/user_checkout_file.rb | 49 --------------- .../user_checkout/user_checkout_file_path.rb | 49 --------------- .../beaker/user_checkout/user_checkout_git.rb | 54 ----------------- .../beaker/user_checkout/user_checkout_http.rb | 61 ------------------- .../beaker/user_checkout/user_checkout_https.rb | 68 --------------------- .../beaker/user_checkout/user_checkout_ssh.rb | 59 ------------------ 130 files changed, 3135 insertions(+), 3135 deletions(-) delete mode 100644 spec/acceptance/beaker/branch_checkout/branch_checkout_file.rb delete mode 100644 spec/acceptance/beaker/branch_checkout/branch_checkout_file_path.rb delete mode 100644 spec/acceptance/beaker/branch_checkout/branch_checkout_git.rb delete mode 100644 spec/acceptance/beaker/branch_checkout/branch_checkout_http.rb delete mode 100644 spec/acceptance/beaker/branch_checkout/branch_checkout_https.rb delete mode 100644 spec/acceptance/beaker/branch_checkout/branch_checkout_ssh.rb delete mode 100644 spec/acceptance/beaker/branch_checkout/negative/branch_checkout_not_exists.rb delete mode 100644 spec/acceptance/beaker/clone/clone_over_different_exiting_repo_with_force.rb delete mode 100644 spec/acceptance/beaker/clone/clone_repo_with_excludes_in_repo.rb delete mode 100644 spec/acceptance/beaker/clone/clone_repo_with_excludes_not_in_repo.rb delete mode 100644 spec/acceptance/beaker/clone/negative/clone_over_different_exiting_repo.rb delete mode 100644 spec/acceptance/beaker/clone/negative/clone_repo_with_hostile_excludes.rb delete mode 100644 spec/acceptance/beaker/compression/compression_0_checkout.rb delete mode 100644 spec/acceptance/beaker/compression/compression_1_checkout.rb delete mode 100644 spec/acceptance/beaker/compression/compression_2_checkout.rb delete mode 100644 spec/acceptance/beaker/compression/compression_3_checkout.rb delete mode 100644 spec/acceptance/beaker/compression/compression_4_checkout.rb delete mode 100644 spec/acceptance/beaker/compression/compression_5_checkout.rb delete mode 100644 spec/acceptance/beaker/compression/compression_6_checkout.rb delete mode 100644 spec/acceptance/beaker/compression/negative/compression_7_checkout.rb delete mode 100644 spec/acceptance/beaker/compression/negative/compression_alpha_checkout.rb delete mode 100644 spec/acceptance/beaker/compression/negative/compression_eval_checkout.rb delete mode 100644 spec/acceptance/beaker/compression/negative/compression_exec_checkout.rb delete mode 100644 spec/acceptance/beaker/compression/negative/compression_negative_checkout.rb delete mode 100644 spec/acceptance/beaker/create/create_bare_repo_that_already_exists.rb delete mode 100644 spec/acceptance/beaker/create/create_repo_that_already_exists.rb delete mode 100644 spec/acceptance/beaker/create/negative/create_bare_repo_specifying_revision.rb create mode 100644 spec/acceptance/beaker/git/branch_checkout/branch_checkout_file.rb create mode 100644 spec/acceptance/beaker/git/branch_checkout/branch_checkout_file_path.rb create mode 100644 spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb create mode 100644 spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb create mode 100644 spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb create mode 100644 spec/acceptance/beaker/git/branch_checkout/branch_checkout_ssh.rb create mode 100644 spec/acceptance/beaker/git/branch_checkout/negative/branch_checkout_not_exists.rb create mode 100644 spec/acceptance/beaker/git/clone/clone_over_different_exiting_repo_with_force.rb create mode 100644 spec/acceptance/beaker/git/clone/clone_repo_with_excludes_in_repo.rb create mode 100644 spec/acceptance/beaker/git/clone/clone_repo_with_excludes_not_in_repo.rb create mode 100644 spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb create mode 100644 spec/acceptance/beaker/git/clone/negative/clone_repo_with_hostile_excludes.rb create mode 100644 spec/acceptance/beaker/git/compression/compression_0_checkout.rb create mode 100644 spec/acceptance/beaker/git/compression/compression_1_checkout.rb create mode 100644 spec/acceptance/beaker/git/compression/compression_2_checkout.rb create mode 100644 spec/acceptance/beaker/git/compression/compression_3_checkout.rb create mode 100644 spec/acceptance/beaker/git/compression/compression_4_checkout.rb create mode 100644 spec/acceptance/beaker/git/compression/compression_5_checkout.rb create mode 100644 spec/acceptance/beaker/git/compression/compression_6_checkout.rb create mode 100644 spec/acceptance/beaker/git/compression/negative/compression_7_checkout.rb create mode 100644 spec/acceptance/beaker/git/compression/negative/compression_alpha_checkout.rb create mode 100644 spec/acceptance/beaker/git/compression/negative/compression_eval_checkout.rb create mode 100644 spec/acceptance/beaker/git/compression/negative/compression_exec_checkout.rb create mode 100644 spec/acceptance/beaker/git/compression/negative/compression_negative_checkout.rb create mode 100644 spec/acceptance/beaker/git/create/create_bare_repo_that_already_exists.rb create mode 100644 spec/acceptance/beaker/git/create/create_repo_that_already_exists.rb create mode 100644 spec/acceptance/beaker/git/create/negative/create_bare_repo_specifying_revision.rb create mode 100644 spec/acceptance/beaker/git/group_checkout/group_checkout_file.rb create mode 100644 spec/acceptance/beaker/git/group_checkout/group_checkout_file_path.rb create mode 100644 spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb create mode 100644 spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb create mode 100644 spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb create mode 100644 spec/acceptance/beaker/git/group_checkout/group_checkout_ssh.rb create mode 100644 spec/acceptance/beaker/git/group_checkout/negative/group_checkout_file_non_existent_group.rb create mode 100644 spec/acceptance/beaker/git/revision_checkout/negative/revision_checkout_not_exists.rb create mode 100644 spec/acceptance/beaker/git/revision_checkout/revision_checkout_file.rb create mode 100644 spec/acceptance/beaker/git/revision_checkout/revision_checkout_file_path.rb create mode 100644 spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb create mode 100644 spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb create mode 100644 spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb create mode 100644 spec/acceptance/beaker/git/revision_checkout/revision_checkout_ssh.rb create mode 100644 spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_hostile_depth.rb create mode 100644 spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_negative_depth.rb create mode 100644 spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_overflow_depth.rb create mode 100644 spec/acceptance/beaker/git/shallow_clone/shallow_clone_file.rb create mode 100644 spec/acceptance/beaker/git/shallow_clone/shallow_clone_file_path.rb create mode 100644 spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb create mode 100644 spec/acceptance/beaker/git/shallow_clone/shallow_clone_http.rb create mode 100644 spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb create mode 100644 spec/acceptance/beaker/git/shallow_clone/shallow_clone_ssh.rb create mode 100644 spec/acceptance/beaker/git/shallow_clone/shallow_clone_zero_depth.rb create mode 100644 spec/acceptance/beaker/git/tag_checkout/negative/tag_checkout_not_exists.rb create mode 100644 spec/acceptance/beaker/git/tag_checkout/tag_checkout_file.rb create mode 100644 spec/acceptance/beaker/git/tag_checkout/tag_checkout_file_path.rb create mode 100644 spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb create mode 100644 spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb create mode 100644 spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb create mode 100644 spec/acceptance/beaker/git/tag_checkout/tag_checkout_ssh.rb create mode 100644 spec/acceptance/beaker/git/user_checkout/negative/user_checkout_file_non_existent_user.rb create mode 100644 spec/acceptance/beaker/git/user_checkout/user_checkout_file.rb create mode 100644 spec/acceptance/beaker/git/user_checkout/user_checkout_file_path.rb create mode 100644 spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb create mode 100644 spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb create mode 100644 spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb create mode 100644 spec/acceptance/beaker/git/user_checkout/user_checkout_ssh.rb delete mode 100644 spec/acceptance/beaker/group_checkout/group_checkout_file.rb delete mode 100644 spec/acceptance/beaker/group_checkout/group_checkout_file_path.rb delete mode 100644 spec/acceptance/beaker/group_checkout/group_checkout_git.rb delete mode 100644 spec/acceptance/beaker/group_checkout/group_checkout_http.rb delete mode 100644 spec/acceptance/beaker/group_checkout/group_checkout_https.rb delete mode 100644 spec/acceptance/beaker/group_checkout/group_checkout_ssh.rb delete mode 100644 spec/acceptance/beaker/group_checkout/negative/group_checkout_file_non_existent_group.rb delete mode 100644 spec/acceptance/beaker/revision_checkout/negative/revision_checkout_not_exists.rb delete mode 100644 spec/acceptance/beaker/revision_checkout/revision_checkout_file.rb delete mode 100644 spec/acceptance/beaker/revision_checkout/revision_checkout_file_path.rb delete mode 100644 spec/acceptance/beaker/revision_checkout/revision_checkout_git.rb delete mode 100644 spec/acceptance/beaker/revision_checkout/revision_checkout_http.rb delete mode 100644 spec/acceptance/beaker/revision_checkout/revision_checkout_https.rb delete mode 100644 spec/acceptance/beaker/revision_checkout/revision_checkout_ssh.rb delete mode 100644 spec/acceptance/beaker/shallow_clone/negative/shallow_clone_hostile_depth.rb delete mode 100644 spec/acceptance/beaker/shallow_clone/negative/shallow_clone_negative_depth.rb delete mode 100644 spec/acceptance/beaker/shallow_clone/negative/shallow_clone_overflow_depth.rb delete mode 100644 spec/acceptance/beaker/shallow_clone/shallow_clone_file.rb delete mode 100644 spec/acceptance/beaker/shallow_clone/shallow_clone_file_path.rb delete mode 100644 spec/acceptance/beaker/shallow_clone/shallow_clone_git.rb delete mode 100644 spec/acceptance/beaker/shallow_clone/shallow_clone_http.rb delete mode 100644 spec/acceptance/beaker/shallow_clone/shallow_clone_https.rb delete mode 100644 spec/acceptance/beaker/shallow_clone/shallow_clone_ssh.rb delete mode 100644 spec/acceptance/beaker/shallow_clone/shallow_clone_zero_depth.rb delete mode 100644 spec/acceptance/beaker/tag_checkout/negative/tag_checkout_not_exists.rb delete mode 100644 spec/acceptance/beaker/tag_checkout/tag_checkout_file.rb delete mode 100644 spec/acceptance/beaker/tag_checkout/tag_checkout_file_path.rb delete mode 100644 spec/acceptance/beaker/tag_checkout/tag_checkout_git.rb delete mode 100644 spec/acceptance/beaker/tag_checkout/tag_checkout_http.rb delete mode 100644 spec/acceptance/beaker/tag_checkout/tag_checkout_https.rb delete mode 100644 spec/acceptance/beaker/tag_checkout/tag_checkout_ssh.rb delete mode 100644 spec/acceptance/beaker/user_checkout/negative/user_checkout_file_non_existent_user.rb delete mode 100644 spec/acceptance/beaker/user_checkout/user_checkout_file.rb delete mode 100644 spec/acceptance/beaker/user_checkout/user_checkout_file_path.rb delete mode 100644 spec/acceptance/beaker/user_checkout/user_checkout_git.rb delete mode 100644 spec/acceptance/beaker/user_checkout/user_checkout_http.rb delete mode 100644 spec/acceptance/beaker/user_checkout/user_checkout_https.rb delete mode 100644 spec/acceptance/beaker/user_checkout/user_checkout_ssh.rb diff --git a/spec/acceptance/beaker/branch_checkout/branch_checkout_file.rb b/spec/acceptance/beaker/branch_checkout/branch_checkout_file.rb deleted file mode 100644 index e78e374..0000000 --- a/spec/acceptance/beaker/branch_checkout/branch_checkout_file.rb +++ /dev/null @@ -1,44 +0,0 @@ -test_name 'C3438 - checkout a branch (file protocol)' - -# Globals -repo_name = 'testrepo_branch_checkout' -branch = 'a_branch' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'checkout a branch with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - revision => '#{branch}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify checkout is on the #{branch} branch" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}" - end - end - -end diff --git a/spec/acceptance/beaker/branch_checkout/branch_checkout_file_path.rb b/spec/acceptance/beaker/branch_checkout/branch_checkout_file_path.rb deleted file mode 100644 index 9870daa..0000000 --- a/spec/acceptance/beaker/branch_checkout/branch_checkout_file_path.rb +++ /dev/null @@ -1,44 +0,0 @@ -test_name 'C3437 - checkout a branch (file path)' - -# Globals -repo_name = 'testrepo_branch_checkout' -branch = 'a_branch' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'checkout a branch with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "#{tmpdir}/testrepo.git", - provider => git, - revision => '#{branch}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify checkout is on the #{branch} branch" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}" - end - end - -end diff --git a/spec/acceptance/beaker/branch_checkout/branch_checkout_git.rb b/spec/acceptance/beaker/branch_checkout/branch_checkout_git.rb deleted file mode 100644 index a319b7d..0000000 --- a/spec/acceptance/beaker/branch_checkout/branch_checkout_git.rb +++ /dev/null @@ -1,49 +0,0 @@ -test_name 'C3436 - checkout a branch (git protocol)' - -# Globals -repo_name = 'testrepo_branch_checkout' -branch = 'a_branch' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - step 'setup - start git daemon' do - install_package(host, 'git-daemon') - on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - on(host, 'pkill -9 git-daemon') - end - - step 'checkout a branch with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "git://#{host}/testrepo.git", - provider => git, - revision => '#{branch}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify checkout is on the #{branch} branch" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}" - end - end - -end diff --git a/spec/acceptance/beaker/branch_checkout/branch_checkout_http.rb b/spec/acceptance/beaker/branch_checkout/branch_checkout_http.rb deleted file mode 100644 index ddfaff5..0000000 --- a/spec/acceptance/beaker/branch_checkout/branch_checkout_http.rb +++ /dev/null @@ -1,56 +0,0 @@ -test_name 'C3441 - checkout a branch (http protocol)' - -# Globals -repo_name = 'testrepo_branch_checkout' -branch = 'a_branch' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - step 'setup - start http server' do - http_daemon =<<-EOF - require 'webrick' - server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") - WEBrick::Daemon.start - server.start - EOF - create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) - on(host, "ruby /tmp/http_daemon.rb") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') - end - - step 'checkout a branch with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "http://#{host}:8000/testrepo.git", - provider => git, - revision => '#{branch}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify checkout is on the #{branch} branch" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}" - end - end - -end diff --git a/spec/acceptance/beaker/branch_checkout/branch_checkout_https.rb b/spec/acceptance/beaker/branch_checkout/branch_checkout_https.rb deleted file mode 100644 index 024daaa..0000000 --- a/spec/acceptance/beaker/branch_checkout/branch_checkout_https.rb +++ /dev/null @@ -1,63 +0,0 @@ -test_name 'C3442 - checkout a branch (https protocol)' - -# Globals -repo_name = 'testrepo_branch_checkout' -branch = 'a_branch' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - step 'setup - start https server' do - https_daemon =<<-EOF - require 'webrick' - require 'webrick/https' - server = WEBrick::HTTPServer.new( - :Port => 8443, - :DocumentRoot => "#{tmpdir}", - :SSLEnable => true, - :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, - :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), - :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), - :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) - WEBrick::Daemon.start - server.start - EOF - create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) - #on(host, "ruby /tmp/https_daemon.rb") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') - end - - step 'checkout a branch with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "https://github.com/johnduarte/testrepo.git", - provider => git, - revision => '#{branch}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify checkout is on the #{branch} branch" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}" - end - end - -end diff --git a/spec/acceptance/beaker/branch_checkout/branch_checkout_ssh.rb b/spec/acceptance/beaker/branch_checkout/branch_checkout_ssh.rb deleted file mode 100644 index 8eabd98..0000000 --- a/spec/acceptance/beaker/branch_checkout/branch_checkout_ssh.rb +++ /dev/null @@ -1,54 +0,0 @@ -test_name 'C3440 - checkout a branch (ssh protocol)' - -# Globals -repo_name = 'testrepo_branch_checkout' -branch = 'a_branch' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - step 'setup - establish ssh keys' do - # create ssh keys - on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') - - # copy public key to authorized_keys - on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') - on(host, 'chown -R root:root /root/.ssh') - end - - teardown do - on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") - end - - step 'checkout a branch with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "ssh://root@#{host}#{tmpdir}/testrepo.git", - provider => git, - revision => '#{branch}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify checkout is on the #{branch} branch" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}" - end - end - -end diff --git a/spec/acceptance/beaker/branch_checkout/negative/branch_checkout_not_exists.rb b/spec/acceptance/beaker/branch_checkout/negative/branch_checkout_not_exists.rb deleted file mode 100644 index 5168ac7..0000000 --- a/spec/acceptance/beaker/branch_checkout/negative/branch_checkout_not_exists.rb +++ /dev/null @@ -1,43 +0,0 @@ -test_name 'C3609 - checkout a branch that does not exist' - -# Globals -repo_name = 'testrepo_branch_checkout' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'checkout branch that does not exist with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - revision => 'non_existent_branch', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify that master branch is checked out' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/master" - end - end - -end diff --git a/spec/acceptance/beaker/clone/clone_over_different_exiting_repo_with_force.rb b/spec/acceptance/beaker/clone/clone_over_different_exiting_repo_with_force.rb deleted file mode 100644 index 2d755fc..0000000 --- a/spec/acceptance/beaker/clone/clone_over_different_exiting_repo_with_force.rb +++ /dev/null @@ -1,44 +0,0 @@ -test_name 'C3511 - clone over an existing repo with force' - -# Globals -repo_name = 'testrepo_already_exists' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - on(host, "mkdir #{tmpdir}/#{repo_name}") - on(host, "cd #{tmpdir}/#{repo_name} && git init") - on(host, "cd #{tmpdir}/#{repo_name} && touch a && git add a && git commit -m 'a'") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'clone over existing repo with force using puppet' do - on(host, "cd #{tmpdir}/#{repo_name} && git log --pretty=format:\"%h\"") do |res| - @existing_sha = res.stdout - end - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - force => true, - } - EOS - - apply_manifest_on(host, pp) - end - - step 'verify new repo has replaced old one' do - on(host, "cd #{tmpdir}/#{repo_name} && git log --pretty=format:\"%h\"") do |res| - fail_test('original repo not replaced by force') if res.stdout.include? "#{@existing_sha}" - end - end - -end diff --git a/spec/acceptance/beaker/clone/clone_repo_with_excludes_in_repo.rb b/spec/acceptance/beaker/clone/clone_repo_with_excludes_in_repo.rb deleted file mode 100644 index 1252e3b..0000000 --- a/spec/acceptance/beaker/clone/clone_repo_with_excludes_in_repo.rb +++ /dev/null @@ -1,42 +0,0 @@ -test_name 'C3507 - clone repo with excludes in repo' - -# Globals -repo_name = 'testrepo_with_excludes_in_repo' -exclude1 = 'file1.txt' -exclude2 ='file2.txt' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'clone repo with excludes in repo with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - excludes => [ '#{exclude1}', '#{exclude2}' ], - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify exludes are known to git' do - on(host, "cat #{tmpdir}/#{repo_name}/.git/info/exclude") do |res| - fail_test('exclude not found') unless res.stdout.include? "#{exclude1}" - fail_test('exclude not found') unless res.stdout.include? "#{exclude2}" - end - end - -end diff --git a/spec/acceptance/beaker/clone/clone_repo_with_excludes_not_in_repo.rb b/spec/acceptance/beaker/clone/clone_repo_with_excludes_not_in_repo.rb deleted file mode 100644 index ce173fd..0000000 --- a/spec/acceptance/beaker/clone/clone_repo_with_excludes_not_in_repo.rb +++ /dev/null @@ -1,42 +0,0 @@ -test_name 'C3508 - clone repo with excludes not in repo' - -# Globals -repo_name = 'testrepo_with_excludes_not_in_repo' -exclude1 = 'worh02o' -exclude2 ='ho398b' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'clone repo with excludes not in repo with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - excludes => [ '#{exclude1}', '#{exclude2}' ], - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify exludes are known to git' do - on(host, "cat #{tmpdir}/#{repo_name}/.git/info/exclude") do |res| - fail_test('exclude not found') unless res.stdout.include? "#{exclude1}" - fail_test('exclude not found') unless res.stdout.include? "#{exclude2}" - end - end - -end diff --git a/spec/acceptance/beaker/clone/negative/clone_over_different_exiting_repo.rb b/spec/acceptance/beaker/clone/negative/clone_over_different_exiting_repo.rb deleted file mode 100644 index 7821ce2..0000000 --- a/spec/acceptance/beaker/clone/negative/clone_over_different_exiting_repo.rb +++ /dev/null @@ -1,43 +0,0 @@ -test_name 'C3482 - clone over an existing repo' - -# Globals -repo_name = 'testrepo_already_exists' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - on(host, "mkdir #{tmpdir}/#{repo_name}") - on(host, "cd #{tmpdir}/#{repo_name} && git init") - on(host, "cd #{tmpdir}/#{repo_name} && touch a && git add a && git commit -m 'a'") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'clone over existing repo using puppet' do - on(host, "cd #{tmpdir}/#{repo_name} && git log --pretty=format:\"%h\"") do |res| - @existing_sha = res.stdout - end - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - } - EOS - - apply_manifest_on(host, pp) - end - - step 'verify original repo was not replaced' do - on(host, "cd #{tmpdir}/#{repo_name} && git log --pretty=format:\"%h\"") do |res| - fail_test('original repo was replaced without force') unless res.stdout.include? "#{@existing_sha}" - end - end - -end diff --git a/spec/acceptance/beaker/clone/negative/clone_repo_with_hostile_excludes.rb b/spec/acceptance/beaker/clone/negative/clone_repo_with_hostile_excludes.rb deleted file mode 100644 index 4e04c78..0000000 --- a/spec/acceptance/beaker/clone/negative/clone_repo_with_hostile_excludes.rb +++ /dev/null @@ -1,40 +0,0 @@ -test_name 'C3509 - clone repo with excludes not in repo' - -# Globals -repo_name = 'testrepo_with_excludes_not_in_repo' -exclude1 = 'rm -rf /tmp' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'clone repo with excludes not in repo with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - excludes => [ '#{exclude1}' ], - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify excludes are known to git' do - on(host, "cat #{tmpdir}/#{repo_name}/.git/info/exclude") do |res| - fail_test('exclude not found') unless res.stdout.include? "#{exclude1}" - end - end - -end diff --git a/spec/acceptance/beaker/compression/compression_0_checkout.rb b/spec/acceptance/beaker/compression/compression_0_checkout.rb deleted file mode 100644 index fc62d4a..0000000 --- a/spec/acceptance/beaker/compression/compression_0_checkout.rb +++ /dev/null @@ -1,39 +0,0 @@ -test_name 'C3495 - checkout with compression 0' - -# Globals -repo_name = 'testrepo_checkout' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'checkout with compression 0 with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - compression => 0, - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify git repo was checked out' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - end - -end diff --git a/spec/acceptance/beaker/compression/compression_1_checkout.rb b/spec/acceptance/beaker/compression/compression_1_checkout.rb deleted file mode 100644 index c1ec2f2..0000000 --- a/spec/acceptance/beaker/compression/compression_1_checkout.rb +++ /dev/null @@ -1,39 +0,0 @@ -test_name 'C3496 - checkout with compression 1' - -# Globals -repo_name = 'testrepo_checkout' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'checkout with compression 1 with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - compression => 1, - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify git repo was checked out' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - end - -end diff --git a/spec/acceptance/beaker/compression/compression_2_checkout.rb b/spec/acceptance/beaker/compression/compression_2_checkout.rb deleted file mode 100644 index c92a878..0000000 --- a/spec/acceptance/beaker/compression/compression_2_checkout.rb +++ /dev/null @@ -1,39 +0,0 @@ -test_name 'C3497 - checkout with compression 2' - -# Globals -repo_name = 'testrepo_checkout' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'checkout with compression 2 with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - compression => 2, - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify git repo was checked out' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - end - -end diff --git a/spec/acceptance/beaker/compression/compression_3_checkout.rb b/spec/acceptance/beaker/compression/compression_3_checkout.rb deleted file mode 100644 index 8cba272..0000000 --- a/spec/acceptance/beaker/compression/compression_3_checkout.rb +++ /dev/null @@ -1,39 +0,0 @@ -test_name 'C3498 - checkout with compression 3' - -# Globals -repo_name = 'testrepo_checkout' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'checkout with compression 3 with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - compression => 3, - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify git repo was checked out' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - end - -end diff --git a/spec/acceptance/beaker/compression/compression_4_checkout.rb b/spec/acceptance/beaker/compression/compression_4_checkout.rb deleted file mode 100644 index c5c12a6..0000000 --- a/spec/acceptance/beaker/compression/compression_4_checkout.rb +++ /dev/null @@ -1,39 +0,0 @@ -test_name 'C3499 - checkout with compression 4' - -# Globals -repo_name = 'testrepo_checkout' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'checkout with compression 4 with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - compression => 4, - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify git repo was checked out' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - end - -end diff --git a/spec/acceptance/beaker/compression/compression_5_checkout.rb b/spec/acceptance/beaker/compression/compression_5_checkout.rb deleted file mode 100644 index 474b62f..0000000 --- a/spec/acceptance/beaker/compression/compression_5_checkout.rb +++ /dev/null @@ -1,39 +0,0 @@ -test_name 'C3500 - checkout with compression 5' - -# Globals -repo_name = 'testrepo_checkout' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'checkout with compression 5 with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - compression => 5, - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify git repo was checked out' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - end - -end diff --git a/spec/acceptance/beaker/compression/compression_6_checkout.rb b/spec/acceptance/beaker/compression/compression_6_checkout.rb deleted file mode 100644 index b3fb71b..0000000 --- a/spec/acceptance/beaker/compression/compression_6_checkout.rb +++ /dev/null @@ -1,39 +0,0 @@ -test_name 'C3501 - checkout with compression 6' - -# Globals -repo_name = 'testrepo_checkout' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'checkout with compression 6 with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - compression => 6, - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify git repo was checked out' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - end - -end diff --git a/spec/acceptance/beaker/compression/negative/compression_7_checkout.rb b/spec/acceptance/beaker/compression/negative/compression_7_checkout.rb deleted file mode 100644 index b7af79a..0000000 --- a/spec/acceptance/beaker/compression/negative/compression_7_checkout.rb +++ /dev/null @@ -1,39 +0,0 @@ -test_name 'C3503 - checkout with compression 7' - -# Globals -repo_name = 'testrepo_checkout' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'checkout with compression 7 with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - compression => 7, - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify git repo was checked out' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - end - -end diff --git a/spec/acceptance/beaker/compression/negative/compression_alpha_checkout.rb b/spec/acceptance/beaker/compression/negative/compression_alpha_checkout.rb deleted file mode 100644 index 06a0a01..0000000 --- a/spec/acceptance/beaker/compression/negative/compression_alpha_checkout.rb +++ /dev/null @@ -1,39 +0,0 @@ -test_name 'C3505 - checkout with compression alpha' - -# Globals -repo_name = 'testrepo_checkout' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'checkout with compression alpha with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - compression => abcde, - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify git repo was checked out' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - end - -end diff --git a/spec/acceptance/beaker/compression/negative/compression_eval_checkout.rb b/spec/acceptance/beaker/compression/negative/compression_eval_checkout.rb deleted file mode 100644 index d66996e..0000000 --- a/spec/acceptance/beaker/compression/negative/compression_eval_checkout.rb +++ /dev/null @@ -1,39 +0,0 @@ -test_name 'C3504 - checkout with compression 10-5' - -# Globals -repo_name = 'testrepo_checkout' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'checkout with compression 10-5 with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - compression => 10-5, - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify git repo was checked out' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - end - -end diff --git a/spec/acceptance/beaker/compression/negative/compression_exec_checkout.rb b/spec/acceptance/beaker/compression/negative/compression_exec_checkout.rb deleted file mode 100644 index 46e730d..0000000 --- a/spec/acceptance/beaker/compression/negative/compression_exec_checkout.rb +++ /dev/null @@ -1,39 +0,0 @@ -test_name 'C3506 - checkout with compression exec' - -# Globals -repo_name = 'testrepo_checkout' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'checkout with compression exec with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - compression => `exec rm -rf /tmp`, - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify git repo was checked out' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - end - -end diff --git a/spec/acceptance/beaker/compression/negative/compression_negative_checkout.rb b/spec/acceptance/beaker/compression/negative/compression_negative_checkout.rb deleted file mode 100644 index ee98057..0000000 --- a/spec/acceptance/beaker/compression/negative/compression_negative_checkout.rb +++ /dev/null @@ -1,39 +0,0 @@ -test_name 'C3502 - checkout with compression -1' - -# Globals -repo_name = 'testrepo_checkout' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'checkout with compression -1 with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - compression => -1, - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify git repo was checked out' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - end - -end diff --git a/spec/acceptance/beaker/create/create_bare_repo_that_already_exists.rb b/spec/acceptance/beaker/create/create_bare_repo_that_already_exists.rb deleted file mode 100644 index 663c758..0000000 --- a/spec/acceptance/beaker/create/create_bare_repo_that_already_exists.rb +++ /dev/null @@ -1,35 +0,0 @@ -test_name 'C3472 - create bare repo that already exists' - -# Globals -repo_name = 'testrepo_bare_repo_already_exists.git' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create bare repo' do - install_package(host, 'git') - on(host, "mkdir #{tmpdir}/#{repo_name}") - on(host, "cd #{tmpdir}/#{repo_name} && git --bare init") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'create bare repo that already exists using puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => bare, - provider => git, - } - EOS - - apply_manifest_on(host, pp) - end - - step 'verify repo does not contain .git directory' do - on(host, "ls -al #{tmpdir}/#{repo_name}") do |res| - fail_test "found .git for #{repo_name}" if res.stdout.include? ".git" - end - end - -end diff --git a/spec/acceptance/beaker/create/create_repo_that_already_exists.rb b/spec/acceptance/beaker/create/create_repo_that_already_exists.rb deleted file mode 100644 index 7c28998..0000000 --- a/spec/acceptance/beaker/create/create_repo_that_already_exists.rb +++ /dev/null @@ -1,37 +0,0 @@ -test_name 'C3470 - create repo that already exists' - -# Globals -repo_name = 'testrepo_already_exists' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - on(host, "cd #{tmpdir} && git clone file://#{tmpdir}/testrepo.git #{repo_name}") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'create repo that already exists using puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - provider => git, - } - EOS - - apply_manifest_on(host, pp) - end - - step 'verify repo is on master branch' do - on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - assert_match(/ref: refs\/heads\/master/, stdout, "Git checkout not on master on #{host}") - end - end - -end diff --git a/spec/acceptance/beaker/create/negative/create_bare_repo_specifying_revision.rb b/spec/acceptance/beaker/create/negative/create_bare_repo_specifying_revision.rb deleted file mode 100644 index 6a12c8c..0000000 --- a/spec/acceptance/beaker/create/negative/create_bare_repo_specifying_revision.rb +++ /dev/null @@ -1,34 +0,0 @@ -test_name 'C3473 - create bare repo specifying revision' - -# Globals -repo_name = 'testrepo_bare.git' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup' do - install_package(host, 'git') - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'create bare repo specifying revision using puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => bare, - revision => master, - provider => git, - } - EOS - - apply_manifest_on(host, pp, :acceptable_exit_codes => [1]) - end - - step 'verify repo was NOT created' do - on(host, "ls -al #{tmpdir}") do |res| - fail_test "found #{repo_name}" if res.stdout.include? "#{repo_name}" - end - end - -end diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file.rb new file mode 100644 index 0000000..6ed945b --- /dev/null +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file.rb @@ -0,0 +1,44 @@ +test_name 'C3438 - checkout a branch (file protocol)' + +# Globals +repo_name = 'testrepo_branch_checkout' +branch = 'a_branch' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout a branch with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + revision => '#{branch}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the #{branch} branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}" + end + end + +end diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file_path.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file_path.rb new file mode 100644 index 0000000..441a2bc --- /dev/null +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file_path.rb @@ -0,0 +1,44 @@ +test_name 'C3437 - checkout a branch (file path)' + +# Globals +repo_name = 'testrepo_branch_checkout' +branch = 'a_branch' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout a branch with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "#{tmpdir}/testrepo.git", + provider => git, + revision => '#{branch}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the #{branch} branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}" + end + end + +end diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb new file mode 100644 index 0000000..d786ae2 --- /dev/null +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb @@ -0,0 +1,49 @@ +test_name 'C3436 - checkout a branch (git protocol)' + +# Globals +repo_name = 'testrepo_branch_checkout' +branch = 'a_branch' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start git daemon' do + install_package(host, 'git-daemon') + on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'pkill -9 git-daemon') + end + + step 'checkout a branch with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "git://#{host}/testrepo.git", + provider => git, + revision => '#{branch}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the #{branch} branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}" + end + end + +end diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb new file mode 100644 index 0000000..151d801 --- /dev/null +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb @@ -0,0 +1,56 @@ +test_name 'C3441 - checkout a branch (http protocol)' + +# Globals +repo_name = 'testrepo_branch_checkout' +branch = 'a_branch' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - start http server' do + http_daemon =<<-EOF + require 'webrick' + server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) + on(host, "ruby /tmp/http_daemon.rb") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + end + + step 'checkout a branch with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "http://#{host}:8000/testrepo.git", + provider => git, + revision => '#{branch}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the #{branch} branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}" + end + end + +end diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb new file mode 100644 index 0000000..273f5aa --- /dev/null +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb @@ -0,0 +1,63 @@ +test_name 'C3442 - checkout a branch (https protocol)' + +# Globals +repo_name = 'testrepo_branch_checkout' +branch = 'a_branch' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start https server' do + https_daemon =<<-EOF + require 'webrick' + require 'webrick/https' + server = WEBrick::HTTPServer.new( + :Port => 8443, + :DocumentRoot => "#{tmpdir}", + :SSLEnable => true, + :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, + :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), + :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), + :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) + #on(host, "ruby /tmp/https_daemon.rb") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + end + + step 'checkout a branch with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "https://github.com/johnduarte/testrepo.git", + provider => git, + revision => '#{branch}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the #{branch} branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}" + end + end + +end diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_ssh.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_ssh.rb new file mode 100644 index 0000000..ea9fb4a --- /dev/null +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_ssh.rb @@ -0,0 +1,54 @@ +test_name 'C3440 - checkout a branch (ssh protocol)' + +# Globals +repo_name = 'testrepo_branch_checkout' +branch = 'a_branch' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - establish ssh keys' do + # create ssh keys + on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') + on(host, 'chown -R root:root /root/.ssh') + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + end + + step 'checkout a branch with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "ssh://root@#{host}#{tmpdir}/testrepo.git", + provider => git, + revision => '#{branch}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the #{branch} branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}" + end + end + +end diff --git a/spec/acceptance/beaker/git/branch_checkout/negative/branch_checkout_not_exists.rb b/spec/acceptance/beaker/git/branch_checkout/negative/branch_checkout_not_exists.rb new file mode 100644 index 0000000..f8c85d0 --- /dev/null +++ b/spec/acceptance/beaker/git/branch_checkout/negative/branch_checkout_not_exists.rb @@ -0,0 +1,43 @@ +test_name 'C3609 - checkout a branch that does not exist' + +# Globals +repo_name = 'testrepo_branch_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout branch that does not exist with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + revision => 'non_existent_branch', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify that master branch is checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/master" + end + end + +end diff --git a/spec/acceptance/beaker/git/clone/clone_over_different_exiting_repo_with_force.rb b/spec/acceptance/beaker/git/clone/clone_over_different_exiting_repo_with_force.rb new file mode 100644 index 0000000..626d807 --- /dev/null +++ b/spec/acceptance/beaker/git/clone/clone_over_different_exiting_repo_with_force.rb @@ -0,0 +1,44 @@ +test_name 'C3511 - clone over an existing repo with force' + +# Globals +repo_name = 'testrepo_already_exists' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + on(host, "mkdir #{tmpdir}/#{repo_name}") + on(host, "cd #{tmpdir}/#{repo_name} && git init") + on(host, "cd #{tmpdir}/#{repo_name} && touch a && git add a && git commit -m 'a'") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'clone over existing repo with force using puppet' do + on(host, "cd #{tmpdir}/#{repo_name} && git log --pretty=format:\"%h\"") do |res| + @existing_sha = res.stdout + end + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + force => true, + } + EOS + + apply_manifest_on(host, pp) + end + + step 'verify new repo has replaced old one' do + on(host, "cd #{tmpdir}/#{repo_name} && git log --pretty=format:\"%h\"") do |res| + fail_test('original repo not replaced by force') if res.stdout.include? "#{@existing_sha}" + end + end + +end diff --git a/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_in_repo.rb b/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_in_repo.rb new file mode 100644 index 0000000..0a5a1a8 --- /dev/null +++ b/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_in_repo.rb @@ -0,0 +1,42 @@ +test_name 'C3507 - clone repo with excludes in repo' + +# Globals +repo_name = 'testrepo_with_excludes_in_repo' +exclude1 = 'file1.txt' +exclude2 ='file2.txt' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'clone repo with excludes in repo with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + excludes => [ '#{exclude1}', '#{exclude2}' ], + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify exludes are known to git' do + on(host, "cat #{tmpdir}/#{repo_name}/.git/info/exclude") do |res| + fail_test('exclude not found') unless res.stdout.include? "#{exclude1}" + fail_test('exclude not found') unless res.stdout.include? "#{exclude2}" + end + end + +end diff --git a/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_not_in_repo.rb b/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_not_in_repo.rb new file mode 100644 index 0000000..c533aa5 --- /dev/null +++ b/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_not_in_repo.rb @@ -0,0 +1,42 @@ +test_name 'C3508 - clone repo with excludes not in repo' + +# Globals +repo_name = 'testrepo_with_excludes_not_in_repo' +exclude1 = 'worh02o' +exclude2 ='ho398b' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'clone repo with excludes not in repo with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + excludes => [ '#{exclude1}', '#{exclude2}' ], + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify exludes are known to git' do + on(host, "cat #{tmpdir}/#{repo_name}/.git/info/exclude") do |res| + fail_test('exclude not found') unless res.stdout.include? "#{exclude1}" + fail_test('exclude not found') unless res.stdout.include? "#{exclude2}" + end + end + +end diff --git a/spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb b/spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb new file mode 100644 index 0000000..67fea06 --- /dev/null +++ b/spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb @@ -0,0 +1,43 @@ +test_name 'C3482 - clone over an existing repo' + +# Globals +repo_name = 'testrepo_already_exists' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + on(host, "mkdir #{tmpdir}/#{repo_name}") + on(host, "cd #{tmpdir}/#{repo_name} && git init") + on(host, "cd #{tmpdir}/#{repo_name} && touch a && git add a && git commit -m 'a'") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'clone over existing repo using puppet' do + on(host, "cd #{tmpdir}/#{repo_name} && git log --pretty=format:\"%h\"") do |res| + @existing_sha = res.stdout + end + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + } + EOS + + apply_manifest_on(host, pp) + end + + step 'verify original repo was not replaced' do + on(host, "cd #{tmpdir}/#{repo_name} && git log --pretty=format:\"%h\"") do |res| + fail_test('original repo was replaced without force') unless res.stdout.include? "#{@existing_sha}" + end + end + +end diff --git a/spec/acceptance/beaker/git/clone/negative/clone_repo_with_hostile_excludes.rb b/spec/acceptance/beaker/git/clone/negative/clone_repo_with_hostile_excludes.rb new file mode 100644 index 0000000..6331840 --- /dev/null +++ b/spec/acceptance/beaker/git/clone/negative/clone_repo_with_hostile_excludes.rb @@ -0,0 +1,40 @@ +test_name 'C3509 - clone repo with excludes not in repo' + +# Globals +repo_name = 'testrepo_with_excludes_not_in_repo' +exclude1 = 'rm -rf /tmp' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'clone repo with excludes not in repo with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + excludes => [ '#{exclude1}' ], + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify excludes are known to git' do + on(host, "cat #{tmpdir}/#{repo_name}/.git/info/exclude") do |res| + fail_test('exclude not found') unless res.stdout.include? "#{exclude1}" + end + end + +end diff --git a/spec/acceptance/beaker/git/compression/compression_0_checkout.rb b/spec/acceptance/beaker/git/compression/compression_0_checkout.rb new file mode 100644 index 0000000..ee5a171 --- /dev/null +++ b/spec/acceptance/beaker/git/compression/compression_0_checkout.rb @@ -0,0 +1,39 @@ +test_name 'C3495 - checkout with compression 0' + +# Globals +repo_name = 'testrepo_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout with compression 0 with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + compression => 0, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify git repo was checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/git/compression/compression_1_checkout.rb b/spec/acceptance/beaker/git/compression/compression_1_checkout.rb new file mode 100644 index 0000000..01478a1 --- /dev/null +++ b/spec/acceptance/beaker/git/compression/compression_1_checkout.rb @@ -0,0 +1,39 @@ +test_name 'C3496 - checkout with compression 1' + +# Globals +repo_name = 'testrepo_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout with compression 1 with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + compression => 1, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify git repo was checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/git/compression/compression_2_checkout.rb b/spec/acceptance/beaker/git/compression/compression_2_checkout.rb new file mode 100644 index 0000000..b3413ea --- /dev/null +++ b/spec/acceptance/beaker/git/compression/compression_2_checkout.rb @@ -0,0 +1,39 @@ +test_name 'C3497 - checkout with compression 2' + +# Globals +repo_name = 'testrepo_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout with compression 2 with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + compression => 2, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify git repo was checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/git/compression/compression_3_checkout.rb b/spec/acceptance/beaker/git/compression/compression_3_checkout.rb new file mode 100644 index 0000000..b8459a5 --- /dev/null +++ b/spec/acceptance/beaker/git/compression/compression_3_checkout.rb @@ -0,0 +1,39 @@ +test_name 'C3498 - checkout with compression 3' + +# Globals +repo_name = 'testrepo_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout with compression 3 with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + compression => 3, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify git repo was checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/git/compression/compression_4_checkout.rb b/spec/acceptance/beaker/git/compression/compression_4_checkout.rb new file mode 100644 index 0000000..f6fb5ec --- /dev/null +++ b/spec/acceptance/beaker/git/compression/compression_4_checkout.rb @@ -0,0 +1,39 @@ +test_name 'C3499 - checkout with compression 4' + +# Globals +repo_name = 'testrepo_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout with compression 4 with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + compression => 4, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify git repo was checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/git/compression/compression_5_checkout.rb b/spec/acceptance/beaker/git/compression/compression_5_checkout.rb new file mode 100644 index 0000000..a09507c --- /dev/null +++ b/spec/acceptance/beaker/git/compression/compression_5_checkout.rb @@ -0,0 +1,39 @@ +test_name 'C3500 - checkout with compression 5' + +# Globals +repo_name = 'testrepo_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout with compression 5 with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + compression => 5, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify git repo was checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/git/compression/compression_6_checkout.rb b/spec/acceptance/beaker/git/compression/compression_6_checkout.rb new file mode 100644 index 0000000..0a2d5d5 --- /dev/null +++ b/spec/acceptance/beaker/git/compression/compression_6_checkout.rb @@ -0,0 +1,39 @@ +test_name 'C3501 - checkout with compression 6' + +# Globals +repo_name = 'testrepo_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout with compression 6 with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + compression => 6, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify git repo was checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/git/compression/negative/compression_7_checkout.rb b/spec/acceptance/beaker/git/compression/negative/compression_7_checkout.rb new file mode 100644 index 0000000..a6be973 --- /dev/null +++ b/spec/acceptance/beaker/git/compression/negative/compression_7_checkout.rb @@ -0,0 +1,39 @@ +test_name 'C3503 - checkout with compression 7' + +# Globals +repo_name = 'testrepo_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout with compression 7 with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + compression => 7, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify git repo was checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/git/compression/negative/compression_alpha_checkout.rb b/spec/acceptance/beaker/git/compression/negative/compression_alpha_checkout.rb new file mode 100644 index 0000000..8acdb57 --- /dev/null +++ b/spec/acceptance/beaker/git/compression/negative/compression_alpha_checkout.rb @@ -0,0 +1,39 @@ +test_name 'C3505 - checkout with compression alpha' + +# Globals +repo_name = 'testrepo_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout with compression alpha with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + compression => abcde, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify git repo was checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/git/compression/negative/compression_eval_checkout.rb b/spec/acceptance/beaker/git/compression/negative/compression_eval_checkout.rb new file mode 100644 index 0000000..5597646 --- /dev/null +++ b/spec/acceptance/beaker/git/compression/negative/compression_eval_checkout.rb @@ -0,0 +1,39 @@ +test_name 'C3504 - checkout with compression 10-5' + +# Globals +repo_name = 'testrepo_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout with compression 10-5 with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + compression => 10-5, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify git repo was checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/git/compression/negative/compression_exec_checkout.rb b/spec/acceptance/beaker/git/compression/negative/compression_exec_checkout.rb new file mode 100644 index 0000000..de95838 --- /dev/null +++ b/spec/acceptance/beaker/git/compression/negative/compression_exec_checkout.rb @@ -0,0 +1,39 @@ +test_name 'C3506 - checkout with compression exec' + +# Globals +repo_name = 'testrepo_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout with compression exec with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + compression => `exec rm -rf /tmp`, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify git repo was checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/git/compression/negative/compression_negative_checkout.rb b/spec/acceptance/beaker/git/compression/negative/compression_negative_checkout.rb new file mode 100644 index 0000000..b89f6f6 --- /dev/null +++ b/spec/acceptance/beaker/git/compression/negative/compression_negative_checkout.rb @@ -0,0 +1,39 @@ +test_name 'C3502 - checkout with compression -1' + +# Globals +repo_name = 'testrepo_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout with compression -1 with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + compression => -1, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify git repo was checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/git/create/create_bare_repo_that_already_exists.rb b/spec/acceptance/beaker/git/create/create_bare_repo_that_already_exists.rb new file mode 100644 index 0000000..663c758 --- /dev/null +++ b/spec/acceptance/beaker/git/create/create_bare_repo_that_already_exists.rb @@ -0,0 +1,35 @@ +test_name 'C3472 - create bare repo that already exists' + +# Globals +repo_name = 'testrepo_bare_repo_already_exists.git' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create bare repo' do + install_package(host, 'git') + on(host, "mkdir #{tmpdir}/#{repo_name}") + on(host, "cd #{tmpdir}/#{repo_name} && git --bare init") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'create bare repo that already exists using puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => bare, + provider => git, + } + EOS + + apply_manifest_on(host, pp) + end + + step 'verify repo does not contain .git directory' do + on(host, "ls -al #{tmpdir}/#{repo_name}") do |res| + fail_test "found .git for #{repo_name}" if res.stdout.include? ".git" + end + end + +end diff --git a/spec/acceptance/beaker/git/create/create_repo_that_already_exists.rb b/spec/acceptance/beaker/git/create/create_repo_that_already_exists.rb new file mode 100644 index 0000000..b1cdeae --- /dev/null +++ b/spec/acceptance/beaker/git/create/create_repo_that_already_exists.rb @@ -0,0 +1,37 @@ +test_name 'C3470 - create repo that already exists' + +# Globals +repo_name = 'testrepo_already_exists' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + on(host, "cd #{tmpdir} && git clone file://#{tmpdir}/testrepo.git #{repo_name}") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'create repo that already exists using puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + provider => git, + } + EOS + + apply_manifest_on(host, pp) + end + + step 'verify repo is on master branch' do + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + assert_match(/ref: refs\/heads\/master/, stdout, "Git checkout not on master on #{host}") + end + end + +end diff --git a/spec/acceptance/beaker/git/create/negative/create_bare_repo_specifying_revision.rb b/spec/acceptance/beaker/git/create/negative/create_bare_repo_specifying_revision.rb new file mode 100644 index 0000000..6a12c8c --- /dev/null +++ b/spec/acceptance/beaker/git/create/negative/create_bare_repo_specifying_revision.rb @@ -0,0 +1,34 @@ +test_name 'C3473 - create bare repo specifying revision' + +# Globals +repo_name = 'testrepo_bare.git' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup' do + install_package(host, 'git') + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'create bare repo specifying revision using puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => bare, + revision => master, + provider => git, + } + EOS + + apply_manifest_on(host, pp, :acceptable_exit_codes => [1]) + end + + step 'verify repo was NOT created' do + on(host, "ls -al #{tmpdir}") do |res| + fail_test "found #{repo_name}" if res.stdout.include? "#{repo_name}" + end + end + +end diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_file.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_file.rb new file mode 100644 index 0000000..6913bd5 --- /dev/null +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_file.rb @@ -0,0 +1,49 @@ +test_name 'C3487 - checkout as a group (file protocol)' + +# Globals +repo_name = 'testrepo_group_checkout' +group = 'mygroup' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - create group' do + apply_manifest_on(host, "group { '#{group}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "group { '#{group}': ensure => absent, }") + end + + step 'checkout as a group with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + group => '#{group}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is own by group #{group}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}" + end + end + +end diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_file_path.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_file_path.rb new file mode 100644 index 0000000..6701dda --- /dev/null +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_file_path.rb @@ -0,0 +1,49 @@ +test_name 'C3486 - checkout as a group (file path)' + +# Globals +repo_name = 'testrepo_group_checkout' +group = 'mygroup' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - create group' do + apply_manifest_on(host, "group { '#{group}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "group { '#{group}': ensure => absent, }") + end + + step 'checkout a group with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "#{tmpdir}/testrepo.git", + provider => git, + group => '#{group}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is own by group #{group}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}" + end + end + +end diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb new file mode 100644 index 0000000..4752e5d --- /dev/null +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb @@ -0,0 +1,54 @@ +test_name 'C3485 - checkout as a group (git protocol)' + +# Globals +repo_name = 'testrepo_group_checkout' +group = 'mygroup' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start git daemon' do + install_package(host, 'git-daemon') + on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") + end + + step 'setup - create group' do + apply_manifest_on(host, "group { '#{group}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'pkill -9 git-daemon') + apply_manifest_on(host, "group { '#{group}': ensure => absent, }") + end + + step 'checkout a group with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "git://#{host}/testrepo.git", + provider => git, + group => '#{group}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is own by group #{group}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}" + end + end + +end diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb new file mode 100644 index 0000000..5c05baa --- /dev/null +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb @@ -0,0 +1,61 @@ +test_name 'C3490 - checkout as a group (http protocol)' + +# Globals +repo_name = 'testrepo_group_checkout' +group = 'mygroup' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - start http server' do + http_daemon =<<-EOF + require 'webrick' + server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) + on(host, "ruby /tmp/http_daemon.rb") + end + + step 'setup - create group' do + apply_manifest_on(host, "group { '#{group}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + apply_manifest_on(host, "group { '#{group}': ensure => absent, }") + end + + step 'checkout a group with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "http://#{host}:8000/testrepo.git", + provider => git, + group => '#{group}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is own by group #{group}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}" + end + end + +end diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb new file mode 100644 index 0000000..4551aee --- /dev/null +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb @@ -0,0 +1,68 @@ +test_name 'C3491 - checkout as a group (https protocol)' + +# Globals +repo_name = 'testrepo_group_checkout' +group = 'mygroup' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start https server' do + https_daemon =<<-EOF + require 'webrick' + require 'webrick/https' + server = WEBrick::HTTPServer.new( + :Port => 8443, + :DocumentRoot => "#{tmpdir}", + :SSLEnable => true, + :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, + :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), + :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), + :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) + #on(host, "ruby /tmp/https_daemon.rb") + end + + step 'setup - create group' do + apply_manifest_on(host, "group { '#{group}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + apply_manifest_on(host, "group { '#{group}': ensure => absent, }") + end + + step 'checkout as a group with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "https://github.com/johnduarte/testrepo.git", + provider => git, + group => '#{group}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is own by group #{group}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}" + end + end + +end diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_ssh.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_ssh.rb new file mode 100644 index 0000000..1255864 --- /dev/null +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_ssh.rb @@ -0,0 +1,59 @@ +test_name 'C3489 - checkout as a group (ssh protocol)' + +# Globals +repo_name = 'testrepo_group_checkout' +group = 'mygroup' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - establish ssh keys' do + # create ssh keys + on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') + on(host, 'chown -R root:root /root/.ssh') + end + + step 'setup - create group' do + apply_manifest_on(host, "group { '#{group}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + apply_manifest_on(host, "group { '#{group}': ensure => absent, }") + end + + step 'checkout as a group with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "ssh://root@#{host}#{tmpdir}/testrepo.git", + provider => git, + group => '#{group}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is own by group #{group}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}" + end + end + +end diff --git a/spec/acceptance/beaker/git/group_checkout/negative/group_checkout_file_non_existent_group.rb b/spec/acceptance/beaker/git/group_checkout/negative/group_checkout_file_non_existent_group.rb new file mode 100644 index 0000000..5bce264 --- /dev/null +++ b/spec/acceptance/beaker/git/group_checkout/negative/group_checkout_file_non_existent_group.rb @@ -0,0 +1,48 @@ +test_name 'C3484 - checkout as a group that is not on system' + +# Globals +repo_name = 'testrepo_group_checkout' +group = 'mygroup' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - delete group' do + apply_manifest_on(host, "group { '#{group}': ensure => absent, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout as a group with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + group => '#{group}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is NOT owned by group #{group}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by group') if res.stdout.include? ":#{group}" + end + end + +end diff --git a/spec/acceptance/beaker/git/revision_checkout/negative/revision_checkout_not_exists.rb b/spec/acceptance/beaker/git/revision_checkout/negative/revision_checkout_not_exists.rb new file mode 100644 index 0000000..d1ee531 --- /dev/null +++ b/spec/acceptance/beaker/git/revision_checkout/negative/revision_checkout_not_exists.rb @@ -0,0 +1,43 @@ +test_name 'C3614 - checkout a revision that does not exist' + +# Globals +repo_name = 'testrepo_revision_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout revision that does not exist with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + revision => '11111111111111111', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify that master revision is checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('revision not found') unless res.stdout.include? "ref: refs/heads/master" + end + end + +end diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file.rb new file mode 100644 index 0000000..3ff44ec --- /dev/null +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file.rb @@ -0,0 +1,49 @@ +test_name 'C3452 - checkout a revision (file protocol)' + +# Globals +repo_name = 'testrepo_revision_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'get revision sha from repo' do + on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| + @sha = res.stdout.chomp + end + end + + step 'checkout a revision with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + revision => '#{@sha}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + stop "verify repo is checked out to revision #{sha}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('revision not found') unless res.stdout.include? "#{@sha}" + end + end + +end diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file_path.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file_path.rb new file mode 100644 index 0000000..cd92139 --- /dev/null +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file_path.rb @@ -0,0 +1,49 @@ +test_name 'C3451 - checkout a revision (file path)' + +# Globals +repo_name = 'testrepo_revision_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'get revision sha from repo' do + on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| + @sha = res.stdout.chomp + end + end + + step 'checkout a revision with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "#{tmpdir}/testrepo.git", + provider => git, + revision => '#{@sha}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + stop "verify repo is checked out to revision #{sha}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('revision not found') unless res.stdout.include? "#{@sha}" + end + end + +end diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb new file mode 100644 index 0000000..6979df3 --- /dev/null +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb @@ -0,0 +1,54 @@ +test_name 'C3450 - checkout a revision (git protocol)' + +# Globals +repo_name = 'testrepo_revision_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start git daemon' do + install_package(host, 'git-daemon') + on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'pkill -9 git-daemon') + end + + step 'get revision sha from repo' do + on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| + @sha = res.stdout.chomp + end + end + + step 'checkout a revision with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "git://#{host}/testrepo.git", + provider => git, + revision => '#{@sha}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is set to revision #{@sha}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('revision not found') unless res.stdout.include? "#{@sha}" + end + end + +end diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb new file mode 100644 index 0000000..40db6c9 --- /dev/null +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb @@ -0,0 +1,61 @@ +test_name 'C3455 - checkout a revision (http protocol)' + +# Globals +repo_name = 'testrepo_revision_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - start http server' do + http_daemon =<<-EOF + require 'webrick' + server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) + on(host, "ruby /tmp/http_daemon.rb") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + end + + step 'get revision sha from repo' do + on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| + @sha = res.stdout.chomp + end + end + + step 'checkout a revision with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "http://#{host}:8000/testrepo.git", + provider => git, + revision => '#{@sha}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is set to revision #{@sha}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('revision not found') unless res.stdout.include? "#{@sha}" + end + end + +end diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb new file mode 100644 index 0000000..dc3dc7f --- /dev/null +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb @@ -0,0 +1,69 @@ +test_name 'C3456 - checkout a revision (https protocol)' + +# Globals +repo_name = 'testrepo_revision_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start https server' do + https_daemon =<<-EOF + require 'webrick' + require 'webrick/https' + server = WEBrick::HTTPServer.new( + :Port => 8443, + :DocumentRoot => "#{tmpdir}", + :SSLEnable => true, + :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, + :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), + :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), + :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) + #on(host, "ruby /tmp/https_daemon.rb") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + end + + step 'get revision sha from repo' do + on(host, "git clone https://github.com/johnduarte/testrepo.git #{tmpdir}/foo") + on(host, "git --git-dir=#{tmpdir}/foo/.git rev-list HEAD | tail -1") do |res| + @sha = res.stdout.chomp + end + end + + step 'checkout a revision with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "https://github.com/johnduarte/testrepo.git", + provider => git, + revision => '#{@sha}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is set to revision #{@sha}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('revision not found') unless res.stdout.include? "#{@sha}" + end + end + +end diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_ssh.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_ssh.rb new file mode 100644 index 0000000..24b507e --- /dev/null +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_ssh.rb @@ -0,0 +1,59 @@ +test_name 'C3454 - checkout a revision (ssh protocol)' + +# Globals +repo_name = 'testrepo_revision_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - establish ssh keys' do + # create ssh keys + on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') + on(host, 'chown -R root:root /root/.ssh') + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + end + + step 'get revision sha from repo' do + on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| + @sha = res.stdout.chomp + end + end + + step 'checkout a revision with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "ssh://root@#{host}#{tmpdir}/testrepo.git", + provider => git, + revision => '#{@sha}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is set to revision #{@sha}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('revision not found') unless res.stdout.include? "#{@sha}" + end + end + +end diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_hostile_depth.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_hostile_depth.rb new file mode 100644 index 0000000..0a4b467 --- /dev/null +++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_hostile_depth.rb @@ -0,0 +1,39 @@ +test_name 'C3608 - shallow clone repo depth hostile input' + +# Globals +repo_name = 'testrepo_shallow_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'shallow clone repo with puppet (bad input ignored, full clone checkedout)' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + depth => 'rm -rf /tmp', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify checkout is NOT shallow' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('shallow not found') if res.stdout.include? "shallow" + end + end + +end diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_negative_depth.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_negative_depth.rb new file mode 100644 index 0000000..2ba1f0f --- /dev/null +++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_negative_depth.rb @@ -0,0 +1,39 @@ +test_name 'C3607 - shallow clone repo depth = -1' + +# Globals +repo_name = 'testrepo_shallow_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'shallow clone repo with puppet (bad input ignored, full clone checkedout)' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + depth => -1, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify checkout is NOT shallow' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('shallow not found') if res.stdout.include? "shallow" + end + end + +end diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_overflow_depth.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_overflow_depth.rb new file mode 100644 index 0000000..55ff878 --- /dev/null +++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_overflow_depth.rb @@ -0,0 +1,39 @@ +test_name 'C3606 - shallow clone repo depth overflow 64bit integer' + +# Globals +repo_name = 'testrepo_shallow_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'shallow clone repo with puppet (bad input ignored, full clone checkedout)' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + depth => 18446744073709551616, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify checkout is NOT shallow' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('shallow not found') if res.stdout.include? "shallow" + end + end + +end diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_file.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_file.rb new file mode 100644 index 0000000..52eb3d2 --- /dev/null +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_file.rb @@ -0,0 +1,43 @@ +test_name 'C3476 - shallow clone repo minimal depth = 1 (file protocol)' + +# Globals +repo_name = 'testrepo_shallow_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'shallow clone repo with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + depth => 1, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify checkout is shallow and of the correct depth' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('shallow not found') unless res.stdout.include? "shallow" + end + + on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| + fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" + end + end + +end diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_file_path.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_file_path.rb new file mode 100644 index 0000000..d9d18ce --- /dev/null +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_file_path.rb @@ -0,0 +1,43 @@ +test_name 'C3475 - shallow clone repo minimal depth = 1 (file path protocol)' + +# Globals +repo_name = 'testrepo_shallow_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'shallow clone repo with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "#{tmpdir}/testrepo.git", + provider => git, + depth => 1, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify checkout is shallow and of the correct depth' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('shallow not found') unless res.stdout.include? "shallow" + end + + on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| + fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" + end + end + +end diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb new file mode 100644 index 0000000..8b3a16a --- /dev/null +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb @@ -0,0 +1,48 @@ +test_name 'C3474 - shallow clone repo minimal depth = 1 (git protocol)' + +# Globals +repo_name = 'testrepo_shallow_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start git daemon' do + install_package(host, 'git-daemon') + on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'pkill -9 git-daemon') + end + + step 'shallow clone repo with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "git://#{host}/testrepo.git", + provider => git, + depth => 1, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify checkout is shallow and of the correct depth' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('shallow not found') unless res.stdout.include? "shallow" + end + + on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| + fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" + end + end + +end diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_http.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_http.rb new file mode 100644 index 0000000..ad7e30e --- /dev/null +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_http.rb @@ -0,0 +1,55 @@ +test_name 'C3479 - shallow clone repo minimal depth = 1 (http protocol)' + +# Globals +repo_name = 'testrepo_shallow_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - start http server' do + http_daemon =<<-EOF + require 'webrick' + server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) + on(host, "ruby /tmp/http_daemon.rb") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + end + + step 'shallow clone repo with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "http://#{host}:8000/testrepo.git", + provider => git, + depth => 1, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify checkout is shallow and of the correct depth' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('shallow not found') unless res.stdout.include? "shallow" + end + + on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| + fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" + end + end + +end diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb new file mode 100644 index 0000000..e016e55 --- /dev/null +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb @@ -0,0 +1,62 @@ +test_name 'C3480 - shallow clone repo minimal depth = 1 (https protocol)' + +# Globals +repo_name = 'testrepo_shallow_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start https server' do + https_daemon =<<-EOF + require 'webrick' + require 'webrick/https' + server = WEBrick::HTTPServer.new( + :Port => 8443, + :DocumentRoot => "#{tmpdir}", + :SSLEnable => true, + :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, + :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), + :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), + :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) + #on(host, "ruby /tmp/https_daemon.rb") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + end + + step 'shallow clone repo with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "https://github.com/johnduarte/testrepo.git", + provider => git, + depth => 1, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify checkout is shallow and of the correct depth' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('shallow not found') unless res.stdout.include? "shallow" + end + + on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| + fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" + end + end + +end diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_ssh.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_ssh.rb new file mode 100644 index 0000000..fda9bf4 --- /dev/null +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_ssh.rb @@ -0,0 +1,53 @@ +test_name 'C3477 - shallow clone repo minimal depth = 1 (ssh protocol)' + +# Globals +repo_name = 'testrepo_shallow_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - establish ssh keys' do + # create ssh keys + on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') + on(host, 'chown -R root:root /root/.ssh') + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + end + + step 'shallow clone repo with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "ssh://root@#{host}#{tmpdir}/testrepo.git", + provider => git, + depth => 1, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify checkout is shallow and of the correct depth' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('shallow not found') unless res.stdout.include? "shallow" + end + + on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| + fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" + end + end + +end diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_zero_depth.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_zero_depth.rb new file mode 100644 index 0000000..6cec2a1 --- /dev/null +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_zero_depth.rb @@ -0,0 +1,39 @@ +test_name 'C3404 - shallow clone repo depth = 0 non shallow' + +# Globals +repo_name = 'testrepo_shallow_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'shallow clone repo with puppet (zero depth means not shallow)' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + depth => 0, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify checkout is NOT shallow' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('shallow found') if res.stdout.include? "shallow" + end + end + +end diff --git a/spec/acceptance/beaker/git/tag_checkout/negative/tag_checkout_not_exists.rb b/spec/acceptance/beaker/git/tag_checkout/negative/tag_checkout_not_exists.rb new file mode 100644 index 0000000..5869513 --- /dev/null +++ b/spec/acceptance/beaker/git/tag_checkout/negative/tag_checkout_not_exists.rb @@ -0,0 +1,43 @@ +test_name 'C3612 - checkout a tag that does not exist' + +# Globals +repo_name = 'testrepo_tag_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout tag that does not exist with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + tag => '11111111111111111', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify that master tag is checked out' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('tag not found') unless res.stdout.include? "ref: refs/heads/master" + end + end + +end diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file.rb new file mode 100644 index 0000000..4ab8a6a --- /dev/null +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file.rb @@ -0,0 +1,44 @@ +test_name 'C3445 - checkout a tag (file protocol)' + +# Globals +repo_name = 'testrepo_tag_checkout' +tag = '0.0.2' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout a tag with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + revision => '#{tag}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout out tag is #{tag}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res| + fail_test('tag not found') unless res.stdout.include? "#{tag}" + end + end + +end diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file_path.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file_path.rb new file mode 100644 index 0000000..f73d4f9 --- /dev/null +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file_path.rb @@ -0,0 +1,44 @@ +test_name 'C3444 - checkout a tag (file path)' + +# Globals +repo_name = 'testrepo_tag_checkout' +tag = '0.0.2' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout a tag with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "#{tmpdir}/testrepo.git", + provider => git, + revision => '#{tag}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout out tag is #{tag}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res| + fail_test('tag not found') unless res.stdout.include? "#{tag}" + end + end + +end diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb new file mode 100644 index 0000000..9ec124d --- /dev/null +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb @@ -0,0 +1,55 @@ +test_name 'C3443 - checkout a tag (git protocol)' + +# Globals +repo_name = 'testrepo_tag_checkout' +tag = '0.0.2' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start git daemon' do + install_package(host, 'git-daemon') + on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'pkill -9 git-daemon') + end + + step 'get tag sha from repo' do + on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| + @sha = res.stdout.chomp + end + end + + step 'checkout a tag with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "git://#{host}/testrepo.git", + provider => git, + revision => '#{tag}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout out tag is #{tag}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res| + fail_test('tag not found') unless res.stdout.include? "#{tag}" + end + end + +end diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb new file mode 100644 index 0000000..3a6d33f --- /dev/null +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb @@ -0,0 +1,62 @@ +test_name 'C3448 - checkout a tag (http protocol)' + +# Globals +repo_name = 'testrepo_tag_checkout' +tag = '0.0.2' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - start http server' do + http_daemon =<<-EOF + require 'webrick' + server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) + on(host, "ruby /tmp/http_daemon.rb") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + end + + step 'get tag sha from repo' do + on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| + @sha = res.stdout.chomp + end + end + + step 'checkout a tag with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "http://#{host}:8000/testrepo.git", + provider => git, + revision => '#{tag}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout out tag is #{tag}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res| + fail_test('tag not found') unless res.stdout.include? "#{tag}" + end + end + +end diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb new file mode 100644 index 0000000..b277d6d --- /dev/null +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb @@ -0,0 +1,69 @@ +test_name 'C3449 - checkout a tag (https protocol)' + +# Globals +repo_name = 'testrepo_tag_checkout' +tag = '0.0.2' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start https server' do + https_daemon =<<-EOF + require 'webrick' + require 'webrick/https' + server = WEBrick::HTTPServer.new( + :Port => 8443, + :DocumentRoot => "#{tmpdir}", + :SSLEnable => true, + :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, + :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), + :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), + :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) + #on(host, "ruby /tmp/https_daemon.rb") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + end + + step 'get tag sha from repo' do + on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| + @sha = res.stdout.chomp + end + end + + step 'checkout a tag with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "https://github.com/johnduarte/testrepo.git", + provider => git, + revision => '#{tag}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout out tag is #{tag}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res| + fail_test('tag not found') unless res.stdout.include? "#{tag}" + end + end + +end diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_ssh.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_ssh.rb new file mode 100644 index 0000000..f57f605 --- /dev/null +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_ssh.rb @@ -0,0 +1,60 @@ +test_name 'C3447 - checkout a tag (ssh protocol)' + +# Globals +repo_name = 'testrepo_tag_checkout' +tag = '0.0.2' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - establish ssh keys' do + # create ssh keys + on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') + on(host, 'chown -R root:root /root/.ssh') + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + end + + step 'get tag sha from repo' do + on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| + @sha = res.stdout.chomp + end + end + + step 'checkout a tag with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "ssh://root@#{host}#{tmpdir}/testrepo.git", + provider => git, + revision => '#{tag}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout out tag is #{tag}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res| + fail_test('tag not found') unless res.stdout.include? "#{tag}" + end + end + +end diff --git a/spec/acceptance/beaker/git/user_checkout/negative/user_checkout_file_non_existent_user.rb b/spec/acceptance/beaker/git/user_checkout/negative/user_checkout_file_non_existent_user.rb new file mode 100644 index 0000000..98099ee --- /dev/null +++ b/spec/acceptance/beaker/git/user_checkout/negative/user_checkout_file_non_existent_user.rb @@ -0,0 +1,48 @@ +test_name 'C3483 - checkout as a user that is not on system' + +# Globals +repo_name = 'testrepo_user_checkout' +user = 'myuser' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - delete user' do + apply_manifest_on(host, "user { '#{user}': ensure => absent, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'checkout as a user with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + owner => '#{user}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is NOT owned by user #{user}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by user') if res.stdout.include? "#{user}:" + end + end + +end diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_file.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_file.rb new file mode 100644 index 0000000..9920b0b --- /dev/null +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_file.rb @@ -0,0 +1,49 @@ +test_name 'C3459 - checkout as a user (file protocol)' + +# Globals +repo_name = 'testrepo_user_checkout' +user = 'myuser' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - create user' do + apply_manifest_on(host, "user { '#{user}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "user { '#{user}': ensure => absent, }") + end + + step 'checkout as a user with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + owner => '#{user}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is owned by user #{user}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:" + end + end + +end diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_file_path.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_file_path.rb new file mode 100644 index 0000000..1817229 --- /dev/null +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_file_path.rb @@ -0,0 +1,49 @@ +test_name 'C3458 - checkout as a user (file path)' + +# Globals +repo_name = 'testrepo_user_checkout' +user = 'myuser' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - create user' do + apply_manifest_on(host, "user { '#{user}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "user { '#{user}': ensure => absent, }") + end + + step 'checkout a user with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "#{tmpdir}/testrepo.git", + provider => git, + owner => '#{user}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is owned by user #{user}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:" + end + end + +end diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb new file mode 100644 index 0000000..d954a5f --- /dev/null +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb @@ -0,0 +1,54 @@ +test_name 'C3457 - checkout as a user (git protocol)' + +# Globals +repo_name = 'testrepo_user_checkout' +user = 'myuser' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start git daemon' do + install_package(host, 'git-daemon') + on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") + end + + step 'setup - create user' do + apply_manifest_on(host, "user { '#{user}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'pkill -9 git-daemon') + apply_manifest_on(host, "user { '#{user}': ensure => absent, }") + end + + step 'checkout a user with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "git://#{host}/testrepo.git", + provider => git, + owner => '#{user}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is owned by user #{user}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:" + end + end + +end diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb new file mode 100644 index 0000000..6faad95 --- /dev/null +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb @@ -0,0 +1,61 @@ +test_name 'C3462 - checkout as a user (http protocol)' + +# Globals +repo_name = 'testrepo_user_checkout' +user = 'myuser' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - start http server' do + http_daemon =<<-EOF + require 'webrick' + server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) + on(host, "ruby /tmp/http_daemon.rb") + end + + step 'setup - create user' do + apply_manifest_on(host, "user { '#{user}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + apply_manifest_on(host, "user { '#{user}': ensure => absent, }") + end + + step 'checkout a user with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "http://#{host}:8000/testrepo.git", + provider => git, + owner => '#{user}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is owned by user #{user}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:" + end + end + +end diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb new file mode 100644 index 0000000..28a17b8 --- /dev/null +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb @@ -0,0 +1,68 @@ +test_name 'C3463 - checkout as a user (https protocol)' + +# Globals +repo_name = 'testrepo_user_checkout' +user = 'myuser' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start https server' do + https_daemon =<<-EOF + require 'webrick' + require 'webrick/https' + server = WEBrick::HTTPServer.new( + :Port => 8443, + :DocumentRoot => "#{tmpdir}", + :SSLEnable => true, + :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, + :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), + :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), + :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) + #on(host, "ruby /tmp/https_daemon.rb") + end + + step 'setup - create user' do + apply_manifest_on(host, "user { '#{user}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + apply_manifest_on(host, "user { '#{user}': ensure => absent, }") + end + + step 'checkout as a user with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "https://github.com/johnduarte/testrepo.git", + provider => git, + owner => '#{user}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is owned by user #{user}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:" + end + end + +end diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_ssh.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_ssh.rb new file mode 100644 index 0000000..50c73f4 --- /dev/null +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_ssh.rb @@ -0,0 +1,59 @@ +test_name 'C3461 - checkout as a user (ssh protocol)' + +# Globals +repo_name = 'testrepo_user_checkout' +user = 'myuser' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - establish ssh keys' do + # create ssh keys + on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') + on(host, 'chown -R root:root /root/.ssh') + end + + step 'setup - create user' do + apply_manifest_on(host, "user { '#{user}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + apply_manifest_on(host, "user { '#{user}': ensure => absent, }") + end + + step 'checkout as a user with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "ssh://root@#{host}#{tmpdir}/testrepo.git", + provider => git, + owner => '#{user}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is owned by user #{user}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:" + end + end + +end diff --git a/spec/acceptance/beaker/group_checkout/group_checkout_file.rb b/spec/acceptance/beaker/group_checkout/group_checkout_file.rb deleted file mode 100644 index 469fb07..0000000 --- a/spec/acceptance/beaker/group_checkout/group_checkout_file.rb +++ /dev/null @@ -1,49 +0,0 @@ -test_name 'C3487 - checkout as a group (file protocol)' - -# Globals -repo_name = 'testrepo_group_checkout' -group = 'mygroup' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - step 'setup - create group' do - apply_manifest_on(host, "group { '#{group}': ensure => present, }") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "group { '#{group}': ensure => absent, }") - end - - step 'checkout as a group with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - group => '#{group}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify git checkout is own by group #{group}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}" - end - end - -end diff --git a/spec/acceptance/beaker/group_checkout/group_checkout_file_path.rb b/spec/acceptance/beaker/group_checkout/group_checkout_file_path.rb deleted file mode 100644 index 07510e1..0000000 --- a/spec/acceptance/beaker/group_checkout/group_checkout_file_path.rb +++ /dev/null @@ -1,49 +0,0 @@ -test_name 'C3486 - checkout as a group (file path)' - -# Globals -repo_name = 'testrepo_group_checkout' -group = 'mygroup' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - step 'setup - create group' do - apply_manifest_on(host, "group { '#{group}': ensure => present, }") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "group { '#{group}': ensure => absent, }") - end - - step 'checkout a group with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "#{tmpdir}/testrepo.git", - provider => git, - group => '#{group}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify git checkout is own by group #{group}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}" - end - end - -end diff --git a/spec/acceptance/beaker/group_checkout/group_checkout_git.rb b/spec/acceptance/beaker/group_checkout/group_checkout_git.rb deleted file mode 100644 index df7ec09..0000000 --- a/spec/acceptance/beaker/group_checkout/group_checkout_git.rb +++ /dev/null @@ -1,54 +0,0 @@ -test_name 'C3485 - checkout as a group (git protocol)' - -# Globals -repo_name = 'testrepo_group_checkout' -group = 'mygroup' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - step 'setup - start git daemon' do - install_package(host, 'git-daemon') - on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") - end - - step 'setup - create group' do - apply_manifest_on(host, "group { '#{group}': ensure => present, }") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - on(host, 'pkill -9 git-daemon') - apply_manifest_on(host, "group { '#{group}': ensure => absent, }") - end - - step 'checkout a group with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "git://#{host}/testrepo.git", - provider => git, - group => '#{group}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify git checkout is own by group #{group}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}" - end - end - -end diff --git a/spec/acceptance/beaker/group_checkout/group_checkout_http.rb b/spec/acceptance/beaker/group_checkout/group_checkout_http.rb deleted file mode 100644 index 96e0205..0000000 --- a/spec/acceptance/beaker/group_checkout/group_checkout_http.rb +++ /dev/null @@ -1,61 +0,0 @@ -test_name 'C3490 - checkout as a group (http protocol)' - -# Globals -repo_name = 'testrepo_group_checkout' -group = 'mygroup' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - step 'setup - start http server' do - http_daemon =<<-EOF - require 'webrick' - server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") - WEBrick::Daemon.start - server.start - EOF - create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) - on(host, "ruby /tmp/http_daemon.rb") - end - - step 'setup - create group' do - apply_manifest_on(host, "group { '#{group}': ensure => present, }") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') - apply_manifest_on(host, "group { '#{group}': ensure => absent, }") - end - - step 'checkout a group with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "http://#{host}:8000/testrepo.git", - provider => git, - group => '#{group}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify git checkout is own by group #{group}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}" - end - end - -end diff --git a/spec/acceptance/beaker/group_checkout/group_checkout_https.rb b/spec/acceptance/beaker/group_checkout/group_checkout_https.rb deleted file mode 100644 index 7fe4e96..0000000 --- a/spec/acceptance/beaker/group_checkout/group_checkout_https.rb +++ /dev/null @@ -1,68 +0,0 @@ -test_name 'C3491 - checkout as a group (https protocol)' - -# Globals -repo_name = 'testrepo_group_checkout' -group = 'mygroup' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - step 'setup - start https server' do - https_daemon =<<-EOF - require 'webrick' - require 'webrick/https' - server = WEBrick::HTTPServer.new( - :Port => 8443, - :DocumentRoot => "#{tmpdir}", - :SSLEnable => true, - :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, - :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), - :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), - :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) - WEBrick::Daemon.start - server.start - EOF - create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) - #on(host, "ruby /tmp/https_daemon.rb") - end - - step 'setup - create group' do - apply_manifest_on(host, "group { '#{group}': ensure => present, }") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') - apply_manifest_on(host, "group { '#{group}': ensure => absent, }") - end - - step 'checkout as a group with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "https://github.com/johnduarte/testrepo.git", - provider => git, - group => '#{group}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify git checkout is own by group #{group}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}" - end - end - -end diff --git a/spec/acceptance/beaker/group_checkout/group_checkout_ssh.rb b/spec/acceptance/beaker/group_checkout/group_checkout_ssh.rb deleted file mode 100644 index 2ede1ef..0000000 --- a/spec/acceptance/beaker/group_checkout/group_checkout_ssh.rb +++ /dev/null @@ -1,59 +0,0 @@ -test_name 'C3489 - checkout as a group (ssh protocol)' - -# Globals -repo_name = 'testrepo_group_checkout' -group = 'mygroup' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - step 'setup - establish ssh keys' do - # create ssh keys - on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') - - # copy public key to authorized_keys - on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') - on(host, 'chown -R root:root /root/.ssh') - end - - step 'setup - create group' do - apply_manifest_on(host, "group { '#{group}': ensure => present, }") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") - apply_manifest_on(host, "group { '#{group}': ensure => absent, }") - end - - step 'checkout as a group with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "ssh://root@#{host}#{tmpdir}/testrepo.git", - provider => git, - group => '#{group}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify git checkout is own by group #{group}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}" - end - end - -end diff --git a/spec/acceptance/beaker/group_checkout/negative/group_checkout_file_non_existent_group.rb b/spec/acceptance/beaker/group_checkout/negative/group_checkout_file_non_existent_group.rb deleted file mode 100644 index 85757aa..0000000 --- a/spec/acceptance/beaker/group_checkout/negative/group_checkout_file_non_existent_group.rb +++ /dev/null @@ -1,48 +0,0 @@ -test_name 'C3484 - checkout as a group that is not on system' - -# Globals -repo_name = 'testrepo_group_checkout' -group = 'mygroup' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - step 'setup - delete group' do - apply_manifest_on(host, "group { '#{group}': ensure => absent, }") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'checkout as a group with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - group => '#{group}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify git checkout is NOT owned by group #{group}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('checkout not owned by group') if res.stdout.include? ":#{group}" - end - end - -end diff --git a/spec/acceptance/beaker/revision_checkout/negative/revision_checkout_not_exists.rb b/spec/acceptance/beaker/revision_checkout/negative/revision_checkout_not_exists.rb deleted file mode 100644 index e4af1b2..0000000 --- a/spec/acceptance/beaker/revision_checkout/negative/revision_checkout_not_exists.rb +++ /dev/null @@ -1,43 +0,0 @@ -test_name 'C3614 - checkout a revision that does not exist' - -# Globals -repo_name = 'testrepo_revision_checkout' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'checkout revision that does not exist with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - revision => '11111111111111111', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify that master revision is checked out' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('revision not found') unless res.stdout.include? "ref: refs/heads/master" - end - end - -end diff --git a/spec/acceptance/beaker/revision_checkout/revision_checkout_file.rb b/spec/acceptance/beaker/revision_checkout/revision_checkout_file.rb deleted file mode 100644 index 70af031..0000000 --- a/spec/acceptance/beaker/revision_checkout/revision_checkout_file.rb +++ /dev/null @@ -1,49 +0,0 @@ -test_name 'C3452 - checkout a revision (file protocol)' - -# Globals -repo_name = 'testrepo_revision_checkout' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'get revision sha from repo' do - on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| - @sha = res.stdout.chomp - end - end - - step 'checkout a revision with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - revision => '#{@sha}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - stop "verify repo is checked out to revision #{sha}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('revision not found') unless res.stdout.include? "#{@sha}" - end - end - -end diff --git a/spec/acceptance/beaker/revision_checkout/revision_checkout_file_path.rb b/spec/acceptance/beaker/revision_checkout/revision_checkout_file_path.rb deleted file mode 100644 index b5fd70a..0000000 --- a/spec/acceptance/beaker/revision_checkout/revision_checkout_file_path.rb +++ /dev/null @@ -1,49 +0,0 @@ -test_name 'C3451 - checkout a revision (file path)' - -# Globals -repo_name = 'testrepo_revision_checkout' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'get revision sha from repo' do - on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| - @sha = res.stdout.chomp - end - end - - step 'checkout a revision with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "#{tmpdir}/testrepo.git", - provider => git, - revision => '#{@sha}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - stop "verify repo is checked out to revision #{sha}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('revision not found') unless res.stdout.include? "#{@sha}" - end - end - -end diff --git a/spec/acceptance/beaker/revision_checkout/revision_checkout_git.rb b/spec/acceptance/beaker/revision_checkout/revision_checkout_git.rb deleted file mode 100644 index b34dfdc..0000000 --- a/spec/acceptance/beaker/revision_checkout/revision_checkout_git.rb +++ /dev/null @@ -1,54 +0,0 @@ -test_name 'C3450 - checkout a revision (git protocol)' - -# Globals -repo_name = 'testrepo_revision_checkout' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - step 'setup - start git daemon' do - install_package(host, 'git-daemon') - on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - on(host, 'pkill -9 git-daemon') - end - - step 'get revision sha from repo' do - on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| - @sha = res.stdout.chomp - end - end - - step 'checkout a revision with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "git://#{host}/testrepo.git", - provider => git, - revision => '#{@sha}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify checkout is set to revision #{@sha}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('revision not found') unless res.stdout.include? "#{@sha}" - end - end - -end diff --git a/spec/acceptance/beaker/revision_checkout/revision_checkout_http.rb b/spec/acceptance/beaker/revision_checkout/revision_checkout_http.rb deleted file mode 100644 index debbb01..0000000 --- a/spec/acceptance/beaker/revision_checkout/revision_checkout_http.rb +++ /dev/null @@ -1,61 +0,0 @@ -test_name 'C3455 - checkout a revision (http protocol)' - -# Globals -repo_name = 'testrepo_revision_checkout' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - step 'setup - start http server' do - http_daemon =<<-EOF - require 'webrick' - server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") - WEBrick::Daemon.start - server.start - EOF - create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) - on(host, "ruby /tmp/http_daemon.rb") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') - end - - step 'get revision sha from repo' do - on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| - @sha = res.stdout.chomp - end - end - - step 'checkout a revision with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "http://#{host}:8000/testrepo.git", - provider => git, - revision => '#{@sha}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify checkout is set to revision #{@sha}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('revision not found') unless res.stdout.include? "#{@sha}" - end - end - -end diff --git a/spec/acceptance/beaker/revision_checkout/revision_checkout_https.rb b/spec/acceptance/beaker/revision_checkout/revision_checkout_https.rb deleted file mode 100644 index c062316..0000000 --- a/spec/acceptance/beaker/revision_checkout/revision_checkout_https.rb +++ /dev/null @@ -1,69 +0,0 @@ -test_name 'C3456 - checkout a revision (https protocol)' - -# Globals -repo_name = 'testrepo_revision_checkout' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - step 'setup - start https server' do - https_daemon =<<-EOF - require 'webrick' - require 'webrick/https' - server = WEBrick::HTTPServer.new( - :Port => 8443, - :DocumentRoot => "#{tmpdir}", - :SSLEnable => true, - :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, - :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), - :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), - :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) - WEBrick::Daemon.start - server.start - EOF - create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) - #on(host, "ruby /tmp/https_daemon.rb") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') - end - - step 'get revision sha from repo' do - on(host, "git clone https://github.com/johnduarte/testrepo.git #{tmpdir}/foo") - on(host, "git --git-dir=#{tmpdir}/foo/.git rev-list HEAD | tail -1") do |res| - @sha = res.stdout.chomp - end - end - - step 'checkout a revision with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "https://github.com/johnduarte/testrepo.git", - provider => git, - revision => '#{@sha}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify checkout is set to revision #{@sha}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('revision not found') unless res.stdout.include? "#{@sha}" - end - end - -end diff --git a/spec/acceptance/beaker/revision_checkout/revision_checkout_ssh.rb b/spec/acceptance/beaker/revision_checkout/revision_checkout_ssh.rb deleted file mode 100644 index 7a0991c..0000000 --- a/spec/acceptance/beaker/revision_checkout/revision_checkout_ssh.rb +++ /dev/null @@ -1,59 +0,0 @@ -test_name 'C3454 - checkout a revision (ssh protocol)' - -# Globals -repo_name = 'testrepo_revision_checkout' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - step 'setup - establish ssh keys' do - # create ssh keys - on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') - - # copy public key to authorized_keys - on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') - on(host, 'chown -R root:root /root/.ssh') - end - - teardown do - on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") - end - - step 'get revision sha from repo' do - on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| - @sha = res.stdout.chomp - end - end - - step 'checkout a revision with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "ssh://root@#{host}#{tmpdir}/testrepo.git", - provider => git, - revision => '#{@sha}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify checkout is set to revision #{@sha}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('revision not found') unless res.stdout.include? "#{@sha}" - end - end - -end diff --git a/spec/acceptance/beaker/shallow_clone/negative/shallow_clone_hostile_depth.rb b/spec/acceptance/beaker/shallow_clone/negative/shallow_clone_hostile_depth.rb deleted file mode 100644 index 9c63716..0000000 --- a/spec/acceptance/beaker/shallow_clone/negative/shallow_clone_hostile_depth.rb +++ /dev/null @@ -1,39 +0,0 @@ -test_name 'C3608 - shallow clone repo depth hostile input' - -# Globals -repo_name = 'testrepo_shallow_clone' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'shallow clone repo with puppet (bad input ignored, full clone checkedout)' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - depth => 'rm -rf /tmp', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify checkout is NOT shallow' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('shallow not found') if res.stdout.include? "shallow" - end - end - -end diff --git a/spec/acceptance/beaker/shallow_clone/negative/shallow_clone_negative_depth.rb b/spec/acceptance/beaker/shallow_clone/negative/shallow_clone_negative_depth.rb deleted file mode 100644 index 10b0559..0000000 --- a/spec/acceptance/beaker/shallow_clone/negative/shallow_clone_negative_depth.rb +++ /dev/null @@ -1,39 +0,0 @@ -test_name 'C3607 - shallow clone repo depth = -1' - -# Globals -repo_name = 'testrepo_shallow_clone' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'shallow clone repo with puppet (bad input ignored, full clone checkedout)' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - depth => -1, - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify checkout is NOT shallow' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('shallow not found') if res.stdout.include? "shallow" - end - end - -end diff --git a/spec/acceptance/beaker/shallow_clone/negative/shallow_clone_overflow_depth.rb b/spec/acceptance/beaker/shallow_clone/negative/shallow_clone_overflow_depth.rb deleted file mode 100644 index 6b34f5d..0000000 --- a/spec/acceptance/beaker/shallow_clone/negative/shallow_clone_overflow_depth.rb +++ /dev/null @@ -1,39 +0,0 @@ -test_name 'C3606 - shallow clone repo depth overflow 64bit integer' - -# Globals -repo_name = 'testrepo_shallow_clone' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'shallow clone repo with puppet (bad input ignored, full clone checkedout)' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - depth => 18446744073709551616, - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify checkout is NOT shallow' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('shallow not found') if res.stdout.include? "shallow" - end - end - -end diff --git a/spec/acceptance/beaker/shallow_clone/shallow_clone_file.rb b/spec/acceptance/beaker/shallow_clone/shallow_clone_file.rb deleted file mode 100644 index 7e6f3a1..0000000 --- a/spec/acceptance/beaker/shallow_clone/shallow_clone_file.rb +++ /dev/null @@ -1,43 +0,0 @@ -test_name 'C3476 - shallow clone repo minimal depth = 1 (file protocol)' - -# Globals -repo_name = 'testrepo_shallow_clone' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'shallow clone repo with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - depth => 1, - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify checkout is shallow and of the correct depth' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('shallow not found') unless res.stdout.include? "shallow" - end - - on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| - fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" - end - end - -end diff --git a/spec/acceptance/beaker/shallow_clone/shallow_clone_file_path.rb b/spec/acceptance/beaker/shallow_clone/shallow_clone_file_path.rb deleted file mode 100644 index fa3e278..0000000 --- a/spec/acceptance/beaker/shallow_clone/shallow_clone_file_path.rb +++ /dev/null @@ -1,43 +0,0 @@ -test_name 'C3475 - shallow clone repo minimal depth = 1 (file path protocol)' - -# Globals -repo_name = 'testrepo_shallow_clone' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'shallow clone repo with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "#{tmpdir}/testrepo.git", - provider => git, - depth => 1, - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify checkout is shallow and of the correct depth' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('shallow not found') unless res.stdout.include? "shallow" - end - - on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| - fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" - end - end - -end diff --git a/spec/acceptance/beaker/shallow_clone/shallow_clone_git.rb b/spec/acceptance/beaker/shallow_clone/shallow_clone_git.rb deleted file mode 100644 index a95716f..0000000 --- a/spec/acceptance/beaker/shallow_clone/shallow_clone_git.rb +++ /dev/null @@ -1,48 +0,0 @@ -test_name 'C3474 - shallow clone repo minimal depth = 1 (git protocol)' - -# Globals -repo_name = 'testrepo_shallow_clone' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - step 'setup - start git daemon' do - install_package(host, 'git-daemon') - on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - on(host, 'pkill -9 git-daemon') - end - - step 'shallow clone repo with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "git://#{host}/testrepo.git", - provider => git, - depth => 1, - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify checkout is shallow and of the correct depth' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('shallow not found') unless res.stdout.include? "shallow" - end - - on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| - fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" - end - end - -end diff --git a/spec/acceptance/beaker/shallow_clone/shallow_clone_http.rb b/spec/acceptance/beaker/shallow_clone/shallow_clone_http.rb deleted file mode 100644 index b43e232..0000000 --- a/spec/acceptance/beaker/shallow_clone/shallow_clone_http.rb +++ /dev/null @@ -1,55 +0,0 @@ -test_name 'C3479 - shallow clone repo minimal depth = 1 (http protocol)' - -# Globals -repo_name = 'testrepo_shallow_clone' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - step 'setup - start http server' do - http_daemon =<<-EOF - require 'webrick' - server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") - WEBrick::Daemon.start - server.start - EOF - create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) - on(host, "ruby /tmp/http_daemon.rb") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') - end - - step 'shallow clone repo with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "http://#{host}:8000/testrepo.git", - provider => git, - depth => 1, - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify checkout is shallow and of the correct depth' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('shallow not found') unless res.stdout.include? "shallow" - end - - on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| - fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" - end - end - -end diff --git a/spec/acceptance/beaker/shallow_clone/shallow_clone_https.rb b/spec/acceptance/beaker/shallow_clone/shallow_clone_https.rb deleted file mode 100644 index 723c979..0000000 --- a/spec/acceptance/beaker/shallow_clone/shallow_clone_https.rb +++ /dev/null @@ -1,62 +0,0 @@ -test_name 'C3480 - shallow clone repo minimal depth = 1 (https protocol)' - -# Globals -repo_name = 'testrepo_shallow_clone' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - step 'setup - start https server' do - https_daemon =<<-EOF - require 'webrick' - require 'webrick/https' - server = WEBrick::HTTPServer.new( - :Port => 8443, - :DocumentRoot => "#{tmpdir}", - :SSLEnable => true, - :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, - :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), - :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), - :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) - WEBrick::Daemon.start - server.start - EOF - create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) - #on(host, "ruby /tmp/https_daemon.rb") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') - end - - step 'shallow clone repo with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "https://github.com/johnduarte/testrepo.git", - provider => git, - depth => 1, - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify checkout is shallow and of the correct depth' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('shallow not found') unless res.stdout.include? "shallow" - end - - on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| - fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" - end - end - -end diff --git a/spec/acceptance/beaker/shallow_clone/shallow_clone_ssh.rb b/spec/acceptance/beaker/shallow_clone/shallow_clone_ssh.rb deleted file mode 100644 index 96f1973..0000000 --- a/spec/acceptance/beaker/shallow_clone/shallow_clone_ssh.rb +++ /dev/null @@ -1,53 +0,0 @@ -test_name 'C3477 - shallow clone repo minimal depth = 1 (ssh protocol)' - -# Globals -repo_name = 'testrepo_shallow_clone' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - step 'setup - establish ssh keys' do - # create ssh keys - on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') - - # copy public key to authorized_keys - on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') - on(host, 'chown -R root:root /root/.ssh') - end - - teardown do - on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") - end - - step 'shallow clone repo with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "ssh://root@#{host}#{tmpdir}/testrepo.git", - provider => git, - depth => 1, - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify checkout is shallow and of the correct depth' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('shallow not found') unless res.stdout.include? "shallow" - end - - on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| - fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" - end - end - -end diff --git a/spec/acceptance/beaker/shallow_clone/shallow_clone_zero_depth.rb b/spec/acceptance/beaker/shallow_clone/shallow_clone_zero_depth.rb deleted file mode 100644 index 264bcfc..0000000 --- a/spec/acceptance/beaker/shallow_clone/shallow_clone_zero_depth.rb +++ /dev/null @@ -1,39 +0,0 @@ -test_name 'C3404 - shallow clone repo depth = 0 non shallow' - -# Globals -repo_name = 'testrepo_shallow_clone' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'shallow clone repo with puppet (zero depth means not shallow)' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - depth => 0, - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify checkout is NOT shallow' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('shallow found') if res.stdout.include? "shallow" - end - end - -end diff --git a/spec/acceptance/beaker/tag_checkout/negative/tag_checkout_not_exists.rb b/spec/acceptance/beaker/tag_checkout/negative/tag_checkout_not_exists.rb deleted file mode 100644 index 28dd107..0000000 --- a/spec/acceptance/beaker/tag_checkout/negative/tag_checkout_not_exists.rb +++ /dev/null @@ -1,43 +0,0 @@ -test_name 'C3612 - checkout a tag that does not exist' - -# Globals -repo_name = 'testrepo_tag_checkout' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'checkout tag that does not exist with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - tag => '11111111111111111', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify that master tag is checked out' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('tag not found') unless res.stdout.include? "ref: refs/heads/master" - end - end - -end diff --git a/spec/acceptance/beaker/tag_checkout/tag_checkout_file.rb b/spec/acceptance/beaker/tag_checkout/tag_checkout_file.rb deleted file mode 100644 index 6d39a62..0000000 --- a/spec/acceptance/beaker/tag_checkout/tag_checkout_file.rb +++ /dev/null @@ -1,44 +0,0 @@ -test_name 'C3445 - checkout a tag (file protocol)' - -# Globals -repo_name = 'testrepo_tag_checkout' -tag = '0.0.2' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'checkout a tag with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - revision => '#{tag}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify checkout out tag is #{tag}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res| - fail_test('tag not found') unless res.stdout.include? "#{tag}" - end - end - -end diff --git a/spec/acceptance/beaker/tag_checkout/tag_checkout_file_path.rb b/spec/acceptance/beaker/tag_checkout/tag_checkout_file_path.rb deleted file mode 100644 index ec0ac9a..0000000 --- a/spec/acceptance/beaker/tag_checkout/tag_checkout_file_path.rb +++ /dev/null @@ -1,44 +0,0 @@ -test_name 'C3444 - checkout a tag (file path)' - -# Globals -repo_name = 'testrepo_tag_checkout' -tag = '0.0.2' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'checkout a tag with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "#{tmpdir}/testrepo.git", - provider => git, - revision => '#{tag}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify checkout out tag is #{tag}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res| - fail_test('tag not found') unless res.stdout.include? "#{tag}" - end - end - -end diff --git a/spec/acceptance/beaker/tag_checkout/tag_checkout_git.rb b/spec/acceptance/beaker/tag_checkout/tag_checkout_git.rb deleted file mode 100644 index dc83ad1..0000000 --- a/spec/acceptance/beaker/tag_checkout/tag_checkout_git.rb +++ /dev/null @@ -1,55 +0,0 @@ -test_name 'C3443 - checkout a tag (git protocol)' - -# Globals -repo_name = 'testrepo_tag_checkout' -tag = '0.0.2' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - step 'setup - start git daemon' do - install_package(host, 'git-daemon') - on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - on(host, 'pkill -9 git-daemon') - end - - step 'get tag sha from repo' do - on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| - @sha = res.stdout.chomp - end - end - - step 'checkout a tag with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "git://#{host}/testrepo.git", - provider => git, - revision => '#{tag}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify checkout out tag is #{tag}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res| - fail_test('tag not found') unless res.stdout.include? "#{tag}" - end - end - -end diff --git a/spec/acceptance/beaker/tag_checkout/tag_checkout_http.rb b/spec/acceptance/beaker/tag_checkout/tag_checkout_http.rb deleted file mode 100644 index 5db0035..0000000 --- a/spec/acceptance/beaker/tag_checkout/tag_checkout_http.rb +++ /dev/null @@ -1,62 +0,0 @@ -test_name 'C3448 - checkout a tag (http protocol)' - -# Globals -repo_name = 'testrepo_tag_checkout' -tag = '0.0.2' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - step 'setup - start http server' do - http_daemon =<<-EOF - require 'webrick' - server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") - WEBrick::Daemon.start - server.start - EOF - create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) - on(host, "ruby /tmp/http_daemon.rb") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') - end - - step 'get tag sha from repo' do - on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| - @sha = res.stdout.chomp - end - end - - step 'checkout a tag with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "http://#{host}:8000/testrepo.git", - provider => git, - revision => '#{tag}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify checkout out tag is #{tag}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res| - fail_test('tag not found') unless res.stdout.include? "#{tag}" - end - end - -end diff --git a/spec/acceptance/beaker/tag_checkout/tag_checkout_https.rb b/spec/acceptance/beaker/tag_checkout/tag_checkout_https.rb deleted file mode 100644 index b4d1a2f..0000000 --- a/spec/acceptance/beaker/tag_checkout/tag_checkout_https.rb +++ /dev/null @@ -1,69 +0,0 @@ -test_name 'C3449 - checkout a tag (https protocol)' - -# Globals -repo_name = 'testrepo_tag_checkout' -tag = '0.0.2' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - step 'setup - start https server' do - https_daemon =<<-EOF - require 'webrick' - require 'webrick/https' - server = WEBrick::HTTPServer.new( - :Port => 8443, - :DocumentRoot => "#{tmpdir}", - :SSLEnable => true, - :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, - :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), - :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), - :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) - WEBrick::Daemon.start - server.start - EOF - create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) - #on(host, "ruby /tmp/https_daemon.rb") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') - end - - step 'get tag sha from repo' do - on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| - @sha = res.stdout.chomp - end - end - - step 'checkout a tag with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "https://github.com/johnduarte/testrepo.git", - provider => git, - revision => '#{tag}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify checkout out tag is #{tag}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res| - fail_test('tag not found') unless res.stdout.include? "#{tag}" - end - end - -end diff --git a/spec/acceptance/beaker/tag_checkout/tag_checkout_ssh.rb b/spec/acceptance/beaker/tag_checkout/tag_checkout_ssh.rb deleted file mode 100644 index a92c7d4..0000000 --- a/spec/acceptance/beaker/tag_checkout/tag_checkout_ssh.rb +++ /dev/null @@ -1,60 +0,0 @@ -test_name 'C3447 - checkout a tag (ssh protocol)' - -# Globals -repo_name = 'testrepo_tag_checkout' -tag = '0.0.2' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - step 'setup - establish ssh keys' do - # create ssh keys - on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') - - # copy public key to authorized_keys - on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') - on(host, 'chown -R root:root /root/.ssh') - end - - teardown do - on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") - end - - step 'get tag sha from repo' do - on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| - @sha = res.stdout.chomp - end - end - - step 'checkout a tag with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "ssh://root@#{host}#{tmpdir}/testrepo.git", - provider => git, - revision => '#{tag}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify checkout out tag is #{tag}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res| - fail_test('tag not found') unless res.stdout.include? "#{tag}" - end - end - -end diff --git a/spec/acceptance/beaker/user_checkout/negative/user_checkout_file_non_existent_user.rb b/spec/acceptance/beaker/user_checkout/negative/user_checkout_file_non_existent_user.rb deleted file mode 100644 index f4c301d..0000000 --- a/spec/acceptance/beaker/user_checkout/negative/user_checkout_file_non_existent_user.rb +++ /dev/null @@ -1,48 +0,0 @@ -test_name 'C3483 - checkout as a user that is not on system' - -# Globals -repo_name = 'testrepo_user_checkout' -user = 'myuser' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - step 'setup - delete user' do - apply_manifest_on(host, "user { '#{user}': ensure => absent, }") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'checkout as a user with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - owner => '#{user}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify git checkout is NOT owned by user #{user}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('checkout not owned by user') if res.stdout.include? "#{user}:" - end - end - -end diff --git a/spec/acceptance/beaker/user_checkout/user_checkout_file.rb b/spec/acceptance/beaker/user_checkout/user_checkout_file.rb deleted file mode 100644 index e2b9582..0000000 --- a/spec/acceptance/beaker/user_checkout/user_checkout_file.rb +++ /dev/null @@ -1,49 +0,0 @@ -test_name 'C3459 - checkout as a user (file protocol)' - -# Globals -repo_name = 'testrepo_user_checkout' -user = 'myuser' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - step 'setup - create user' do - apply_manifest_on(host, "user { '#{user}': ensure => present, }") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "user { '#{user}': ensure => absent, }") - end - - step 'checkout as a user with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - owner => '#{user}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify git checkout is owned by user #{user}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:" - end - end - -end diff --git a/spec/acceptance/beaker/user_checkout/user_checkout_file_path.rb b/spec/acceptance/beaker/user_checkout/user_checkout_file_path.rb deleted file mode 100644 index 50592a2..0000000 --- a/spec/acceptance/beaker/user_checkout/user_checkout_file_path.rb +++ /dev/null @@ -1,49 +0,0 @@ -test_name 'C3458 - checkout as a user (file path)' - -# Globals -repo_name = 'testrepo_user_checkout' -user = 'myuser' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - step 'setup - create user' do - apply_manifest_on(host, "user { '#{user}': ensure => present, }") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "user { '#{user}': ensure => absent, }") - end - - step 'checkout a user with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "#{tmpdir}/testrepo.git", - provider => git, - owner => '#{user}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify git checkout is owned by user #{user}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:" - end - end - -end diff --git a/spec/acceptance/beaker/user_checkout/user_checkout_git.rb b/spec/acceptance/beaker/user_checkout/user_checkout_git.rb deleted file mode 100644 index a7ddfd0..0000000 --- a/spec/acceptance/beaker/user_checkout/user_checkout_git.rb +++ /dev/null @@ -1,54 +0,0 @@ -test_name 'C3457 - checkout as a user (git protocol)' - -# Globals -repo_name = 'testrepo_user_checkout' -user = 'myuser' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - step 'setup - start git daemon' do - install_package(host, 'git-daemon') - on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") - end - - step 'setup - create user' do - apply_manifest_on(host, "user { '#{user}': ensure => present, }") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - on(host, 'pkill -9 git-daemon') - apply_manifest_on(host, "user { '#{user}': ensure => absent, }") - end - - step 'checkout a user with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "git://#{host}/testrepo.git", - provider => git, - owner => '#{user}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify git checkout is owned by user #{user}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:" - end - end - -end diff --git a/spec/acceptance/beaker/user_checkout/user_checkout_http.rb b/spec/acceptance/beaker/user_checkout/user_checkout_http.rb deleted file mode 100644 index 3ffb377..0000000 --- a/spec/acceptance/beaker/user_checkout/user_checkout_http.rb +++ /dev/null @@ -1,61 +0,0 @@ -test_name 'C3462 - checkout as a user (http protocol)' - -# Globals -repo_name = 'testrepo_user_checkout' -user = 'myuser' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - step 'setup - start http server' do - http_daemon =<<-EOF - require 'webrick' - server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") - WEBrick::Daemon.start - server.start - EOF - create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) - on(host, "ruby /tmp/http_daemon.rb") - end - - step 'setup - create user' do - apply_manifest_on(host, "user { '#{user}': ensure => present, }") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') - apply_manifest_on(host, "user { '#{user}': ensure => absent, }") - end - - step 'checkout a user with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "http://#{host}:8000/testrepo.git", - provider => git, - owner => '#{user}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify git checkout is owned by user #{user}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:" - end - end - -end diff --git a/spec/acceptance/beaker/user_checkout/user_checkout_https.rb b/spec/acceptance/beaker/user_checkout/user_checkout_https.rb deleted file mode 100644 index e76a93d..0000000 --- a/spec/acceptance/beaker/user_checkout/user_checkout_https.rb +++ /dev/null @@ -1,68 +0,0 @@ -test_name 'C3463 - checkout as a user (https protocol)' - -# Globals -repo_name = 'testrepo_user_checkout' -user = 'myuser' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - step 'setup - start https server' do - https_daemon =<<-EOF - require 'webrick' - require 'webrick/https' - server = WEBrick::HTTPServer.new( - :Port => 8443, - :DocumentRoot => "#{tmpdir}", - :SSLEnable => true, - :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, - :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), - :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), - :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) - WEBrick::Daemon.start - server.start - EOF - create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) - #on(host, "ruby /tmp/https_daemon.rb") - end - - step 'setup - create user' do - apply_manifest_on(host, "user { '#{user}': ensure => present, }") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') - apply_manifest_on(host, "user { '#{user}': ensure => absent, }") - end - - step 'checkout as a user with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "https://github.com/johnduarte/testrepo.git", - provider => git, - owner => '#{user}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify git checkout is owned by user #{user}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:" - end - end - -end diff --git a/spec/acceptance/beaker/user_checkout/user_checkout_ssh.rb b/spec/acceptance/beaker/user_checkout/user_checkout_ssh.rb deleted file mode 100644 index 8de2bc3..0000000 --- a/spec/acceptance/beaker/user_checkout/user_checkout_ssh.rb +++ /dev/null @@ -1,59 +0,0 @@ -test_name 'C3461 - checkout as a user (ssh protocol)' - -# Globals -repo_name = 'testrepo_user_checkout' -user = 'myuser' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - step 'setup - establish ssh keys' do - # create ssh keys - on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') - - # copy public key to authorized_keys - on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') - on(host, 'chown -R root:root /root/.ssh') - end - - step 'setup - create user' do - apply_manifest_on(host, "user { '#{user}': ensure => present, }") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") - apply_manifest_on(host, "user { '#{user}': ensure => absent, }") - end - - step 'checkout as a user with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "ssh://root@#{host}#{tmpdir}/testrepo.git", - provider => git, - owner => '#{user}', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step "verify git checkout is owned by user #{user}" do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('checkout not found') unless res.stdout.include? "HEAD" - end - - on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| - fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:" - end - end - -end -- cgit v1.2.3 From ef946812c16f2d5e9d120199378b5ade825740c3 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Sat, 10 May 2014 21:40:19 -0700 Subject: Fix typos in verify steps for revision tests --- spec/acceptance/beaker/git/revision_checkout/revision_checkout_file.rb | 2 +- .../beaker/git/revision_checkout/revision_checkout_file_path.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file.rb index 3ff44ec..8ca10bd 100644 --- a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file.rb +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file.rb @@ -36,7 +36,7 @@ hosts.each do |host| apply_manifest_on(host, pp) end - stop "verify repo is checked out to revision #{sha}" do + step "verify repo is checked out to revision #{@sha}" do on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| fail_test('checkout not found') unless res.stdout.include? "HEAD" end diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file_path.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file_path.rb index cd92139..2410e2e 100644 --- a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file_path.rb +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file_path.rb @@ -36,7 +36,7 @@ hosts.each do |host| apply_manifest_on(host, pp) end - stop "verify repo is checked out to revision #{sha}" do + step "verify repo is checked out to revision #{@sha}" do on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| fail_test('checkout not found') unless res.stdout.include? "HEAD" end -- cgit v1.2.3 From eaf1e2d77754bc5f9070274f2c4da9409a003208 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Sun, 11 May 2014 08:07:10 -0700 Subject: Set neg bare test to expect bare repo --- .../git/create/negative/create_bare_repo_specifying_revision.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/acceptance/beaker/git/create/negative/create_bare_repo_specifying_revision.rb b/spec/acceptance/beaker/git/create/negative/create_bare_repo_specifying_revision.rb index 6a12c8c..6cd4f72 100644 --- a/spec/acceptance/beaker/git/create/negative/create_bare_repo_specifying_revision.rb +++ b/spec/acceptance/beaker/git/create/negative/create_bare_repo_specifying_revision.rb @@ -22,12 +22,12 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp, :acceptable_exit_codes => [1]) + apply_manifest_on(host, pp) end - step 'verify repo was NOT created' do - on(host, "ls -al #{tmpdir}") do |res| - fail_test "found #{repo_name}" if res.stdout.include? "#{repo_name}" + step 'verify repo does not contain .git directory' do + on(host, "ls -al #{tmpdir}/#{repo_name}") do |res| + fail_test "found .git for #{repo_name}" if res.stdout.include? ".git" end end -- cgit v1.2.3 From 4040e4a1cccc72692c00d5efc06f8e8d5e1174f1 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Sun, 11 May 2014 12:00:21 -0700 Subject: Update expectations for shallow clone --- .../negative/shallow_clone_file_path.rb | 39 +++++++++++++++ .../shallow_clone/negative/shallow_clone_http.rb | 51 ++++++++++++++++++++ .../git/shallow_clone/shallow_clone_file_path.rb | 43 ----------------- .../beaker/git/shallow_clone/shallow_clone_http.rb | 55 ---------------------- 4 files changed, 90 insertions(+), 98 deletions(-) create mode 100644 spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb create mode 100644 spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb delete mode 100644 spec/acceptance/beaker/git/shallow_clone/shallow_clone_file_path.rb delete mode 100644 spec/acceptance/beaker/git/shallow_clone/shallow_clone_http.rb diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb new file mode 100644 index 0000000..9cebe45 --- /dev/null +++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb @@ -0,0 +1,39 @@ +test_name 'C3475 - shallow clone repo minimal depth = 1 (file path protocol)' + +# Globals +repo_name = 'testrepo_shallow_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'shallow clone repo with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "#{tmpdir}/testrepo.git", + provider => git, + depth => 1, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'git does not support shallow clone via file path: verify checkout is NOT created' do + on(host, "ls #{tmpdir}") do |res| + fail_test('checkout found') if res.stdout.include? "#{repo_name}" + end + end + +end diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb new file mode 100644 index 0000000..f80239b --- /dev/null +++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb @@ -0,0 +1,51 @@ +test_name 'C3479 - shallow clone repo minimal depth = 1 (http protocol)' + +# Globals +repo_name = 'testrepo_shallow_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - start http server' do + http_daemon =<<-EOF + require 'webrick' + server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) + on(host, "ruby /tmp/http_daemon.rb") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + end + + step 'shallow clone repo with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "http://#{host}:8000/testrepo.git", + provider => git, + depth => 1, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'git does not support shallow clone via HTTP: verify checkout is NOT created' do + on(host, "ls #{tmpdir}") do |res| + fail_test('checkout found') if res.stdout.include? "#{repo_name}" + end + end + +end diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_file_path.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_file_path.rb deleted file mode 100644 index d9d18ce..0000000 --- a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_file_path.rb +++ /dev/null @@ -1,43 +0,0 @@ -test_name 'C3475 - shallow clone repo minimal depth = 1 (file path protocol)' - -# Globals -repo_name = 'testrepo_shallow_clone' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'shallow clone repo with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "#{tmpdir}/testrepo.git", - provider => git, - depth => 1, - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify checkout is shallow and of the correct depth' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('shallow not found') unless res.stdout.include? "shallow" - end - - on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| - fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" - end - end - -end diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_http.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_http.rb deleted file mode 100644 index ad7e30e..0000000 --- a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_http.rb +++ /dev/null @@ -1,55 +0,0 @@ -test_name 'C3479 - shallow clone repo minimal depth = 1 (http protocol)' - -# Globals -repo_name = 'testrepo_shallow_clone' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - step 'setup - start http server' do - http_daemon =<<-EOF - require 'webrick' - server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") - WEBrick::Daemon.start - server.start - EOF - create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) - on(host, "ruby /tmp/http_daemon.rb") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') - end - - step 'shallow clone repo with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "http://#{host}:8000/testrepo.git", - provider => git, - depth => 1, - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify checkout is shallow and of the correct depth' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('shallow not found') unless res.stdout.include? "shallow" - end - - on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| - fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" - end - end - -end -- cgit v1.2.3 From 93a410c9ad3d8b3cb8da1ce79040cd00475fceaf Mon Sep 17 00:00:00 2001 From: John Duarte Date: Mon, 12 May 2014 10:39:37 -0700 Subject: Add tests git using ssh scp syntax --- .../git/branch_checkout/branch_checkout_scp.rb | 54 +++++++++++++++++++ .../git/group_checkout/group_checkout_scp.rb | 59 +++++++++++++++++++++ .../git/revision_checkout/revision_checkout_scp.rb | 59 +++++++++++++++++++++ .../beaker/git/shallow_clone/shallow_clone_scp.rb | 53 +++++++++++++++++++ .../beaker/git/tag_checkout/tag_checkout_scp.rb | 60 ++++++++++++++++++++++ .../beaker/git/user_checkout/user_checkout_scp.rb | 59 +++++++++++++++++++++ 6 files changed, 344 insertions(+) create mode 100644 spec/acceptance/beaker/git/branch_checkout/branch_checkout_scp.rb create mode 100644 spec/acceptance/beaker/git/group_checkout/group_checkout_scp.rb create mode 100644 spec/acceptance/beaker/git/revision_checkout/revision_checkout_scp.rb create mode 100644 spec/acceptance/beaker/git/shallow_clone/shallow_clone_scp.rb create mode 100644 spec/acceptance/beaker/git/tag_checkout/tag_checkout_scp.rb create mode 100644 spec/acceptance/beaker/git/user_checkout/user_checkout_scp.rb diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_scp.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_scp.rb new file mode 100644 index 0000000..0a4e07a --- /dev/null +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_scp.rb @@ -0,0 +1,54 @@ +test_name 'C3439 - checkout a branch (ssh protocol, scp syntax)' + +# Globals +repo_name = 'testrepo_branch_checkout' +branch = 'a_branch' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - establish ssh keys' do + # create ssh keys + on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') + on(host, 'chown -R root:root /root/.ssh') + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + end + + step 'checkout a branch with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "root@#{host}:#{tmpdir}/testrepo.git", + provider => git, + revision => '#{branch}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the #{branch} branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}" + end + end + +end diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_scp.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_scp.rb new file mode 100644 index 0000000..d8f5bb5 --- /dev/null +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_scp.rb @@ -0,0 +1,59 @@ +test_name 'C3488 - checkout as a group (ssh protocol, scp syntax)' + +# Globals +repo_name = 'testrepo_group_checkout' +group = 'mygroup' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - establish ssh keys' do + # create ssh keys + on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') + on(host, 'chown -R root:root /root/.ssh') + end + + step 'setup - create group' do + apply_manifest_on(host, "group { '#{group}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + apply_manifest_on(host, "group { '#{group}': ensure => absent, }") + end + + step 'checkout as a group with puppet (scp syntax)' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "root@#{host}:#{tmpdir}/testrepo.git", + provider => git, + group => '#{group}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is own by group #{group}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}" + end + end + +end diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_scp.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_scp.rb new file mode 100644 index 0000000..c920fb4 --- /dev/null +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_scp.rb @@ -0,0 +1,59 @@ +test_name 'C3453 - checkout a revision (ssh protocol, scp syntax)' + +# Globals +repo_name = 'testrepo_revision_checkout' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - establish ssh keys' do + # create ssh keys + on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') + on(host, 'chown -R root:root /root/.ssh') + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + end + + step 'get revision sha from repo' do + on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| + @sha = res.stdout.chomp + end + end + + step 'checkout a revision with puppet (scp syntax)' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "root@#{host}:#{tmpdir}/testrepo.git", + provider => git, + revision => '#{@sha}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is set to revision #{@sha}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('revision not found') unless res.stdout.include? "#{@sha}" + end + end + +end diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_scp.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_scp.rb new file mode 100644 index 0000000..6837802 --- /dev/null +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_scp.rb @@ -0,0 +1,53 @@ +test_name 'C3478 - shallow clone repo minimal depth = 1 (ssh protocol, scp syntax)' + +# Globals +repo_name = 'testrepo_shallow_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - establish ssh keys' do + # create ssh keys + on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') + on(host, 'chown -R root:root /root/.ssh') + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + end + + step 'shallow clone repo with puppet (scp syntax)' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "root@#{host}:#{tmpdir}/testrepo.git", + provider => git, + depth => 1, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify checkout is shallow and of the correct depth' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('shallow not found') unless res.stdout.include? "shallow" + end + + on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| + fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" + end + end + +end diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_scp.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_scp.rb new file mode 100644 index 0000000..d602689 --- /dev/null +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_scp.rb @@ -0,0 +1,60 @@ +test_name 'C3446 - checkout a tag (ssh protocol, scp syntax)' + +# Globals +repo_name = 'testrepo_tag_checkout' +tag = '0.0.2' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - establish ssh keys' do + # create ssh keys + on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') + on(host, 'chown -R root:root /root/.ssh') + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + end + + step 'get tag sha from repo' do + on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res| + @sha = res.stdout.chomp + end + end + + step 'checkout a tag with puppet (scp syntax)' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "root@#{host}:#{tmpdir}/testrepo.git", + provider => git, + revision => '#{tag}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout out tag is #{tag}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res| + fail_test('tag not found') unless res.stdout.include? "#{tag}" + end + end + +end diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_scp.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_scp.rb new file mode 100644 index 0000000..a4f7261 --- /dev/null +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_scp.rb @@ -0,0 +1,59 @@ +test_name 'C3460 - checkout as a user (ssh protocol, scp syntax)' + +# Globals +repo_name = 'testrepo_user_checkout' +user = 'myuser' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - establish ssh keys' do + # create ssh keys + on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') + on(host, 'chown -R root:root /root/.ssh') + end + + step 'setup - create user' do + apply_manifest_on(host, "user { '#{user}': ensure => present, }") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + apply_manifest_on(host, "user { '#{user}': ensure => absent, }") + end + + step 'checkout as a user with puppet (scp syntax)' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "root@#{host}:#{tmpdir}/testrepo.git", + provider => git, + owner => '#{user}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify git checkout is owned by user #{user}" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('checkout not owned by user') unless res.stdout.include? "#{user}:" + end + end + +end -- cgit v1.2.3 From 8d0d19cc6d7d684b526ddc00172ca1db65207073 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Mon, 12 May 2014 11:02:15 -0700 Subject: Fix root path depth for negative shallow tests --- .../beaker/git/shallow_clone/negative/shallow_clone_file_path.rb | 2 +- spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb index 9cebe45..a2565db 100644 --- a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb +++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb @@ -7,7 +7,7 @@ hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") end diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb index f80239b..a67ec00 100644 --- a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb +++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb @@ -7,7 +7,7 @@ hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") end -- cgit v1.2.3 From b362b35825638c27a7a19da97bd14bc9d7e133b4 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Mon, 12 May 2014 11:24:16 -0700 Subject: Fix exec test for shallow clone --- .../negative/shallow_clone_exec_depth.rb | 39 ++++++++++++++++++++++ .../negative/shallow_clone_hostile_depth.rb | 39 ---------------------- 2 files changed, 39 insertions(+), 39 deletions(-) create mode 100644 spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_exec_depth.rb delete mode 100644 spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_hostile_depth.rb diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_exec_depth.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_exec_depth.rb new file mode 100644 index 0000000..caef5a6 --- /dev/null +++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_exec_depth.rb @@ -0,0 +1,39 @@ +test_name 'C3608 - shallow clone repo depth hostile input' + +# Globals +repo_name = 'testrepo_shallow_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'shallow clone repo with puppet (bad input ignored, full clone checkedout)' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + depth => "exec 'rm -rf /tmp'", + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify checkout is NOT shallow' do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('shallow not found') if res.stdout.include? "shallow" + end + end + +end diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_hostile_depth.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_hostile_depth.rb deleted file mode 100644 index 0a4b467..0000000 --- a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_hostile_depth.rb +++ /dev/null @@ -1,39 +0,0 @@ -test_name 'C3608 - shallow clone repo depth hostile input' - -# Globals -repo_name = 'testrepo_shallow_clone' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'shallow clone repo with puppet (bad input ignored, full clone checkedout)' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - depth => 'rm -rf /tmp', - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify checkout is NOT shallow' do - on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| - fail_test('shallow not found') if res.stdout.include? "shallow" - end - end - -end -- cgit v1.2.3 From 3c032db01ae041281e9fba449f1e9bbdfb93dc07 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Mon, 12 May 2014 11:24:45 -0700 Subject: Fix exec test for compression --- .../beaker/git/compression/negative/compression_exec_checkout.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/acceptance/beaker/git/compression/negative/compression_exec_checkout.rb b/spec/acceptance/beaker/git/compression/negative/compression_exec_checkout.rb index de95838..c85818d 100644 --- a/spec/acceptance/beaker/git/compression/negative/compression_exec_checkout.rb +++ b/spec/acceptance/beaker/git/compression/negative/compression_exec_checkout.rb @@ -22,7 +22,7 @@ hosts.each do |host| ensure => present, source => "file://#{tmpdir}/testrepo.git", provider => git, - compression => `exec rm -rf /tmp`, + compression => "exec 'rm -rf /tmp'", } EOS -- cgit v1.2.3 From eeb52c491869c7916758b4d878018ef4df460bf3 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Mon, 12 May 2014 11:27:37 -0700 Subject: Fix exec test for clone --- .../negative/clone_repo_with_exec_excludes.rb | 40 ++++++++++++++++++++++ .../negative/clone_repo_with_hostile_excludes.rb | 40 ---------------------- 2 files changed, 40 insertions(+), 40 deletions(-) create mode 100644 spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb delete mode 100644 spec/acceptance/beaker/git/clone/negative/clone_repo_with_hostile_excludes.rb diff --git a/spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb b/spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb new file mode 100644 index 0000000..2ab213c --- /dev/null +++ b/spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb @@ -0,0 +1,40 @@ +test_name 'C3509 - clone repo with excludes not in repo' + +# Globals +repo_name = 'testrepo_with_excludes_not_in_repo' +exclude1 = "'exec 'rm -rf /tmp'" + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'clone repo with excludes not in repo with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + excludes => [ '#{exclude1}' ], + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step 'verify excludes are known to git' do + on(host, "cat #{tmpdir}/#{repo_name}/.git/info/exclude") do |res| + fail_test('exclude not found') unless res.stdout.include? "#{exclude1}" + end + end + +end diff --git a/spec/acceptance/beaker/git/clone/negative/clone_repo_with_hostile_excludes.rb b/spec/acceptance/beaker/git/clone/negative/clone_repo_with_hostile_excludes.rb deleted file mode 100644 index 6331840..0000000 --- a/spec/acceptance/beaker/git/clone/negative/clone_repo_with_hostile_excludes.rb +++ /dev/null @@ -1,40 +0,0 @@ -test_name 'C3509 - clone repo with excludes not in repo' - -# Globals -repo_name = 'testrepo_with_excludes_not_in_repo' -exclude1 = 'rm -rf /tmp' - -hosts.each do |host| - tmpdir = host.tmpdir('vcsrepo') - step 'setup - create repo' do - install_package(host, 'git') - my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - end - - teardown do - on(host, "rm -fr #{tmpdir}") - end - - step 'clone repo with excludes not in repo with puppet' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": - ensure => present, - source => "file://#{tmpdir}/testrepo.git", - provider => git, - excludes => [ '#{exclude1}' ], - } - EOS - - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) - end - - step 'verify excludes are known to git' do - on(host, "cat #{tmpdir}/#{repo_name}/.git/info/exclude") do |res| - fail_test('exclude not found') unless res.stdout.include? "#{exclude1}" - end - end - -end -- cgit v1.2.3 From 3d35e61e4377e73365b9f7c340b225d787fe3cbb Mon Sep 17 00:00:00 2001 From: John Duarte Date: Mon, 12 May 2014 14:42:56 -0700 Subject: Add beaker tests for git basic auth --- .../git/basic_auth/basic_auth_checkout_http.rb | 66 ++++++++++++++++++++ .../git/basic_auth/basic_auth_checkout_https.rb | 71 ++++++++++++++++++++++ .../basic_auth/negative/basic_auth_checkout_git.rb | 49 +++++++++++++++ 3 files changed, 186 insertions(+) create mode 100644 spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb create mode 100644 spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb create mode 100644 spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb diff --git a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb new file mode 100644 index 0000000..d43ae0a --- /dev/null +++ b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb @@ -0,0 +1,66 @@ +test_name 'C3492 - checkout with basic auth (http protocol)' + +# Globals +repo_name = 'testrepo_checkout' +user = 'foo' +password = 'bar' +http_server_script = 'basic_auth_http_daemon.rb' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - start http server' do + script =<<-EOF + require 'webrick' + + authenticate = Proc.new do |req, res| + WEBrick::HTTPAuth.basic_auth(req, res, '') do |user, password| + user == '#{user}' && password == '#{password}' + end + end + + server = WEBrick::HTTPServer.new( + :Port => 8000, + :DocumentRoot => "#{tmpdir}", + :DocumentRootOptions=> {:HandlerCallback => authenticate}, + ) + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, "#{tmpdir}/#{http_server_script}", script) + on(host, "ruby #{tmpdir}/#{http_server_script}") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, "ps ax | grep 'ruby #{tmpdir}/#{http_server_script}' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") + end + + step 'checkout with puppet using basic auth' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "http://#{host}:8000/testrepo.git", + provider => git, + basic_auth_username => '#{user}', + basic_auth_password => '#{password}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb new file mode 100644 index 0000000..f033d22 --- /dev/null +++ b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb @@ -0,0 +1,71 @@ +test_name 'C3493 - checkout with basic auth (https protocol)' + +# Globals +repo_name = 'testrepo_checkout' +user = 'foo' +password = 'bar' +http_server_script = 'basic_auth_https_daemon.rb' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - start https server' do + script =<<-EOF + require 'webrick' + require 'webrick/https' + + authenticate = Proc.new do |req, res| + WEBrick::HTTPAuth.basic_auth(req, res, '') do |user, password| + user == '#{user}' && password == '#{password}' + end + end + + server = WEBrick::HTTPServer.new( + :Port => 8443, + :DocumentRoot => "#{tmpdir}", + :DocumentRootOptions=> {:HandlerCallback => authenticate}, + :SSLEnable => true, + :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, + :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), + :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), + :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, "#{tmpdir}/#{http_server_script}", script) + on(host, "ruby #{tmpdir}/#{http_server_script}") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, "ps ax | grep 'ruby #{tmpdir}/#{http_server_script}' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") + end + + step 'checkout with puppet using basic auth' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "http://#{host}:8443/testrepo.git", + provider => git, + basic_auth_username => '#{user}', + basic_auth_password => '#{password}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end diff --git a/spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb b/spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb new file mode 100644 index 0000000..9b0f190 --- /dev/null +++ b/spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb @@ -0,0 +1,49 @@ +test_name 'C3494 - checkout with basic auth (git protocol)' + +# Globals +repo_name = 'testrepo_checkout' +user = 'foo' +password = 'bar' +http_server_script = 'basic_auth_http_daemon.rb' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - start git daemon' do + install_package(host, 'git-daemon') + on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'pkill -9 git-daemon') + end + + step 'checkout with puppet using basic auth' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "git://#{host}/testrepo.git", + provider => git, + basic_auth_username => '#{user}', + basic_auth_password => '#{password}', + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout (silent error for basic auth using git protocol)" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + end + +end -- cgit v1.2.3 From 97e64b52f63f3dd673dfa2fe92c71d4d9ddbcbc7 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Thu, 15 May 2014 11:43:29 -0700 Subject: Add conditional ruby path based on pe --- spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb | 5 +++-- spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb | 5 +++-- spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb | 5 +++-- spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb | 5 +++-- spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb | 5 +++-- spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb | 5 +++-- .../beaker/git/revision_checkout/revision_checkout_http.rb | 5 +++-- .../beaker/git/revision_checkout/revision_checkout_https.rb | 5 +++-- .../beaker/git/shallow_clone/negative/shallow_clone_http.rb | 5 +++-- spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb | 5 +++-- spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb | 5 +++-- spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb | 5 +++-- spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb | 5 +++-- spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb | 5 +++-- 14 files changed, 42 insertions(+), 28 deletions(-) diff --git a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb index d43ae0a..f2486cd 100644 --- a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb +++ b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb @@ -7,6 +7,7 @@ password = 'bar' http_server_script = 'basic_auth_http_daemon.rb' hosts.each do |host| + ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -34,12 +35,12 @@ hosts.each do |host| server.start EOF create_remote_file(host, "#{tmpdir}/#{http_server_script}", script) - on(host, "ruby #{tmpdir}/#{http_server_script}") + on(host, "#{ruby} #{tmpdir}/#{http_server_script} &") end teardown do on(host, "rm -fr #{tmpdir}") - on(host, "ps ax | grep 'ruby #{tmpdir}/#{http_server_script}' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") + on(host, "ps ax | grep '#{ruby} #{tmpdir}/#{http_server_script}' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") end step 'checkout with puppet using basic auth' do diff --git a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb index f033d22..67a6f73 100644 --- a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb +++ b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb @@ -7,6 +7,7 @@ password = 'bar' http_server_script = 'basic_auth_https_daemon.rb' hosts.each do |host| + ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -39,12 +40,12 @@ hosts.each do |host| server.start EOF create_remote_file(host, "#{tmpdir}/#{http_server_script}", script) - on(host, "ruby #{tmpdir}/#{http_server_script}") + on(host, "#{ruby} #{tmpdir}/#{http_server_script}") end teardown do on(host, "rm -fr #{tmpdir}") - on(host, "ps ax | grep 'ruby #{tmpdir}/#{http_server_script}' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") + on(host, "ps ax | grep '#{ruby} #{tmpdir}/#{http_server_script}' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") end step 'checkout with puppet using basic auth' do diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb index 151d801..9fea700 100644 --- a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb @@ -5,6 +5,7 @@ repo_name = 'testrepo_branch_checkout' branch = 'a_branch' hosts.each do |host| + ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -21,12 +22,12 @@ hosts.each do |host| server.start EOF create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) - on(host, "ruby /tmp/http_daemon.rb") + on(host, "#{ruby} /tmp/http_daemon.rb") end teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + on(host, 'ps ax | grep "#{ruby} /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') end step 'checkout a branch with puppet' do diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb index 273f5aa..4d6a4ab 100644 --- a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb @@ -5,6 +5,7 @@ repo_name = 'testrepo_branch_checkout' branch = 'a_branch' hosts.each do |host| + ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -28,12 +29,12 @@ hosts.each do |host| server.start EOF create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) - #on(host, "ruby /tmp/https_daemon.rb") + #on(host, "#{ruby} /tmp/https_daemon.rb") end teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + on(host, 'ps ax | grep "#{ruby} /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') end step 'checkout a branch with puppet' do diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb index 5c05baa..4888bd2 100644 --- a/spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb @@ -5,6 +5,7 @@ repo_name = 'testrepo_group_checkout' group = 'mygroup' hosts.each do |host| + ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -21,7 +22,7 @@ hosts.each do |host| server.start EOF create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) - on(host, "ruby /tmp/http_daemon.rb") + on(host, "#{ruby} /tmp/http_daemon.rb") end step 'setup - create group' do @@ -30,7 +31,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + on(host, 'ps ax | grep "#{ruby} /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') apply_manifest_on(host, "group { '#{group}': ensure => absent, }") end diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb index 4551aee..3a72cc8 100644 --- a/spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb @@ -5,6 +5,7 @@ repo_name = 'testrepo_group_checkout' group = 'mygroup' hosts.each do |host| + ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -28,7 +29,7 @@ hosts.each do |host| server.start EOF create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) - #on(host, "ruby /tmp/https_daemon.rb") + #on(host, "#{ruby} /tmp/https_daemon.rb") end step 'setup - create group' do @@ -37,7 +38,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + on(host, 'ps ax | grep "#{ruby} /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') apply_manifest_on(host, "group { '#{group}': ensure => absent, }") end diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb index 40db6c9..5f5d9e5 100644 --- a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb @@ -4,6 +4,7 @@ test_name 'C3455 - checkout a revision (http protocol)' repo_name = 'testrepo_revision_checkout' hosts.each do |host| + ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -20,12 +21,12 @@ hosts.each do |host| server.start EOF create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) - on(host, "ruby /tmp/http_daemon.rb") + on(host, "#{ruby} /tmp/http_daemon.rb") end teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + on(host, 'ps ax | grep "#{ruby} /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') end step 'get revision sha from repo' do diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb index dc3dc7f..0a935aa 100644 --- a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb @@ -4,6 +4,7 @@ test_name 'C3456 - checkout a revision (https protocol)' repo_name = 'testrepo_revision_checkout' hosts.each do |host| + ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -27,12 +28,12 @@ hosts.each do |host| server.start EOF create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) - #on(host, "ruby /tmp/https_daemon.rb") + #on(host, "#{ruby} /tmp/https_daemon.rb") end teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + on(host, 'ps ax | grep "#{ruby} /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') end step 'get revision sha from repo' do diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb index a67ec00..4c43be1 100644 --- a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb +++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb @@ -4,6 +4,7 @@ test_name 'C3479 - shallow clone repo minimal depth = 1 (http protocol)' repo_name = 'testrepo_shallow_clone' hosts.each do |host| + ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -20,12 +21,12 @@ hosts.each do |host| server.start EOF create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) - on(host, "ruby /tmp/http_daemon.rb") + on(host, "#{ruby} /tmp/http_daemon.rb") end teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + on(host, 'ps ax | grep "#{ruby} /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') end step 'shallow clone repo with puppet' do diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb index e016e55..1a34521 100644 --- a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb @@ -4,6 +4,7 @@ test_name 'C3480 - shallow clone repo minimal depth = 1 (https protocol)' repo_name = 'testrepo_shallow_clone' hosts.each do |host| + ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -27,12 +28,12 @@ hosts.each do |host| server.start EOF create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) - #on(host, "ruby /tmp/https_daemon.rb") + #on(host, "#{ruby} /tmp/https_daemon.rb") end teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + on(host, 'ps ax | grep "#{ruby} /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') end step 'shallow clone repo with puppet' do diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb index 3a6d33f..f2f721a 100644 --- a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb @@ -5,6 +5,7 @@ repo_name = 'testrepo_tag_checkout' tag = '0.0.2' hosts.each do |host| + ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -21,12 +22,12 @@ hosts.each do |host| server.start EOF create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) - on(host, "ruby /tmp/http_daemon.rb") + on(host, "#{ruby} /tmp/http_daemon.rb") end teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + on(host, 'ps ax | grep "#{ruby} /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') end step 'get tag sha from repo' do diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb index b277d6d..fdfa02c 100644 --- a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb @@ -5,6 +5,7 @@ repo_name = 'testrepo_tag_checkout' tag = '0.0.2' hosts.each do |host| + ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -28,12 +29,12 @@ hosts.each do |host| server.start EOF create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) - #on(host, "ruby /tmp/https_daemon.rb") + #on(host, "#{ruby} /tmp/https_daemon.rb") end teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + on(host, 'ps ax | grep "#{ruby} /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') end step 'get tag sha from repo' do diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb index 6faad95..379425b 100644 --- a/spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb @@ -5,6 +5,7 @@ repo_name = 'testrepo_user_checkout' user = 'myuser' hosts.each do |host| + ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -21,7 +22,7 @@ hosts.each do |host| server.start EOF create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) - on(host, "ruby /tmp/http_daemon.rb") + on(host, "#{ruby} /tmp/http_daemon.rb") end step 'setup - create user' do @@ -30,7 +31,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + on(host, 'ps ax | grep "#{ruby} /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') apply_manifest_on(host, "user { '#{user}': ensure => absent, }") end diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb index 28a17b8..bd9b498 100644 --- a/spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb @@ -5,6 +5,7 @@ repo_name = 'testrepo_user_checkout' user = 'myuser' hosts.each do |host| + ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -28,7 +29,7 @@ hosts.each do |host| server.start EOF create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) - #on(host, "ruby /tmp/https_daemon.rb") + #on(host, "#{ruby} /tmp/https_daemon.rb") end step 'setup - create user' do @@ -37,7 +38,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "ruby /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + on(host, 'ps ax | grep "#{ruby} /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') apply_manifest_on(host, "user { '#{user}': ensure => absent, }") end -- cgit v1.2.3 From 123fe4099e4e4fdda7b34a769458a1dcaad75aae Mon Sep 17 00:00:00 2001 From: John Duarte Date: Thu, 15 May 2014 13:21:13 -0700 Subject: Use sinatra to set up basic auth HTTP server --- .../git/basic_auth/basic_auth_checkout_http.rb | 25 ++++++++++------------ 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb index f2486cd..69e1941 100644 --- a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb +++ b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb @@ -8,6 +8,7 @@ http_server_script = 'basic_auth_http_daemon.rb' hosts.each do |host| ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' + gem = '/opt/puppet/bin/gem' if host.is_pe? || 'gem' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -18,23 +19,19 @@ hosts.each do |host| step 'setup - start http server' do script =<<-EOF - require 'webrick' + require 'sinatra' + + set :bind, '0.0.0.0' + set :static, true + set :public_folder, '#{tmpdir}' - authenticate = Proc.new do |req, res| - WEBrick::HTTPAuth.basic_auth(req, res, '') do |user, password| - user == '#{user}' && password == '#{password}' - end - end - server = WEBrick::HTTPServer.new( - :Port => 8000, - :DocumentRoot => "#{tmpdir}", - :DocumentRootOptions=> {:HandlerCallback => authenticate}, - ) - WEBrick::Daemon.start - server.start + use Rack::Auth::Basic do |username, password| + username == '#{user}' && password == '#{password}' + end EOF create_remote_file(host, "#{tmpdir}/#{http_server_script}", script) + on(host, "#{gem} install sinatra") on(host, "#{ruby} #{tmpdir}/#{http_server_script} &") end @@ -47,7 +44,7 @@ hosts.each do |host| pp = <<-EOS vcsrepo { "#{tmpdir}/#{repo_name}": ensure => present, - source => "http://#{host}:8000/testrepo.git", + source => "http://#{host}:4567/testrepo.git", provider => git, basic_auth_username => '#{user}', basic_auth_password => '#{password}', -- cgit v1.2.3 From 0406d627bcd7e24d181944b4d2c70a7b6e50ccf5 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Fri, 16 May 2014 14:58:17 -0700 Subject: Fix calls to ruby --- spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb | 2 +- spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb | 4 ++-- spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb | 4 ++-- spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb | 4 ++-- spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb | 4 ++-- .../acceptance/beaker/git/revision_checkout/revision_checkout_http.rb | 4 ++-- .../beaker/git/revision_checkout/revision_checkout_https.rb | 4 ++-- .../beaker/git/shallow_clone/negative/shallow_clone_http.rb | 2 +- spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb | 2 +- spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb | 4 ++-- spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb | 4 ++-- spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb | 4 ++-- spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb | 4 ++-- 13 files changed, 23 insertions(+), 23 deletions(-) diff --git a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb index 67a6f73..67a7ed9 100644 --- a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb +++ b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb @@ -7,7 +7,7 @@ password = 'bar' http_server_script = 'basic_auth_https_daemon.rb' hosts.each do |host| - ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' + ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb index 9fea700..6da34e8 100644 --- a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb @@ -5,7 +5,7 @@ repo_name = 'testrepo_branch_checkout' branch = 'a_branch' hosts.each do |host| - ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' + ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -27,7 +27,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "#{ruby} /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") end step 'checkout a branch with puppet' do diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb index 4d6a4ab..6ebd9fd 100644 --- a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb @@ -5,7 +5,7 @@ repo_name = 'testrepo_branch_checkout' branch = 'a_branch' hosts.each do |host| - ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' + ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -34,7 +34,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "#{ruby} /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") end step 'checkout a branch with puppet' do diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb index 4888bd2..0c86c77 100644 --- a/spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb @@ -5,7 +5,7 @@ repo_name = 'testrepo_group_checkout' group = 'mygroup' hosts.each do |host| - ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' + ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -31,7 +31,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "#{ruby} /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") apply_manifest_on(host, "group { '#{group}': ensure => absent, }") end diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb index 3a72cc8..0bcbd97 100644 --- a/spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb @@ -5,7 +5,7 @@ repo_name = 'testrepo_group_checkout' group = 'mygroup' hosts.each do |host| - ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' + ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -38,7 +38,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "#{ruby} /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") apply_manifest_on(host, "group { '#{group}': ensure => absent, }") end diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb index 5f5d9e5..9755d8e 100644 --- a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb @@ -4,7 +4,7 @@ test_name 'C3455 - checkout a revision (http protocol)' repo_name = 'testrepo_revision_checkout' hosts.each do |host| - ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' + ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -26,7 +26,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "#{ruby} /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") end step 'get revision sha from repo' do diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb index 0a935aa..16b5145 100644 --- a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb @@ -4,7 +4,7 @@ test_name 'C3456 - checkout a revision (https protocol)' repo_name = 'testrepo_revision_checkout' hosts.each do |host| - ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' + ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -33,7 +33,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "#{ruby} /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") end step 'get revision sha from repo' do diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb index 4c43be1..ecd51ad 100644 --- a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb +++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb @@ -4,7 +4,7 @@ test_name 'C3479 - shallow clone repo minimal depth = 1 (http protocol)' repo_name = 'testrepo_shallow_clone' hosts.each do |host| - ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' + ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb index 1a34521..6254865 100644 --- a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb @@ -4,7 +4,7 @@ test_name 'C3480 - shallow clone repo minimal depth = 1 (https protocol)' repo_name = 'testrepo_shallow_clone' hosts.each do |host| - ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' + ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb index f2f721a..cff6071 100644 --- a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb @@ -5,7 +5,7 @@ repo_name = 'testrepo_tag_checkout' tag = '0.0.2' hosts.each do |host| - ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' + ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -27,7 +27,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "#{ruby} /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") end step 'get tag sha from repo' do diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb index fdfa02c..1e3cc51 100644 --- a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb @@ -5,7 +5,7 @@ repo_name = 'testrepo_tag_checkout' tag = '0.0.2' hosts.each do |host| - ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' + ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -34,7 +34,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "#{ruby} /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") end step 'get tag sha from repo' do diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb index 379425b..07f5c1c 100644 --- a/spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb @@ -5,7 +5,7 @@ repo_name = 'testrepo_user_checkout' user = 'myuser' hosts.each do |host| - ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' + ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -31,7 +31,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "#{ruby} /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") apply_manifest_on(host, "user { '#{user}': ensure => absent, }") end diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb index bd9b498..7187586 100644 --- a/spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb @@ -5,7 +5,7 @@ repo_name = 'testrepo_user_checkout' user = 'myuser' hosts.each do |host| - ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby' + ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do install_package(host, 'git') @@ -38,7 +38,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "#{ruby} /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") apply_manifest_on(host, "user { '#{user}': ensure => absent, }") end -- cgit v1.2.3 From a50c949a695e04a0b5927d816c3e25ba46745c19 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Fri, 16 May 2014 14:59:19 -0700 Subject: Skip tests for unsupported features --- spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb | 1 + .../beaker/git/shallow_clone/negative/shallow_clone_file_path.rb | 1 + spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb | 1 + 3 files changed, 3 insertions(+) diff --git a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb index 67a7ed9..32e3ef4 100644 --- a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb +++ b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb @@ -1,4 +1,5 @@ test_name 'C3493 - checkout with basic auth (https protocol)' +skip_test 'waiting for CA trust solution' # Globals repo_name = 'testrepo_checkout' diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb index a2565db..c336842 100644 --- a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb +++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb @@ -1,4 +1,5 @@ test_name 'C3475 - shallow clone repo minimal depth = 1 (file path protocol)' +skip_test 'Not currently supported. See FM-1285' # Globals repo_name = 'testrepo_shallow_clone' diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb index 6254865..9220e27 100644 --- a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb @@ -1,4 +1,5 @@ test_name 'C3480 - shallow clone repo minimal depth = 1 (https protocol)' +skip_test 'Not currently supported. See FM-1286' # Globals repo_name = 'testrepo_shallow_clone' -- cgit v1.2.3 From 88727e3b8d934e59707afd8816b84943be7e3b56 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Fri, 16 May 2014 15:00:18 -0700 Subject: Fix exec for clone with excludes test --- .../beaker/git/clone/negative/clone_repo_with_exec_excludes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb b/spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb index 2ab213c..2e8d1eb 100644 --- a/spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb +++ b/spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb @@ -2,7 +2,7 @@ test_name 'C3509 - clone repo with excludes not in repo' # Globals repo_name = 'testrepo_with_excludes_not_in_repo' -exclude1 = "'exec 'rm -rf /tmp'" +exclude1 = "`exec \"rm -rf /tmp\"`" hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') -- cgit v1.2.3 From e42f4047c086a79fa0286dc9e46cdfe187a18320 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Sun, 18 May 2014 17:26:20 -0700 Subject: Fix git daemon call --- .../beaker/git/basic_auth/negative/basic_auth_checkout_git.rb | 2 +- spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb | 2 +- spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb | 2 +- spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb | 2 +- spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb | 2 +- spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb | 2 +- spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb b/spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb index 9b0f190..60a4fc2 100644 --- a/spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb +++ b/spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb @@ -17,7 +17,7 @@ hosts.each do |host| step 'setup - start git daemon' do install_package(host, 'git-daemon') - on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") + on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach") end teardown do diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb index d786ae2..baeb5ec 100644 --- a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb @@ -14,7 +14,7 @@ hosts.each do |host| end step 'setup - start git daemon' do install_package(host, 'git-daemon') - on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") + on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach") end teardown do diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb index 4752e5d..31ef286 100644 --- a/spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb @@ -14,7 +14,7 @@ hosts.each do |host| end step 'setup - start git daemon' do install_package(host, 'git-daemon') - on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") + on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach") end step 'setup - create group' do diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb index 6979df3..3fa6cbd 100644 --- a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb @@ -13,7 +13,7 @@ hosts.each do |host| end step 'setup - start git daemon' do install_package(host, 'git-daemon') - on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") + on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach") end teardown do diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb index 8b3a16a..d7c81fb 100644 --- a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb @@ -13,7 +13,7 @@ hosts.each do |host| end step 'setup - start git daemon' do install_package(host, 'git-daemon') - on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") + on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach") end teardown do diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb index 9ec124d..45a737e 100644 --- a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb @@ -14,7 +14,7 @@ hosts.each do |host| end step 'setup - start git daemon' do install_package(host, 'git-daemon') - on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") + on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach") end teardown do diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb index d954a5f..d7504b0 100644 --- a/spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb @@ -14,7 +14,7 @@ hosts.each do |host| end step 'setup - start git daemon' do install_package(host, 'git-daemon') - on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") + on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach") end step 'setup - create user' do -- cgit v1.2.3 From 982056a260cdf590acba5e33ba6eab3822428104 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Sun, 18 May 2014 17:30:33 -0700 Subject: Skip HTTP basic auth (see FM-1331) --- spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb index 69e1941..192c4f3 100644 --- a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb +++ b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb @@ -1,4 +1,5 @@ test_name 'C3492 - checkout with basic auth (http protocol)' +skip_test 'HTTP not supported yet for basic auth using git. See FM-1331' # Globals repo_name = 'testrepo_checkout' -- cgit v1.2.3 From 07be768979161434c480c6ec23d848185e157096 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Sun, 18 May 2014 17:31:34 -0700 Subject: Skip exec excludes until expectations are defined --- .../beaker/git/clone/negative/clone_repo_with_exec_excludes.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb b/spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb index 2e8d1eb..b994a6a 100644 --- a/spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb +++ b/spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb @@ -1,4 +1,5 @@ test_name 'C3509 - clone repo with excludes not in repo' +skip_test 'expectations not defined' # Globals repo_name = 'testrepo_with_excludes_not_in_repo' -- cgit v1.2.3 From 9a8e5680a5bd9179e227a13e9732721178d3ddf2 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Mon, 5 May 2014 13:49:51 -0700 Subject: Ensure vagrant user/group for non-vagrant testing These tests assert the vagrant user and group. When testing on non-vagrant systems these tests will fail. Ensure that the user/group are present in order to allow the tests to pass on other systems. --- spec/acceptance/clone_repo_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb index 4e2db19..1797c64 100644 --- a/spec/acceptance/clone_repo_spec.rb +++ b/spec/acceptance/clone_repo_spec.rb @@ -184,6 +184,13 @@ describe 'clones a remote repo' do end context 'with an owner' do + pp = <<-EOS + user { 'vagrant': + ensure => present, + } + EOS + + apply_manifest(pp, :catch_failures => true) it 'clones a repo' do pp = <<-EOS vcsrepo { "#{tmpdir}/testrepo_owner": @@ -206,6 +213,14 @@ describe 'clones a remote repo' do end context 'with a group' do + pp = <<-EOS + group { 'vagrant': + ensure => present, + } + EOS + + apply_manifest(pp, :catch_failures => true) + it 'clones a repo' do pp = <<-EOS vcsrepo { "/#{tmpdir}/testrepo_group": -- cgit v1.2.3 From d6b22213f2cea9b58d5e2fa48f4fea2227c184ef Mon Sep 17 00:00:00 2001 From: John Duarte Date: Mon, 19 May 2014 11:53:54 -0700 Subject: Move protocol tests to beaker suite The protocol tests are more closely aligned with the rest of the beaker test suite. The beaker tests have received more vetting, so the setup and teardown process should be less prone to failure on repeated execution. --- spec/acceptance/beaker/git/clone/clone_file.rb | 42 ++++ .../acceptance/beaker/git/clone/clone_file_path.rb | 42 ++++ spec/acceptance/beaker/git/clone/clone_git.rb | 47 +++++ spec/acceptance/beaker/git/clone/clone_http.rb | 55 +++++ spec/acceptance/beaker/git/clone/clone_https.rb | 62 ++++++ spec/acceptance/beaker/git/clone/clone_scp.rb | 52 +++++ spec/acceptance/beaker/git/clone/clone_ssh.rb | 52 +++++ spec/acceptance/git_clone_protocols_spec.rb | 230 --------------------- 8 files changed, 352 insertions(+), 230 deletions(-) create mode 100644 spec/acceptance/beaker/git/clone/clone_file.rb create mode 100644 spec/acceptance/beaker/git/clone/clone_file_path.rb create mode 100644 spec/acceptance/beaker/git/clone/clone_git.rb create mode 100644 spec/acceptance/beaker/git/clone/clone_http.rb create mode 100644 spec/acceptance/beaker/git/clone/clone_https.rb create mode 100644 spec/acceptance/beaker/git/clone/clone_scp.rb create mode 100644 spec/acceptance/beaker/git/clone/clone_ssh.rb delete mode 100644 spec/acceptance/git_clone_protocols_spec.rb diff --git a/spec/acceptance/beaker/git/clone/clone_file.rb b/spec/acceptance/beaker/git/clone/clone_file.rb new file mode 100644 index 0000000..dc3a503 --- /dev/null +++ b/spec/acceptance/beaker/git/clone/clone_file.rb @@ -0,0 +1,42 @@ +test_name 'C3427 - clone (file protocol)' + +# Globals +repo_name = 'testrepo_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'clone with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the master branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master" + end + end + +end diff --git a/spec/acceptance/beaker/git/clone/clone_file_path.rb b/spec/acceptance/beaker/git/clone/clone_file_path.rb new file mode 100644 index 0000000..b76e9b9 --- /dev/null +++ b/spec/acceptance/beaker/git/clone/clone_file_path.rb @@ -0,0 +1,42 @@ +test_name 'C3426 - clone (file path)' + +# Globals +repo_name = 'testrepo_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'clone with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "#{tmpdir}/testrepo.git", + provider => git, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the master branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master" + end + end + +end diff --git a/spec/acceptance/beaker/git/clone/clone_git.rb b/spec/acceptance/beaker/git/clone/clone_git.rb new file mode 100644 index 0000000..01d2ce9 --- /dev/null +++ b/spec/acceptance/beaker/git/clone/clone_git.rb @@ -0,0 +1,47 @@ +test_name 'C3425 - clone (git protocol)' + +# Globals +repo_name = 'testrepo_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start git daemon' do + install_package(host, 'git-daemon') + on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, 'pkill -9 git-daemon') + end + + step 'clone with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "git://#{host}/testrepo.git", + provider => git, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the master branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master" + end + end + +end diff --git a/spec/acceptance/beaker/git/clone/clone_http.rb b/spec/acceptance/beaker/git/clone/clone_http.rb new file mode 100644 index 0000000..664ab10 --- /dev/null +++ b/spec/acceptance/beaker/git/clone/clone_http.rb @@ -0,0 +1,55 @@ +test_name 'C3430 - clone (http protocol)' + +# Globals +repo_name = 'testrepo_clone' + +hosts.each do |host| + ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + + step 'setup - start http server' do + http_daemon =<<-EOF + require 'webrick' + server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/http_daemon.rb', http_daemon) + on(host, "#{ruby} /tmp/http_daemon.rb") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") + end + + step 'clone with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "http://#{host}:8000/testrepo.git", + provider => git, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the master branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master" + end + end + +end diff --git a/spec/acceptance/beaker/git/clone/clone_https.rb b/spec/acceptance/beaker/git/clone/clone_https.rb new file mode 100644 index 0000000..4e41c99 --- /dev/null +++ b/spec/acceptance/beaker/git/clone/clone_https.rb @@ -0,0 +1,62 @@ +test_name 'C3431 - clone (https protocol)' + +# Globals +repo_name = 'testrepo_clone' + +hosts.each do |host| + ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - start https server' do + https_daemon =<<-EOF + require 'webrick' + require 'webrick/https' + server = WEBrick::HTTPServer.new( + :Port => 8443, + :DocumentRoot => "#{tmpdir}", + :SSLEnable => true, + :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, + :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), + :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), + :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) + WEBrick::Daemon.start + server.start + EOF + create_remote_file(host, '/tmp/https_daemon.rb', https_daemon) + #on(host, "#{ruby} /tmp/https_daemon.rb") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") + end + + step 'clone with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "https://github.com/johnduarte/testrepo.git", + provider => git, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the master branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master" + end + end + +end diff --git a/spec/acceptance/beaker/git/clone/clone_scp.rb b/spec/acceptance/beaker/git/clone/clone_scp.rb new file mode 100644 index 0000000..ba8d519 --- /dev/null +++ b/spec/acceptance/beaker/git/clone/clone_scp.rb @@ -0,0 +1,52 @@ +test_name 'C3428 - clone (ssh protocol, scp syntax)' + +# Globals +repo_name = 'testrepo_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - establish ssh keys' do + # create ssh keys + on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') + on(host, 'chown -R root:root /root/.ssh') + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + end + + step 'clone with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "root@#{host}:#{tmpdir}/testrepo.git", + provider => git, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the master branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master" + end + end + +end diff --git a/spec/acceptance/beaker/git/clone/clone_ssh.rb b/spec/acceptance/beaker/git/clone/clone_ssh.rb new file mode 100644 index 0000000..fcc85e3 --- /dev/null +++ b/spec/acceptance/beaker/git/clone/clone_ssh.rb @@ -0,0 +1,52 @@ +test_name 'C3429 - clone (ssh protocol)' + +# Globals +repo_name = 'testrepo_clone' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + end + step 'setup - establish ssh keys' do + # create ssh keys + on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') + on(host, 'chown -R root:root /root/.ssh') + end + + teardown do + on(host, "rm -fr #{tmpdir}") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + end + + step 'clone with puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "ssh://root@#{host}#{tmpdir}/testrepo.git", + provider => git, + } + EOS + + apply_manifest_on(host, pp) + apply_manifest_on(host, pp) + end + + step "verify checkout is on the master branch" do + on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res| + fail_test('checkout not found') unless res.stdout.include? "HEAD" + end + + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master" + end + end + +end diff --git a/spec/acceptance/git_clone_protocols_spec.rb b/spec/acceptance/git_clone_protocols_spec.rb deleted file mode 100644 index 4d9129e..0000000 --- a/spec/acceptance/git_clone_protocols_spec.rb +++ /dev/null @@ -1,230 +0,0 @@ -require 'spec_helper_acceptance' - -hosts.each do |host| - - describe 'clones a repo with git' do - tmpdir = host.tmpdir('vcsrepo') - - before(:all) do - # {{{ setup - apply_manifest_on(host, "user{'testuser': ensure => present, managehome => true }") - apply_manifest_on(host, "user{'vagrant': ensure => present, }") - # install git - install_package(host, 'git') - install_package(host, 'git-daemon') - # create ssh keys - on(host, 'mkdir -p /home/testuser/.ssh') - on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') - - # copy public key to authorized_keys - on(host, 'cat /root/.ssh/id_rsa.pub >> /home/testuser/.ssh/authorized_keys') - on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /home/testuser/.ssh/config') - on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') - on(host, 'chown -R testuser:testuser /home/testuser/.ssh') - on(host, 'chown -R root:root /root/.ssh') - - # create git repo - my_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) - scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) - on(host, "cd #{tmpdir} && ./create_git_repo.sh") - - # copy ssl keys - scp_to(host, "#{my_root}/acceptance/files/server.crt", tmpdir) - scp_to(host, "#{my_root}/acceptance/files/server.key", tmpdir) - # }}} - end - - after(:all) do - # {{{ teardown - apply_manifest_on(host, "user{'testuser': ensure => absent, managehome => true }") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") - # }}} - end - - - #--------------- TESTS ----------------------# - - context 'using local protocol (file URL)' do - before(:all) do - apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") - end - - it 'should have HEAD pointing to master' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/testrepo": - ensure => present, - provider => git, - source => "file://#{tmpdir}/testrepo.git", - } - EOS - - # Run it twice and test for idempotency - apply_manifest_on(host, pp, :catch_failures => true) - apply_manifest_on(host, pp, :catch_changes => true) - end - - describe file("#{tmpdir}/testrepo/.git/HEAD") do - it { should contain 'ref: refs/heads/master' } - end - - end - - context 'using local protocol (file path)' do - before(:all) do - apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") - end - - it 'should have HEAD pointing to master' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/testrepo": - ensure => present, - provider => git, - source => "#{tmpdir}/testrepo.git", - } - EOS - - # Run it twice and test for idempotency - apply_manifest_on(host, pp, :catch_failures => true) - apply_manifest_on(host, pp, :catch_changes => true) - end - - describe file("#{tmpdir}/testrepo/.git/HEAD") do - it { should contain 'ref: refs/heads/master' } - end - - end - - context 'using git protocol' do - before(:all) do - apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") - on(host, "nohup git daemon --detach --base-path=/#{tmpdir}") - end - - it 'should have HEAD pointing to master' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/testrepo": - ensure => present, - provider => git, - source => "git://#{host}/testrepo.git", - } - EOS - - # Run it twice and test for idempotency - apply_manifest_on(host, pp, :catch_failures => true) - apply_manifest_on(host, pp, :catch_changes => true) - end - describe file("#{tmpdir}/testrepo/.git/HEAD") do - it { should contain 'ref: refs/heads/master' } - end - - after(:all) do - on(host, 'pkill -9 git') - end - end - - context 'using http protocol' do - before(:all) do - apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") - daemon =<<-EOF - require 'webrick' - server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}") - WEBrick::Daemon.start - server.start - EOF - create_remote_file(host, '/tmp/daemon.rb', daemon) - on(host, "ruby /tmp/daemon.rb") - end - - it 'should have HEAD pointing to master' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/testrepo": - ensure => present, - provider => git, - source => "http://#{host}:8000/testrepo.git", - } - EOS - - # Run it twice and test for idempotency - apply_manifest_on(host, pp, :catch_failures => true) - apply_manifest_on(host, pp, :catch_changes => true) - end - describe file("#{tmpdir}/testrepo/.git/HEAD") do - it { should contain 'ref: refs/heads/master' } - end - - after(:all) do - on(host, 'pkill -9 ruby') - end - end - - context 'using https protocol' do - before(:all) do - apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") - daemon =<<-EOF - require 'webrick' - require 'webrick/https' - server = WEBrick::HTTPServer.new( - :Port => 8443, - :DocumentRoot => "#{tmpdir}", - :SSLEnable => true, - :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, - :SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read), - :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read), - :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ]) - WEBrick::Daemon.start - server.start - EOF - create_remote_file(host, '/tmp/daemon.rb', daemon) - on(host, "ruby /tmp/daemon.rb") - end - - it 'should have HEAD pointing to master' do - # howto whitelist ssl cert - pp = <<-EOS - vcsrepo { "#{tmpdir}/testrepo": - ensure => present, - provider => git, - source => "https://#{host}:8443/testrepo.git", - } - EOS - - # Run it twice and test for idempotency - apply_manifest_on(host, pp, :catch_failures => true) - apply_manifest_on(host, pp, :catch_changes => true) - end - - describe file("#{tmpdir}/testrepo/.git/HEAD") do - it { should contain 'ref: refs/heads/master' } - end - - after(:all) do - on(host, 'pkill -9 ruby') - end - end - - context 'using ssh protocol' do - before(:all) do - apply_manifest_on(host, "file {'#{tmpdir}/testrepo': ensure => directory, purge => true, recurse => true, recurselimit => 1, force => true; }") - end - it 'should have HEAD pointing to master' do - pp = <<-EOS - vcsrepo { "#{tmpdir}/testrepo": - ensure => present, - provider => git, - source => "ssh://root@#{host}#{tmpdir}/testrepo.git", - } - EOS - - # Run it twice and test for idempotency - apply_manifest_on(host, pp, :catch_failures => true) - apply_manifest_on(host, pp, :catch_changes => true) - end - - describe file("#{tmpdir}/testrepo/.git/HEAD") do - it { should contain 'ref: refs/heads/master' } - end - end - - end -end -- cgit v1.2.3 From 932eb74ac487c815e51b1e99bb2f57ee82169be2 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Thu, 22 May 2014 00:16:10 +0200 Subject: Un-optional the non-optional commands. --- lib/puppet/provider/vcsrepo/bzr.rb | 2 +- lib/puppet/provider/vcsrepo/cvs.rb | 2 +- lib/puppet/provider/vcsrepo/git.rb | 5 +++-- lib/puppet/provider/vcsrepo/hg.rb | 5 +++-- lib/puppet/provider/vcsrepo/svn.rb | 6 +++--- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/puppet/provider/vcsrepo/bzr.rb b/lib/puppet/provider/vcsrepo/bzr.rb index 80b18ed..797d84d 100644 --- a/lib/puppet/provider/vcsrepo/bzr.rb +++ b/lib/puppet/provider/vcsrepo/bzr.rb @@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '..', 'vcsrepo') Puppet::Type.type(:vcsrepo).provide(:bzr, :parent => Puppet::Provider::Vcsrepo) do desc "Supports Bazaar repositories" - optional_commands :bzr => 'bzr' + commands :bzr => 'bzr' has_features :reference_tracking def create diff --git a/lib/puppet/provider/vcsrepo/cvs.rb b/lib/puppet/provider/vcsrepo/cvs.rb index 206e732..01094b1 100644 --- a/lib/puppet/provider/vcsrepo/cvs.rb +++ b/lib/puppet/provider/vcsrepo/cvs.rb @@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '..', 'vcsrepo') Puppet::Type.type(:vcsrepo).provide(:cvs, :parent => Puppet::Provider::Vcsrepo) do desc "Supports CVS repositories/workspaces" - optional_commands :cvs => 'cvs' + commands :cvs => 'cvs' has_features :gzip_compression, :reference_tracking, :modules, :cvs_rsh def create diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 61044e0..1bccfb6 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -4,8 +4,9 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) desc "Supports Git repositories" ##TODO modify the commands below so that the su - is included - optional_commands :git => 'git', - :su => 'su' + commands :git => 'git' + optional_commands :su => 'su' + has_features :bare_repositories, :reference_tracking, :ssh_identity, :multiple_remotes, :user, :depth def create diff --git a/lib/puppet/provider/vcsrepo/hg.rb b/lib/puppet/provider/vcsrepo/hg.rb index 6c6f936..56ca527 100644 --- a/lib/puppet/provider/vcsrepo/hg.rb +++ b/lib/puppet/provider/vcsrepo/hg.rb @@ -3,8 +3,9 @@ require File.join(File.dirname(__FILE__), '..', 'vcsrepo') Puppet::Type.type(:vcsrepo).provide(:hg, :parent => Puppet::Provider::Vcsrepo) do desc "Supports Mercurial repositories" - optional_commands :hg => 'hg', - :su => 'su' + commands :hg => 'hg' + optional_commands :su => 'su' + has_features :reference_tracking, :ssh_identity, :user def create diff --git a/lib/puppet/provider/vcsrepo/svn.rb b/lib/puppet/provider/vcsrepo/svn.rb index 7856acd..316a3a1 100644 --- a/lib/puppet/provider/vcsrepo/svn.rb +++ b/lib/puppet/provider/vcsrepo/svn.rb @@ -3,9 +3,9 @@ require File.join(File.dirname(__FILE__), '..', 'vcsrepo') Puppet::Type.type(:vcsrepo).provide(:svn, :parent => Puppet::Provider::Vcsrepo) do desc "Supports Subversion repositories" - optional_commands :svn => 'svn', - :svnadmin => 'svnadmin', - :svnlook => 'svnlook' + commands :svn => 'svn', + :svnadmin => 'svnadmin', + :svnlook => 'svnlook' has_features :filesystem_types, :reference_tracking, :basic_auth, :configuration -- cgit v1.2.3 From 0d9e938e92a25673c3712866e2d2108a255b67d5 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Tue, 20 May 2014 18:15:03 -0700 Subject: Update specs and fix FM-1361 - Add install.rb for pre-suite - Add catches for failures/changes to manifest application - Correct root ssh key copying - Add sleeps for killing processes releasing ports - Fix FM-1361 --- Gemfile | 3 --- lib/puppet/provider/vcsrepo/git.rb | 9 ++++----- .../beaker/git/basic_auth/basic_auth_checkout_http.rb | 6 +++--- .../beaker/git/basic_auth/basic_auth_checkout_https.rb | 6 +++--- .../git/basic_auth/negative/basic_auth_checkout_git.rb | 6 +++--- .../beaker/git/branch_checkout/branch_checkout_file.rb | 4 ++-- .../git/branch_checkout/branch_checkout_file_path.rb | 4 ++-- .../beaker/git/branch_checkout/branch_checkout_git.rb | 6 +++--- .../beaker/git/branch_checkout/branch_checkout_http.rb | 6 +++--- .../git/branch_checkout/branch_checkout_https.rb | 6 +++--- .../beaker/git/branch_checkout/branch_checkout_scp.rb | 11 ++++++----- .../beaker/git/branch_checkout/branch_checkout_ssh.rb | 11 ++++++----- .../negative/branch_checkout_not_exists.rb | 3 +-- spec/acceptance/beaker/git/clone/clone_file.rb | 4 ++-- spec/acceptance/beaker/git/clone/clone_file_path.rb | 4 ++-- spec/acceptance/beaker/git/clone/clone_git.rb | 6 +++--- spec/acceptance/beaker/git/clone/clone_http.rb | 6 +++--- spec/acceptance/beaker/git/clone/clone_https.rb | 6 +++--- .../clone_over_different_exiting_repo_with_force.rb | 3 ++- .../git/clone/clone_repo_with_excludes_in_repo.rb | 4 ++-- .../git/clone/clone_repo_with_excludes_not_in_repo.rb | 4 ++-- spec/acceptance/beaker/git/clone/clone_scp.rb | 11 ++++++----- spec/acceptance/beaker/git/clone/clone_ssh.rb | 11 ++++++----- .../negative/clone_over_different_exiting_repo.rb | 3 ++- .../clone/negative/clone_repo_with_exec_excludes.rb | 4 ++-- .../beaker/git/compression/compression_0_checkout.rb | 4 ++-- .../beaker/git/compression/compression_1_checkout.rb | 4 ++-- .../beaker/git/compression/compression_2_checkout.rb | 4 ++-- .../beaker/git/compression/compression_3_checkout.rb | 4 ++-- .../beaker/git/compression/compression_4_checkout.rb | 4 ++-- .../beaker/git/compression/compression_5_checkout.rb | 4 ++-- .../beaker/git/compression/compression_6_checkout.rb | 4 ++-- .../git/compression/negative/compression_7_checkout.rb | 4 ++-- .../compression/negative/compression_alpha_checkout.rb | 4 ++-- .../compression/negative/compression_eval_checkout.rb | 4 ++-- .../compression/negative/compression_exec_checkout.rb | 4 ++-- .../negative/compression_negative_checkout.rb | 4 ++-- .../git/create/create_bare_repo_that_already_exists.rb | 3 ++- .../git/create/create_repo_that_already_exists.rb | 3 ++- .../negative/create_bare_repo_specifying_revision.rb | 6 +++--- .../beaker/git/group_checkout/group_checkout_file.rb | 8 ++++---- .../git/group_checkout/group_checkout_file_path.rb | 8 ++++---- .../beaker/git/group_checkout/group_checkout_git.rb | 10 +++++----- .../beaker/git/group_checkout/group_checkout_http.rb | 10 +++++----- .../beaker/git/group_checkout/group_checkout_https.rb | 10 +++++----- .../beaker/git/group_checkout/group_checkout_scp.rb | 15 ++++++++------- .../beaker/git/group_checkout/group_checkout_ssh.rb | 15 ++++++++------- .../negative/group_checkout_file_non_existent_group.rb | 5 ++--- .../negative/revision_checkout_not_exists.rb | 3 +-- .../git/revision_checkout/revision_checkout_file.rb | 4 ++-- .../revision_checkout/revision_checkout_file_path.rb | 4 ++-- .../git/revision_checkout/revision_checkout_git.rb | 6 +++--- .../git/revision_checkout/revision_checkout_http.rb | 6 +++--- .../git/revision_checkout/revision_checkout_https.rb | 6 +++--- .../git/revision_checkout/revision_checkout_scp.rb | 11 ++++++----- .../git/revision_checkout/revision_checkout_ssh.rb | 11 ++++++----- .../shallow_clone/negative/shallow_clone_exec_depth.rb | 4 ++-- .../shallow_clone/negative/shallow_clone_file_path.rb | 4 ++-- .../git/shallow_clone/negative/shallow_clone_http.rb | 5 ++--- .../negative/shallow_clone_negative_depth.rb | 4 ++-- .../negative/shallow_clone_overflow_depth.rb | 4 ++-- .../beaker/git/shallow_clone/shallow_clone_file.rb | 4 ++-- .../beaker/git/shallow_clone/shallow_clone_git.rb | 6 +++--- .../beaker/git/shallow_clone/shallow_clone_https.rb | 6 +++--- .../beaker/git/shallow_clone/shallow_clone_scp.rb | 11 ++++++----- .../beaker/git/shallow_clone/shallow_clone_ssh.rb | 11 ++++++----- .../git/shallow_clone/shallow_clone_zero_depth.rb | 4 ++-- .../tag_checkout/negative/tag_checkout_not_exists.rb | 4 ++-- .../beaker/git/tag_checkout/tag_checkout_file.rb | 4 ++-- .../beaker/git/tag_checkout/tag_checkout_file_path.rb | 4 ++-- .../beaker/git/tag_checkout/tag_checkout_git.rb | 6 +++--- .../beaker/git/tag_checkout/tag_checkout_http.rb | 6 +++--- .../beaker/git/tag_checkout/tag_checkout_https.rb | 6 +++--- .../beaker/git/tag_checkout/tag_checkout_scp.rb | 11 ++++++----- .../beaker/git/tag_checkout/tag_checkout_ssh.rb | 11 ++++++----- .../negative/user_checkout_file_non_existent_user.rb | 5 ++--- .../beaker/git/user_checkout/user_checkout_file.rb | 8 ++++---- .../git/user_checkout/user_checkout_file_path.rb | 8 ++++---- .../beaker/git/user_checkout/user_checkout_git.rb | 10 +++++----- .../beaker/git/user_checkout/user_checkout_http.rb | 10 +++++----- .../beaker/git/user_checkout/user_checkout_https.rb | 10 +++++----- .../beaker/git/user_checkout/user_checkout_scp.rb | 15 ++++++++------- .../beaker/git/user_checkout/user_checkout_ssh.rb | 15 ++++++++------- spec/acceptance/beaker_helper.rb | 18 ++++++++++++++++++ spec/unit/puppet/provider/vcsrepo/git_spec.rb | 7 ++++--- 85 files changed, 294 insertions(+), 266 deletions(-) create mode 100644 spec/acceptance/beaker_helper.rb diff --git a/Gemfile b/Gemfile index ad7f34e..2fcc822 100644 --- a/Gemfile +++ b/Gemfile @@ -4,9 +4,6 @@ group :development, :test do gem 'rake', :require => false gem 'rspec-puppet', :require => false gem 'puppetlabs_spec_helper', :require => false - gem 'rspec-system', :require => false - gem 'rspec-system-puppet', :require => false - gem 'rspec-system-serverspec', :require => false gem 'serverspec', :require => false gem 'puppet-lint', :require => false gem 'pry', :require => false diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 61044e0..f6ee407 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -9,16 +9,15 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) has_features :bare_repositories, :reference_tracking, :ssh_identity, :multiple_remotes, :user, :depth def create + if @resource.value(:revision) and @resource.value(:ensure) == :bare + fail("Cannot set a revision (#{@resource.value(:revision)}) on a bare repository") + end if !@resource.value(:source) init_repository(@resource.value(:path)) else clone_repository(@resource.value(:source), @resource.value(:path)) if @resource.value(:revision) - if @resource.value(:ensure) == :bare - notice "Ignoring revision for bare repository" - else - checkout - end + checkout end if @resource.value(:ensure) != :bare update_submodules diff --git a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb index 192c4f3..18c7534 100644 --- a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb +++ b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb @@ -38,7 +38,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, "ps ax | grep '#{ruby} #{tmpdir}/#{http_server_script}' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") + on(host, "ps ax | grep '#{ruby} #{tmpdir}/#{http_server_script}' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1") end step 'checkout with puppet using basic auth' do @@ -52,8 +52,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout" do diff --git a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb index 32e3ef4..ac1359e 100644 --- a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb +++ b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb @@ -46,7 +46,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, "ps ax | grep '#{ruby} #{tmpdir}/#{http_server_script}' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") + on(host, "ps ax | grep '#{ruby} #{tmpdir}/#{http_server_script}' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1") end step 'checkout with puppet using basic auth' do @@ -60,8 +60,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout" do diff --git a/spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb b/spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb index 60a4fc2..67544bf 100644 --- a/spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb +++ b/spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb @@ -22,7 +22,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'pkill -9 git-daemon') + on(host, 'pkill -9 git-daemon ; sleep 1') end step 'checkout with puppet using basic auth' do @@ -36,8 +36,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout (silent error for basic auth using git protocol)" do diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file.rb index 6ed945b..1fbdd1a 100644 --- a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file.rb +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file.rb @@ -27,8 +27,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout is on the #{branch} branch" do diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file_path.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file_path.rb index 441a2bc..efbedc7 100644 --- a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file_path.rb +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file_path.rb @@ -27,8 +27,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout is on the #{branch} branch" do diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb index baeb5ec..8afa813 100644 --- a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb @@ -19,7 +19,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'pkill -9 git-daemon') + on(host, 'pkill -9 git-daemon ; sleep 1') end step 'checkout a branch with puppet' do @@ -32,8 +32,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout is on the #{branch} branch" do diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb index 6da34e8..a8d622d 100644 --- a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb @@ -27,7 +27,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") + on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1") end step 'checkout a branch with puppet' do @@ -40,8 +40,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout is on the #{branch} branch" do diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb index 6ebd9fd..f6baf19 100644 --- a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb @@ -34,7 +34,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") + on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1") end step 'checkout a branch with puppet' do @@ -47,8 +47,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout is on the #{branch} branch" do diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_scp.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_scp.rb index 0a4e07a..e55f805 100644 --- a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_scp.rb +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_scp.rb @@ -14,17 +14,18 @@ hosts.each do |host| end step 'setup - establish ssh keys' do # create ssh keys - on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') # copy public key to authorized_keys + on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys') on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') on(host, 'chown -R root:root /root/.ssh') end teardown do on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true) + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true) end step 'checkout a branch with puppet' do @@ -37,8 +38,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout is on the #{branch} branch" do diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_ssh.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_ssh.rb index ea9fb4a..6063bb9 100644 --- a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_ssh.rb +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_ssh.rb @@ -14,17 +14,18 @@ hosts.each do |host| end step 'setup - establish ssh keys' do # create ssh keys - on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') # copy public key to authorized_keys + on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys') on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') on(host, 'chown -R root:root /root/.ssh') end teardown do on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true) + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true) end step 'checkout a branch with puppet' do @@ -37,8 +38,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout is on the #{branch} branch" do diff --git a/spec/acceptance/beaker/git/branch_checkout/negative/branch_checkout_not_exists.rb b/spec/acceptance/beaker/git/branch_checkout/negative/branch_checkout_not_exists.rb index f8c85d0..e44ea7e 100644 --- a/spec/acceptance/beaker/git/branch_checkout/negative/branch_checkout_not_exists.rb +++ b/spec/acceptance/beaker/git/branch_checkout/negative/branch_checkout_not_exists.rb @@ -26,8 +26,7 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :expect_failures => true) end step 'verify that master branch is checked out' do diff --git a/spec/acceptance/beaker/git/clone/clone_file.rb b/spec/acceptance/beaker/git/clone/clone_file.rb index dc3a503..a9ca366 100644 --- a/spec/acceptance/beaker/git/clone/clone_file.rb +++ b/spec/acceptance/beaker/git/clone/clone_file.rb @@ -25,8 +25,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout is on the master branch" do diff --git a/spec/acceptance/beaker/git/clone/clone_file_path.rb b/spec/acceptance/beaker/git/clone/clone_file_path.rb index b76e9b9..616030c 100644 --- a/spec/acceptance/beaker/git/clone/clone_file_path.rb +++ b/spec/acceptance/beaker/git/clone/clone_file_path.rb @@ -25,8 +25,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout is on the master branch" do diff --git a/spec/acceptance/beaker/git/clone/clone_git.rb b/spec/acceptance/beaker/git/clone/clone_git.rb index 01d2ce9..8a810af 100644 --- a/spec/acceptance/beaker/git/clone/clone_git.rb +++ b/spec/acceptance/beaker/git/clone/clone_git.rb @@ -18,7 +18,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'pkill -9 git-daemon') + on(host, 'pkill -9 git-daemon ; sleep 1') end step 'clone with puppet' do @@ -30,8 +30,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout is on the master branch" do diff --git a/spec/acceptance/beaker/git/clone/clone_http.rb b/spec/acceptance/beaker/git/clone/clone_http.rb index 664ab10..5ba7915 100644 --- a/spec/acceptance/beaker/git/clone/clone_http.rb +++ b/spec/acceptance/beaker/git/clone/clone_http.rb @@ -26,7 +26,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") + on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1") end step 'clone with puppet' do @@ -38,8 +38,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout is on the master branch" do diff --git a/spec/acceptance/beaker/git/clone/clone_https.rb b/spec/acceptance/beaker/git/clone/clone_https.rb index 4e41c99..0d3d1f6 100644 --- a/spec/acceptance/beaker/git/clone/clone_https.rb +++ b/spec/acceptance/beaker/git/clone/clone_https.rb @@ -33,7 +33,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") + on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1") end step 'clone with puppet' do @@ -45,8 +45,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout is on the master branch" do diff --git a/spec/acceptance/beaker/git/clone/clone_over_different_exiting_repo_with_force.rb b/spec/acceptance/beaker/git/clone/clone_over_different_exiting_repo_with_force.rb index 626d807..a88709f 100644 --- a/spec/acceptance/beaker/git/clone/clone_over_different_exiting_repo_with_force.rb +++ b/spec/acceptance/beaker/git/clone/clone_over_different_exiting_repo_with_force.rb @@ -32,7 +32,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify new repo has replaced old one' do diff --git a/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_in_repo.rb b/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_in_repo.rb index 0a5a1a8..89844c3 100644 --- a/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_in_repo.rb +++ b/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_in_repo.rb @@ -28,8 +28,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify exludes are known to git' do diff --git a/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_not_in_repo.rb b/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_not_in_repo.rb index c533aa5..10c0e8e 100644 --- a/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_not_in_repo.rb +++ b/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_not_in_repo.rb @@ -28,8 +28,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify exludes are known to git' do diff --git a/spec/acceptance/beaker/git/clone/clone_scp.rb b/spec/acceptance/beaker/git/clone/clone_scp.rb index ba8d519..709079d 100644 --- a/spec/acceptance/beaker/git/clone/clone_scp.rb +++ b/spec/acceptance/beaker/git/clone/clone_scp.rb @@ -13,17 +13,18 @@ hosts.each do |host| end step 'setup - establish ssh keys' do # create ssh keys - on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') # copy public key to authorized_keys + on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys') on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') on(host, 'chown -R root:root /root/.ssh') end teardown do on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true) + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true) end step 'clone with puppet' do @@ -35,8 +36,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout is on the master branch" do diff --git a/spec/acceptance/beaker/git/clone/clone_ssh.rb b/spec/acceptance/beaker/git/clone/clone_ssh.rb index fcc85e3..7f4a9a4 100644 --- a/spec/acceptance/beaker/git/clone/clone_ssh.rb +++ b/spec/acceptance/beaker/git/clone/clone_ssh.rb @@ -13,17 +13,18 @@ hosts.each do |host| end step 'setup - establish ssh keys' do # create ssh keys - on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') # copy public key to authorized_keys + on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys') on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') on(host, 'chown -R root:root /root/.ssh') end teardown do on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true) + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true) end step 'clone with puppet' do @@ -35,8 +36,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout is on the master branch" do diff --git a/spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb b/spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb index 67fea06..8adb1af 100644 --- a/spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb +++ b/spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb @@ -31,7 +31,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify original repo was not replaced' do diff --git a/spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb b/spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb index b994a6a..2264015 100644 --- a/spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb +++ b/spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb @@ -28,8 +28,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify excludes are known to git' do diff --git a/spec/acceptance/beaker/git/compression/compression_0_checkout.rb b/spec/acceptance/beaker/git/compression/compression_0_checkout.rb index ee5a171..f17d497 100644 --- a/spec/acceptance/beaker/git/compression/compression_0_checkout.rb +++ b/spec/acceptance/beaker/git/compression/compression_0_checkout.rb @@ -26,8 +26,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify git repo was checked out' do diff --git a/spec/acceptance/beaker/git/compression/compression_1_checkout.rb b/spec/acceptance/beaker/git/compression/compression_1_checkout.rb index 01478a1..ee910fd 100644 --- a/spec/acceptance/beaker/git/compression/compression_1_checkout.rb +++ b/spec/acceptance/beaker/git/compression/compression_1_checkout.rb @@ -26,8 +26,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify git repo was checked out' do diff --git a/spec/acceptance/beaker/git/compression/compression_2_checkout.rb b/spec/acceptance/beaker/git/compression/compression_2_checkout.rb index b3413ea..aeec31a 100644 --- a/spec/acceptance/beaker/git/compression/compression_2_checkout.rb +++ b/spec/acceptance/beaker/git/compression/compression_2_checkout.rb @@ -26,8 +26,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify git repo was checked out' do diff --git a/spec/acceptance/beaker/git/compression/compression_3_checkout.rb b/spec/acceptance/beaker/git/compression/compression_3_checkout.rb index b8459a5..fe1ee0a 100644 --- a/spec/acceptance/beaker/git/compression/compression_3_checkout.rb +++ b/spec/acceptance/beaker/git/compression/compression_3_checkout.rb @@ -26,8 +26,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify git repo was checked out' do diff --git a/spec/acceptance/beaker/git/compression/compression_4_checkout.rb b/spec/acceptance/beaker/git/compression/compression_4_checkout.rb index f6fb5ec..071cc5e 100644 --- a/spec/acceptance/beaker/git/compression/compression_4_checkout.rb +++ b/spec/acceptance/beaker/git/compression/compression_4_checkout.rb @@ -26,8 +26,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify git repo was checked out' do diff --git a/spec/acceptance/beaker/git/compression/compression_5_checkout.rb b/spec/acceptance/beaker/git/compression/compression_5_checkout.rb index a09507c..1ea0737 100644 --- a/spec/acceptance/beaker/git/compression/compression_5_checkout.rb +++ b/spec/acceptance/beaker/git/compression/compression_5_checkout.rb @@ -26,8 +26,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify git repo was checked out' do diff --git a/spec/acceptance/beaker/git/compression/compression_6_checkout.rb b/spec/acceptance/beaker/git/compression/compression_6_checkout.rb index 0a2d5d5..a8376d7 100644 --- a/spec/acceptance/beaker/git/compression/compression_6_checkout.rb +++ b/spec/acceptance/beaker/git/compression/compression_6_checkout.rb @@ -26,8 +26,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify git repo was checked out' do diff --git a/spec/acceptance/beaker/git/compression/negative/compression_7_checkout.rb b/spec/acceptance/beaker/git/compression/negative/compression_7_checkout.rb index a6be973..c5f49e6 100644 --- a/spec/acceptance/beaker/git/compression/negative/compression_7_checkout.rb +++ b/spec/acceptance/beaker/git/compression/negative/compression_7_checkout.rb @@ -26,8 +26,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify git repo was checked out' do diff --git a/spec/acceptance/beaker/git/compression/negative/compression_alpha_checkout.rb b/spec/acceptance/beaker/git/compression/negative/compression_alpha_checkout.rb index 8acdb57..74fd112 100644 --- a/spec/acceptance/beaker/git/compression/negative/compression_alpha_checkout.rb +++ b/spec/acceptance/beaker/git/compression/negative/compression_alpha_checkout.rb @@ -26,8 +26,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify git repo was checked out' do diff --git a/spec/acceptance/beaker/git/compression/negative/compression_eval_checkout.rb b/spec/acceptance/beaker/git/compression/negative/compression_eval_checkout.rb index 5597646..ba56621 100644 --- a/spec/acceptance/beaker/git/compression/negative/compression_eval_checkout.rb +++ b/spec/acceptance/beaker/git/compression/negative/compression_eval_checkout.rb @@ -26,8 +26,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify git repo was checked out' do diff --git a/spec/acceptance/beaker/git/compression/negative/compression_exec_checkout.rb b/spec/acceptance/beaker/git/compression/negative/compression_exec_checkout.rb index c85818d..abab7f1 100644 --- a/spec/acceptance/beaker/git/compression/negative/compression_exec_checkout.rb +++ b/spec/acceptance/beaker/git/compression/negative/compression_exec_checkout.rb @@ -26,8 +26,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify git repo was checked out' do diff --git a/spec/acceptance/beaker/git/compression/negative/compression_negative_checkout.rb b/spec/acceptance/beaker/git/compression/negative/compression_negative_checkout.rb index b89f6f6..2485424 100644 --- a/spec/acceptance/beaker/git/compression/negative/compression_negative_checkout.rb +++ b/spec/acceptance/beaker/git/compression/negative/compression_negative_checkout.rb @@ -26,8 +26,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify git repo was checked out' do diff --git a/spec/acceptance/beaker/git/create/create_bare_repo_that_already_exists.rb b/spec/acceptance/beaker/git/create/create_bare_repo_that_already_exists.rb index 663c758..b72963b 100644 --- a/spec/acceptance/beaker/git/create/create_bare_repo_that_already_exists.rb +++ b/spec/acceptance/beaker/git/create/create_bare_repo_that_already_exists.rb @@ -23,7 +23,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify repo does not contain .git directory' do diff --git a/spec/acceptance/beaker/git/create/create_repo_that_already_exists.rb b/spec/acceptance/beaker/git/create/create_repo_that_already_exists.rb index b1cdeae..f31dda0 100644 --- a/spec/acceptance/beaker/git/create/create_repo_that_already_exists.rb +++ b/spec/acceptance/beaker/git/create/create_repo_that_already_exists.rb @@ -25,7 +25,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify repo is on master branch' do diff --git a/spec/acceptance/beaker/git/create/negative/create_bare_repo_specifying_revision.rb b/spec/acceptance/beaker/git/create/negative/create_bare_repo_specifying_revision.rb index 6cd4f72..ece10a5 100644 --- a/spec/acceptance/beaker/git/create/negative/create_bare_repo_specifying_revision.rb +++ b/spec/acceptance/beaker/git/create/negative/create_bare_repo_specifying_revision.rb @@ -22,12 +22,12 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :expect_failures => true) end step 'verify repo does not contain .git directory' do - on(host, "ls -al #{tmpdir}/#{repo_name}") do |res| - fail_test "found .git for #{repo_name}" if res.stdout.include? ".git" + on(host, "ls -al #{tmpdir}") do |res| + fail_test "found repo for #{repo_name}" if res.stdout.include? repo_name end end diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_file.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_file.rb index 6913bd5..be5ae92 100644 --- a/spec/acceptance/beaker/git/group_checkout/group_checkout_file.rb +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_file.rb @@ -14,12 +14,12 @@ hosts.each do |host| end step 'setup - create group' do - apply_manifest_on(host, "group { '#{group}': ensure => present, }") + apply_manifest_on(host, "group { '#{group}': ensure => present, }", :catch_failures => true) end teardown do on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "group { '#{group}': ensure => absent, }") + apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true) end step 'checkout as a group with puppet' do @@ -32,8 +32,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify git checkout is own by group #{group}" do diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_file_path.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_file_path.rb index 6701dda..c204792 100644 --- a/spec/acceptance/beaker/git/group_checkout/group_checkout_file_path.rb +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_file_path.rb @@ -14,12 +14,12 @@ hosts.each do |host| end step 'setup - create group' do - apply_manifest_on(host, "group { '#{group}': ensure => present, }") + apply_manifest_on(host, "group { '#{group}': ensure => present, }", :catch_failures => true) end teardown do on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "group { '#{group}': ensure => absent, }") + apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true) end step 'checkout a group with puppet' do @@ -32,8 +32,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify git checkout is own by group #{group}" do diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb index 31ef286..6147549 100644 --- a/spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb @@ -18,13 +18,13 @@ hosts.each do |host| end step 'setup - create group' do - apply_manifest_on(host, "group { '#{group}': ensure => present, }") + apply_manifest_on(host, "group { '#{group}': ensure => present, }", :catch_failures => true) end teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'pkill -9 git-daemon') - apply_manifest_on(host, "group { '#{group}': ensure => absent, }") + on(host, 'pkill -9 git-daemon ; sleep 1') + apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true) end step 'checkout a group with puppet' do @@ -37,8 +37,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify git checkout is own by group #{group}" do diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb index 0c86c77..43c3f2e 100644 --- a/spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb @@ -26,13 +26,13 @@ hosts.each do |host| end step 'setup - create group' do - apply_manifest_on(host, "group { '#{group}': ensure => present, }") + apply_manifest_on(host, "group { '#{group}': ensure => present, }", :catch_failures => true) end teardown do on(host, "rm -fr #{tmpdir}") - on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") - apply_manifest_on(host, "group { '#{group}': ensure => absent, }") + on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1") + apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true) end step 'checkout a group with puppet' do @@ -45,8 +45,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify git checkout is own by group #{group}" do diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb index 0bcbd97..6825df3 100644 --- a/spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb @@ -33,13 +33,13 @@ hosts.each do |host| end step 'setup - create group' do - apply_manifest_on(host, "group { '#{group}': ensure => present, }") + apply_manifest_on(host, "group { '#{group}': ensure => present, }", :catch_failures => true) end teardown do on(host, "rm -fr #{tmpdir}") - on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") - apply_manifest_on(host, "group { '#{group}': ensure => absent, }") + on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1") + apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true) end step 'checkout as a group with puppet' do @@ -52,8 +52,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify git checkout is own by group #{group}" do diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_scp.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_scp.rb index d8f5bb5..0bcf143 100644 --- a/spec/acceptance/beaker/git/group_checkout/group_checkout_scp.rb +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_scp.rb @@ -14,22 +14,23 @@ hosts.each do |host| end step 'setup - establish ssh keys' do # create ssh keys - on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') # copy public key to authorized_keys + on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys') on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') on(host, 'chown -R root:root /root/.ssh') end step 'setup - create group' do - apply_manifest_on(host, "group { '#{group}': ensure => present, }") + apply_manifest_on(host, "group { '#{group}': ensure => present, }", :catch_failures => true) end teardown do on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") - apply_manifest_on(host, "group { '#{group}': ensure => absent, }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true) + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true) + apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true) end step 'checkout as a group with puppet (scp syntax)' do @@ -42,8 +43,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify git checkout is own by group #{group}" do diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_ssh.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_ssh.rb index 1255864..87bad69 100644 --- a/spec/acceptance/beaker/git/group_checkout/group_checkout_ssh.rb +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_ssh.rb @@ -14,22 +14,23 @@ hosts.each do |host| end step 'setup - establish ssh keys' do # create ssh keys - on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') # copy public key to authorized_keys + on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys') on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') on(host, 'chown -R root:root /root/.ssh') end step 'setup - create group' do - apply_manifest_on(host, "group { '#{group}': ensure => present, }") + apply_manifest_on(host, "group { '#{group}': ensure => present, }", :catch_failures => true) end teardown do on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") - apply_manifest_on(host, "group { '#{group}': ensure => absent, }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true) + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true) + apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true) end step 'checkout as a group with puppet' do @@ -42,8 +43,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify git checkout is own by group #{group}" do diff --git a/spec/acceptance/beaker/git/group_checkout/negative/group_checkout_file_non_existent_group.rb b/spec/acceptance/beaker/git/group_checkout/negative/group_checkout_file_non_existent_group.rb index 5bce264..5388f7f 100644 --- a/spec/acceptance/beaker/git/group_checkout/negative/group_checkout_file_non_existent_group.rb +++ b/spec/acceptance/beaker/git/group_checkout/negative/group_checkout_file_non_existent_group.rb @@ -14,7 +14,7 @@ hosts.each do |host| end step 'setup - delete group' do - apply_manifest_on(host, "group { '#{group}': ensure => absent, }") + apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true) end teardown do @@ -31,8 +31,7 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :expect_failures => true) end step "verify git checkout is NOT owned by group #{group}" do diff --git a/spec/acceptance/beaker/git/revision_checkout/negative/revision_checkout_not_exists.rb b/spec/acceptance/beaker/git/revision_checkout/negative/revision_checkout_not_exists.rb index d1ee531..7f0f1b2 100644 --- a/spec/acceptance/beaker/git/revision_checkout/negative/revision_checkout_not_exists.rb +++ b/spec/acceptance/beaker/git/revision_checkout/negative/revision_checkout_not_exists.rb @@ -26,8 +26,7 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :expect_failures => true) end step 'verify that master revision is checked out' do diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file.rb index 8ca10bd..be84f0e 100644 --- a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file.rb +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file.rb @@ -32,8 +32,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify repo is checked out to revision #{@sha}" do diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file_path.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file_path.rb index 2410e2e..93db164 100644 --- a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file_path.rb +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file_path.rb @@ -32,8 +32,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify repo is checked out to revision #{@sha}" do diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb index 3fa6cbd..52349d7 100644 --- a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb @@ -18,7 +18,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'pkill -9 git-daemon') + on(host, 'pkill -9 git-daemon ; sleep 1') end step 'get revision sha from repo' do @@ -37,8 +37,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout is set to revision #{@sha}" do diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb index 9755d8e..8101794 100644 --- a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb @@ -26,7 +26,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") + on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1") end step 'get revision sha from repo' do @@ -45,8 +45,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout is set to revision #{@sha}" do diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb index 16b5145..adab3a8 100644 --- a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb @@ -33,7 +33,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") + on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1") end step 'get revision sha from repo' do @@ -53,8 +53,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout is set to revision #{@sha}" do diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_scp.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_scp.rb index c920fb4..fb6a20a 100644 --- a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_scp.rb +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_scp.rb @@ -13,17 +13,18 @@ hosts.each do |host| end step 'setup - establish ssh keys' do # create ssh keys - on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') # copy public key to authorized_keys + on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys') on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') on(host, 'chown -R root:root /root/.ssh') end teardown do on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true) + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true) end step 'get revision sha from repo' do @@ -42,8 +43,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout is set to revision #{@sha}" do diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_ssh.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_ssh.rb index 24b507e..9325a0b 100644 --- a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_ssh.rb +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_ssh.rb @@ -13,17 +13,18 @@ hosts.each do |host| end step 'setup - establish ssh keys' do # create ssh keys - on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') # copy public key to authorized_keys + on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys') on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') on(host, 'chown -R root:root /root/.ssh') end teardown do on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true) + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true) end step 'get revision sha from repo' do @@ -42,8 +43,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout is set to revision #{@sha}" do diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_exec_depth.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_exec_depth.rb index caef5a6..d82e3c6 100644 --- a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_exec_depth.rb +++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_exec_depth.rb @@ -26,8 +26,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify checkout is NOT shallow' do diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb index c336842..961d0fe 100644 --- a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb +++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb @@ -27,8 +27,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'git does not support shallow clone via file path: verify checkout is NOT created' do diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb index ecd51ad..956d7de 100644 --- a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb +++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb @@ -26,7 +26,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "#{ruby} /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + on(host, 'ps ax | grep "#{ruby} /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh ; sleep 1') end step 'shallow clone repo with puppet' do @@ -39,8 +39,7 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :expect_failures => true) end step 'git does not support shallow clone via HTTP: verify checkout is NOT created' do diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_negative_depth.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_negative_depth.rb index 2ba1f0f..c80faa0 100644 --- a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_negative_depth.rb +++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_negative_depth.rb @@ -26,8 +26,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify checkout is NOT shallow' do diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_overflow_depth.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_overflow_depth.rb index 55ff878..fdf4977 100644 --- a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_overflow_depth.rb +++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_overflow_depth.rb @@ -26,8 +26,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify checkout is NOT shallow' do diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_file.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_file.rb index 52eb3d2..f54f1ab 100644 --- a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_file.rb +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_file.rb @@ -26,8 +26,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify checkout is shallow and of the correct depth' do diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb index d7c81fb..ab3bd07 100644 --- a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb @@ -18,7 +18,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'pkill -9 git-daemon') + on(host, 'pkill -9 git-daemon ; sleep 1') end step 'shallow clone repo with puppet' do @@ -31,8 +31,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify checkout is shallow and of the correct depth' do diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb index 9220e27..93a328c 100644 --- a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb @@ -34,7 +34,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'ps ax | grep "#{ruby} /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh') + on(host, 'ps ax | grep "#{ruby} /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh ; sleep 1') end step 'shallow clone repo with puppet' do @@ -47,8 +47,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify checkout is shallow and of the correct depth' do diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_scp.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_scp.rb index 6837802..ddef4e7 100644 --- a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_scp.rb +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_scp.rb @@ -13,17 +13,18 @@ hosts.each do |host| end step 'setup - establish ssh keys' do # create ssh keys - on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') # copy public key to authorized_keys + on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys') on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') on(host, 'chown -R root:root /root/.ssh') end teardown do on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true) + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true) end step 'shallow clone repo with puppet (scp syntax)' do @@ -36,8 +37,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify checkout is shallow and of the correct depth' do diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_ssh.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_ssh.rb index fda9bf4..da5528c 100644 --- a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_ssh.rb +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_ssh.rb @@ -13,17 +13,18 @@ hosts.each do |host| end step 'setup - establish ssh keys' do # create ssh keys - on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') # copy public key to authorized_keys + on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys') on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') on(host, 'chown -R root:root /root/.ssh') end teardown do on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true) + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true) end step 'shallow clone repo with puppet' do @@ -36,8 +37,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify checkout is shallow and of the correct depth' do diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_zero_depth.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_zero_depth.rb index 6cec2a1..eb8b121 100644 --- a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_zero_depth.rb +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_zero_depth.rb @@ -26,8 +26,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify checkout is NOT shallow' do diff --git a/spec/acceptance/beaker/git/tag_checkout/negative/tag_checkout_not_exists.rb b/spec/acceptance/beaker/git/tag_checkout/negative/tag_checkout_not_exists.rb index 5869513..04dd014 100644 --- a/spec/acceptance/beaker/git/tag_checkout/negative/tag_checkout_not_exists.rb +++ b/spec/acceptance/beaker/git/tag_checkout/negative/tag_checkout_not_exists.rb @@ -26,8 +26,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step 'verify that master tag is checked out' do diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file.rb index 4ab8a6a..8929b0b 100644 --- a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file.rb +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file.rb @@ -27,8 +27,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout out tag is #{tag}" do diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file_path.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file_path.rb index f73d4f9..33d7f41 100644 --- a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file_path.rb +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file_path.rb @@ -27,8 +27,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout out tag is #{tag}" do diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb index 45a737e..694626e 100644 --- a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb @@ -19,7 +19,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'pkill -9 git-daemon') + on(host, 'pkill -9 git-daemon ; sleep 1') end step 'get tag sha from repo' do @@ -38,8 +38,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout out tag is #{tag}" do diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb index cff6071..bb211c1 100644 --- a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb @@ -27,7 +27,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") + on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1") end step 'get tag sha from repo' do @@ -46,8 +46,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout out tag is #{tag}" do diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb index 1e3cc51..95a98f5 100644 --- a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb @@ -34,7 +34,7 @@ hosts.each do |host| teardown do on(host, "rm -fr #{tmpdir}") - on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") + on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1") end step 'get tag sha from repo' do @@ -53,8 +53,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout out tag is #{tag}" do diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_scp.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_scp.rb index d602689..f7af937 100644 --- a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_scp.rb +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_scp.rb @@ -14,17 +14,18 @@ hosts.each do |host| end step 'setup - establish ssh keys' do # create ssh keys - on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') # copy public key to authorized_keys + on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys') on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') on(host, 'chown -R root:root /root/.ssh') end teardown do on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true) + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true) end step 'get tag sha from repo' do @@ -43,8 +44,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout out tag is #{tag}" do diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_ssh.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_ssh.rb index f57f605..006646a 100644 --- a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_ssh.rb +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_ssh.rb @@ -14,17 +14,18 @@ hosts.each do |host| end step 'setup - establish ssh keys' do # create ssh keys - on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') # copy public key to authorized_keys + on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys') on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') on(host, 'chown -R root:root /root/.ssh') end teardown do on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true) + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true) end step 'get tag sha from repo' do @@ -43,8 +44,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify checkout out tag is #{tag}" do diff --git a/spec/acceptance/beaker/git/user_checkout/negative/user_checkout_file_non_existent_user.rb b/spec/acceptance/beaker/git/user_checkout/negative/user_checkout_file_non_existent_user.rb index 98099ee..19af709 100644 --- a/spec/acceptance/beaker/git/user_checkout/negative/user_checkout_file_non_existent_user.rb +++ b/spec/acceptance/beaker/git/user_checkout/negative/user_checkout_file_non_existent_user.rb @@ -14,7 +14,7 @@ hosts.each do |host| end step 'setup - delete user' do - apply_manifest_on(host, "user { '#{user}': ensure => absent, }") + apply_manifest_on(host, "user { '#{user}': ensure => absent, }", :catch_failures => true) end teardown do @@ -31,8 +31,7 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :expect_failures => true) end step "verify git checkout is NOT owned by user #{user}" do diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_file.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_file.rb index 9920b0b..9133661 100644 --- a/spec/acceptance/beaker/git/user_checkout/user_checkout_file.rb +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_file.rb @@ -14,12 +14,12 @@ hosts.each do |host| end step 'setup - create user' do - apply_manifest_on(host, "user { '#{user}': ensure => present, }") + apply_manifest_on(host, "user { '#{user}': ensure => present, }", :catch_failures => true) end teardown do on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "user { '#{user}': ensure => absent, }") + apply_manifest_on(host, "user { '#{user}': ensure => absent, }", :catch_failures => true) end step 'checkout as a user with puppet' do @@ -32,8 +32,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify git checkout is owned by user #{user}" do diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_file_path.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_file_path.rb index 1817229..1104fdd 100644 --- a/spec/acceptance/beaker/git/user_checkout/user_checkout_file_path.rb +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_file_path.rb @@ -14,12 +14,12 @@ hosts.each do |host| end step 'setup - create user' do - apply_manifest_on(host, "user { '#{user}': ensure => present, }") + apply_manifest_on(host, "user { '#{user}': ensure => present, }", :catch_failures => true) end teardown do on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "user { '#{user}': ensure => absent, }") + apply_manifest_on(host, "user { '#{user}': ensure => absent, }", :catch_failures => true) end step 'checkout a user with puppet' do @@ -32,8 +32,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify git checkout is owned by user #{user}" do diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb index d7504b0..1fb61b6 100644 --- a/spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb @@ -18,13 +18,13 @@ hosts.each do |host| end step 'setup - create user' do - apply_manifest_on(host, "user { '#{user}': ensure => present, }") + apply_manifest_on(host, "user { '#{user}': ensure => present, }", :catch_failures => true) end teardown do on(host, "rm -fr #{tmpdir}") - on(host, 'pkill -9 git-daemon') - apply_manifest_on(host, "user { '#{user}': ensure => absent, }") + on(host, 'pkill -9 git-daemon ; sleep 1') + apply_manifest_on(host, "user { '#{user}': ensure => absent, }", :catch_failures => true) end step 'checkout a user with puppet' do @@ -37,8 +37,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify git checkout is owned by user #{user}" do diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb index 07f5c1c..03ea27b 100644 --- a/spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb @@ -26,13 +26,13 @@ hosts.each do |host| end step 'setup - create user' do - apply_manifest_on(host, "user { '#{user}': ensure => present, }") + apply_manifest_on(host, "user { '#{user}': ensure => present, }", :catch_failures => true) end teardown do on(host, "rm -fr #{tmpdir}") - on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") - apply_manifest_on(host, "user { '#{user}': ensure => absent, }") + on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1") + apply_manifest_on(host, "user { '#{user}': ensure => absent, }", :catch_failures => true) end step 'checkout a user with puppet' do @@ -45,8 +45,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify git checkout is owned by user #{user}" do diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb index 7187586..7348755 100644 --- a/spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb @@ -33,13 +33,13 @@ hosts.each do |host| end step 'setup - create user' do - apply_manifest_on(host, "user { '#{user}': ensure => present, }") + apply_manifest_on(host, "user { '#{user}': ensure => present, }", :catch_failures => true) end teardown do on(host, "rm -fr #{tmpdir}") - on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh") - apply_manifest_on(host, "user { '#{user}': ensure => absent, }") + on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1") + apply_manifest_on(host, "user { '#{user}': ensure => absent, }", :catch_failures => true) end step 'checkout as a user with puppet' do @@ -52,8 +52,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify git checkout is owned by user #{user}" do diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_scp.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_scp.rb index a4f7261..dccf9f8 100644 --- a/spec/acceptance/beaker/git/user_checkout/user_checkout_scp.rb +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_scp.rb @@ -14,22 +14,23 @@ hosts.each do |host| end step 'setup - establish ssh keys' do # create ssh keys - on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') # copy public key to authorized_keys + on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys') on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') on(host, 'chown -R root:root /root/.ssh') end step 'setup - create user' do - apply_manifest_on(host, "user { '#{user}': ensure => present, }") + apply_manifest_on(host, "user { '#{user}': ensure => present, }", :catch_failures => true) end teardown do on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") - apply_manifest_on(host, "user { '#{user}': ensure => absent, }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true) + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true) + apply_manifest_on(host, "user { '#{user}': ensure => absent, }", :catch_failures => true) end step 'checkout as a user with puppet (scp syntax)' do @@ -42,8 +43,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify git checkout is owned by user #{user}" do diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_ssh.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_ssh.rb index 50c73f4..5ee01b1 100644 --- a/spec/acceptance/beaker/git/user_checkout/user_checkout_ssh.rb +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_ssh.rb @@ -14,22 +14,23 @@ hosts.each do |host| end step 'setup - establish ssh keys' do # create ssh keys - on(host, 'ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') + on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""') # copy public key to authorized_keys + on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys') on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config') on(host, 'chown -R root:root /root/.ssh') end step 'setup - create user' do - apply_manifest_on(host, "user { '#{user}': ensure => present, }") + apply_manifest_on(host, "user { '#{user}': ensure => present, }", :catch_failures => true) end teardown do on(host, "rm -fr #{tmpdir}") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }") - apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }") - apply_manifest_on(host, "user { '#{user}': ensure => absent, }") + apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true) + apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true) + apply_manifest_on(host, "user { '#{user}': ensure => absent, }", :catch_failures => true) end step 'checkout as a user with puppet' do @@ -42,8 +43,8 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp) - apply_manifest_on(host, pp) + apply_manifest_on(host, pp, :catch_failures => true) + apply_manifest_on(host, pp, :catch_changes => true) end step "verify git checkout is owned by user #{user}" do diff --git a/spec/acceptance/beaker_helper.rb b/spec/acceptance/beaker_helper.rb new file mode 100644 index 0000000..2bf663b --- /dev/null +++ b/spec/acceptance/beaker_helper.rb @@ -0,0 +1,18 @@ +test_name "Installing Puppet and vcsrepo module" do + step 'install puppet' do + if @options[:provision] + # This will fail if puppet is already installed, ie --no-provision + if hosts.first.is_pe? + install_pe + else + install_puppet + end + end + end + step 'install module' do + proj_root = File.expand_path(File.join(File.dirname(__FILE__),'..','..')) + # Waiting on release of puppet_module_install in beaker + #puppet_module_install(:source => proj_root, :module_name => 'vcsrepo') + scp_to(hosts, proj_root, File.join(hosts.first['distmoduledir'], 'vcsrepo')) + end +end diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index daec038..a753610 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -90,10 +90,9 @@ branches context "with an ensure of bare" do context "with revision" do - it "should just execute 'git clone --bare'" do + it "should raise an error" do resource[:ensure] = :bare - provider.expects(:git).with('clone', '--bare', resource.value(:source), resource.value(:path)) - provider.create + expect { provider.create }.to raise_error Puppet::Error, /cannot set a revision.+bare/i end end context "without revision" do @@ -144,6 +143,7 @@ branches it "should execute 'git init --bare'" do resource[:ensure] = :bare resource.delete(:source) + resource.delete(:revision) expects_chdir expects_mkdir expects_directory?(false) @@ -157,6 +157,7 @@ branches it "should convert it to a bare repository" do resource[:ensure] = :bare resource.delete(:source) + resource.delete(:revision) provider.expects(:working_copy_exists?).returns(true) provider.expects(:convert_working_copy_to_bare) provider.create -- cgit v1.2.3 From c2108b67f6349068ae897265b28a7242d230be1b Mon Sep 17 00:00:00 2001 From: John Duarte Date: Wed, 21 May 2014 18:25:54 -0700 Subject: Adjust Rake tasks for beaker testing Adjust Rake tasks for testing beaker-rspec suite, beaker suite, and both in combination. The beaker hosts config file is set via the BEAKER_setfile environmental variable. The hosts defined within this file supersede the host past in as an argument, but the argument is still required. For an arbitrary hosts config file this provides the following options. 1. Run the beaker-rspec test suite BEAKER_setfile=/path/to/my_hosts.cfg rake beaker:rspec:test[foo,pe] 2. Run the beaker test suite BEAKER_setfile=/path/to/my_hosts.cfg rake beaker:test[foo,pe] 3. Run both beaker-rspec and beaker test suites BEAKER_setfile=/path/to/my_hosts.cfg rake beaker:test:all[foo,pe] --- Rakefile | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/Rakefile b/Rakefile index 3ccf664..36a7998 100755 --- a/Rakefile +++ b/Rakefile @@ -1,18 +1,18 @@ require 'puppetlabs_spec_helper/rake_tasks' require 'rake' -task 'beaker:test',[:host,:type] => :set_beaker_variables do |t,args| +desc "Run beaker-rspec and beaker tests" +task 'beaker:test:all',[:host,:type] => ["rake:beaker:rspec:test", "rake:beaker:test"] do |t,args| +end +desc "Run beaker-rspec tests" +task 'beaker:rspec:test',[:host,:type] => [:set_beaker_variables] do |t,args| Rake::Task['beaker-rspec:test'].invoke(args) +end - if File.exists?('./acceptance') - Dir.chdir('./acceptance') - exec(build_beaker_command args) - Dir.chdir('../') - else - puts "No acceptance directory found, not running beaker tests" - end - +desc "Run beaker tests" +task 'beaker:test',[:host,:type] => [:set_beaker_variables] do |t,args| + sh(build_beaker_command args) end desc "Run beaker rspec tasks against pe" @@ -40,6 +40,9 @@ task :set_beaker_variables do |t,args| puts "Host to test #{ENV['BEAKER_set']}" end ENV['BEAKER_IS_PE'] = args[:type] == 'pe'? "true": "false" + if ENV['BEAKER_setfile'] + @hosts_config = ENV['BEAKER_setfile'] + end end def build_beaker_command(args) @@ -48,11 +51,14 @@ def build_beaker_command(args) if File.exists?("./.beaker-#{args[:type]}.cfg") cmd << "--options-file ./.beaker-#{args[:type]}.cfg" end - if File.exists?("config/#{args[:host]}.cfg") - cmd << "--hosts config/#{args[:host]}.cfg" + if File.exists?(@hosts_config) + cmd << "--hosts #{@hosts_config}" + end + if File.exists?('./spec/acceptance/beaker_helper.rb') + cmd << "--pre-suite ./spec/acceptance/beaker_helper.rb" end - if File.exists?("./tests") - cmd << "--tests ./tests" + if File.exists?("./spec/acceptance/beaker") + cmd << "--tests ./spec/acceptance/beaker" end cmd.join(" ") end -- cgit v1.2.3 From d11fb1c90a115e7dd27cf32ad0bfdb65700c5eab Mon Sep 17 00:00:00 2001 From: John Duarte Date: Thu, 22 May 2014 08:07:57 -0700 Subject: Set git bare with revision test to fail When the revision attribute is defined in conjunction with the bare attribute when using the git provider, the repo should fail to be written to disk. See: FM-1361 --- spec/acceptance/create_repo_spec.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/spec/acceptance/create_repo_spec.rb b/spec/acceptance/create_repo_spec.rb index 675517e..1b46449 100644 --- a/spec/acceptance/create_repo_spec.rb +++ b/spec/acceptance/create_repo_spec.rb @@ -54,7 +54,7 @@ describe 'create a repo' do end context 'bare repo with a revision' do - it 'creates a bare repo' do + it 'does not create a bare repo when a revision is defined' do pp = <<-EOS vcsrepo { "#{tmpdir}/testrepo_bare_repo_rev": ensure => bare, @@ -63,14 +63,10 @@ describe 'create a repo' do } EOS - apply_manifest(pp, :catch_failures => true) - end - - describe file("#{tmpdir}/testrepo_bare_repo_rev/config") do - it { should contain 'bare = true' } + apply_manifest(pp, :expect_failures => true) end - describe file("#{tmpdir}/testrepo_bare_repo_rev/.git") do + describe file("#{tmpdir}/testrepo_bare_repo_rev") do it { should_not be_directory } end end -- cgit v1.2.3 From 11dfa3835e855161dbb3ca98159442463d6fa8d2 Mon Sep 17 00:00:00 2001 From: Luke Blaney Date: Tue, 27 May 2014 13:46:49 +0100 Subject: Update Modulefile to use hyphen in name, not slash For details about the difference, see: http://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html#another-note-on-module-names --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index d2bbe92..7b41839 100644 --- a/Modulefile +++ b/Modulefile @@ -1,4 +1,4 @@ -name 'puppetlabs/vcsrepo' +name 'puppetlabs-vcsrepo' version '0.2.0' summary 'Manage repositories from various version control systems' description 'Manage repositories from various version control systems' -- cgit v1.2.3 From b3b253f2432e5cda15c04b11b89bb3d47e84dc76 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Tue, 27 May 2014 11:04:40 -0700 Subject: Add optional keyfile argument to rake tasks This addition walks over any extra arguments provided to the rake task. If the file is a key file, it is used to set the BEAKER_keyfile ENVIRONMENT variable for beaker-rspec and/or the `--keyfile` command line argument for beaker as needed. Example: BEAKER_setfile=../vcenterhost.cfg rake beaker:rspec:test[foo,pe,'/home/myuser/.ssh/id_rsa-secret'] --- Rakefile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Rakefile b/Rakefile index 36a7998..b1e0e14 100755 --- a/Rakefile +++ b/Rakefile @@ -43,6 +43,9 @@ task :set_beaker_variables do |t,args| if ENV['BEAKER_setfile'] @hosts_config = ENV['BEAKER_setfile'] end + if File.exists?(check_args_for_keyfile(args.extras)) + ENV['BEAKER_keyfile'] = check_args_for_keyfile(args.extras) + end end def build_beaker_command(args) @@ -60,5 +63,16 @@ def build_beaker_command(args) if File.exists?("./spec/acceptance/beaker") cmd << "--tests ./spec/acceptance/beaker" end + if File.exists?(check_args_for_keyfile(args.extras)) + cmd << "--keyfile #{check_args_for_keyfile(args.extras)}" + end cmd.join(" ") end + +def check_args_for_keyfile(extra_args) + keyfile = '' + extra_args.each do |a| + keyfile = a if (`file -b #{a}`.gsub(/\n/,"").match(/ key/)) + end + return keyfile +end -- cgit v1.2.3 From 521d321181c95eb042c23c8277e79cfe1d066117 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Tue, 27 May 2014 12:41:31 -0700 Subject: Update tests for ubuntu 14.04 In ubuntu 14.04 git 1.9.1 is the default version, and 1.9+ fatally fail if the user.email and user.name are not set (previously it would just warn). This commit sets those up so the tests will actually run. --- spec/acceptance/beaker_helper.rb | 6 ++++++ spec/acceptance/files/create_git_repo.sh | 4 ++-- spec/spec_helper_acceptance.rb | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/spec/acceptance/beaker_helper.rb b/spec/acceptance/beaker_helper.rb index 2bf663b..262cb62 100644 --- a/spec/acceptance/beaker_helper.rb +++ b/spec/acceptance/beaker_helper.rb @@ -14,5 +14,11 @@ test_name "Installing Puppet and vcsrepo module" do # Waiting on release of puppet_module_install in beaker #puppet_module_install(:source => proj_root, :module_name => 'vcsrepo') scp_to(hosts, proj_root, File.join(hosts.first['distmoduledir'], 'vcsrepo')) + gitconfig = <<-EOS +[user] + email = root@localhost + name = root +EOS + create_remote_file(host, "/root/.gitconfig", script) end end diff --git a/spec/acceptance/files/create_git_repo.sh b/spec/acceptance/files/create_git_repo.sh index 40f341a..b5e930c 100755 --- a/spec/acceptance/files/create_git_repo.sh +++ b/spec/acceptance/files/create_git_repo.sh @@ -6,12 +6,12 @@ touch file1.txt file2.txt file3.txt git init echo 'change 1' > file1.txt git add file1.txt -git tag 0.0.1 git commit -m 'add file1' +git tag 0.0.1 echo 'change 2' > file2.txt git add file2.txt -git tag 0.0.2 git commit -m 'add file2' +git tag 0.0.2 echo 'change 3' > file3.txt git add file3.txt git commit -m 'add file3' diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index dec9331..d0d84d0 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -34,6 +34,8 @@ RSpec.configure do |c| exit end end + shell('git config --global user.email "root@localhost"') + shell('git config --global user.name "root"') end end end -- cgit v1.2.3 From 22397d9b36938f6537bc83293e5bee0aff403756 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Tue, 27 May 2014 17:18:37 -0700 Subject: Fix logic to validate keyfile --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index b1e0e14..cb80def 100755 --- a/Rakefile +++ b/Rakefile @@ -72,7 +72,7 @@ end def check_args_for_keyfile(extra_args) keyfile = '' extra_args.each do |a| - keyfile = a if (`file -b #{a}`.gsub(/\n/,"").match(/ key/)) + keyfile = a unless (`ssh-keygen -l -f #{a}`.gsub(/\n/,"").match(/is not a .*key file/)) end return keyfile end -- cgit v1.2.3 From e528ebe011c8db4f2b405343adb7fd1fa4c3aa87 Mon Sep 17 00:00:00 2001 From: Peter Souter Date: Mon, 2 Jun 2014 22:51:31 +0100 Subject: Update .gitignore Ignore .vagrant folder for Beaker --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 44e004c..b5fe773 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ coverage \#* Gemfile.lock log +.vagrant #Intellij .idea -- cgit v1.2.3 From 17c91e7ab8f89453c926b432e5ff82335d280e90 Mon Sep 17 00:00:00 2001 From: Peter Souter Date: Mon, 2 Jun 2014 23:03:19 +0100 Subject: (MODULES-1014) Adding noop mode option --- lib/puppet/type/vcsrepo.rb | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/puppet/type/vcsrepo.rb b/lib/puppet/type/vcsrepo.rb index 3dd7bc6..0e4450b 100644 --- a/lib/puppet/type/vcsrepo.rb +++ b/lib/puppet/type/vcsrepo.rb @@ -98,10 +98,15 @@ Puppet::Type.newtype(:vcsrepo) do if prov if prov.working_copy_exists? if @resource.value(:force) - notice "Deleting current repository before recloning" - prov.destroy - notice "Create repository from latest" - prov.create + if noop? + notice "Noop Mode - Would have deleted repository" + notice "Noop Mode - Would have created repository from latest" + else + notice "Deleting current repository before recloning" + prov.destroy + notice "Create repository from latest" + prov.create + end end (@should.include?(:latest) && prov.latest?) ? :latest : :present elsif prov.class.feature?(:bare_repositories) and prov.bare_exists? @@ -208,4 +213,12 @@ Puppet::Type.newtype(:vcsrepo) do ['git', 'git-core'] end + def noop? + if defined?(@noop) + @noop + else + Puppet[:noop] + end + end + end -- cgit v1.2.3 From cdf207a3d87149937a28953850fedfbe8c78e5f9 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 19 May 2014 14:47:11 -0400 Subject: Updated modulefile and added metadata.json for 1.0.0 release. Supported OS list should be checked in metadata. CHANGELOG still needs to be updated for 1.0.0 release. --- Modulefile | 2 +- metadata.json | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 metadata.json diff --git a/Modulefile b/Modulefile index d2bbe92..52dede3 100644 --- a/Modulefile +++ b/Modulefile @@ -1,4 +1,4 @@ name 'puppetlabs/vcsrepo' -version '0.2.0' +version '1.0.0' summary 'Manage repositories from various version control systems' description 'Manage repositories from various version control systems' diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..752d3c2 --- /dev/null +++ b/metadata.json @@ -0,0 +1,48 @@ +{ + "name": "puppetlabs-vcsrepo", + "version": "1.0.0", + "source": "https://github.com/puppetlabs/puppetlabs-vcsrepo", + "author": "Puppet Labs", + "license": "GPLv2", + "project_page": "https://github.com/puppetlabs/puppetlabs-vcsrepo", + "summary": "Puppet module providing a type to manage repositories from various version control systems", + "operatingsystem_support": [ + { + "operatingsystem": "RedHat", + "operatingsystemrelease": [ + "5", + "6", + "7" + ] + }, + { + "operatingsystem": "CentOS", + "operatingsystemrelease": [ + "5", + "6", + "7" + + ] + }, + { + "operatingsystem": "Debian", + "operatingsystemrelease": [ + "6", + "7" + ] + }, + { + "operatingsystem": "Ubuntu", + "operatingsystemrelease": [ + "10.04", + "12.04", + "14.04" + ] + } + ], + "requirements": [ + { "name": "pe", "version_requirement": ">= 3.2.0 < 3.4.0" }, + { "name": "puppet", "version_requirement": "3.x" } + ], + "dependencies": [] +} -- cgit v1.2.3 From 9a1df86686f0a771eace81e4344e1e9c27c98d79 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 4 Jun 2014 14:40:37 -0400 Subject: Update changelog and metadata for 1.0.0 release. --- CHANGELOG | 26 ++++++++++++++++++++++++++ metadata.json | 23 ++++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 8142f5d..812a2c7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,29 @@ +2014-06-04 - Version 1.0.0 + +Summary: + +This release focuses on a number of bugfixes, and also has some +new features for Bzr and Git. + +Features: +- Bzr: + - Call set_ownership +- Git: + - Add ability for shallow clones + - Use -a and desired for HARD resets + - Use rev-parse to get tag canonical revision + +Fixes: +- HG: + - Only add ssh options when it's talking to the network +- Git: + - Fix for issue with detached HEAD + - force => true will now destroy and recreate repo + - Actually use the remote parameter + - Use origin/master instead of origin/HEAD when on master +- SVN: + - Fix svnlook behavior with plain directories + 2013-11-13 - Version 0.2.0 Summary: diff --git a/metadata.json b/metadata.json index 752d3c2..c9a139e 100644 --- a/metadata.json +++ b/metadata.json @@ -21,7 +21,28 @@ "5", "6", "7" - + ] + }, + { + "operatingsystem": "OracleLinux", + "operatingsystemrelease": [ + "5", + "6", + "7" + ] + }, + { + "operatingsystem": "Scientific", + "operatingsystemrelease": [ + "5", + "6", + "7" + ] + }, + { + "operatingsystem": "SLES", + "operatingsystemrelease": [ + "11 SP1" ] }, { -- cgit v1.2.3 From c7bb9399041c0933ed2d03768dd58db950ad2702 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Wed, 4 Jun 2014 15:43:09 -0700 Subject: Remove beaker from Gemfile Having both `beaker` and `beaker-rspec` in the Gemfile results in a dual inclusion of `beaker` as a dependency resulting in version 2.0.0 of `beaker-rspec` being installed. The tests for vcsrepo require the `BEAKER_setfile` ENV var, which is only available in `beaker-rspec` 2.2.0 and above. Removing `beaker` allows the latest version of `beaker-rspec` to be installed, thus satisfying this requirement. --- Gemfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Gemfile b/Gemfile index 2fcc822..e32d3da 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,6 @@ group :development, :test do gem 'serverspec', :require => false gem 'puppet-lint', :require => false gem 'pry', :require => false - gem 'beaker', :require => false gem 'beaker-rspec', :require => false gem 'simplecov', :require => false end -- cgit v1.2.3 From 504d9d9215f8bbc6f2ad99f4a349286d4555eb21 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Thu, 5 Jun 2014 13:11:57 -0700 Subject: Pin gem versions in Gemfile Pin beaker-rspec to ~2.2 Pin rspec to ~2.14 --- Gemfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index e32d3da..0120ece 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,8 @@ group :development, :test do gem 'serverspec', :require => false gem 'puppet-lint', :require => false gem 'pry', :require => false - gem 'beaker-rspec', :require => false + gem 'beaker-rspec', '~>2.2', :require => false + gem 'rspec', '~>2.14', :require => false gem 'simplecov', :require => false end -- cgit v1.2.3 From 7d4457e7faa15a27eb224fbcf70c312f11460798 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Thu, 12 Jun 2014 11:41:16 -0400 Subject: Pin versions in the supported branch. --- Gemfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index e32d3da..0120ece 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,8 @@ group :development, :test do gem 'serverspec', :require => false gem 'puppet-lint', :require => false gem 'pry', :require => false - gem 'beaker-rspec', :require => false + gem 'beaker-rspec', '~>2.2', :require => false + gem 'rspec', '~>2.14', :require => false gem 'simplecov', :require => false end -- cgit v1.2.3 From 9c78a08ed018f279e965c4ebd2d4eb7159897d1a Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Mon, 16 Jun 2014 10:18:01 -0700 Subject: Patch beaker spec helper for create_remote_file --- spec/acceptance/beaker_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/acceptance/beaker_helper.rb b/spec/acceptance/beaker_helper.rb index 262cb62..2518a40 100644 --- a/spec/acceptance/beaker_helper.rb +++ b/spec/acceptance/beaker_helper.rb @@ -19,6 +19,6 @@ test_name "Installing Puppet and vcsrepo module" do email = root@localhost name = root EOS - create_remote_file(host, "/root/.gitconfig", script) + create_remote_file(hosts.first, "/root/.gitconfig", script) end end -- cgit v1.2.3 From b55d04145e0ff2ebcb59515fa348ff1e9d22b4e2 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Mon, 16 Jun 2014 10:27:12 -0700 Subject: Need to make the moduledir before scping the module to agents --- spec/acceptance/beaker_helper.rb | 1 + spec/spec_helper_acceptance.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/spec/acceptance/beaker_helper.rb b/spec/acceptance/beaker_helper.rb index 2518a40..4ac5185 100644 --- a/spec/acceptance/beaker_helper.rb +++ b/spec/acceptance/beaker_helper.rb @@ -6,6 +6,7 @@ test_name "Installing Puppet and vcsrepo module" do install_pe else install_puppet + on host, "mkdir -p #{host['distmoduledir']}" end end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index d0d84d0..7ffedf0 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -7,6 +7,7 @@ unless ENV['RS_PROVISION'] == 'no' install_pe else install_puppet + on host, "mkdir -p #{host['distmoduledir']}" end end end -- cgit v1.2.3 From c98fc9385884f4e8416cbd67302ba7c94c0deb67 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Mon, 16 Jun 2014 10:45:29 -0700 Subject: Fix typo in mkdir --- spec/acceptance/beaker_helper.rb | 2 +- spec/spec_helper_acceptance.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/acceptance/beaker_helper.rb b/spec/acceptance/beaker_helper.rb index 4ac5185..4f0121f 100644 --- a/spec/acceptance/beaker_helper.rb +++ b/spec/acceptance/beaker_helper.rb @@ -6,7 +6,7 @@ test_name "Installing Puppet and vcsrepo module" do install_pe else install_puppet - on host, "mkdir -p #{host['distmoduledir']}" + on hosts, "mkdir -p #{host['distmoduledir']}" end end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 7ffedf0..1294710 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -7,7 +7,7 @@ unless ENV['RS_PROVISION'] == 'no' install_pe else install_puppet - on host, "mkdir -p #{host['distmoduledir']}" + on hosts, "mkdir -p #{host['distmoduledir']}" end end end -- cgit v1.2.3 From 29c335fd633850db1fa60bc7b4ad19f2eaa131eb Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Mon, 16 Jun 2014 10:51:52 -0700 Subject: More typos --- spec/acceptance/beaker_helper.rb | 2 +- spec/spec_helper_acceptance.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/acceptance/beaker_helper.rb b/spec/acceptance/beaker_helper.rb index 4f0121f..414796d 100644 --- a/spec/acceptance/beaker_helper.rb +++ b/spec/acceptance/beaker_helper.rb @@ -6,7 +6,7 @@ test_name "Installing Puppet and vcsrepo module" do install_pe else install_puppet - on hosts, "mkdir -p #{host['distmoduledir']}" + on hosts, "mkdir -p #{hosts.first['distmoduledir']}" end end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 1294710..c371f1f 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -7,7 +7,7 @@ unless ENV['RS_PROVISION'] == 'no' install_pe else install_puppet - on hosts, "mkdir -p #{host['distmoduledir']}" + on hosts, "mkdir -p #{hosts.first['distmoduledir']}" end end end -- cgit v1.2.3 From 9603ec23e4217154932b6dbae115760b4f2e2274 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Mon, 16 Jun 2014 10:57:02 -0700 Subject: Correct gitconfig typo --- spec/acceptance/beaker_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/acceptance/beaker_helper.rb b/spec/acceptance/beaker_helper.rb index 414796d..6b5fd46 100644 --- a/spec/acceptance/beaker_helper.rb +++ b/spec/acceptance/beaker_helper.rb @@ -20,6 +20,6 @@ test_name "Installing Puppet and vcsrepo module" do email = root@localhost name = root EOS - create_remote_file(hosts.first, "/root/.gitconfig", script) + create_remote_file(hosts.first, "/root/.gitconfig", gitconfig) end end -- cgit v1.2.3 From bef473f1424a4d798bae5cf7b2afbb694aa793c5 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Mon, 16 Jun 2014 11:31:13 -0700 Subject: Correct shallow clone count The manifest is set to clone at a depth of 1, but checks for a shallow depth of 2. It should either checkout a depth of 2, or only check for a depth of 1. This commit makes it check for a depth of 1 --- spec/acceptance/beaker/git/shallow_clone/shallow_clone_file.rb | 2 +- spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb | 2 +- spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb | 2 +- spec/acceptance/beaker/git/shallow_clone/shallow_clone_scp.rb | 2 +- spec/acceptance/beaker/git/shallow_clone/shallow_clone_ssh.rb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_file.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_file.rb index f54f1ab..e68bbd4 100644 --- a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_file.rb +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_file.rb @@ -36,7 +36,7 @@ hosts.each do |host| end on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| - fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" + fail_test('shallow not found') unless res.stdout.include? "1 #{tmpdir}/#{repo_name}/.git/shallow" end end diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb index ab3bd07..b83f4ea 100644 --- a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb @@ -41,7 +41,7 @@ hosts.each do |host| end on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| - fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" + fail_test('shallow not found') unless res.stdout.include? "1 #{tmpdir}/#{repo_name}/.git/shallow" end end diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb index 93a328c..c045018 100644 --- a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb @@ -57,7 +57,7 @@ hosts.each do |host| end on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| - fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" + fail_test('shallow not found') unless res.stdout.include? "1 #{tmpdir}/#{repo_name}/.git/shallow" end end diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_scp.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_scp.rb index ddef4e7..1201710 100644 --- a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_scp.rb +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_scp.rb @@ -47,7 +47,7 @@ hosts.each do |host| end on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| - fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" + fail_test('shallow not found') unless res.stdout.include? "1 #{tmpdir}/#{repo_name}/.git/shallow" end end diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_ssh.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_ssh.rb index da5528c..76f2a46 100644 --- a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_ssh.rb +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_ssh.rb @@ -47,7 +47,7 @@ hosts.each do |host| end on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res| - fail_test('shallow not found') unless res.stdout.include? "2 #{tmpdir}/#{repo_name}/.git/shallow" + fail_test('shallow not found') unless res.stdout.include? "1 #{tmpdir}/#{repo_name}/.git/shallow" end end -- cgit v1.2.3 From 47b32a8d380beb48e0ea85be904c48da0405e982 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Sat, 14 Jun 2014 08:02:45 -0700 Subject: Change tests to not install git-daemon on debian The git-daemon is not a valid package on debian based systems. Update tests to not try installing git-daemon on debian systems. --- .../beaker/git/basic_auth/negative/basic_auth_checkout_git.rb | 2 +- spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb | 2 +- spec/acceptance/beaker/git/clone/clone_git.rb | 2 +- spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb | 2 +- spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb | 2 +- spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb | 2 +- spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb | 2 +- spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb b/spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb index 67544bf..628c627 100644 --- a/spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb +++ b/spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb @@ -16,7 +16,7 @@ hosts.each do |host| end step 'setup - start git daemon' do - install_package(host, 'git-daemon') + install_package(host, 'git-daemon') unless host['platform'] =~ /debian|ubuntu/ on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach") end diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb index 8afa813..837e170 100644 --- a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb @@ -13,7 +13,7 @@ hosts.each do |host| on(host, "cd #{tmpdir} && ./create_git_repo.sh") end step 'setup - start git daemon' do - install_package(host, 'git-daemon') + install_package(host, 'git-daemon') unless host['platform'] =~ /debian|ubuntu/ on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach") end diff --git a/spec/acceptance/beaker/git/clone/clone_git.rb b/spec/acceptance/beaker/git/clone/clone_git.rb index 8a810af..7656860 100644 --- a/spec/acceptance/beaker/git/clone/clone_git.rb +++ b/spec/acceptance/beaker/git/clone/clone_git.rb @@ -12,7 +12,7 @@ hosts.each do |host| on(host, "cd #{tmpdir} && ./create_git_repo.sh") end step 'setup - start git daemon' do - install_package(host, 'git-daemon') + install_package(host, 'git-daemon') unless host['platform'] =~ /debian|ubuntu/ on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach") end diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb index 6147549..04238ea 100644 --- a/spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb @@ -13,7 +13,7 @@ hosts.each do |host| on(host, "cd #{tmpdir} && ./create_git_repo.sh") end step 'setup - start git daemon' do - install_package(host, 'git-daemon') + install_package(host, 'git-daemon') unless host['platform'] =~ /debian|ubuntu/ on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach") end diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb index 52349d7..2994bb5 100644 --- a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb @@ -12,7 +12,7 @@ hosts.each do |host| on(host, "cd #{tmpdir} && ./create_git_repo.sh") end step 'setup - start git daemon' do - install_package(host, 'git-daemon') + install_package(host, 'git-daemon') unless host['platform'] =~ /debian|ubuntu/ on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach") end diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb index b83f4ea..3ceb58e 100644 --- a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb @@ -12,7 +12,7 @@ hosts.each do |host| on(host, "cd #{tmpdir} && ./create_git_repo.sh") end step 'setup - start git daemon' do - install_package(host, 'git-daemon') + install_package(host, 'git-daemon') unless host['platform'] =~ /debian|ubuntu/ on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach") end diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb index 694626e..44b0324 100644 --- a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb @@ -13,7 +13,7 @@ hosts.each do |host| on(host, "cd #{tmpdir} && ./create_git_repo.sh") end step 'setup - start git daemon' do - install_package(host, 'git-daemon') + install_package(host, 'git-daemon') unless host['platform'] =~ /debian|ubuntu/ on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach") end diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb index 1fb61b6..4110d05 100644 --- a/spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb @@ -13,7 +13,7 @@ hosts.each do |host| on(host, "cd #{tmpdir} && ./create_git_repo.sh") end step 'setup - start git daemon' do - install_package(host, 'git-daemon') + install_package(host, 'git-daemon') unless host['platform'] =~ /debian|ubuntu/ on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach") end -- cgit v1.2.3 From e6a561125b6477051c339d5dfce909e4318f504c Mon Sep 17 00:00:00 2001 From: John Duarte Date: Sat, 14 Jun 2014 11:57:07 -0700 Subject: Accomodate ubuntu-10 package for git in beaker tests Add conditional to install `git-core` if the platform under test is ubuntu-10. The `git` package is not available for this platform. --- spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb | 6 +++++- spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb | 6 +++++- .../beaker/git/basic_auth/negative/basic_auth_checkout_git.rb | 6 +++++- spec/acceptance/beaker/git/branch_checkout/branch_checkout_file.rb | 6 +++++- .../beaker/git/branch_checkout/branch_checkout_file_path.rb | 6 +++++- spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb | 6 +++++- spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb | 6 +++++- spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb | 6 +++++- spec/acceptance/beaker/git/branch_checkout/branch_checkout_scp.rb | 6 +++++- spec/acceptance/beaker/git/branch_checkout/branch_checkout_ssh.rb | 6 +++++- .../git/branch_checkout/negative/branch_checkout_not_exists.rb | 6 +++++- spec/acceptance/beaker/git/clone/clone_file.rb | 6 +++++- spec/acceptance/beaker/git/clone/clone_file_path.rb | 6 +++++- spec/acceptance/beaker/git/clone/clone_git.rb | 6 +++++- spec/acceptance/beaker/git/clone/clone_http.rb | 6 +++++- spec/acceptance/beaker/git/clone/clone_https.rb | 6 +++++- .../git/clone/clone_over_different_exiting_repo_with_force.rb | 6 +++++- .../acceptance/beaker/git/clone/clone_repo_with_excludes_in_repo.rb | 6 +++++- .../beaker/git/clone/clone_repo_with_excludes_not_in_repo.rb | 6 +++++- spec/acceptance/beaker/git/clone/clone_scp.rb | 6 +++++- spec/acceptance/beaker/git/clone/clone_ssh.rb | 6 +++++- .../beaker/git/clone/negative/clone_over_different_exiting_repo.rb | 6 +++++- .../beaker/git/clone/negative/clone_repo_with_exec_excludes.rb | 6 +++++- spec/acceptance/beaker/git/compression/compression_0_checkout.rb | 6 +++++- spec/acceptance/beaker/git/compression/compression_1_checkout.rb | 6 +++++- spec/acceptance/beaker/git/compression/compression_2_checkout.rb | 6 +++++- spec/acceptance/beaker/git/compression/compression_3_checkout.rb | 6 +++++- spec/acceptance/beaker/git/compression/compression_4_checkout.rb | 6 +++++- spec/acceptance/beaker/git/compression/compression_5_checkout.rb | 6 +++++- spec/acceptance/beaker/git/compression/compression_6_checkout.rb | 6 +++++- .../beaker/git/compression/negative/compression_7_checkout.rb | 6 +++++- .../beaker/git/compression/negative/compression_alpha_checkout.rb | 6 +++++- .../beaker/git/compression/negative/compression_eval_checkout.rb | 6 +++++- .../beaker/git/compression/negative/compression_exec_checkout.rb | 6 +++++- .../git/compression/negative/compression_negative_checkout.rb | 6 +++++- .../beaker/git/create/create_bare_repo_that_already_exists.rb | 6 +++++- .../acceptance/beaker/git/create/create_repo_that_already_exists.rb | 6 +++++- .../git/create/negative/create_bare_repo_specifying_revision.rb | 6 +++++- spec/acceptance/beaker/git/group_checkout/group_checkout_file.rb | 6 +++++- .../beaker/git/group_checkout/group_checkout_file_path.rb | 6 +++++- spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb | 6 +++++- spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb | 6 +++++- spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb | 6 +++++- spec/acceptance/beaker/git/group_checkout/group_checkout_scp.rb | 6 +++++- spec/acceptance/beaker/git/group_checkout/group_checkout_ssh.rb | 6 +++++- .../negative/group_checkout_file_non_existent_group.rb | 6 +++++- .../git/revision_checkout/negative/revision_checkout_not_exists.rb | 6 +++++- .../beaker/git/revision_checkout/revision_checkout_file.rb | 6 +++++- .../beaker/git/revision_checkout/revision_checkout_file_path.rb | 6 +++++- .../beaker/git/revision_checkout/revision_checkout_git.rb | 6 +++++- .../beaker/git/revision_checkout/revision_checkout_http.rb | 6 +++++- .../beaker/git/revision_checkout/revision_checkout_https.rb | 6 +++++- .../beaker/git/revision_checkout/revision_checkout_scp.rb | 6 +++++- .../beaker/git/revision_checkout/revision_checkout_ssh.rb | 6 +++++- .../beaker/git/shallow_clone/negative/shallow_clone_exec_depth.rb | 6 +++++- .../beaker/git/shallow_clone/negative/shallow_clone_file_path.rb | 6 +++++- .../beaker/git/shallow_clone/negative/shallow_clone_http.rb | 6 +++++- .../git/shallow_clone/negative/shallow_clone_negative_depth.rb | 6 +++++- .../git/shallow_clone/negative/shallow_clone_overflow_depth.rb | 6 +++++- spec/acceptance/beaker/git/shallow_clone/shallow_clone_file.rb | 6 +++++- spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb | 6 +++++- spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb | 6 +++++- spec/acceptance/beaker/git/shallow_clone/shallow_clone_scp.rb | 6 +++++- spec/acceptance/beaker/git/shallow_clone/shallow_clone_ssh.rb | 6 +++++- .../acceptance/beaker/git/shallow_clone/shallow_clone_zero_depth.rb | 6 +++++- .../beaker/git/tag_checkout/negative/tag_checkout_not_exists.rb | 6 +++++- spec/acceptance/beaker/git/tag_checkout/tag_checkout_file.rb | 6 +++++- spec/acceptance/beaker/git/tag_checkout/tag_checkout_file_path.rb | 6 +++++- spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb | 6 +++++- spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb | 6 +++++- spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb | 6 +++++- spec/acceptance/beaker/git/tag_checkout/tag_checkout_scp.rb | 6 +++++- spec/acceptance/beaker/git/tag_checkout/tag_checkout_ssh.rb | 6 +++++- .../user_checkout/negative/user_checkout_file_non_existent_user.rb | 6 +++++- spec/acceptance/beaker/git/user_checkout/user_checkout_file.rb | 6 +++++- spec/acceptance/beaker/git/user_checkout/user_checkout_file_path.rb | 6 +++++- spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb | 6 +++++- spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb | 6 +++++- spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb | 6 +++++- spec/acceptance/beaker/git/user_checkout/user_checkout_scp.rb | 6 +++++- spec/acceptance/beaker/git/user_checkout/user_checkout_ssh.rb | 6 +++++- 81 files changed, 405 insertions(+), 81 deletions(-) diff --git a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb index 18c7534..421c5f0 100644 --- a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb +++ b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb @@ -12,7 +12,11 @@ hosts.each do |host| gem = '/opt/puppet/bin/gem' if host.is_pe? || 'gem' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb index ac1359e..753e50c 100644 --- a/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb +++ b/spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb @@ -11,7 +11,11 @@ hosts.each do |host| ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb b/spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb index 628c627..3b47c48 100644 --- a/spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb +++ b/spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb @@ -9,7 +9,11 @@ http_server_script = 'basic_auth_http_daemon.rb' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file.rb index 1fbdd1a..3d2131c 100644 --- a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file.rb +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file.rb @@ -7,7 +7,11 @@ branch = 'a_branch' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file_path.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file_path.rb index efbedc7..49b034e 100644 --- a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file_path.rb +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_file_path.rb @@ -7,7 +7,11 @@ branch = 'a_branch' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb index 837e170..9557de8 100644 --- a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb @@ -7,7 +7,11 @@ branch = 'a_branch' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb index a8d622d..fec60e2 100644 --- a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb @@ -8,7 +8,11 @@ hosts.each do |host| ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb index f6baf19..3474c73 100644 --- a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb @@ -8,7 +8,11 @@ hosts.each do |host| ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_scp.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_scp.rb index e55f805..493b3f4 100644 --- a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_scp.rb +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_scp.rb @@ -7,7 +7,11 @@ branch = 'a_branch' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_ssh.rb b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_ssh.rb index 6063bb9..5195ab8 100644 --- a/spec/acceptance/beaker/git/branch_checkout/branch_checkout_ssh.rb +++ b/spec/acceptance/beaker/git/branch_checkout/branch_checkout_ssh.rb @@ -7,7 +7,11 @@ branch = 'a_branch' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/branch_checkout/negative/branch_checkout_not_exists.rb b/spec/acceptance/beaker/git/branch_checkout/negative/branch_checkout_not_exists.rb index e44ea7e..7b9e64d 100644 --- a/spec/acceptance/beaker/git/branch_checkout/negative/branch_checkout_not_exists.rb +++ b/spec/acceptance/beaker/git/branch_checkout/negative/branch_checkout_not_exists.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_branch_checkout' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/clone/clone_file.rb b/spec/acceptance/beaker/git/clone/clone_file.rb index a9ca366..45413a9 100644 --- a/spec/acceptance/beaker/git/clone/clone_file.rb +++ b/spec/acceptance/beaker/git/clone/clone_file.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_clone' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/clone/clone_file_path.rb b/spec/acceptance/beaker/git/clone/clone_file_path.rb index 616030c..a57e05a 100644 --- a/spec/acceptance/beaker/git/clone/clone_file_path.rb +++ b/spec/acceptance/beaker/git/clone/clone_file_path.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_clone' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/clone/clone_git.rb b/spec/acceptance/beaker/git/clone/clone_git.rb index 7656860..3bceb5d 100644 --- a/spec/acceptance/beaker/git/clone/clone_git.rb +++ b/spec/acceptance/beaker/git/clone/clone_git.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_clone' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/clone/clone_http.rb b/spec/acceptance/beaker/git/clone/clone_http.rb index 5ba7915..f545dab 100644 --- a/spec/acceptance/beaker/git/clone/clone_http.rb +++ b/spec/acceptance/beaker/git/clone/clone_http.rb @@ -7,7 +7,11 @@ hosts.each do |host| ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/clone/clone_https.rb b/spec/acceptance/beaker/git/clone/clone_https.rb index 0d3d1f6..8758435 100644 --- a/spec/acceptance/beaker/git/clone/clone_https.rb +++ b/spec/acceptance/beaker/git/clone/clone_https.rb @@ -7,7 +7,11 @@ hosts.each do |host| ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/clone/clone_over_different_exiting_repo_with_force.rb b/spec/acceptance/beaker/git/clone/clone_over_different_exiting_repo_with_force.rb index a88709f..3bc3e30 100644 --- a/spec/acceptance/beaker/git/clone/clone_over_different_exiting_repo_with_force.rb +++ b/spec/acceptance/beaker/git/clone/clone_over_different_exiting_repo_with_force.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_already_exists' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_in_repo.rb b/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_in_repo.rb index 89844c3..dec275f 100644 --- a/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_in_repo.rb +++ b/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_in_repo.rb @@ -8,7 +8,11 @@ exclude2 ='file2.txt' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_not_in_repo.rb b/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_not_in_repo.rb index 10c0e8e..ba37930 100644 --- a/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_not_in_repo.rb +++ b/spec/acceptance/beaker/git/clone/clone_repo_with_excludes_not_in_repo.rb @@ -8,7 +8,11 @@ exclude2 ='ho398b' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/clone/clone_scp.rb b/spec/acceptance/beaker/git/clone/clone_scp.rb index 709079d..59370eb 100644 --- a/spec/acceptance/beaker/git/clone/clone_scp.rb +++ b/spec/acceptance/beaker/git/clone/clone_scp.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_clone' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/clone/clone_ssh.rb b/spec/acceptance/beaker/git/clone/clone_ssh.rb index 7f4a9a4..5bc06ec 100644 --- a/spec/acceptance/beaker/git/clone/clone_ssh.rb +++ b/spec/acceptance/beaker/git/clone/clone_ssh.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_clone' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb b/spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb index 8adb1af..6826673 100644 --- a/spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb +++ b/spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_already_exists' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb b/spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb index 2264015..9805355 100644 --- a/spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb +++ b/spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb @@ -8,7 +8,11 @@ exclude1 = "`exec \"rm -rf /tmp\"`" hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/compression/compression_0_checkout.rb b/spec/acceptance/beaker/git/compression/compression_0_checkout.rb index f17d497..7ac4c4a 100644 --- a/spec/acceptance/beaker/git/compression/compression_0_checkout.rb +++ b/spec/acceptance/beaker/git/compression/compression_0_checkout.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_checkout' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/compression/compression_1_checkout.rb b/spec/acceptance/beaker/git/compression/compression_1_checkout.rb index ee910fd..8b7455d 100644 --- a/spec/acceptance/beaker/git/compression/compression_1_checkout.rb +++ b/spec/acceptance/beaker/git/compression/compression_1_checkout.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_checkout' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/compression/compression_2_checkout.rb b/spec/acceptance/beaker/git/compression/compression_2_checkout.rb index aeec31a..81d32c3 100644 --- a/spec/acceptance/beaker/git/compression/compression_2_checkout.rb +++ b/spec/acceptance/beaker/git/compression/compression_2_checkout.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_checkout' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/compression/compression_3_checkout.rb b/spec/acceptance/beaker/git/compression/compression_3_checkout.rb index fe1ee0a..12b60a3 100644 --- a/spec/acceptance/beaker/git/compression/compression_3_checkout.rb +++ b/spec/acceptance/beaker/git/compression/compression_3_checkout.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_checkout' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/compression/compression_4_checkout.rb b/spec/acceptance/beaker/git/compression/compression_4_checkout.rb index 071cc5e..66d2d5e 100644 --- a/spec/acceptance/beaker/git/compression/compression_4_checkout.rb +++ b/spec/acceptance/beaker/git/compression/compression_4_checkout.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_checkout' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/compression/compression_5_checkout.rb b/spec/acceptance/beaker/git/compression/compression_5_checkout.rb index 1ea0737..b60a9f7 100644 --- a/spec/acceptance/beaker/git/compression/compression_5_checkout.rb +++ b/spec/acceptance/beaker/git/compression/compression_5_checkout.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_checkout' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/compression/compression_6_checkout.rb b/spec/acceptance/beaker/git/compression/compression_6_checkout.rb index a8376d7..2f6b075 100644 --- a/spec/acceptance/beaker/git/compression/compression_6_checkout.rb +++ b/spec/acceptance/beaker/git/compression/compression_6_checkout.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_checkout' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/compression/negative/compression_7_checkout.rb b/spec/acceptance/beaker/git/compression/negative/compression_7_checkout.rb index c5f49e6..e74cca9 100644 --- a/spec/acceptance/beaker/git/compression/negative/compression_7_checkout.rb +++ b/spec/acceptance/beaker/git/compression/negative/compression_7_checkout.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_checkout' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/compression/negative/compression_alpha_checkout.rb b/spec/acceptance/beaker/git/compression/negative/compression_alpha_checkout.rb index 74fd112..59aaf21 100644 --- a/spec/acceptance/beaker/git/compression/negative/compression_alpha_checkout.rb +++ b/spec/acceptance/beaker/git/compression/negative/compression_alpha_checkout.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_checkout' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/compression/negative/compression_eval_checkout.rb b/spec/acceptance/beaker/git/compression/negative/compression_eval_checkout.rb index ba56621..b989e58 100644 --- a/spec/acceptance/beaker/git/compression/negative/compression_eval_checkout.rb +++ b/spec/acceptance/beaker/git/compression/negative/compression_eval_checkout.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_checkout' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/compression/negative/compression_exec_checkout.rb b/spec/acceptance/beaker/git/compression/negative/compression_exec_checkout.rb index abab7f1..e1373af 100644 --- a/spec/acceptance/beaker/git/compression/negative/compression_exec_checkout.rb +++ b/spec/acceptance/beaker/git/compression/negative/compression_exec_checkout.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_checkout' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/compression/negative/compression_negative_checkout.rb b/spec/acceptance/beaker/git/compression/negative/compression_negative_checkout.rb index 2485424..1253db1 100644 --- a/spec/acceptance/beaker/git/compression/negative/compression_negative_checkout.rb +++ b/spec/acceptance/beaker/git/compression/negative/compression_negative_checkout.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_checkout' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/create/create_bare_repo_that_already_exists.rb b/spec/acceptance/beaker/git/create/create_bare_repo_that_already_exists.rb index b72963b..ccb8a70 100644 --- a/spec/acceptance/beaker/git/create/create_bare_repo_that_already_exists.rb +++ b/spec/acceptance/beaker/git/create/create_bare_repo_that_already_exists.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_bare_repo_already_exists.git' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create bare repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) on(host, "mkdir #{tmpdir}/#{repo_name}") on(host, "cd #{tmpdir}/#{repo_name} && git --bare init") end diff --git a/spec/acceptance/beaker/git/create/create_repo_that_already_exists.rb b/spec/acceptance/beaker/git/create/create_repo_that_already_exists.rb index f31dda0..8fb8543 100644 --- a/spec/acceptance/beaker/git/create/create_repo_that_already_exists.rb +++ b/spec/acceptance/beaker/git/create/create_repo_that_already_exists.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_already_exists' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/create/negative/create_bare_repo_specifying_revision.rb b/spec/acceptance/beaker/git/create/negative/create_bare_repo_specifying_revision.rb index ece10a5..5b789df 100644 --- a/spec/acceptance/beaker/git/create/negative/create_bare_repo_specifying_revision.rb +++ b/spec/acceptance/beaker/git/create/negative/create_bare_repo_specifying_revision.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_bare.git' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) end teardown do diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_file.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_file.rb index be5ae92..beea7b8 100644 --- a/spec/acceptance/beaker/git/group_checkout/group_checkout_file.rb +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_file.rb @@ -7,7 +7,11 @@ group = 'mygroup' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_file_path.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_file_path.rb index c204792..319a8e7 100644 --- a/spec/acceptance/beaker/git/group_checkout/group_checkout_file_path.rb +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_file_path.rb @@ -7,7 +7,11 @@ group = 'mygroup' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb index 04238ea..e5b9cf2 100644 --- a/spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb @@ -7,7 +7,11 @@ group = 'mygroup' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb index 43c3f2e..bf86f2e 100644 --- a/spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb @@ -8,7 +8,11 @@ hosts.each do |host| ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb index 6825df3..c4c645f 100644 --- a/spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb @@ -8,7 +8,11 @@ hosts.each do |host| ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_scp.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_scp.rb index 0bcf143..c65acc4 100644 --- a/spec/acceptance/beaker/git/group_checkout/group_checkout_scp.rb +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_scp.rb @@ -7,7 +7,11 @@ group = 'mygroup' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/group_checkout/group_checkout_ssh.rb b/spec/acceptance/beaker/git/group_checkout/group_checkout_ssh.rb index 87bad69..cccad19 100644 --- a/spec/acceptance/beaker/git/group_checkout/group_checkout_ssh.rb +++ b/spec/acceptance/beaker/git/group_checkout/group_checkout_ssh.rb @@ -7,7 +7,11 @@ group = 'mygroup' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/group_checkout/negative/group_checkout_file_non_existent_group.rb b/spec/acceptance/beaker/git/group_checkout/negative/group_checkout_file_non_existent_group.rb index 5388f7f..081642d 100644 --- a/spec/acceptance/beaker/git/group_checkout/negative/group_checkout_file_non_existent_group.rb +++ b/spec/acceptance/beaker/git/group_checkout/negative/group_checkout_file_non_existent_group.rb @@ -7,7 +7,11 @@ group = 'mygroup' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/revision_checkout/negative/revision_checkout_not_exists.rb b/spec/acceptance/beaker/git/revision_checkout/negative/revision_checkout_not_exists.rb index 7f0f1b2..85f1fcc 100644 --- a/spec/acceptance/beaker/git/revision_checkout/negative/revision_checkout_not_exists.rb +++ b/spec/acceptance/beaker/git/revision_checkout/negative/revision_checkout_not_exists.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_revision_checkout' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file.rb index be84f0e..b17dc73 100644 --- a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file.rb +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_revision_checkout' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file_path.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file_path.rb index 93db164..c80eb81 100644 --- a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file_path.rb +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_file_path.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_revision_checkout' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb index 2994bb5..69a7fe2 100644 --- a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_revision_checkout' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb index 8101794..7cac163 100644 --- a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb @@ -7,7 +7,11 @@ hosts.each do |host| ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb index adab3a8..1c705a5 100644 --- a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb @@ -7,7 +7,11 @@ hosts.each do |host| ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_scp.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_scp.rb index fb6a20a..b5dbd24 100644 --- a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_scp.rb +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_scp.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_revision_checkout' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_ssh.rb b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_ssh.rb index 9325a0b..222653e 100644 --- a/spec/acceptance/beaker/git/revision_checkout/revision_checkout_ssh.rb +++ b/spec/acceptance/beaker/git/revision_checkout/revision_checkout_ssh.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_revision_checkout' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_exec_depth.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_exec_depth.rb index d82e3c6..f01a488 100644 --- a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_exec_depth.rb +++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_exec_depth.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_shallow_clone' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb index 961d0fe..47fb338 100644 --- a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb +++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb @@ -7,7 +7,11 @@ repo_name = 'testrepo_shallow_clone' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb index 956d7de..723a0b6 100644 --- a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb +++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb @@ -7,7 +7,11 @@ hosts.each do |host| ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_negative_depth.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_negative_depth.rb index c80faa0..869620d 100644 --- a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_negative_depth.rb +++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_negative_depth.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_shallow_clone' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_overflow_depth.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_overflow_depth.rb index fdf4977..a40a204 100644 --- a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_overflow_depth.rb +++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_overflow_depth.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_shallow_clone' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_file.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_file.rb index e68bbd4..9e2abe2 100644 --- a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_file.rb +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_file.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_shallow_clone' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb index 3ceb58e..49683d2 100644 --- a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_shallow_clone' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb index c045018..2392728 100644 --- a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb @@ -8,7 +8,11 @@ hosts.each do |host| ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_scp.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_scp.rb index 1201710..1d5b35a 100644 --- a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_scp.rb +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_scp.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_shallow_clone' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_ssh.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_ssh.rb index 76f2a46..0f00b30 100644 --- a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_ssh.rb +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_ssh.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_shallow_clone' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_zero_depth.rb b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_zero_depth.rb index eb8b121..34c624f 100644 --- a/spec/acceptance/beaker/git/shallow_clone/shallow_clone_zero_depth.rb +++ b/spec/acceptance/beaker/git/shallow_clone/shallow_clone_zero_depth.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_shallow_clone' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/tag_checkout/negative/tag_checkout_not_exists.rb b/spec/acceptance/beaker/git/tag_checkout/negative/tag_checkout_not_exists.rb index 04dd014..1849f02 100644 --- a/spec/acceptance/beaker/git/tag_checkout/negative/tag_checkout_not_exists.rb +++ b/spec/acceptance/beaker/git/tag_checkout/negative/tag_checkout_not_exists.rb @@ -6,7 +6,11 @@ repo_name = 'testrepo_tag_checkout' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file.rb index 8929b0b..9c74485 100644 --- a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file.rb +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file.rb @@ -7,7 +7,11 @@ tag = '0.0.2' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file_path.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file_path.rb index 33d7f41..01f319c 100644 --- a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file_path.rb +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_file_path.rb @@ -7,7 +7,11 @@ tag = '0.0.2' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb index 44b0324..42e689c 100644 --- a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb @@ -7,7 +7,11 @@ tag = '0.0.2' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb index bb211c1..3ea363c 100644 --- a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb @@ -8,7 +8,11 @@ hosts.each do |host| ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb index 95a98f5..d508c43 100644 --- a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb @@ -8,7 +8,11 @@ hosts.each do |host| ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_scp.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_scp.rb index f7af937..cb96b4e 100644 --- a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_scp.rb +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_scp.rb @@ -7,7 +7,11 @@ tag = '0.0.2' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_ssh.rb b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_ssh.rb index 006646a..bc416e8 100644 --- a/spec/acceptance/beaker/git/tag_checkout/tag_checkout_ssh.rb +++ b/spec/acceptance/beaker/git/tag_checkout/tag_checkout_ssh.rb @@ -7,7 +7,11 @@ tag = '0.0.2' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/user_checkout/negative/user_checkout_file_non_existent_user.rb b/spec/acceptance/beaker/git/user_checkout/negative/user_checkout_file_non_existent_user.rb index 19af709..245e175 100644 --- a/spec/acceptance/beaker/git/user_checkout/negative/user_checkout_file_non_existent_user.rb +++ b/spec/acceptance/beaker/git/user_checkout/negative/user_checkout_file_non_existent_user.rb @@ -7,7 +7,11 @@ user = 'myuser' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_file.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_file.rb index 9133661..ccd9ad4 100644 --- a/spec/acceptance/beaker/git/user_checkout/user_checkout_file.rb +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_file.rb @@ -7,7 +7,11 @@ user = 'myuser' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_file_path.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_file_path.rb index 1104fdd..602769d 100644 --- a/spec/acceptance/beaker/git/user_checkout/user_checkout_file_path.rb +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_file_path.rb @@ -7,7 +7,11 @@ user = 'myuser' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb index 4110d05..af2ffb7 100644 --- a/spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb @@ -7,7 +7,11 @@ user = 'myuser' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb index 03ea27b..e8713e5 100644 --- a/spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb @@ -8,7 +8,11 @@ hosts.each do |host| ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb index 7348755..4e633d7 100644 --- a/spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb @@ -8,7 +8,11 @@ hosts.each do |host| ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby' tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_scp.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_scp.rb index dccf9f8..98efb46 100644 --- a/spec/acceptance/beaker/git/user_checkout/user_checkout_scp.rb +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_scp.rb @@ -7,7 +7,11 @@ user = 'myuser' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") diff --git a/spec/acceptance/beaker/git/user_checkout/user_checkout_ssh.rb b/spec/acceptance/beaker/git/user_checkout/user_checkout_ssh.rb index 5ee01b1..cfd521e 100644 --- a/spec/acceptance/beaker/git/user_checkout/user_checkout_ssh.rb +++ b/spec/acceptance/beaker/git/user_checkout/user_checkout_ssh.rb @@ -7,7 +7,11 @@ user = 'myuser' hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do - install_package(host, 'git') + git_pkg = 'git' + if host['platform'] =~ /ubuntu-10/ + git_pkg = 'git-core' + end + install_package(host, git_pkg) my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) on(host, "cd #{tmpdir} && ./create_git_repo.sh") -- cgit v1.2.3 From 40c4826933848bf827e69e2276f0c9be05877344 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Tue, 17 Jun 2014 10:02:07 -0700 Subject: Remove compatability guarantees for SLES We have some as-of-yet unsolved failures on sles. --- metadata.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/metadata.json b/metadata.json index c9a139e..29fb041 100644 --- a/metadata.json +++ b/metadata.json @@ -39,12 +39,6 @@ "7" ] }, - { - "operatingsystem": "SLES", - "operatingsystemrelease": [ - "11 SP1" - ] - }, { "operatingsystem": "Debian", "operatingsystemrelease": [ -- cgit v1.2.3 From 3d4f2f81eace493052b9dc038a12ef900554025b Mon Sep 17 00:00:00 2001 From: Lauren Rother Date: Tue, 17 Jun 2014 15:10:52 -0700 Subject: Update README to conform with template Add template sections and organization to original README. Add information about providers, features, and parameters. General edits for clarity and completeness. --- README.markdown | 477 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 459 insertions(+), 18 deletions(-) diff --git a/README.markdown b/README.markdown index 8487256..d0b9169 100644 --- a/README.markdown +++ b/README.markdown @@ -1,32 +1,473 @@ -vcsrepo -======= +#vcsrepo [![Build Status](https://travis-ci.org/puppetlabs/puppetlabs-vcsrepo.png?branch=master)](https://travis-ci.org/puppetlabs/puppetlabs-vcsrepo) -Purpose -------- +####Table of Contents -This provides a single type, `vcsrepo`. +1. [Overview](#overview) +2. [Module Description - What the module does and why it is useful](#module-description) +3. [Setup - The basics of getting started with vcsrepo](#setup) + * [Beginning with vcsrepo](#beginning-with-vcsrepo) +4. [Usage - Configuration options and additional functionality](#usage) + * [Bazaar](#bazaar) + * [CVS](#cvs) + * [Git](#git) + * [Mercurial](#mercurial) + * [Subversion](#subversion) +5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) + * [Type: vcsrepo](#type-vcsrepo) + * [Providers](#providers) + * [Features](#features) + * [Parameters](#parameters) + * [Features and Parameters by Provider](#features-and-parameters-by-provider) +5. [Limitations - OS compatibility, etc.](#limitations) +6. [Development - Guide for contributing to the module](#development) -This type can be used to describe: +##Overview + +The vcsrepo module allows you to use Puppet to easily deploy code from your version control system (VCS). + +##Module Description + +This module provides a single type with providers for each VCS, which can be used to describe: * A working copy checked out from a (remote or local) source, at an arbitrary revision -* A "blank" working copy not associated with a source (when it makes +* A blank working copy not associated with a source (when it makes sense for the VCS being used) -* A "blank" central repository (when the distinction makes sense for the VCS - being used) +* A blank central repository (when the distinction makes sense for the VCS + being used) + +##Setup + +###Beginning with vcsrepo + +To get started with the vcsrepo module, you must simply define the type `vcsrepo` with a path to your repository and the [type of VCS](#Usage) you're using in `provider` (in the below example, Git). + + vcsrepo { "/path/to/repo": + ensure => present, + provider => git, + } + +##Usage + +The vcsrepo module works with the following VCSs: + +* [Bazaar (bzr)](#bazaar) +* [CVS (cvs)](#cvs) +* [Git (git)](#git) +* [Mercurial (hg)](#mercurial) +* [Subversion (svn)](#subversion) + +###Bazaar + +#####Create a blank repository + +To create a blank repository suitable for use as a central repository, +define `vcsrepo` without `source` or `revision`. + + vcsrepo { "/path/to/repo": + ensure => present, + provider => bzr, + } + +#####Branch from an existing repository + +Provide the `source` location to branch from an existing repository. + + vcsrepo { "/path/to/repo": + ensure => present, + provider => bzr, + source => 'lp:myproj', + } + +For a specific revision, use `revision` with a valid revisionspec +(see `bzr help revisionspec` for more information on formatting a revision). + + vcsrepo { "/path/to/repo": + ensure => present, + provider => bzr, + source => 'lp:myproj', + revision => 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x', + } + +#####Sources that use SSH + +When your source uses SSH, for instance 'bzr+ssh://...' or 'sftp://...,' +you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present. + +#####Further examples + +For more examples using Bazaar, see `examples/bzr/`. + +###CVS + +#####To create a blank repository + +To create a blank repository suitable for use as a central repository, +define `vcsrepo` without `source` or `revision`. + + vcsrepo { "/path/to/repo": + ensure => present, + provider => cvs, + } + +#####To checkout/update from a repository + +To get the current mainline, + + vcsrepo { "/path/to/workspace": + ensure => present, + provider => cvs, + source => ":pserver:anonymous@example.com:/sources/myproj", + } + +To get a specific module on the current mainline, + + vcsrepo {"/vagrant/lockss-daemon-source": + ensure => present, + provider => cvs, + source => ":pserver:anonymous@lockss.cvs.sourceforge.net:/cvsroot/lockss", + module => "lockss-daemon", + } + + +You can use the `compression` parameter to set the GZIP compression levels for your repository history. + + vcsrepo { "/path/to/workspace": + ensure => present, + provider => cvs, + compression => 3, + source => ":pserver:anonymous@example.com:/sources/myproj", + } + +For a specific tag, use `revision`. + + vcsrepo { "/path/to/workspace": + ensure => present, + provider => cvs, + compression => 3, + source => ":pserver:anonymous@example.com:/sources/myproj", + revision => "SOMETAG", + } + +#####Sources that use SSH + +When your source uses SSH, you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present. + +#####Further examples + +For for more examples using CVS, see `examples/cvs/`. + +###Git + +#####To create a blank repository + +To create a blank repository suitable for use as a central repository, +define `vcsrepo` without `source` or `revision`. + + vcsrepo { "/path/to/repo": + ensure => present, + provider => git, + } + +If you're defining `vcsrepo` for a central or official repository, you may want to make it a bare repository. You do this by setting `ensure` to 'bare' rather than 'present'. + + vcsrepo { "/path/to/repo": + ensure => bare, + provider => git, + } + +#####To clone/pull a repository + +To get the current HEAD on the master branch, + + vcsrepo { "/path/to/repo": + ensure => present, + provider => git, + source => "git://example.com/repo.git", + } + +To get a specific revision or branch (can be a commit SHA, tag, or branch name), + + **SHA** + + vcsrepo { "/path/to/repo": + ensure => present, + provider => git, + source => 'git://example.com/repo.git', + revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31', + } + +**Tag** + + vcsrepo { "/path/to/repo": + ensure => present, + provider => git, + source => 'git://example.com/repo.git', + revision => '1.1.2rc1', + } + +**Branch name** + + vcsrepo { "/path/to/repo": + ensure => present, + provider => git, + source => 'git://example.com/repo.git', + revision => 'development', + } + +To check out a branch as a specific user, + + vcsrepo { "/path/to/repo": + ensure => present, + provider => git, + source => 'git://example.com/repo.git', + revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31', + user => 'someUser', + } + +To keep the repository at the latest revision (**WARNING:** this will always overwrite local changes to the repository), + + vcsrepo { "/path/to/repo": + ensure => latest, + provider => git, + source => 'git://example.com/repo.git', + revision => 'master', + } + +#####Sources that use SSH + +When your source uses SSH, such as 'username@server:…', you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present. + +For SSH keys associated with a user, enter the username in the `user` parameter. Doing so will use that user's keys. + + user => 'toto' # will use toto's $HOME/.ssh setup + +#####Further Examples + +For for more examples using Git, see `examples/git/`. + +###Mercurial + +#####To create a blank repository + +To create a blank repository suitable for use as a central repository, +define `vcsrepo` without `source` or `revision`. + + vcsrepo { "/path/to/repo": + ensure => present, + provider => hg, + } + +#####To clone/pull & update a repository + +To get the default branch tip, + + vcsrepo { "/path/to/repo": + ensure => present, + provider => hg, + source => "http://hg.example.com/myrepo", + } + +For a specific changeset, use `revision`. + + vcsrepo { "/path/to/repo": + ensure => present, + provider => hg, + source => "http://hg.example.com/myrepo", + revision => '21ea4598c962', + } + +You can also set `revision` to a tag. + + vcsrepo { "/path/to/repo": + ensure => present, + provider => hg, + source => "http://hg.example.com/myrepo", + revision => '1.1.2', + } + +To check out as a specific user, + + vcsrepo { "/path/to/repo": + ensure => present, + provider => hg, + source => "http://hg.example.com/myrepo", + user => 'user', + } + +To specify an SSH identity key, + + vcsrepo { "/path/to/repo": + ensure => present, + provider => hg, + source => "ssh://hg@hg.example.com/myrepo", + identity => "/home/user/.ssh/id_dsa, + } + +#####Sources that use SSH + +When your source uses SSH, such as 'ssh://...', you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present. + +#####Further Examples + +For more examples using Mercurial, see `examples/hg/`. + +###Subversion + +#####To create a blank repository + +To create a blank repository suitable for use as a central repository, +define `vcsrepo` without `source` or `revision`. + + vcsrepo { "/path/to/repo": + ensure => present, + provider => svn, + } + +#####To check out from a repository + +Provide a `source` pointing to the branch/tag you want to check out from a repository. + + vcsrepo { "/path/to/repo": + ensure => present, + provider => svn, + source => "svn://svnrepo/hello/branches/foo", + } + +You can also provide a specific revision. + + vcsrepo { "/path/to/repo": + ensure => present, + provider => svn, + source => "svn://svnrepo/hello/branches/foo", + revision => '1234', + } + +#####Using a specific Subversion configuration directory + +To use a specific configuration directory, provide a `configuration` parameter which should be a directory path on the local system where your svn configuration files are. Typically, it is '/path/to/.subversion'. + + vcsrepo { "/path/to/repo": + ensure => present, + provider => svn, + source => "svn://svnrepo/hello/branches/foo", + configuration => "/path/to/.subversion", + } + +#####Sources that use SSH + +When your source uses SSH, such as 'svn+ssh://...', you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present. + +####Further examples + +For more examples using Subversion, see `examples/svn/`. + +##Reference + +###Type: vcsrepo + +The vcsrepo module is slightly unusual in that it is simply a type and providers. Each provider abstracts a different VCS, and a series of features are available to each provider based on its specific needs. + +####Providers + +**Note**: Not all features are available with all providers. + +* `bar` - Supports the Bazaar VCS. (Contains features: `reference_tracking`.) +* `cvs` - Supports the CVS VCS. (Contains features: `cvs_rsh`, `gzip_compression`, `modules`,`reference_tracking`.) +* `dummy` - +* `git` - Supports the Git VCS. (Contains features: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`.) +* `hg` - Supports the Mercurial VCS. (Contains features: `reference_tracking`, `ssh_identity`, `user`.) +* `svn` - Supports the Subversion VCS. (Contains features: `basic_auth`, `configuration`, `filesystem_types`, `reference_tracking`.) + +####Features + +**Note**: Not all features are available with all providers. + +* `bare_repositories` - The provider differentiates between bare repositories and those with working copies. (Available with `git`.) +* `basic_auth` - The provider supports HTTP Basic Authentication. (Available with `svn`.) +* `configuration` - The provider supports setting the configuration path.(Available with `svn`.) +* `cvs_rsh` - The provider understands the CVS_RSH environment variable. (Available with `cvs`.) +* `depth` - The provider can do shallow clones. (Available with `git`.) +* `filesystem_types` - The provider supports different filesystem types. (Available with `svn`.) +* `gzip_compression` - The provider supports explicit GZip compression levels. (Available with `cvs`.) +* `modules` - The provider allows specific repository modules to be chosen. (Available with `cvs`.) +* `multiple_remotes` - The repository tracks multiple remote repositories. (Available with `git`.) +* `reference_tracking` - The provider supports tracking revision references that can change over time (e.g. some VCS tags and branch names). (Available with `bar`, `cvs`, `git`, `hg`, `svn`.) +* `ssh_identity` - The provider supports a configurable SSH identity file. (Available with `git` and `hg`.) +* `user` - The provider can run as a different user. (Available with `git` and `hg`.) + +####Parameters + +* `basic_auth_password` - Specifies the HTTP Basic Authentication password. (Requires the `basic_auth` feature.) +* `basic_auth_username` - Specifies the HTTP Basic Authentication username. (Requires the `basic_auth` feature.) +* `compression` - Set the GZIP compression levels for your repository history. (Requires the `gzip_compression` feature.) +* `configuration` - Sets the configuration directory to use. (Requires the `configuration` feature.) +* `cvs_rsh` - The value to be used for the CVS_RSH environment variable. (Requires the `cvs_rsh` feature.) +* `depth` - The value to be used to do a shallow clone. (Requires the `depth` feature.) +* `ensure` - Determines the state of the repository. Valid values are 'present', 'bare', 'absent', 'latest'. +* `excludes` - Lists any files to be excluded from the repository. +* `force` - Forces repository creation. Valid values are 'true' and 'false'. **WARNING** Forcing will destroy any files in the path. +* `fstype` - Sets the filesystem type. (Requires the `filesystem_types` feature.) +* `group` - Determines the group/gid that owns the repository files. +* `identity` - Specifies the SSH identity file. (Requires the `ssh_identity` feature.) +* `module` - Specifies the repository module to manage. (Requires the `modules` feature.) +* `owner` - Specifies the user/uid that owns the repository files. +* `path` - Specifies the absolute path to the repository. If omitted, the value defaults to the resource's title. +* `provider` - The specific backend to use for this vcsrepo resource. Puppet will usually discover the appropriate provider for your platform. +* `remote` - Specifies the remote repository to track. (Requires the `multiple_remotes` feature.) +* `revision` - Sets the revision of the repository. Values can match /^\S+$/. +* `source` - Specifies the source URI for the repository. +* `user` - Specifies the user to run as for repository operations. + +####Features and Parameters by Provider + +#####`bzr` +**Features**: `reference_tracking` + +**Parameters**: `ensure`, `excludes`, `force`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `user` + +#####`cvs` +**Features**: `cvs_rsh`, `gzip_compression`, `modules`, `reference_tracking`, `revision` + +**Parameters**: `compression`, `cvs_rsh`, `ensure`, `excludes`, `force`, `group`, `module`, `owner`, `path`, `provider`, `revision`, `source`, `user` + +#####`git` +**Features**: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user` + +**Parameters**: `depth`, `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `remote`, `revision`, `source`, `user` + +#####`hg` +**Features**: `reference_tracking`, `ssh_identity`, `user` + +**Parameters**: `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `revision`, `source`, `user` + +#####`svn` +**Features**: `basic_auth`, `configuration`, `filesystem_types`, `reference_tracking` + +**Parameters**: `basic_auth_password`, `basic_auth_username`, `configuration`, `ensure`, `excludes`, `force`, `fstype`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `user` + +##Limitations + +This module has been built on and tested against Puppet 2.7 and higher. + +The module has been tested on: + +RedHat Enterprise Linux 5/6 +Debian 6/7 +CentOS 5/6 +Ubuntu 12.04 +Gentoo +Arch Linux +FreeBSD -Supported Version Control Systems ---------------------------------- +Testing on other platforms has been light and cannot be guaranteed. -This module supports a wide range of VCS types, each represented by a -separate provider. +##Development -For information on how to use this module with a specific VCS, see -`README..markdown`. +Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve. -License -------- +We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. -See LICENSE. +You can read the complete module contribution guide on the Puppet Labs wiki. \ No newline at end of file -- cgit v1.2.3 From 8e4a9d2201c73fdd8d2601fcdec64f4089dbdb8f Mon Sep 17 00:00:00 2001 From: Lauren Rother Date: Tue, 17 Jun 2014 15:18:10 -0700 Subject: Remove extra READMEs Delete the per-VCS readmes. They are all combined in the main readme now. --- README.BZR.markdown | 47 -------------------------- README.CVS.markdown | 66 ------------------------------------- README.GIT.markdown | 95 ----------------------------------------------------- README.HG.markdown | 73 ---------------------------------------- README.SVN.markdown | 62 ---------------------------------- README.markdown | 6 ++-- 6 files changed, 3 insertions(+), 346 deletions(-) delete mode 100644 README.BZR.markdown delete mode 100644 README.CVS.markdown delete mode 100644 README.GIT.markdown delete mode 100644 README.HG.markdown delete mode 100644 README.SVN.markdown diff --git a/README.BZR.markdown b/README.BZR.markdown deleted file mode 100644 index cc257e9..0000000 --- a/README.BZR.markdown +++ /dev/null @@ -1,47 +0,0 @@ -Using vcsrepo with Bazaar -========================= - -To create a blank repository ----------------------------- - -Define a `vcsrepo` without a `source` or `revision`: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => bzr - } - -To branch from an existing repository -------------------------------------- - -Provide the `source` location: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => bzr, - source => 'lp:myproj' - } - -For a specific revision, use `revision` with a valid revisionspec -(see `bzr help revisionspec` for more information on formatting a revision): - - vcsrepo { "/path/to/repo": - ensure => present, - provider => bzr, - source => 'lp:myproj', - revision => 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x' - } - -For sources that use SSH (eg, `bzr+ssh://...`, `sftp://...`) ------------------------------------------------------------- - -Manage your SSH keys with Puppet and use `require` in your `vcsrepo` -to ensure they are present. For more information, see the `require` -metaparameter documentation[1]. - -More Examples -------------- - -For examples you can run, see `examples/bzr/` - -[1]: http://docs.puppetlabs.com/references/stable/metaparameter.html#require diff --git a/README.CVS.markdown b/README.CVS.markdown deleted file mode 100644 index 3bdd59d..0000000 --- a/README.CVS.markdown +++ /dev/null @@ -1,66 +0,0 @@ -Using vcsrepo with CVS -====================== - -To create a blank repository ----------------------------- - -Define a `vcsrepo` without a `source` or `revision`: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => cvs - } - -To checkout/update from a repository ------------------------------------- - -To get the current mainline: - - vcsrepo { "/path/to/workspace": - ensure => present, - provider => cvs, - source => ":pserver:anonymous@example.com:/sources/myproj" - } - -To get a specific module on the current mainline: - - vcsrepo {"/vagrant/lockss-daemon-source": - ensure => present, - provider => cvs, - source => ":pserver:anonymous@lockss.cvs.sourceforge.net:/cvsroot/lockss", - module => "lockss-daemon", - } - - -You can use the `compression` parameter (it works like CVS `-z`): - - vcsrepo { "/path/to/workspace": - ensure => present, - provider => cvs, - compression => 3, - source => ":pserver:anonymous@example.com:/sources/myproj" - } - -For a specific tag, use `revision`: - - vcsrepo { "/path/to/workspace": - ensure => present, - provider => cvs, - compression => 3, - source => ":pserver:anonymous@example.com:/sources/myproj", - revision => "SOMETAG" - } - -For sources that use SSH ------------------------- - -Manage your SSH keys with Puppet and use `require` in your `vcsrepo` -to ensure they are present. For more information, see the `require` -metaparameter documentation[1]. - -More Examples -------------- - -For examples you can run, see `examples/cvs/` - -[1]: http://docs.puppetlabs.com/references/stable/metaparameter.html#require diff --git a/README.GIT.markdown b/README.GIT.markdown deleted file mode 100644 index 846bdcc..0000000 --- a/README.GIT.markdown +++ /dev/null @@ -1,95 +0,0 @@ -Using vcsrepo with Git -====================== - -To create a blank repository ----------------------------- - -Define a `vcsrepo` without a `source` or `revision`: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => git - } - -If you're defining this for a central/"official" repository, you'll -probably want to make it a "bare" repository. Do this by setting -`ensure` to `bare` instead of `present`: - - vcsrepo { "/path/to/repo": - ensure => bare, - provider => git - } - -To clone/pull a repository ----------------------------- - -To get the current [master] HEAD: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - source => "git://example.com/repo.git" - } - -For a specific revision or branch (can be a commit SHA, tag or branch name): - - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - source => 'git://example.com/repo.git', - revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31' - } - - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - source => 'git://example.com/repo.git', - revision => '1.1.2rc1' - } - - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - source => 'git://example.com/repo.git', - revision => 'development' - } - -Check out as a user: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - source => 'git://example.com/repo.git', - revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31', - user => 'someUser' - } - -Keep the repository at the latest revision (note: this will always overwrite local changes to the repository): - - vcsrepo { "/path/to/repo": - ensure => latest, - provider => git, - source => 'git://example.com/repo.git', - revision => 'master', - } - -For sources that use SSH (eg, `username@server:...`) ----------------------------------------------------- - -If your SSH key is associated with a user, simply fill the `user` parameter to use his keys. - -Example: - - user => 'toto' # will use toto's $HOME/.ssh setup - - -Otherwise, manage your SSH keys with Puppet and use `require` in your `vcsrepo` to ensure they are present. -For more information, see the `require` metaparameter documentation[1]. - -More Examples -------------- - -For examples you can run, see `examples/git/` - -[1]: http://docs.puppetlabs.com/references/stable/metaparameter.html#require - diff --git a/README.HG.markdown b/README.HG.markdown deleted file mode 100644 index 55ceef4..0000000 --- a/README.HG.markdown +++ /dev/null @@ -1,73 +0,0 @@ -Using vcsrepo with Mercurial -============================ - -To create a blank repository ----------------------------- - -Define a `vcsrepo` without a `source` or `revision`: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => hg - } - -To clone/pull & update a repository ------------------------------------ - -To get the default branch tip: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => hg, - source => "http://hg.example.com/myrepo" - } - -For a specific changeset, use `revision`: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => hg, - source => "http://hg.example.com/myrepo", - revision => '21ea4598c962' - } - -You can also set `revision` to a tag: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => hg, - source => "http://hg.example.com/myrepo", - revision => '1.1.2' - } - -Check out as a user: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => hg, - source => "http://hg.example.com/myrepo", - user => 'user' - } - -Specify an SSH identity key: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => hg, - source => "ssh://hg@hg.example.com/myrepo", - identity => "/home/user/.ssh/id_dsa, - } - -For sources that use SSH (eg, `ssh://...`) ------------------------------------------- - -Manage your SSH keys with Puppet and use `require` in your `vcsrepo` -to ensure they are present. For more information, see the `require` -metaparameter documentation[1]. - -More Examples -------------- - -For examples you can run, see `examples/hg/` - -[1]: http://docs.puppetlabs.com/references/stable/metaparameter.html#require diff --git a/README.SVN.markdown b/README.SVN.markdown deleted file mode 100644 index f374094..0000000 --- a/README.SVN.markdown +++ /dev/null @@ -1,62 +0,0 @@ -Using vcsrepo with Subversion -============================= - -To create a blank repository ----------------------------- - -To create a blank repository suitable for use as a central repository, -define a `vcsrepo` without a `source` or `revision`: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => svn - } - -To checkout from a repository ------------------------------ - -Provide a `source` qualified to the branch/tag you want: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => svn, - source => "svn://svnrepo/hello/branches/foo" - } - -You can provide a specific `revision`: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => svn, - source => "svn://svnrepo/hello/branches/foo", - revision => '1234' - } - - -Using a specified Subversion configuration directory ------------------------------ - -Provide a `configuration` parameter which should be a directory path on the local system where your svn configuration -files are. Typically, it is /path/to/.subversion: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => svn, - source => "svn://svnrepo/hello/branches/foo", - configuration => "/path/to/.subversion" - } - - -For sources that use SSH (eg, `svn+ssh://...`) ----------------------------------------------- - -Manage your SSH keys with Puppet and use `require` in your `vcsrepo` -to ensure they are present. For more information, see the `require` -metaparameter documentation[1]. - -More Examples -------------- - -For examples you can run, see `examples/svn/` - -[1]: http://docs.puppetlabs.com/references/stable/metaparameter.html#require diff --git a/README.markdown b/README.markdown index d0b9169..39cd249 100644 --- a/README.markdown +++ b/README.markdown @@ -25,7 +25,7 @@ ##Overview -The vcsrepo module allows you to use Puppet to easily deploy code from your version control system (VCS). +The vcsrepo module allows you to use Puppet to easily deploy content from your version control system (VCS). ##Module Description @@ -246,7 +246,7 @@ For SSH keys associated with a user, enter the username in the `user` parameter. #####Further Examples -For for more examples using Git, see `examples/git/`. +For more examples using Git, see `examples/git/`. ###Mercurial @@ -415,7 +415,7 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers * `module` - Specifies the repository module to manage. (Requires the `modules` feature.) * `owner` - Specifies the user/uid that owns the repository files. * `path` - Specifies the absolute path to the repository. If omitted, the value defaults to the resource's title. -* `provider` - The specific backend to use for this vcsrepo resource. Puppet will usually discover the appropriate provider for your platform. +* `provider` - Specifies the backend to use for this vcsrepo resource. * `remote` - Specifies the remote repository to track. (Requires the `multiple_remotes` feature.) * `revision` - Sets the revision of the repository. Values can match /^\S+$/. * `source` - Specifies the source URI for the repository. -- cgit v1.2.3 From 57cd521d35a4ea169382479403fbc89437428ae1 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Tue, 17 Jun 2014 17:05:12 -0700 Subject: Release 1.0.1 Summary: This release is the first supported release of vcsrepo. The readme has been greatly improved. Features: - Updated and expanded readme to follow readme template Fixes: - Remove SLES from compatability metadata - Unpin rspec development dependencies - Update acceptance level testing --- CHANGELOG | 14 ++++++++++++++ Modulefile | 2 +- metadata.json | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 812a2c7..7ae0fcc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,17 @@ +2014-06-17 - Supported Release 1.0.1 + +Summary: +This release is the first supported release of vcsrepo. The readme has been +greatly improved. + +Features: +- Updated and expanded readme to follow readme template + +Fixes: +- Remove SLES from compatability metadata +- Unpin rspec development dependencies +- Update acceptance level testing + 2014-06-04 - Version 1.0.0 Summary: diff --git a/Modulefile b/Modulefile index 8a468ab..726c13c 100644 --- a/Modulefile +++ b/Modulefile @@ -1,4 +1,4 @@ name 'puppetlabs-vcsrepo' -version '1.0.0' +version '1.0.1' summary 'Manage repositories from various version control systems' description 'Manage repositories from various version control systems' diff --git a/metadata.json b/metadata.json index 29fb041..22d3443 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-vcsrepo", - "version": "1.0.0", + "version": "1.0.1", "source": "https://github.com/puppetlabs/puppetlabs-vcsrepo", "author": "Puppet Labs", "license": "GPLv2", -- cgit v1.2.3 From 7867045623b1308aa6c64812976beac2558f14b8 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 18 Jun 2014 09:43:59 -0700 Subject: Pending overflow depth test This test is pending as git cannot handle the overflow correctly, though vcsrepo handles it fine. --- .../beaker/git/shallow_clone/negative/shallow_clone_overflow_depth.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_overflow_depth.rb b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_overflow_depth.rb index a40a204..5da9fd7 100644 --- a/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_overflow_depth.rb +++ b/spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_overflow_depth.rb @@ -3,6 +3,8 @@ test_name 'C3606 - shallow clone repo depth overflow 64bit integer' # Globals repo_name = 'testrepo_shallow_clone' +pending_test("The overflow can't be handled on some git versions") + hosts.each do |host| tmpdir = host.tmpdir('vcsrepo') step 'setup - create repo' do -- cgit v1.2.3 From 508373904f746242f5ac9a8132269c25081f26fc Mon Sep 17 00:00:00 2001 From: John Duarte Date: Sun, 15 Jun 2014 10:57:25 -0700 Subject: Define group in clone_repo_spec test A matching group is not added for a user when added on SLES 11. This commit adds a group to the setup manifests in order to ensure that the proper group is added to the system during the test preparation. --- spec/acceptance/clone_repo_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb index e76f4bc..a989661 100644 --- a/spec/acceptance/clone_repo_spec.rb +++ b/spec/acceptance/clone_repo_spec.rb @@ -324,8 +324,12 @@ describe 'clones a remote repo' do before(:all) do shell("chmod 707 #{tmpdir}") pp = <<-EOS + group { 'testuser': + ensure => present, + } user { 'testuser': ensure => present, + groups => 'testuser', } EOS @@ -388,8 +392,12 @@ describe 'clones a remote repo' do before(:all) do # create user pp = <<-EOS + group { 'testuser-ssh': + ensure => present, + } user { 'testuser-ssh': ensure => present, + groups => 'testuser-ssh', managehome => true, } EOS -- cgit v1.2.3 From 02c38ece76ba621807f0a415d0ea90fff0f395bb Mon Sep 17 00:00:00 2001 From: Justin Stoller Date: Wed, 18 Jun 2014 14:02:33 -0700 Subject: (QENG-798) Update acceptance helpers to create distmoduledir Previously we were creating the module dir on foss installs, but not on PE. PE agents do not have a module dir deployed as part of the base PE install, so to test on PE agents we need to create the module dir. `mkdir -p` is idempotent, so we use it as a cudgle here. We also update the beaker_helper and spec_helper_acceptance to contain the same installation steps for test dependencies, warnings, and installation methods. --- spec/acceptance/beaker_helper.rb | 36 ++++++++++++++++++++++++++++++------ spec/spec_helper_acceptance.rb | 16 ++++++++++++---- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/spec/acceptance/beaker_helper.rb b/spec/acceptance/beaker_helper.rb index 6b5fd46..05aa4e7 100644 --- a/spec/acceptance/beaker_helper.rb +++ b/spec/acceptance/beaker_helper.rb @@ -10,16 +10,40 @@ test_name "Installing Puppet and vcsrepo module" do end end end + + step 'Ensure we can install our module' do + # We ask the host to interpolate it's distmoduledir because we don't + # actually know it on Windows until we've let it redirect us (depending + # on whether we're running as a 32/64 bit process on 32/64 bit Windows + moduledir = on(host, "echo #{host['distmoduledir']}").stdout.chomp + on host, "mkdir -p #{moduledir}" + end + step 'install module' do - proj_root = File.expand_path(File.join(File.dirname(__FILE__),'..','..')) - # Waiting on release of puppet_module_install in beaker - #puppet_module_install(:source => proj_root, :module_name => 'vcsrepo') - scp_to(hosts, proj_root, File.join(hosts.first['distmoduledir'], 'vcsrepo')) - gitconfig = <<-EOS + hosts.each do |host| + proj_root = File.expand_path(File.join(File.dirname(__FILE__),'..','..')) + + # This require beaker 1.12.2 I believe + puppet_module_install(:source => proj_root, :module_name => 'vcsrepo') + + case fact_on(host, 'osfamily') + when 'RedHat' + install_package(host, 'git') + when 'Debian' + install_package(host, 'git-core') + else + if !check_for_package(host, 'git') + puts "Git package is required for this module" + exit + end + end + + gitconfig = <<-EOS [user] email = root@localhost name = root EOS - create_remote_file(hosts.first, "/root/.gitconfig", gitconfig) + create_remote_file(host, "/root/.gitconfig", gitconfig) + end end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index c371f1f..e566a12 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -9,6 +9,12 @@ unless ENV['RS_PROVISION'] == 'no' install_puppet on hosts, "mkdir -p #{hosts.first['distmoduledir']}" end + + # We ask the host to interpolate it's distmoduledir because we don't + # actually know it on Windows until we've let it redirect us (depending + # on whether we're running as a 32/64 bit process on 32/64 bit Windows + moduledir = on(host, "echo #{host['distmoduledir']}").stdout.chomp + on host, "mkdir -p #{moduledir}" end end @@ -21,10 +27,12 @@ RSpec.configure do |c| # Configure all nodes in nodeset c.before :suite do - # Install module and dependencies + # Install module and dependencies on all hosts puppet_module_install(:source => proj_root, :module_name => 'vcsrepo') + + # ensure test dependencies are available on all hosts hosts.each do |host| - case fact('osfamily') + case fact_on(host, 'osfamily') when 'RedHat' install_package(host, 'git') when 'Debian' @@ -35,8 +43,8 @@ RSpec.configure do |c| exit end end - shell('git config --global user.email "root@localhost"') - shell('git config --global user.name "root"') + on host, 'git config --global user.email "root@localhost"' + on host, 'git config --global user.name "root"' end end end -- cgit v1.2.3 From 78b159a59af224c7bf89ee01e6c46ed746e37979 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 18 Jun 2014 15:13:43 -0700 Subject: Revert "Remove compatability guarantees for SLES" This reverts commit 40c4826933848bf827e69e2276f0c9be05877344. --- metadata.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/metadata.json b/metadata.json index 22d3443..4772445 100644 --- a/metadata.json +++ b/metadata.json @@ -39,6 +39,12 @@ "7" ] }, + { + "operatingsystem": "SLES", + "operatingsystemrelease": [ + "11 SP1" + ] + }, { "operatingsystem": "Debian", "operatingsystemrelease": [ -- cgit v1.2.3 From d2bb24e33860090a7051ce9ef6dfbb695cf23447 Mon Sep 17 00:00:00 2001 From: Paul Allen Date: Wed, 11 Jun 2014 22:32:21 +0100 Subject: Basic Perforce provider Supports sync and client create/update --- lib/puppet/provider/vcsrepo/p4.rb | 217 ++++++++++++++++++++++++++++++++++++++ lib/puppet/type/vcsrepo.rb | 19 ++++ 2 files changed, 236 insertions(+) create mode 100644 lib/puppet/provider/vcsrepo/p4.rb diff --git a/lib/puppet/provider/vcsrepo/p4.rb b/lib/puppet/provider/vcsrepo/p4.rb new file mode 100644 index 0000000..2fdae70 --- /dev/null +++ b/lib/puppet/provider/vcsrepo/p4.rb @@ -0,0 +1,217 @@ +require File.join(File.dirname(__FILE__), '..', 'vcsrepo') + +Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) do + desc "Supports Perforce depots" + + has_features :filesystem_types, :reference_tracking, :p4_config + + def create + # create or update client + create_client(client_name, @resource.value(:path)) + + # if source provided, sync client + source = @resource.value(:source) + if source + revision = @resource.value(:revision) + sync_client(source, revision) + end + + update_owner + end + + def working_copy_exists? + # Check if the server is there, or raise error + p4(['info'], {:marshal => false}) + + # Check if workspace is setup + args = ['where'] + args.push(@resource.value(:path) + "...") + hash = p4(args, {:raise => false}) + + return (hash['code'] != "error") + end + + def exists? + working_copy_exists? + end + + def destroy + args = ['client'] + args.push('-d', '-f') + args.push(client_name) + p4(args) + FileUtils.rm_rf(@resource.value(:path)) + end + + def latest? + rev = self.revision + if rev + (rev >= self.latest) + else + true + end + end + + def latest + args = ['changes'] + args.push('-m1', @resource.value(:source)) + hash = p4(args) + + return hash['change'].to_i + end + + def revision + args = ['cstat'] + args.push(@resource.value(:source)) + hash = p4(args) + + if hash['status'] == "have" + return hash['change'].to_i + else + return 0 + end + end + + def revision=(desired) + sync_client(@resource.value(:source), desired) + update_owner + end + + private + + def update_owner + if @resource.value(:owner) or @resource.value(:group) + set_ownership + end + end + + # Sync the client workspace files to head or specified revision. + # Params: + # +source+:: Depot path to sync + # +revision+:: Perforce change list to sync to (optional) + def sync_client(source, revision) + notice "Syncing: #{source}" + args = ['sync'] + if revision + args.push(source + "@" + revision) + else + args.push(source) + end + p4(args) + end + + # Returns the name of the Perforce client workspace + def client_name + path = @resource.value(:path) + client = @resource.value(:p4client) + if not client + client = "puppet-" + Digest::MD5.hexdigest(path) + end + return client + end + + # Create (or update) a client workspace spec. + # If a client name is not provided then a hash based on the path is used. + # Params: + # +client+:: Name of client workspace + # +path+:: The Root location of the Perforce client workspace + def create_client(client, path) + notice "Creating client: #{client}" + hash = parse_client(client) + hash['Root'] = path + hash['Description'] = "Generated by Puppet VCSrepo" + save_client(hash) + end + + + # Fetches a client workspace spec from Perforce and returns a hash map representation. + # Params: + # +client+:: name of the client workspace + def parse_client(client) + args = ['client'] + args.push('-o', client) + hash = p4(args) + + return hash + end + + + # Saves the client workspace spec from the given hash + # Params: + # +hash+:: hash map of client spec + def save_client(hash) + spec = String.new + view = "\nView:\n" + + hash.each do |k,v| + next if( k == "code" ) + if(k.to_s =~ /View/ ) + view += "\t#{v}\n" + else + spec += "#{k.to_s}: #{v.to_s}\n" + end + end + spec += view + + args = ['client'] + args.push('-i') + p4(args, {:input => spec, :marshal => false}) + end + + def config + p4port = @resource.value(:p4port) + p4user = @resource.value(:p4user) + p4charset = @resource.value(:p4charset) + p4client = @resource.value(:p4client) || client_name + + cfg = Hash.new + cfg.store 'P4USER', p4user if p4user + cfg.store 'P4PORT', p4port if p4port + cfg.store 'P4CHARSET', p4charset if p4charset + cfg.store 'P4CLIENT', p4client if p4client + + return cfg + end + + def p4(args, options = {}) + # Merge custom options with defaults + opts = { + :raise => true, # Raise errors + :marshal => true, # Marshal output + }.merge(options) + + cmd = ['p4'] + cmd.push '-R' if opts[:marshal] + cmd.push args + cmd_str = cmd.respond_to?(:join) ? cmd.join(' ') : cmd + + notice "environment: #{config}" + notice "command: #{cmd_str}" + + hash = Hash.new + Open3.popen3(config, cmd_str) do |i, o, e, t| + # Send input stream if provided + if(opts[:input]) + notice "input:\n" + opts[:input] + i.write opts[:input] + i.close + end + + if(opts[:marshal]) + hash = Marshal.load(o) + else + hash['data'] = o.read + end + + # Raise errors, Perforce or Exec + if(opts[:raise]) + p4_err = "P4: " + hash['data'] if(hash['code'] == 'error') + raise Puppet::DevError, "#{p4_err}\n#{e.read}\nExit: #{t.value}" if(t.value != 0) + end + end + + notice "hash: #{hash}\n" + return hash + end + +end diff --git a/lib/puppet/type/vcsrepo.rb b/lib/puppet/type/vcsrepo.rb index 0e4450b..ad964c5 100644 --- a/lib/puppet/type/vcsrepo.rb +++ b/lib/puppet/type/vcsrepo.rb @@ -40,6 +40,9 @@ Puppet::Type.newtype(:vcsrepo) do feature :depth, "The provider can do shallow clones" + feature :p4_config, + "The provider understands Perforce Configuration" + ensurable do attr_accessor :latest @@ -209,6 +212,22 @@ Puppet::Type.newtype(:vcsrepo) do desc "The value to be used to do a shallow clone." end + newparam :p4port, :required_features => [:p4_config] do + desc "The Perforce P4PORT environment." + end + + newparam :p4user, :required_features => [:p4_config] do + desc "The Perforce P4USER environment." + end + + newparam :p4client, :required_features => [:p4_config] do + desc "The Perforce P4CLIENT environment." + end + + newparam :p4charset, :required_features => [:p4_config] do + desc "The Perforce P4CHARSET environment." + end + autorequire(:package) do ['git', 'git-core'] end -- cgit v1.2.3 From b16e4c0f9251279fe2211f651459654e0759dbf0 Mon Sep 17 00:00:00 2001 From: Paul Allen Date: Thu, 12 Jun 2014 17:49:19 +0100 Subject: Markdown and examples --- README.P4.markdown | 82 ++++++++++++++++++++++++++++++++++++++++++++ examples/p4/create_client.pp | 5 +++ examples/p4/delete_client.pp | 5 +++ examples/p4/latest_client.pp | 6 ++++ examples/p4/sync_client.pp | 7 ++++ 5 files changed, 105 insertions(+) create mode 100644 README.P4.markdown create mode 100644 examples/p4/create_client.pp create mode 100644 examples/p4/delete_client.pp create mode 100644 examples/p4/latest_client.pp create mode 100644 examples/p4/sync_client.pp diff --git a/README.P4.markdown b/README.P4.markdown new file mode 100644 index 0000000..39fffd2 --- /dev/null +++ b/README.P4.markdown @@ -0,0 +1,82 @@ +Using vcsrepo with Perforce +=========================== + +To create an empty Workspace +---------------------------- + +Define a `vcsrepo` without a `source` or `revision`: + + vcsrepo { "/path/to/repo": + ensure => present, + provider => p4 + } + +If no `p4client` name is provided a workspace generated name is calculated based on the +Digest of path. For example: + + puppet-91bc00640c4e5a17787286acbe2c021c + +Providing a `p4client` name will create/update the client workspace in Perforce. + + vcsrepo { "/path/to/repo": + ensure => present, + provider => p4 + p4client => "my_client_ws" + } + +To create/update and sync a Perforce workspace +---------------------------------------------- + +To sync a depot path to head (latest): + + vcsrepo { "/path/to/repo": + ensure => present, + provider => p4, + source => '//depot/branch/...' + } + +For a specific changelist, use `revision`: + + vcsrepo { "/path/to/repo": + ensure => present, + provider => p4, + source => '//depot/branch/...', + revision => '2341' + } + +You can also set `revision` to a label: + + vcsrepo { "/path/to/repo": + ensure => present, + provider => p4, + source => '//depot/branch/...', + revision => 'my_label' + } + +Check out as a user by setting `p4user`: + + vcsrepo { "/path/to/repo": + ensure => present, + provider => p4, + source => '//depot/branch/...', + p4user => 'user' + } + +You can set `p4port` to specify a Perforce server: + + vcsrepo { "/path/to/repo": + ensure => present, + provider => p4, + source => '//depot/branch/...', + p4port => 'ssl:perforce.com:1666' + } + +If `p4port`, `p4user`, `p4charset` or `p4client` are specified they will override the +environment variabels P4PORT, P4USER, etc... If a P4CONFIG file is defined, the config +file settings will take precedence. + + +More Examples +------------- + +For examples you can run, see `examples/p4/` diff --git a/examples/p4/create_client.pp b/examples/p4/create_client.pp new file mode 100644 index 0000000..f7605e6 --- /dev/null +++ b/examples/p4/create_client.pp @@ -0,0 +1,5 @@ +vcsrepo { "/tmp/vcstest-p4-create_client": + ensure => present, + provider => p4, + p4client => "puppet-test001" +} \ No newline at end of file diff --git a/examples/p4/delete_client.pp b/examples/p4/delete_client.pp new file mode 100644 index 0000000..315222f --- /dev/null +++ b/examples/p4/delete_client.pp @@ -0,0 +1,5 @@ +vcsrepo { "/tmp/vcstest-p4-create_client": + ensure => absent, + provider => p4, + p4client => "puppet-test001" +} \ No newline at end of file diff --git a/examples/p4/latest_client.pp b/examples/p4/latest_client.pp new file mode 100644 index 0000000..719e180 --- /dev/null +++ b/examples/p4/latest_client.pp @@ -0,0 +1,6 @@ +vcsrepo { "/tmp/vcstest-p4-create_client": + ensure => latest, + provider => p4, + p4client => "puppet-test001", + source => "//depot/..." +} \ No newline at end of file diff --git a/examples/p4/sync_client.pp b/examples/p4/sync_client.pp new file mode 100644 index 0000000..c1128bc --- /dev/null +++ b/examples/p4/sync_client.pp @@ -0,0 +1,7 @@ +vcsrepo { "/tmp/vcstest-p4-create_client": + ensure => present, + provider => p4, + p4client => "puppet-test001", + source => "//depot/..." + revision => "30" +} \ No newline at end of file -- cgit v1.2.3 From 58f9cb20657a7be01777c920a37279f30dc1fce6 Mon Sep 17 00:00:00 2001 From: Paul Allen Date: Thu, 12 Jun 2014 17:50:55 +0100 Subject: Spec tests for p4 provider Test create, destroy and exists? access points. --- spec/unit/puppet/provider/vcsrepo/p4_spec.rb | 73 ++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 spec/unit/puppet/provider/vcsrepo/p4_spec.rb diff --git a/spec/unit/puppet/provider/vcsrepo/p4_spec.rb b/spec/unit/puppet/provider/vcsrepo/p4_spec.rb new file mode 100644 index 0000000..822106d --- /dev/null +++ b/spec/unit/puppet/provider/vcsrepo/p4_spec.rb @@ -0,0 +1,73 @@ +require 'spec_helper' + +describe Puppet::Type.type(:vcsrepo).provider(:p4) do + + let(:resource) { Puppet::Type.type(:vcsrepo).new({ + :name => 'test', + :ensure => :present, + :provider => :p4, + :path => '/tmp/vcsrepo', + })} + + let(:provider) { resource.provider } + + before :each do + Puppet::Util.stubs(:which).with('p4').returns('/usr/local/bin/p4') + end + + spec = { + :input => "Root: /tmp/vcsrepo\nDescription: Generated by Puppet VCSrepo\n\nView:\n", + :marshal => false + } + + describe 'creating' do + context 'with source and revision' do + it "should execute 'p4 sync' with the revision" do + resource[:source] = 'something' + resource[:p4client] = 'client_ws' + resource[:revision] = '1' + provider.expects(:p4).with(['client', '-o', resource.value(:p4client)]).returns({}) + provider.expects(:p4).with(['client', '-i'], spec) + provider.expects(:p4).with(['sync', resource.value(:source) + "@" + resource.value(:revision)]) + provider.create + end + end + + context 'without revision' do + it "should just execute 'p4 sync' without a revision" do + resource[:source] = 'something' + resource[:p4client] = 'client_ws' + provider.expects(:p4).with(['client', '-o', resource.value(:p4client)]).returns({}) + provider.expects(:p4).with(['client', '-i'], spec) + provider.expects(:p4).with(['sync', resource.value(:source)]) + provider.create + end + end + + context "when a client and source are not given" do + it "should execute 'p4 client'" do + provider.expects(:p4).with(['client', '-o', "puppet-51f0a4b45dbfc10614df94f0a189c16f"]).returns({}) + provider.expects(:p4).with(['client', '-i'], spec) + provider.create + end + end + end + + describe 'destroying' do + it "it should remove the directory" do + resource[:p4client] = 'test_client' + provider.expects(:p4).with(['client', '-d', '-f', resource.value(:p4client)]) + expects_rm_rf + provider.destroy + end + end + + describe "checking existence" do + it "should check for the directory" do + provider.expects(:p4).with(['info'], {:marshal => false}).returns({}) + provider.expects(:p4).with(['where', resource.value(:path) + "..."], {:raise => false}).returns({}) + provider.exists? + end + end + +end -- cgit v1.2.3 From 8256eff1800e1377c7cf2b961ef63074a2ede0d4 Mon Sep 17 00:00:00 2001 From: Paul Allen Date: Mon, 16 Jun 2014 17:04:52 +0100 Subject: Add support for passing password/ticket MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Uses param ‘p4passwd’ to set P4PASSWD environment to pass a valid ticket or password. --- README.P4.markdown | 15 ++++++++++++--- lib/puppet/provider/vcsrepo/p4.rb | 2 ++ lib/puppet/type/vcsrepo.rb | 4 ++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/README.P4.markdown b/README.P4.markdown index 39fffd2..f92f616 100644 --- a/README.P4.markdown +++ b/README.P4.markdown @@ -71,9 +71,18 @@ You can set `p4port` to specify a Perforce server: p4port => 'ssl:perforce.com:1666' } -If `p4port`, `p4user`, `p4charset` or `p4client` are specified they will override the -environment variabels P4PORT, P4USER, etc... If a P4CONFIG file is defined, the config -file settings will take precedence. +You can set `p4passwd` for authentication : + + vcsrepo { "/path/to/repo": + ensure => present, + provider => p4, + source => '//depot/branch/...', + p4port => 'ssl:perforce.com:1666' + } + +If `p4port`, `p4user`, `p4charset`, `p4passwd` or `p4client` are specified they will +override the environment variabels P4PORT, P4USER, etc... If a P4CONFIG file is +defined, the config file settings will take precedence. More Examples diff --git a/lib/puppet/provider/vcsrepo/p4.rb b/lib/puppet/provider/vcsrepo/p4.rb index 2fdae70..df1ec21 100644 --- a/lib/puppet/provider/vcsrepo/p4.rb +++ b/lib/puppet/provider/vcsrepo/p4.rb @@ -162,12 +162,14 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d p4port = @resource.value(:p4port) p4user = @resource.value(:p4user) p4charset = @resource.value(:p4charset) + p4passwd = @resource.value(:p4passwd) p4client = @resource.value(:p4client) || client_name cfg = Hash.new cfg.store 'P4USER', p4user if p4user cfg.store 'P4PORT', p4port if p4port cfg.store 'P4CHARSET', p4charset if p4charset + cfg.store 'P4PASSWD', p4passwd if p4passwd cfg.store 'P4CLIENT', p4client if p4client return cfg diff --git a/lib/puppet/type/vcsrepo.rb b/lib/puppet/type/vcsrepo.rb index ad964c5..649789a 100644 --- a/lib/puppet/type/vcsrepo.rb +++ b/lib/puppet/type/vcsrepo.rb @@ -227,6 +227,10 @@ Puppet::Type.newtype(:vcsrepo) do newparam :p4charset, :required_features => [:p4_config] do desc "The Perforce P4CHARSET environment." end + + newparam :p4passwd, :required_features => [:p4_config] do + desc "The Perforce P4PASSWD environment." + end autorequire(:package) do ['git', 'git-core'] -- cgit v1.2.3 From 24e2f91ffb0091bc6f67b4d90f9702690bc1179f Mon Sep 17 00:00:00 2001 From: Paul Allen Date: Fri, 20 Jun 2014 09:59:42 +0100 Subject: Detab to 2 spaces. --- examples/p4/create_client.pp | 6 +- examples/p4/delete_client.pp | 6 +- examples/p4/latest_client.pp | 8 +- examples/p4/sync_client.pp | 10 +- lib/puppet/provider/vcsrepo/p4.rb | 388 +++++++++++++-------------- spec/unit/puppet/provider/vcsrepo/p4_spec.rb | 12 +- 6 files changed, 215 insertions(+), 215 deletions(-) diff --git a/examples/p4/create_client.pp b/examples/p4/create_client.pp index f7605e6..94017bc 100644 --- a/examples/p4/create_client.pp +++ b/examples/p4/create_client.pp @@ -1,5 +1,5 @@ vcsrepo { "/tmp/vcstest-p4-create_client": - ensure => present, - provider => p4, - p4client => "puppet-test001" + ensure => present, + provider => p4, + p4client => "puppet-test001" } \ No newline at end of file diff --git a/examples/p4/delete_client.pp b/examples/p4/delete_client.pp index 315222f..20bdd47 100644 --- a/examples/p4/delete_client.pp +++ b/examples/p4/delete_client.pp @@ -1,5 +1,5 @@ vcsrepo { "/tmp/vcstest-p4-create_client": - ensure => absent, - provider => p4, - p4client => "puppet-test001" + ensure => absent, + provider => p4, + p4client => "puppet-test001" } \ No newline at end of file diff --git a/examples/p4/latest_client.pp b/examples/p4/latest_client.pp index 719e180..54f9062 100644 --- a/examples/p4/latest_client.pp +++ b/examples/p4/latest_client.pp @@ -1,6 +1,6 @@ vcsrepo { "/tmp/vcstest-p4-create_client": - ensure => latest, - provider => p4, - p4client => "puppet-test001", - source => "//depot/..." + ensure => latest, + provider => p4, + p4client => "puppet-test001", + source => "//depot/..." } \ No newline at end of file diff --git a/examples/p4/sync_client.pp b/examples/p4/sync_client.pp index c1128bc..e22f6b0 100644 --- a/examples/p4/sync_client.pp +++ b/examples/p4/sync_client.pp @@ -1,7 +1,7 @@ vcsrepo { "/tmp/vcstest-p4-create_client": - ensure => present, - provider => p4, - p4client => "puppet-test001", - source => "//depot/..." - revision => "30" + ensure => present, + provider => p4, + p4client => "puppet-test001", + source => "//depot/..." + revision => "30" } \ No newline at end of file diff --git a/lib/puppet/provider/vcsrepo/p4.rb b/lib/puppet/provider/vcsrepo/p4.rb index df1ec21..de3bc7a 100644 --- a/lib/puppet/provider/vcsrepo/p4.rb +++ b/lib/puppet/provider/vcsrepo/p4.rb @@ -1,219 +1,219 @@ require File.join(File.dirname(__FILE__), '..', 'vcsrepo') Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) do - desc "Supports Perforce depots" + desc "Supports Perforce depots" - has_features :filesystem_types, :reference_tracking, :p4_config - - def create - # create or update client - create_client(client_name, @resource.value(:path)) - - # if source provided, sync client - source = @resource.value(:source) - if source - revision = @resource.value(:revision) - sync_client(source, revision) - end + has_features :filesystem_types, :reference_tracking, :p4_config + + def create + # create or update client + create_client(client_name, @resource.value(:path)) + + # if source provided, sync client + source = @resource.value(:source) + if source + revision = @resource.value(:revision) + sync_client(source, revision) + end - update_owner - end + update_owner + end - def working_copy_exists? - # Check if the server is there, or raise error - p4(['info'], {:marshal => false}) - - # Check if workspace is setup - args = ['where'] - args.push(@resource.value(:path) + "...") - hash = p4(args, {:raise => false}) - - return (hash['code'] != "error") - end + def working_copy_exists? + # Check if the server is there, or raise error + p4(['info'], {:marshal => false}) + + # Check if workspace is setup + args = ['where'] + args.push(@resource.value(:path) + "...") + hash = p4(args, {:raise => false}) + + return (hash['code'] != "error") + end - def exists? - working_copy_exists? - end + def exists? + working_copy_exists? + end - def destroy - args = ['client'] - args.push('-d', '-f') - args.push(client_name) - p4(args) - FileUtils.rm_rf(@resource.value(:path)) - end + def destroy + args = ['client'] + args.push('-d', '-f') + args.push(client_name) + p4(args) + FileUtils.rm_rf(@resource.value(:path)) + end - def latest? - rev = self.revision - if rev - (rev >= self.latest) - else - true - end - end + def latest? + rev = self.revision + if rev + (rev >= self.latest) + else + true + end + end - def latest - args = ['changes'] - args.push('-m1', @resource.value(:source)) - hash = p4(args) - - return hash['change'].to_i - end + def latest + args = ['changes'] + args.push('-m1', @resource.value(:source)) + hash = p4(args) + + return hash['change'].to_i + end - def revision - args = ['cstat'] - args.push(@resource.value(:source)) - hash = p4(args) - - if hash['status'] == "have" - return hash['change'].to_i - else - return 0 - end - end + def revision + args = ['cstat'] + args.push(@resource.value(:source)) + hash = p4(args) + + if hash['status'] == "have" + return hash['change'].to_i + else + return 0 + end + end - def revision=(desired) - sync_client(@resource.value(:source), desired) - update_owner - end + def revision=(desired) + sync_client(@resource.value(:source), desired) + update_owner + end - private + private - def update_owner - if @resource.value(:owner) or @resource.value(:group) - set_ownership - end - end - - # Sync the client workspace files to head or specified revision. - # Params: + def update_owner + if @resource.value(:owner) or @resource.value(:group) + set_ownership + end + end + + # Sync the client workspace files to head or specified revision. + # Params: # +source+:: Depot path to sync # +revision+:: Perforce change list to sync to (optional) - def sync_client(source, revision) - notice "Syncing: #{source}" - args = ['sync'] - if revision - args.push(source + "@" + revision) - else - args.push(source) - end - p4(args) - end - - # Returns the name of the Perforce client workspace - def client_name - path = @resource.value(:path) - client = @resource.value(:p4client) - if not client - client = "puppet-" + Digest::MD5.hexdigest(path) - end - return client - end - - # Create (or update) a client workspace spec. - # If a client name is not provided then a hash based on the path is used. - # Params: - # +client+:: Name of client workspace + def sync_client(source, revision) + notice "Syncing: #{source}" + args = ['sync'] + if revision + args.push(source + "@" + revision) + else + args.push(source) + end + p4(args) + end + + # Returns the name of the Perforce client workspace + def client_name + path = @resource.value(:path) + client = @resource.value(:p4client) + if not client + client = "puppet-" + Digest::MD5.hexdigest(path) + end + return client + end + + # Create (or update) a client workspace spec. + # If a client name is not provided then a hash based on the path is used. + # Params: + # +client+:: Name of client workspace # +path+:: The Root location of the Perforce client workspace - def create_client(client, path) - notice "Creating client: #{client}" - hash = parse_client(client) - hash['Root'] = path - hash['Description'] = "Generated by Puppet VCSrepo" - save_client(hash) - end + def create_client(client, path) + notice "Creating client: #{client}" + hash = parse_client(client) + hash['Root'] = path + hash['Description'] = "Generated by Puppet VCSrepo" + save_client(hash) + end - # Fetches a client workspace spec from Perforce and returns a hash map representation. + # Fetches a client workspace spec from Perforce and returns a hash map representation. # Params: # +client+:: name of the client workspace - def parse_client(client) - args = ['client'] - args.push('-o', client) - hash = p4(args) + def parse_client(client) + args = ['client'] + args.push('-o', client) + hash = p4(args) - return hash - end - - - # Saves the client workspace spec from the given hash + return hash + end + + + # Saves the client workspace spec from the given hash # Params: # +hash+:: hash map of client spec - def save_client(hash) - spec = String.new - view = "\nView:\n" - - hash.each do |k,v| - next if( k == "code" ) - if(k.to_s =~ /View/ ) - view += "\t#{v}\n" - else - spec += "#{k.to_s}: #{v.to_s}\n" - end - end - spec += view - - args = ['client'] - args.push('-i') - p4(args, {:input => spec, :marshal => false}) - end - - def config - p4port = @resource.value(:p4port) - p4user = @resource.value(:p4user) - p4charset = @resource.value(:p4charset) - p4passwd = @resource.value(:p4passwd) - p4client = @resource.value(:p4client) || client_name - - cfg = Hash.new - cfg.store 'P4USER', p4user if p4user - cfg.store 'P4PORT', p4port if p4port - cfg.store 'P4CHARSET', p4charset if p4charset - cfg.store 'P4PASSWD', p4passwd if p4passwd - cfg.store 'P4CLIENT', p4client if p4client - - return cfg - end - - def p4(args, options = {}) - # Merge custom options with defaults - opts = { - :raise => true, # Raise errors - :marshal => true, # Marshal output - }.merge(options) - - cmd = ['p4'] - cmd.push '-R' if opts[:marshal] - cmd.push args - cmd_str = cmd.respond_to?(:join) ? cmd.join(' ') : cmd - - notice "environment: #{config}" - notice "command: #{cmd_str}" - - hash = Hash.new - Open3.popen3(config, cmd_str) do |i, o, e, t| - # Send input stream if provided - if(opts[:input]) - notice "input:\n" + opts[:input] - i.write opts[:input] - i.close - end - - if(opts[:marshal]) - hash = Marshal.load(o) - else - hash['data'] = o.read - end - - # Raise errors, Perforce or Exec - if(opts[:raise]) - p4_err = "P4: " + hash['data'] if(hash['code'] == 'error') - raise Puppet::DevError, "#{p4_err}\n#{e.read}\nExit: #{t.value}" if(t.value != 0) - end - end - - notice "hash: #{hash}\n" - return hash - end - + def save_client(hash) + spec = String.new + view = "\nView:\n" + + hash.each do |k,v| + next if( k == "code" ) + if(k.to_s =~ /View/ ) + view += "\t#{v}\n" + else + spec += "#{k.to_s}: #{v.to_s}\n" + end + end + spec += view + + args = ['client'] + args.push('-i') + p4(args, {:input => spec, :marshal => false}) + end + + def config + p4port = @resource.value(:p4port) + p4user = @resource.value(:p4user) + p4charset = @resource.value(:p4charset) + p4passwd = @resource.value(:p4passwd) + p4client = @resource.value(:p4client) || client_name + + cfg = Hash.new + cfg.store 'P4USER', p4user if p4user + cfg.store 'P4PORT', p4port if p4port + cfg.store 'P4CHARSET', p4charset if p4charset + cfg.store 'P4PASSWD', p4passwd if p4passwd + cfg.store 'P4CLIENT', p4client if p4client + + return cfg + end + + def p4(args, options = {}) + # Merge custom options with defaults + opts = { + :raise => true, # Raise errors + :marshal => true, # Marshal output + }.merge(options) + + cmd = ['p4'] + cmd.push '-R' if opts[:marshal] + cmd.push args + cmd_str = cmd.respond_to?(:join) ? cmd.join(' ') : cmd + + notice "environment: #{config}" + notice "command: #{cmd_str}" + + hash = Hash.new + Open3.popen3(config, cmd_str) do |i, o, e, t| + # Send input stream if provided + if(opts[:input]) + notice "input:\n" + opts[:input] + i.write opts[:input] + i.close + end + + if(opts[:marshal]) + hash = Marshal.load(o) + else + hash['data'] = o.read + end + + # Raise errors, Perforce or Exec + if(opts[:raise]) + p4_err = "P4: " + hash['data'] if(hash['code'] == 'error') + raise Puppet::DevError, "#{p4_err}\n#{e.read}\nExit: #{t.value}" if(t.value != 0) + end + end + + notice "hash: #{hash}\n" + return hash + end + end diff --git a/spec/unit/puppet/provider/vcsrepo/p4_spec.rb b/spec/unit/puppet/provider/vcsrepo/p4_spec.rb index 822106d..2c202f2 100644 --- a/spec/unit/puppet/provider/vcsrepo/p4_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/p4_spec.rb @@ -15,7 +15,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:p4) do Puppet::Util.stubs(:which).with('p4').returns('/usr/local/bin/p4') end - spec = { + spec = { :input => "Root: /tmp/vcsrepo\nDescription: Generated by Puppet VCSrepo\n\nView:\n", :marshal => false } @@ -46,17 +46,17 @@ describe Puppet::Type.type(:vcsrepo).provider(:p4) do context "when a client and source are not given" do it "should execute 'p4 client'" do - provider.expects(:p4).with(['client', '-o', "puppet-51f0a4b45dbfc10614df94f0a189c16f"]).returns({}) - provider.expects(:p4).with(['client', '-i'], spec) - provider.create + provider.expects(:p4).with(['client', '-o', "puppet-51f0a4b45dbfc10614df94f0a189c16f"]).returns({}) + provider.expects(:p4).with(['client', '-i'], spec) + provider.create end end end describe 'destroying' do it "it should remove the directory" do - resource[:p4client] = 'test_client' - provider.expects(:p4).with(['client', '-d', '-f', resource.value(:p4client)]) + resource[:p4client] = 'test_client' + provider.expects(:p4).with(['client', '-d', '-f', resource.value(:p4client)]) expects_rm_rf provider.destroy end -- cgit v1.2.3 From ac4e14770fc04db02be2f48f6de675e90e3f6b29 Mon Sep 17 00:00:00 2001 From: Paul Allen Date: Fri, 20 Jun 2014 11:45:58 +0100 Subject: Moved p4.markdown content to project's markdown --- README.P4.markdown | 91 ----------------------------------------------------- README.markdown | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 91 deletions(-) delete mode 100644 README.P4.markdown diff --git a/README.P4.markdown b/README.P4.markdown deleted file mode 100644 index f92f616..0000000 --- a/README.P4.markdown +++ /dev/null @@ -1,91 +0,0 @@ -Using vcsrepo with Perforce -=========================== - -To create an empty Workspace ----------------------------- - -Define a `vcsrepo` without a `source` or `revision`: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => p4 - } - -If no `p4client` name is provided a workspace generated name is calculated based on the -Digest of path. For example: - - puppet-91bc00640c4e5a17787286acbe2c021c - -Providing a `p4client` name will create/update the client workspace in Perforce. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => p4 - p4client => "my_client_ws" - } - -To create/update and sync a Perforce workspace ----------------------------------------------- - -To sync a depot path to head (latest): - - vcsrepo { "/path/to/repo": - ensure => present, - provider => p4, - source => '//depot/branch/...' - } - -For a specific changelist, use `revision`: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => p4, - source => '//depot/branch/...', - revision => '2341' - } - -You can also set `revision` to a label: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => p4, - source => '//depot/branch/...', - revision => 'my_label' - } - -Check out as a user by setting `p4user`: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => p4, - source => '//depot/branch/...', - p4user => 'user' - } - -You can set `p4port` to specify a Perforce server: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => p4, - source => '//depot/branch/...', - p4port => 'ssl:perforce.com:1666' - } - -You can set `p4passwd` for authentication : - - vcsrepo { "/path/to/repo": - ensure => present, - provider => p4, - source => '//depot/branch/...', - p4port => 'ssl:perforce.com:1666' - } - -If `p4port`, `p4user`, `p4charset`, `p4passwd` or `p4client` are specified they will -override the environment variabels P4PORT, P4USER, etc... If a P4CONFIG file is -defined, the config file settings will take precedence. - - -More Examples -------------- - -For examples you can run, see `examples/p4/` diff --git a/README.markdown b/README.markdown index 39cd249..6dc36d2 100644 --- a/README.markdown +++ b/README.markdown @@ -13,6 +13,7 @@ * [CVS](#cvs) * [Git](#git) * [Mercurial](#mercurial) + * [Perforce](#perforce) * [Subversion](#subversion) 5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) * [Type: vcsrepo](#type-vcsrepo) @@ -57,6 +58,7 @@ The vcsrepo module works with the following VCSs: * [CVS (cvs)](#cvs) * [Git (git)](#git) * [Mercurial (hg)](#mercurial) +* [Perforce (p4)](#perforce) * [Subversion (svn)](#subversion) ###Bazaar @@ -314,6 +316,96 @@ When your source uses SSH, such as 'ssh://...', you can manage your SSH keys wit For more examples using Mercurial, see `examples/hg/`. +###Perforce + +#####To create an empty Workspace + +To create an empty Workspace, define a `vcsrepo` without a `source` or `revision`. The +Environment variables P4PORT, P4USER, etc... are used to define the Perforce server +connection settings. + + vcsrepo { "/path/to/repo": + ensure => present, + provider => p4 + } + +If no `p4client` name is provided a workspace generated name is calculated based on the +Digest of path. For example: + + puppet-91bc00640c4e5a17787286acbe2c021c + +Providing a `p4client` name will create/update the client workspace in Perforce. The +value replaces the P4CLIENT environment variable. + + vcsrepo { "/path/to/repo": + ensure => present, + provider => p4 + p4client => "my_client_ws" + } + +#####To create/update and sync a Perforce workspace + +To sync a depot path to head (latest): + + vcsrepo { "/path/to/repo": + ensure => present, + provider => p4, + source => '//depot/branch/...' + } + +For a specific changelist, use `revision`: + + vcsrepo { "/path/to/repo": + ensure => present, + provider => p4, + source => '//depot/branch/...', + revision => '2341' + } + +You can also set `revision` to a label: + + vcsrepo { "/path/to/repo": + ensure => present, + provider => p4, + source => '//depot/branch/...', + revision => 'my_label' + } + +Check out as a user by setting `p4user`: + + vcsrepo { "/path/to/repo": + ensure => present, + provider => p4, + source => '//depot/branch/...', + p4user => 'user' + } + +You can set `p4port` to specify a Perforce server: + + vcsrepo { "/path/to/repo": + ensure => present, + provider => p4, + source => '//depot/branch/...', + p4port => 'ssl:perforce.com:1666' + } + +You can set `p4passwd` for authentication : + + vcsrepo { "/path/to/repo": + ensure => present, + provider => p4, + source => '//depot/branch/...', + p4port => 'ssl:perforce.com:1666' + } + +If `p4port`, `p4user`, `p4charset`, `p4passwd` or `p4client` are specified they will +override the environment variabels P4PORT, P4USER, etc... If a P4CONFIG file is defined, +the config file settings will take precedence. + +#####Further Examples + +For examples you can run, see `examples/p4/` + ###Subversion #####To create a blank repository -- cgit v1.2.3 From 319f9fbe1954fd172da638f3ccd76e58c3ec8c7f Mon Sep 17 00:00:00 2001 From: Paul Allen Date: Mon, 23 Jun 2014 15:51:28 +0100 Subject: Added support for p4config. - Removed p4port, p4client, p4user to keep name space clean. - Changed notify to Puppet.debug - Updated markdown and examples - Updated unit tests --- README.markdown | 45 ++++++------------------ examples/p4/create_client.pp | 5 ++- examples/p4/delete_client.pp | 5 ++- examples/p4/latest_client.pp | 3 +- examples/p4/sync_client.pp | 5 ++- lib/puppet/provider/vcsrepo/p4.rb | 51 +++++++++++++++------------- lib/puppet/type/vcsrepo.rb | 22 ++---------- spec/unit/puppet/provider/vcsrepo/p4_spec.rb | 15 ++++---- 8 files changed, 57 insertions(+), 94 deletions(-) diff --git a/README.markdown b/README.markdown index 6dc36d2..5f8aa9d 100644 --- a/README.markdown +++ b/README.markdown @@ -329,18 +329,19 @@ connection settings. provider => p4 } -If no `p4client` name is provided a workspace generated name is calculated based on the -Digest of path. For example: +If no `P4CLIENT` environment name is provided a workspace generated name is calculated +based on the Digest of path. For example: puppet-91bc00640c4e5a17787286acbe2c021c -Providing a `p4client` name will create/update the client workspace in Perforce. The -value replaces the P4CLIENT environment variable. +A Perforce configuration file can be used by setting the `P4CONFIG` environment or +defining `p4config`. If a configuration is defined, then the environment variable for +`P4CLIENT` is replaced. vcsrepo { "/path/to/repo": ensure => present, - provider => p4 - p4client => "my_client_ws" + provider => p4, + p4config => '.p4config' } #####To create/update and sync a Perforce workspace @@ -371,36 +372,10 @@ You can also set `revision` to a label: revision => 'my_label' } -Check out as a user by setting `p4user`: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => p4, - source => '//depot/branch/...', - p4user => 'user' - } - -You can set `p4port` to specify a Perforce server: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => p4, - source => '//depot/branch/...', - p4port => 'ssl:perforce.com:1666' - } - -You can set `p4passwd` for authentication : - - vcsrepo { "/path/to/repo": - ensure => present, - provider => p4, - source => '//depot/branch/...', - p4port => 'ssl:perforce.com:1666' - } +#####To authenticate against the Perforce server -If `p4port`, `p4user`, `p4charset`, `p4passwd` or `p4client` are specified they will -override the environment variabels P4PORT, P4USER, etc... If a P4CONFIG file is defined, -the config file settings will take precedence. +Either set the environment variables `P4USER` and `P4PASSWD` or use a configuration file. +For secure servers set the `P4PASSWD` with a valid ticket generated using `p4 login -p`. #####Further Examples diff --git a/examples/p4/create_client.pp b/examples/p4/create_client.pp index 94017bc..f491701 100644 --- a/examples/p4/create_client.pp +++ b/examples/p4/create_client.pp @@ -1,5 +1,4 @@ -vcsrepo { "/tmp/vcstest-p4-create_client": +vcsrepo { "/tmp/vcstest/p4_client_root": ensure => present, - provider => p4, - p4client => "puppet-test001" + provider => p4 } \ No newline at end of file diff --git a/examples/p4/delete_client.pp b/examples/p4/delete_client.pp index 20bdd47..239349b 100644 --- a/examples/p4/delete_client.pp +++ b/examples/p4/delete_client.pp @@ -1,5 +1,4 @@ -vcsrepo { "/tmp/vcstest-p4-create_client": +vcsrepo { "/tmp/vcstest/p4_client_root": ensure => absent, - provider => p4, - p4client => "puppet-test001" + provider => p4 } \ No newline at end of file diff --git a/examples/p4/latest_client.pp b/examples/p4/latest_client.pp index 54f9062..9dcd68e 100644 --- a/examples/p4/latest_client.pp +++ b/examples/p4/latest_client.pp @@ -1,6 +1,5 @@ -vcsrepo { "/tmp/vcstest-p4-create_client": +vcsrepo { "/tmp/vcstest/p4_client_root": ensure => latest, provider => p4, - p4client => "puppet-test001", source => "//depot/..." } \ No newline at end of file diff --git a/examples/p4/sync_client.pp b/examples/p4/sync_client.pp index e22f6b0..55dc9dc 100644 --- a/examples/p4/sync_client.pp +++ b/examples/p4/sync_client.pp @@ -1,7 +1,6 @@ -vcsrepo { "/tmp/vcstest-p4-create_client": +vcsrepo { "/tmp/vcstest/p4_client_root": ensure => present, provider => p4, - p4client => "puppet-test001", - source => "//depot/..." + source => "//depot/...", revision => "30" } \ No newline at end of file diff --git a/lib/puppet/provider/vcsrepo/p4.rb b/lib/puppet/provider/vcsrepo/p4.rb index de3bc7a..ec40cf3 100644 --- a/lib/puppet/provider/vcsrepo/p4.rb +++ b/lib/puppet/provider/vcsrepo/p4.rb @@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '..', 'vcsrepo') Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) do desc "Supports Perforce depots" - has_features :filesystem_types, :reference_tracking, :p4_config + has_features :filesystem_types, :reference_tracking, :p4config def create # create or update client @@ -90,7 +90,7 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d # +source+:: Depot path to sync # +revision+:: Perforce change list to sync to (optional) def sync_client(source, revision) - notice "Syncing: #{source}" + Puppet.debug "Syncing: #{source}" args = ['sync'] if revision args.push(source + "@" + revision) @@ -102,12 +102,23 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d # Returns the name of the Perforce client workspace def client_name + p4config = @resource.value(:p4config) + + # default (generated) client name path = @resource.value(:path) - client = @resource.value(:p4client) - if not client - client = "puppet-" + Digest::MD5.hexdigest(path) + default = "puppet-" + Digest::MD5.hexdigest(path) + + # check config for client name + set_client = nil + if p4config && File.file?(p4config) + open(p4config) do |f| + m = f.grep(/^P4CLIENT=/).pop + p = /^P4CLIENT=(.*)$/ + set_client = p.match(m)[1] if m + end end - return client + + return set_client || ENV['P4CLIENT'] || default end # Create (or update) a client workspace spec. @@ -116,7 +127,7 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d # +client+:: Name of client workspace # +path+:: The Root location of the Perforce client workspace def create_client(client, path) - notice "Creating client: #{client}" + Puppet.debug "Creating client: #{client}" hash = parse_client(client) hash['Root'] = path hash['Description'] = "Generated by Puppet VCSrepo" @@ -158,20 +169,14 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d p4(args, {:input => spec, :marshal => false}) end + # Sets Perforce Configuration environment. + # P4CLIENT generated, but overwitten if defined in config. def config - p4port = @resource.value(:p4port) - p4user = @resource.value(:p4user) - p4charset = @resource.value(:p4charset) - p4passwd = @resource.value(:p4passwd) - p4client = @resource.value(:p4client) || client_name - - cfg = Hash.new - cfg.store 'P4USER', p4user if p4user - cfg.store 'P4PORT', p4port if p4port - cfg.store 'P4CHARSET', p4charset if p4charset - cfg.store 'P4PASSWD', p4passwd if p4passwd - cfg.store 'P4CLIENT', p4client if p4client + p4config = @resource.value(:p4config) + cfg = Hash.new + cfg.store 'P4CONFIG', p4config if p4config + cfg.store 'P4CLIENT', client_name return cfg end @@ -187,14 +192,14 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d cmd.push args cmd_str = cmd.respond_to?(:join) ? cmd.join(' ') : cmd - notice "environment: #{config}" - notice "command: #{cmd_str}" + Puppet.debug "environment: #{config}" + Puppet.debug "command: #{cmd_str}" hash = Hash.new Open3.popen3(config, cmd_str) do |i, o, e, t| # Send input stream if provided if(opts[:input]) - notice "input:\n" + opts[:input] + Puppet.debug "input:\n" + opts[:input] i.write opts[:input] i.close end @@ -212,7 +217,7 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d end end - notice "hash: #{hash}\n" + Puppet.debug "hash: #{hash}\n" return hash end diff --git a/lib/puppet/type/vcsrepo.rb b/lib/puppet/type/vcsrepo.rb index 649789a..7ada022 100644 --- a/lib/puppet/type/vcsrepo.rb +++ b/lib/puppet/type/vcsrepo.rb @@ -40,7 +40,7 @@ Puppet::Type.newtype(:vcsrepo) do feature :depth, "The provider can do shallow clones" - feature :p4_config, + feature :p4config, "The provider understands Perforce Configuration" ensurable do @@ -212,26 +212,10 @@ Puppet::Type.newtype(:vcsrepo) do desc "The value to be used to do a shallow clone." end - newparam :p4port, :required_features => [:p4_config] do - desc "The Perforce P4PORT environment." - end - - newparam :p4user, :required_features => [:p4_config] do - desc "The Perforce P4USER environment." - end - - newparam :p4client, :required_features => [:p4_config] do - desc "The Perforce P4CLIENT environment." + newparam :p4config, :required_features => [:p4config] do + desc "The Perforce P4CONFIG environment." end - newparam :p4charset, :required_features => [:p4_config] do - desc "The Perforce P4CHARSET environment." - end - - newparam :p4passwd, :required_features => [:p4_config] do - desc "The Perforce P4PASSWD environment." - end - autorequire(:package) do ['git', 'git-core'] end diff --git a/spec/unit/puppet/provider/vcsrepo/p4_spec.rb b/spec/unit/puppet/provider/vcsrepo/p4_spec.rb index 2c202f2..2bb81c8 100644 --- a/spec/unit/puppet/provider/vcsrepo/p4_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/p4_spec.rb @@ -24,9 +24,10 @@ describe Puppet::Type.type(:vcsrepo).provider(:p4) do context 'with source and revision' do it "should execute 'p4 sync' with the revision" do resource[:source] = 'something' - resource[:p4client] = 'client_ws' resource[:revision] = '1' - provider.expects(:p4).with(['client', '-o', resource.value(:p4client)]).returns({}) + ENV['P4CLIENT'] = 'client_ws1' + + provider.expects(:p4).with(['client', '-o', 'client_ws1']).returns({}) provider.expects(:p4).with(['client', '-i'], spec) provider.expects(:p4).with(['sync', resource.value(:source) + "@" + resource.value(:revision)]) provider.create @@ -36,8 +37,9 @@ describe Puppet::Type.type(:vcsrepo).provider(:p4) do context 'without revision' do it "should just execute 'p4 sync' without a revision" do resource[:source] = 'something' - resource[:p4client] = 'client_ws' - provider.expects(:p4).with(['client', '-o', resource.value(:p4client)]).returns({}) + ENV['P4CLIENT'] = 'client_ws2' + + provider.expects(:p4).with(['client', '-o', 'client_ws2']).returns({}) provider.expects(:p4).with(['client', '-i'], spec) provider.expects(:p4).with(['sync', resource.value(:source)]) provider.create @@ -55,8 +57,9 @@ describe Puppet::Type.type(:vcsrepo).provider(:p4) do describe 'destroying' do it "it should remove the directory" do - resource[:p4client] = 'test_client' - provider.expects(:p4).with(['client', '-d', '-f', resource.value(:p4client)]) + ENV['P4CLIENT'] = 'test_client' + + provider.expects(:p4).with(['client', '-d', '-f', 'test_client']) expects_rm_rf provider.destroy end -- cgit v1.2.3 From 457035ec1c15df0d53abf7232dad63b2722b1720 Mon Sep 17 00:00:00 2001 From: Paul Allen Date: Mon, 23 Jun 2014 16:22:35 +0100 Subject: Add hostname to Digest for default client name. --- README.markdown | 2 +- lib/puppet/provider/vcsrepo/p4.rb | 3 ++- spec/unit/puppet/provider/vcsrepo/p4_spec.rb | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.markdown b/README.markdown index 5f8aa9d..575950c 100644 --- a/README.markdown +++ b/README.markdown @@ -330,7 +330,7 @@ connection settings. } If no `P4CLIENT` environment name is provided a workspace generated name is calculated -based on the Digest of path. For example: +based on the Digest of path and hostname. For example: puppet-91bc00640c4e5a17787286acbe2c021c diff --git a/lib/puppet/provider/vcsrepo/p4.rb b/lib/puppet/provider/vcsrepo/p4.rb index ec40cf3..612cc56 100644 --- a/lib/puppet/provider/vcsrepo/p4.rb +++ b/lib/puppet/provider/vcsrepo/p4.rb @@ -106,7 +106,8 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d # default (generated) client name path = @resource.value(:path) - default = "puppet-" + Digest::MD5.hexdigest(path) + host = Facter.value('hostname') + default = "puppet-" + Digest::MD5.hexdigest(path + host) # check config for client name set_client = nil diff --git a/spec/unit/puppet/provider/vcsrepo/p4_spec.rb b/spec/unit/puppet/provider/vcsrepo/p4_spec.rb index 2bb81c8..e45650a 100644 --- a/spec/unit/puppet/provider/vcsrepo/p4_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/p4_spec.rb @@ -48,7 +48,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:p4) do context "when a client and source are not given" do it "should execute 'p4 client'" do - provider.expects(:p4).with(['client', '-o', "puppet-51f0a4b45dbfc10614df94f0a189c16f"]).returns({}) + provider.expects(:p4).with(['client', '-o', "puppet-1c5e7a8e4f702e5091dfba173bc0e7c0"]).returns({}) provider.expects(:p4).with(['client', '-i'], spec) provider.create end -- cgit v1.2.3 From 2ff03cff1795d3e43c922f7bceb235ce69175013 Mon Sep 17 00:00:00 2001 From: Stuart Whelan Date: Sat, 21 Jun 2014 17:26:14 +1200 Subject: Added support for basic authentication to hg provider Updated unit tests Updated hg readme and added examples --- README.markdown | 12 +++++++++++- examples/hg/clone_basic_auth.pp | 7 +++++++ lib/puppet/provider/vcsrepo/hg.rb | 12 +++++++++++- spec/unit/puppet/provider/vcsrepo/hg_spec.rb | 16 ++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 examples/hg/clone_basic_auth.pp diff --git a/README.markdown b/README.markdown index 39cd249..99c5ac9 100644 --- a/README.markdown +++ b/README.markdown @@ -306,6 +306,16 @@ To specify an SSH identity key, identity => "/home/user/.ssh/id_dsa, } +To specify a username and password for HTTP Basic authentication, + + vcsrepo { "/path/to/repo": + ensure => latest, + provider => hg, + source => 'http://hg.example.com/myrepo', + basic_auth_username => 'hgusername', + basic_auth_password => 'hgpassword', + } + #####Sources that use SSH When your source uses SSH, such as 'ssh://...', you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present. @@ -470,4 +480,4 @@ Puppet Labs modules on the Puppet Forge are open projects, and community contrib We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. -You can read the complete module contribution guide on the Puppet Labs wiki. \ No newline at end of file +You can read the complete module contribution guide on the Puppet Labs wiki. diff --git a/examples/hg/clone_basic_auth.pp b/examples/hg/clone_basic_auth.pp new file mode 100644 index 0000000..1931e1f --- /dev/null +++ b/examples/hg/clone_basic_auth.pp @@ -0,0 +1,7 @@ +vcsrepo { '/path/to/repo': + ensure => latest, + provider => hg, + source => 'http://hg.example.com/myrepo', + basic_auth_username => 'hgusername', + basic_auth_password => 'hgpassword', +} diff --git a/lib/puppet/provider/vcsrepo/hg.rb b/lib/puppet/provider/vcsrepo/hg.rb index 56ca527..090f019 100644 --- a/lib/puppet/provider/vcsrepo/hg.rb +++ b/lib/puppet/provider/vcsrepo/hg.rb @@ -6,7 +6,7 @@ Puppet::Type.type(:vcsrepo).provide(:hg, :parent => Puppet::Provider::Vcsrepo) d commands :hg => 'hg' optional_commands :su => 'su' - has_features :reference_tracking, :ssh_identity, :user + has_features :reference_tracking, :ssh_identity, :user, :basic_auth def create if !@resource.value(:source) @@ -108,6 +108,16 @@ Puppet::Type.type(:vcsrepo).provide(:hg, :parent => Puppet::Provider::Vcsrepo) d if args.length > 0 and args[-1].is_a? Hash options.merge!(args.pop) end + + if @resource.value(:basic_auth_username) && @resource.value(:basic_auth_password) + args += [ + "--config", "\"auth.x.prefix=#{@resource.value(:source)}\"", + "--config", "\"auth.x.username=#{@resource.value(:basic_auth_username)}\"", + "--config", "\"auth.x.password=#{@resource.value(:basic_auth_password)}\"", + "--config", "\"auth.x.schemes=http https\"" + ] + end + if options[:remote] and @resource.value(:identity) args += ["--ssh", "ssh -oStrictHostKeyChecking=no -oPasswordAuthentication=no -oKbdInteractiveAuthentication=no -oChallengeResponseAuthentication=no -i #{@resource.value(:identity)}"] end diff --git a/spec/unit/puppet/provider/vcsrepo/hg_spec.rb b/spec/unit/puppet/provider/vcsrepo/hg_spec.rb index 7fd5348..6b21c1c 100644 --- a/spec/unit/puppet/provider/vcsrepo/hg_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/hg_spec.rb @@ -42,6 +42,22 @@ describe Puppet::Type.type(:vcsrepo).provider(:hg) do provider.create end end + + context "when basic auth is used" do + it "should execute 'hg clone'" do + resource[:source] = 'something' + resource[:basic_auth_username] = 'user' + resource[:basic_auth_password] = 'pass' + provider.expects(:hg).with('clone', + resource.value(:source), + resource.value(:path), + "--config","\"auth.x.prefix=" + resource.value(:source) + "\"", + "--config","\"auth.x.username=" + resource.value(:basic_auth_username) + "\"", + "--config","\"auth.x.password=" + resource.value(:basic_auth_password) + "\"", + "--config","\"auth.x.schemes=http https" + "\"") + provider.create + end + end end describe 'destroying' do -- cgit v1.2.3 From e1aa644dd075c275dd22d85cdc03c88dda029d87 Mon Sep 17 00:00:00 2001 From: Paul Allen Date: Tue, 24 Jun 2014 13:57:30 +0100 Subject: Support streams and fix Marshal for 'p4 cstat' --- README.markdown | 6 ++-- lib/puppet/provider/vcsrepo/p4.rb | 76 ++++++++++++++++++++++++++++++++------- 2 files changed, 67 insertions(+), 15 deletions(-) diff --git a/README.markdown b/README.markdown index 575950c..d977886 100644 --- a/README.markdown +++ b/README.markdown @@ -346,15 +346,15 @@ defining `p4config`. If a configuration is defined, then the environment variab #####To create/update and sync a Perforce workspace -To sync a depot path to head (latest): +To sync a depot path to head, ensure `latest`: vcsrepo { "/path/to/repo": - ensure => present, + ensure => latest, provider => p4, source => '//depot/branch/...' } -For a specific changelist, use `revision`: +For a specific changelist, ensure `present` and specify a `revision`: vcsrepo { "/path/to/repo": ensure => present, diff --git a/lib/puppet/provider/vcsrepo/p4.rb b/lib/puppet/provider/vcsrepo/p4.rb index 612cc56..da9c953 100644 --- a/lib/puppet/provider/vcsrepo/p4.rb +++ b/lib/puppet/provider/vcsrepo/p4.rb @@ -7,7 +7,7 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d def create # create or update client - create_client(client_name, @resource.value(:path)) + create_client(client_name) # if source provided, sync client source = @resource.value(:source) @@ -63,13 +63,19 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d def revision args = ['cstat'] args.push(@resource.value(:source)) - hash = p4(args) + hash = p4(args, {:marshal => false}) + hash = marshal_cstat(hash) - if hash['status'] == "have" - return hash['change'].to_i - else - return 0 + revision = 0 + if hash && hash['code'] != 'error' + hash['data'].each do |c| + if c['status'] == 'have' + change = c['change'].to_i + revision = change if change > revision + end + end end + return revision end def revision=(desired) @@ -93,7 +99,7 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d Puppet.debug "Syncing: #{source}" args = ['sync'] if revision - args.push(source + "@" + revision) + args.push(source + "@#{revision}") else args.push(source) end @@ -127,11 +133,29 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d # Params: # +client+:: Name of client workspace # +path+:: The Root location of the Perforce client workspace - def create_client(client, path) + def create_client(client) Puppet.debug "Creating client: #{client}" + + # fetch client spec hash = parse_client(client) - hash['Root'] = path + hash['Root'] = @resource.value(:path) hash['Description'] = "Generated by Puppet VCSrepo" + + # check is source is a Stream + source = @resource.value(:source) + if source + parts = source.split(/\//) + if parts && parts.length >= 4 + source = "//" + parts[2] + "/" + parts[3] + streams = p4(['streams', source], {:raise => false}) + if streams['code'] == "stat" + hash['Stream'] = streams['Stream'] + notice "Streams" + streams['Stream'].inspect + end + end + end + + # save client spec save_client(hash) end @@ -212,9 +236,11 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d end # Raise errors, Perforce or Exec - if(opts[:raise]) - p4_err = "P4: " + hash['data'] if(hash['code'] == 'error') - raise Puppet::DevError, "#{p4_err}\n#{e.read}\nExit: #{t.value}" if(t.value != 0) + if(opts[:raise] && !e.eof && t.value != 0) + raise Puppet::Error, "\nP4: #{e.read}" + end + if(opts[:raise] && hash['code'] == 'error' && t.value != 0) + raise Puppet::Error, "\nP4: #{hash['data']}" end end @@ -222,4 +248,30 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d return hash end + # helper method as cstat does not Marshal + def marshal_cstat(hash) + data = hash['data'] + code = 'error' + + list = Array.new + change = Hash.new + data.each_line do |l| + p = /^\.\.\. (.*) (.*)$/ + m = p.match(l) + if m + change[m[1]] = m[2] + if m[1] == 'status' + code = 'stat' + list.push change + change = Hash.new + end + end + end + + hash = Hash.new + hash.store 'code', code + hash.store 'data', list + return hash + end + end -- cgit v1.2.3 From f88ae5fd6c746de3b454e38a8616f016ada8cff9 Mon Sep 17 00:00:00 2001 From: Paul Allen Date: Tue, 24 Jun 2014 14:16:05 +0100 Subject: Sort keys on hash generate same test result. Keys in the Client spec were processed out of order and failing tests. --- lib/puppet/provider/vcsrepo/p4.rb | 3 ++- spec/unit/puppet/provider/vcsrepo/p4_spec.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/puppet/provider/vcsrepo/p4.rb b/lib/puppet/provider/vcsrepo/p4.rb index da9c953..4f53415 100644 --- a/lib/puppet/provider/vcsrepo/p4.rb +++ b/lib/puppet/provider/vcsrepo/p4.rb @@ -179,7 +179,8 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d spec = String.new view = "\nView:\n" - hash.each do |k,v| + hash.keys.sort.each do |k| + v = hash[k] next if( k == "code" ) if(k.to_s =~ /View/ ) view += "\t#{v}\n" diff --git a/spec/unit/puppet/provider/vcsrepo/p4_spec.rb b/spec/unit/puppet/provider/vcsrepo/p4_spec.rb index e45650a..1261915 100644 --- a/spec/unit/puppet/provider/vcsrepo/p4_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/p4_spec.rb @@ -16,7 +16,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:p4) do end spec = { - :input => "Root: /tmp/vcsrepo\nDescription: Generated by Puppet VCSrepo\n\nView:\n", + :input => "Description: Generated by Puppet VCSrepo\nRoot: /tmp/vcsrepo\n\nView:\n", :marshal => false } -- cgit v1.2.3 From a73df3732f942d010dc7b289804bb6d8a6f13a37 Mon Sep 17 00:00:00 2001 From: Lauren Rother Date: Wed, 25 Jun 2014 10:39:37 -0700 Subject: Add supported information and reorder to highlight support Include notice that Git is the only supported provider and reorder README so Git is the first VCS addressed. --- README.markdown | 197 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 101 insertions(+), 96 deletions(-) diff --git a/README.markdown b/README.markdown index 39cd249..93b23d2 100644 --- a/README.markdown +++ b/README.markdown @@ -53,12 +53,104 @@ To get started with the vcsrepo module, you must simply define the type `vcsrepo The vcsrepo module works with the following VCSs: +* [Git (git)](#git)* * [Bazaar (bzr)](#bazaar) * [CVS (cvs)](#cvs) -* [Git (git)](#git) * [Mercurial (hg)](#mercurial) * [Subversion (svn)](#subversion) +**Note:* Git is the only VCS provider officially [supported](https://forge.puppetlabs.com/supported) by Puppet Labs. + + +###Git + +#####To create a blank repository + +To create a blank repository suitable for use as a central repository, +define `vcsrepo` without `source` or `revision`. + + vcsrepo { "/path/to/repo": + ensure => present, + provider => git, + } + +If you're defining `vcsrepo` for a central or official repository, you may want to make it a bare repository. You do this by setting `ensure` to 'bare' rather than 'present'. + + vcsrepo { "/path/to/repo": + ensure => bare, + provider => git, + } + +#####To clone/pull a repository + +To get the current HEAD on the master branch, + + vcsrepo { "/path/to/repo": + ensure => present, + provider => git, + source => "git://example.com/repo.git", + } + +To get a specific revision or branch (can be a commit SHA, tag, or branch name), + + **SHA** + + vcsrepo { "/path/to/repo": + ensure => present, + provider => git, + source => 'git://example.com/repo.git', + revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31', + } + +**Tag** + + vcsrepo { "/path/to/repo": + ensure => present, + provider => git, + source => 'git://example.com/repo.git', + revision => '1.1.2rc1', + } + +**Branch name** + + vcsrepo { "/path/to/repo": + ensure => present, + provider => git, + source => 'git://example.com/repo.git', + revision => 'development', + } + +To check out a branch as a specific user, + + vcsrepo { "/path/to/repo": + ensure => present, + provider => git, + source => 'git://example.com/repo.git', + revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31', + user => 'someUser', + } + +To keep the repository at the latest revision (**WARNING:** this will always overwrite local changes to the repository), + + vcsrepo { "/path/to/repo": + ensure => latest, + provider => git, + source => 'git://example.com/repo.git', + revision => 'master', + } + +#####Sources that use SSH + +When your source uses SSH, such as 'username@server:…', you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present. + +For SSH keys associated with a user, enter the username in the `user` parameter. Doing so will use that user's keys. + + user => 'toto' # will use toto's $HOME/.ssh setup + +#####Further Examples + +For more examples using Git, see `examples/git/`. + ###Bazaar #####Create a blank repository @@ -159,95 +251,6 @@ When your source uses SSH, you can manage your SSH keys with Puppet using the [r For for more examples using CVS, see `examples/cvs/`. -###Git - -#####To create a blank repository - -To create a blank repository suitable for use as a central repository, -define `vcsrepo` without `source` or `revision`. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - } - -If you're defining `vcsrepo` for a central or official repository, you may want to make it a bare repository. You do this by setting `ensure` to 'bare' rather than 'present'. - - vcsrepo { "/path/to/repo": - ensure => bare, - provider => git, - } - -#####To clone/pull a repository - -To get the current HEAD on the master branch, - - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - source => "git://example.com/repo.git", - } - -To get a specific revision or branch (can be a commit SHA, tag, or branch name), - - **SHA** - - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - source => 'git://example.com/repo.git', - revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31', - } - -**Tag** - - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - source => 'git://example.com/repo.git', - revision => '1.1.2rc1', - } - -**Branch name** - - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - source => 'git://example.com/repo.git', - revision => 'development', - } - -To check out a branch as a specific user, - - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - source => 'git://example.com/repo.git', - revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31', - user => 'someUser', - } - -To keep the repository at the latest revision (**WARNING:** this will always overwrite local changes to the repository), - - vcsrepo { "/path/to/repo": - ensure => latest, - provider => git, - source => 'git://example.com/repo.git', - revision => 'master', - } - -#####Sources that use SSH - -When your source uses SSH, such as 'username@server:…', you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present. - -For SSH keys associated with a user, enter the username in the `user` parameter. Doing so will use that user's keys. - - user => 'toto' # will use toto's $HOME/.ssh setup - -#####Further Examples - -For more examples using Git, see `examples/git/`. - ###Mercurial #####To create a blank repository @@ -374,10 +377,10 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers **Note**: Not all features are available with all providers. +* `git` - Supports the Git VCS. (Contains features: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`.) * `bar` - Supports the Bazaar VCS. (Contains features: `reference_tracking`.) * `cvs` - Supports the CVS VCS. (Contains features: `cvs_rsh`, `gzip_compression`, `modules`,`reference_tracking`.) * `dummy` - -* `git` - Supports the Git VCS. (Contains features: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`.) * `hg` - Supports the Mercurial VCS. (Contains features: `reference_tracking`, `ssh_identity`, `user`.) * `svn` - Supports the Subversion VCS. (Contains features: `basic_auth`, `configuration`, `filesystem_types`, `reference_tracking`.) @@ -423,6 +426,11 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers ####Features and Parameters by Provider +#####`git` +**Features**: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user` + +**Parameters**: `depth`, `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `remote`, `revision`, `source`, `user` + #####`bzr` **Features**: `reference_tracking` @@ -433,11 +441,6 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers **Parameters**: `compression`, `cvs_rsh`, `ensure`, `excludes`, `force`, `group`, `module`, `owner`, `path`, `provider`, `revision`, `source`, `user` -#####`git` -**Features**: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user` - -**Parameters**: `depth`, `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `remote`, `revision`, `source`, `user` - #####`hg` **Features**: `reference_tracking`, `ssh_identity`, `user` @@ -450,6 +453,8 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers ##Limitations +Git is the only VCS provider officially [supported](https://forge.puppetlabs.com/supported) by Puppet Labs. + This module has been built on and tested against Puppet 2.7 and higher. The module has been tested on: -- cgit v1.2.3 From 85770ad9e9b093113d98f3a35ec45d6ac28f3042 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Wed, 25 Jun 2014 16:03:59 -0700 Subject: Add configuration file for modulesync https://github.com/puppetlabs/modulesync --- .sync.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .sync.yml diff --git a/.sync.yml b/.sync.yml new file mode 100644 index 0000000..dd55f49 --- /dev/null +++ b/.sync.yml @@ -0,0 +1,22 @@ +--- +.travis.yml: + env_matrix: + - PUPPET_GEM_VERSION="~> 2.7.0" + - PUPPET_GEM_VERSION="~> 3.3.0" + additional: + - + configs: + after_success: + - git clone -q git://github.com/puppetlabs/ghpublisher.git .forge-release + - .forge-release/publish + - + configs: + before_install: + - gem update --system 2.1.11 + - gem --version + comments: + - Temporary workaround for broken Rubygems on Travis +Rakefile: + unmanaged: true +spec/spec_helper.rb: + unmanaged: true -- cgit v1.2.3 From 42abb2a599e9c863ab890ef7d8d43db1acdfe84d Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Wed, 25 Jun 2014 18:01:00 -0700 Subject: Sync files --- .gitignore | 16 +- .travis.yml | 34 ++- CONTRIBUTING.md | 234 +++++++++++++++++++++ Gemfile | 6 +- spec/acceptance/nodesets/centos-59-x64.yml | 10 + spec/acceptance/nodesets/centos-64-x64-pe.yml | 12 ++ spec/acceptance/nodesets/centos-65-x64.yml | 10 + .../acceptance/nodesets/ubuntu-server-1404-x64.yml | 11 + 8 files changed, 302 insertions(+), 31 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 spec/acceptance/nodesets/centos-59-x64.yml create mode 100644 spec/acceptance/nodesets/centos-64-x64-pe.yml create mode 100644 spec/acceptance/nodesets/centos-65-x64.yml create mode 100644 spec/acceptance/nodesets/ubuntu-server-1404-x64.yml diff --git a/.gitignore b/.gitignore index b5fe773..b5b7a00 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,7 @@ -coverage -.DS_Store -.#* -\#* +pkg/ Gemfile.lock -log -.vagrant - -#Intellij -.idea -*.iml +vendor/ +spec/fixtures/ +.vagrant/ +.bundle/ +coverage/ diff --git a/.travis.yml b/.travis.yml index ed1b75c..ef2a36e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,35 +1,33 @@ +--- branches: only: - master language: ruby bundler_args: --without development script: "bundle exec rake spec SPEC_OPTS='--format documentation'" -after_success: - - git clone -q git://github.com/puppetlabs/ghpublisher.git .forge-release - - .forge-release/publish rvm: - 1.8.7 - 1.9.3 - 2.0.0 env: matrix: - - PUPPET_GEM_VERSION="~> 2.7.0" - - PUPPET_GEM_VERSION="~> 3.3.0" - global: - - PUBLISHER_LOGIN=puppetlabs - - secure: |- - ZiIkYd9+CdPzpwSjFPnVkCx1FIlipxpbdyD33q94h2Tj5zXjNb1GXizVy0NR - kVxGhU5Ld8y9z8DTqKRgCI1Yymg3H//OU++PKLOQj/X5juWVR4URBNPeBOzu - IJBDl1MADKA4i1+jAZPpz4mTvTtKS4pWKErgCSmhSfsY1hs7n6c= + - PUPPET_GEM_VERSION="~> 2.7.0" + - PUPPET_GEM_VERSION="~> 3.3.0" matrix: + fast_finish: true exclude: - - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 2.7.0" - - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 2.7.0" + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 2.7.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 2.7.0" notifications: email: false -# Temporary workaround for broken Rubygems on Travis +after_success: +- git clone -q git://github.com/puppetlabs/ghpublisher.git .forge-release +- .forge-release/publish before_install: - - gem update --system 2.1.11 - - gem --version +- gem update --system 2.1.11 +- gem --version +comments: +- Temporary workaround for broken Rubygems on Travis + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..e128847 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,234 @@ +Checklist (and a short version for the impatient) +================================================= + + * Commits: + + - Make commits of logical units. + + - Check for unnecessary whitespace with "git diff --check" before + committing. + + - Commit using Unix line endings (check the settings around "crlf" in + git-config(1)). + + - Do not check in commented out code or unneeded files. + + - The first line of the commit message should be a short + description (50 characters is the soft limit, excluding ticket + number(s)), and should skip the full stop. + + - Associate the issue in the message. The first line should include + the issue number in the form "(#XXXX) Rest of message". + + - The body should provide a meaningful commit message, which: + + - uses the imperative, present tense: "change", not "changed" or + "changes". + + - includes motivation for the change, and contrasts its + implementation with the previous behavior. + + - Make sure that you have tests for the bug you are fixing, or + feature you are adding. + + - Make sure the test suites passes after your commit: + `bundle exec rspec spec/acceptance` More information on [testing](#Testing) below + + - When introducing a new feature, make sure it is properly + documented in the README.md + + * Submission: + + * Pre-requisites: + + - Sign the [Contributor License Agreement](https://cla.puppetlabs.com/) + + - Make sure you have a [GitHub account](https://github.com/join) + + - [Create a ticket](http://projects.puppetlabs.com/projects/modules/issues/new), or [watch the ticket](http://projects.puppetlabs.com/projects/modules/issues) you are patching for. + + * Preferred method: + + - Fork the repository on GitHub. + + - Push your changes to a topic branch in your fork of the + repository. (the format ticket/1234-short_description_of_change is + usually preferred for this project). + + - Submit a pull request to the repository in the puppetlabs + organization. + +The long version +================ + + 1. Make separate commits for logically separate changes. + + Please break your commits down into logically consistent units + which include new or changed tests relevant to the rest of the + change. The goal of doing this is to make the diff easier to + read for whoever is reviewing your code. In general, the easier + your diff is to read, the more likely someone will be happy to + review it and get it into the code base. + + If you are going to refactor a piece of code, please do so as a + separate commit from your feature or bug fix changes. + + We also really appreciate changes that include tests to make + sure the bug is not re-introduced, and that the feature is not + accidentally broken. + + Describe the technical detail of the change(s). If your + description starts to get too long, that is a good sign that you + probably need to split up your commit into more finely grained + pieces. + + Commits which plainly describe the things which help + reviewers check the patch and future developers understand the + code are much more likely to be merged in with a minimum of + bike-shedding or requested changes. Ideally, the commit message + would include information, and be in a form suitable for + inclusion in the release notes for the version of Puppet that + includes them. + + Please also check that you are not introducing any trailing + whitespace or other "whitespace errors". You can do this by + running "git diff --check" on your changes before you commit. + + 2. Sign the Contributor License Agreement + + Before we can accept your changes, we do need a signed Puppet + Labs Contributor License Agreement (CLA). + + You can access the CLA via the [Contributor License Agreement link](https://cla.puppetlabs.com/) + + If you have any questions about the CLA, please feel free to + contact Puppet Labs via email at cla-submissions@puppetlabs.com. + + 3. Sending your patches + + To submit your changes via a GitHub pull request, we _highly_ + recommend that you have them on a topic branch, instead of + directly on "master". + It makes things much easier to keep track of, especially if + you decide to work on another thing before your first change + is merged in. + + GitHub has some pretty good + [general documentation](http://help.github.com/) on using + their site. They also have documentation on + [creating pull requests](http://help.github.com/send-pull-requests/). + + In general, after pushing your topic branch up to your + repository on GitHub, you can switch to the branch in the + GitHub UI and click "Pull Request" towards the top of the page + in order to open a pull request. + + + 4. Update the related GitHub issue. + + If there is a GitHub issue associated with the change you + submitted, then you should update the ticket to include the + location of your branch, along with any other commentary you + may wish to make. + +Testing +======= + +Getting Started +--------------- + +Our puppet modules provide [`Gemfile`](./Gemfile)s which can tell a ruby +package manager such as [bundler](http://bundler.io/) what Ruby packages, +or Gems, are required to build, develop, and test this software. + +Please make sure you have [bundler installed](http://bundler.io/#getting-started) +on your system, then use it to install all dependencies needed for this project, +by running + +```shell +% bundle install +Fetching gem metadata from https://rubygems.org/........ +Fetching gem metadata from https://rubygems.org/.. +Using rake (10.1.0) +Using builder (3.2.2) +-- 8><-- many more --><8 -- +Using rspec-system-puppet (2.2.0) +Using serverspec (0.6.3) +Using rspec-system-serverspec (1.0.0) +Using bundler (1.3.5) +Your bundle is complete! +Use `bundle show [gemname]` to see where a bundled gem is installed. +``` + +NOTE some systems may require you to run this command with sudo. + +If you already have those gems installed, make sure they are up-to-date: + +```shell +% bundle update +``` + +With all dependencies in place and up-to-date we can now run the tests: + +```shell +% rake spec +``` + +This will execute all the [rspec tests](http://rspec-puppet.com/) tests +under [spec/defines](./spec/defines), [spec/classes](./spec/classes), +and so on. rspec tests may have the same kind of dependencies as the +module they are testing. While the module defines in its [Modulefile](./Modulefile), +rspec tests define them in [.fixtures.yml](./fixtures.yml). + +Some puppet modules also come with [beaker](https://github.com/puppetlabs/beaker) +tests. These tests spin up a virtual machine under +[VirtualBox](https://www.virtualbox.org/)) with, controlling it with +[Vagrant](http://www.vagrantup.com/) to actually simulate scripted test +scenarios. In order to run these, you will need both of those tools +installed on your system. + +You can run them by issuing the following command + +```shell +% rake spec_clean +% rspec spec/acceptance +``` + +This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml), +install puppet, copy this module and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb) +and then run all the tests under [spec/acceptance](./spec/acceptance). + +Writing Tests +------------- + +XXX getting started writing tests. + +If you have commit access to the repository +=========================================== + +Even if you have commit access to the repository, you will still need to +go through the process above, and have someone else review and merge +in your changes. The rule is that all changes must be reviewed by a +developer on the project (that did not write the code) to ensure that +all changes go through a code review process. + +Having someone other than the author of the topic branch recorded as +performing the merge is the record that they performed the code +review. + + +Additional Resources +==================== + +* [Getting additional help](http://projects.puppetlabs.com/projects/puppet/wiki/Getting_Help) + +* [Writing tests](http://projects.puppetlabs.com/projects/puppet/wiki/Development_Writing_Tests) + +* [Patchwork](https://patchwork.puppetlabs.com) + +* [Contributor License Agreement](https://projects.puppetlabs.com/contributor_licenses/sign) + +* [General GitHub documentation](http://help.github.com/) + +* [GitHub pull request documentation](http://help.github.com/send-pull-requests/) + diff --git a/Gemfile b/Gemfile index 0120ece..9074f1e 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ -source 'https://rubygems.org' +source ENV['GEM_SOURCE'] || "https://rubygems.org" group :development, :test do gem 'rake', :require => false @@ -6,9 +6,9 @@ group :development, :test do gem 'puppetlabs_spec_helper', :require => false gem 'serverspec', :require => false gem 'puppet-lint', :require => false + gem 'beaker', :require => false + gem 'beaker-rspec', :require => false gem 'pry', :require => false - gem 'beaker-rspec', '~>2.2', :require => false - gem 'rspec', '~>2.14', :require => false gem 'simplecov', :require => false end diff --git a/spec/acceptance/nodesets/centos-59-x64.yml b/spec/acceptance/nodesets/centos-59-x64.yml new file mode 100644 index 0000000..2ad90b8 --- /dev/null +++ b/spec/acceptance/nodesets/centos-59-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-59-x64: + roles: + - master + platform: el-5-x86_64 + box : centos-59-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-59-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: git diff --git a/spec/acceptance/nodesets/centos-64-x64-pe.yml b/spec/acceptance/nodesets/centos-64-x64-pe.yml new file mode 100644 index 0000000..7d9242f --- /dev/null +++ b/spec/acceptance/nodesets/centos-64-x64-pe.yml @@ -0,0 +1,12 @@ +HOSTS: + centos-64-x64: + roles: + - master + - database + - dashboard + platform: el-6-x86_64 + box : centos-64-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: pe diff --git a/spec/acceptance/nodesets/centos-65-x64.yml b/spec/acceptance/nodesets/centos-65-x64.yml new file mode 100644 index 0000000..4e2cb80 --- /dev/null +++ b/spec/acceptance/nodesets/centos-65-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-65-x64: + roles: + - master + platform: el-6-x86_64 + box : centos-65-x64-vbox436-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml b/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml new file mode 100644 index 0000000..cba1cd0 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + ubuntu-server-1404-x64: + roles: + - master + platform: ubuntu-14.04-amd64 + box : puppetlabs/ubuntu-14.04-64-nocm + box_url : https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm + hypervisor : vagrant +CONFIG: + log_level : debug + type: git -- cgit v1.2.3 From 818f5298b6be3b1a25e997ba84eae237d9051be9 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 20 Jun 2014 13:48:02 -0700 Subject: Update noop to work --- lib/puppet/type/vcsrepo.rb | 14 ++-------- spec/acceptance/clone_repo_spec.rb | 40 ++++++++++++++++++++------- spec/unit/puppet/provider/vcsrepo/git_spec.rb | 22 +++++++++++++++ 3 files changed, 54 insertions(+), 22 deletions(-) diff --git a/lib/puppet/type/vcsrepo.rb b/lib/puppet/type/vcsrepo.rb index 0e4450b..42767ab 100644 --- a/lib/puppet/type/vcsrepo.rb +++ b/lib/puppet/type/vcsrepo.rb @@ -98,9 +98,8 @@ Puppet::Type.newtype(:vcsrepo) do if prov if prov.working_copy_exists? if @resource.value(:force) - if noop? - notice "Noop Mode - Would have deleted repository" - notice "Noop Mode - Would have created repository from latest" + if noop + notice "Noop Mode - Would have deleted repository and re-created from latest" else notice "Deleting current repository before recloning" prov.destroy @@ -212,13 +211,4 @@ Puppet::Type.newtype(:vcsrepo) do autorequire(:package) do ['git', 'git-core'] end - - def noop? - if defined?(@noop) - @noop - else - Puppet[:noop] - end - end - end diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb index a989661..23b0b31 100644 --- a/spec/acceptance/clone_repo_spec.rb +++ b/spec/acceptance/clone_repo_spec.rb @@ -318,6 +318,36 @@ describe 'clones a remote repo' do describe file("#{tmpdir}/testrepo_force/.git") do it { should be_directory } end + + context 'and noop' do + let(:repo_name) do + 'testrepo_already_exists' + end + before(:all) do + shell("mkdir #{tmpdir}/#{repo_name}") + shell("cd #{tmpdir}/#{repo_name} && git init") + shell("cd #{tmpdir}/#{repo_name} && touch a && git add a && git commit -m 'a'") + end + after(:all) do + shell("rm -rf #{tmpdir}/#{repo_name}") + end + + it 'applies the manifest' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + force => true, + noop => true, + } + EOS + + apply_manifest_on(host, pp, :catch_changes => true) do |r| + expect(r.stdout).to match(/Noop Mode/) + end + end + end end context 'as a user' do @@ -474,15 +504,5 @@ describe 'clones a remote repo' do apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_changes => true) end - - after(:all) do - pp = <<-EOS - user { 'testuser-ssh': - ensure => absent, - managehome => true, - } - EOS - apply_manifest(pp, :catch_failures => true) - end end end diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index a753610..2fd63f0 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -175,6 +175,28 @@ branches provider.expects(:git).with('checkout', '--force', resource.value(:revision)) provider.create end + it "should warn about destroying it using force and noop attribute" do + resource[:force] = true + resource[:noop] = true + resource.delete(:revision) + provider.expects(:working_copy_exists?).returns(true) + + provider.expects(:destroy).never + provider.expects(:create).never + Puppet::Type::Vcsrepo::Ensure.any_instance.expects(:send_log).with(:notice, "Noop Mode - Would have deleted repository and re-created from latest") + provider.resource.retrieve + end + it "should warn about destroying it using force and global noop" do + resource[:force] = true + Puppet[:noop] = true + resource.delete(:revision) + provider.expects(:working_copy_exists?).returns(true) + + provider.expects(:destroy).never + provider.expects(:create).never + Puppet::Type::Vcsrepo::Ensure.any_instance.expects(:send_log).with(:notice, "Noop Mode - Would have deleted repository and re-created from latest") + provider.resource.retrieve + end end context "when the path is not empty and not a repository" do -- cgit v1.2.3 From 0435f81a3b8821a36dedc038982c3efdab90a3b1 Mon Sep 17 00:00:00 2001 From: Paul Allen Date: Fri, 27 Jun 2014 14:14:47 +0100 Subject: Clear P4CLIENT Environment before test --- spec/unit/puppet/provider/vcsrepo/p4_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/unit/puppet/provider/vcsrepo/p4_spec.rb b/spec/unit/puppet/provider/vcsrepo/p4_spec.rb index 1261915..3a4605b 100644 --- a/spec/unit/puppet/provider/vcsrepo/p4_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/p4_spec.rb @@ -48,6 +48,8 @@ describe Puppet::Type.type(:vcsrepo).provider(:p4) do context "when a client and source are not given" do it "should execute 'p4 client'" do + ENV['P4CLIENT'] = nil + provider.expects(:p4).with(['client', '-o', "puppet-1c5e7a8e4f702e5091dfba173bc0e7c0"]).returns({}) provider.expects(:p4).with(['client', '-i'], spec) provider.create -- cgit v1.2.3 From b56654d263e4a613e6dc5ae1b99c81cc4f3b643b Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Fri, 27 Jun 2014 09:22:41 -0700 Subject: Update .sync.yml to support new .travis.yml configs --- .sync.yml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/.sync.yml b/.sync.yml index dd55f49..9fe38a6 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,21 +1,4 @@ --- -.travis.yml: - env_matrix: - - PUPPET_GEM_VERSION="~> 2.7.0" - - PUPPET_GEM_VERSION="~> 3.3.0" - additional: - - - configs: - after_success: - - git clone -q git://github.com/puppetlabs/ghpublisher.git .forge-release - - .forge-release/publish - - - configs: - before_install: - - gem update --system 2.1.11 - - gem --version - comments: - - Temporary workaround for broken Rubygems on Travis Rakefile: unmanaged: true spec/spec_helper.rb: -- cgit v1.2.3 From b5b2dd296eb30df25ea3d4ca125ca451b162393c Mon Sep 17 00:00:00 2001 From: Paul Allen Date: Fri, 27 Jun 2014 17:44:27 +0100 Subject: Calculate client workspace name for test case (The value of host will be different) --- spec/unit/puppet/provider/vcsrepo/p4_spec.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/unit/puppet/provider/vcsrepo/p4_spec.rb b/spec/unit/puppet/provider/vcsrepo/p4_spec.rb index 3a4605b..2d382da 100644 --- a/spec/unit/puppet/provider/vcsrepo/p4_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/p4_spec.rb @@ -50,7 +50,11 @@ describe Puppet::Type.type(:vcsrepo).provider(:p4) do it "should execute 'p4 client'" do ENV['P4CLIENT'] = nil - provider.expects(:p4).with(['client', '-o', "puppet-1c5e7a8e4f702e5091dfba173bc0e7c0"]).returns({}) + path = resource.value(:path) + host = Facter.value('hostname') + default = "puppet-" + Digest::MD5.hexdigest(path + host) + + provider.expects(:p4).with(['client', '-o', default]).returns({}) provider.expects(:p4).with(['client', '-i'], spec) provider.create end -- cgit v1.2.3 From 8bbde47ae3c3917cf313fed3f94f4dcd5192b41e Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Fri, 27 Jun 2014 10:55:29 -0700 Subject: Synchronize .travis.yml --- .travis.yml | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index ef2a36e..c72d5e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,33 +1,17 @@ --- -branches: - only: - - master language: ruby bundler_args: --without development script: "bundle exec rake spec SPEC_OPTS='--format documentation'" -rvm: - - 1.8.7 - - 1.9.3 - - 2.0.0 -env: - matrix: - - PUPPET_GEM_VERSION="~> 2.7.0" - - PUPPET_GEM_VERSION="~> 3.3.0" matrix: fast_finish: true - exclude: + include: + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 2.7.0" + env: PUPPET_GEM_VERSION="~> 3.0" - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 2.7.0" + env: PUPPET_GEM_VERSION="~> 3.0" notifications: email: false -after_success: -- git clone -q git://github.com/puppetlabs/ghpublisher.git .forge-release -- .forge-release/publish -before_install: -- gem update --system 2.1.11 -- gem --version -comments: -- Temporary workaround for broken Rubygems on Travis - -- cgit v1.2.3 From 7ff254a6fcf3b4d77faf5197d780028791bfe6ba Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Fri, 27 Jun 2014 12:01:21 -0700 Subject: Add module-specific travis script to .sync.yml --- .sync.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.sync.yml b/.sync.yml index 9fe38a6..6fa460a 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,4 +1,6 @@ --- +.travis.yml: + script: "\"bundle exec rake spec SPEC_OPTS='--format documentation'\"" Rakefile: unmanaged: true spec/spec_helper.rb: -- cgit v1.2.3 From cefcee8dd6e87a61301b7af267eb524b45700afd Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 27 Jun 2014 12:40:33 -0700 Subject: Patch misuse of apply_manifest_on --- spec/acceptance/clone_repo_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb index 23b0b31..c52a5d2 100644 --- a/spec/acceptance/clone_repo_spec.rb +++ b/spec/acceptance/clone_repo_spec.rb @@ -343,7 +343,7 @@ describe 'clones a remote repo' do } EOS - apply_manifest_on(host, pp, :catch_changes => true) do |r| + apply_manifest(pp, :catch_changes => true) do |r| expect(r.stdout).to match(/Noop Mode/) end end -- cgit v1.2.3 From 200ca342783c438a2b829fbd54c13739b1a197f2 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Mon, 30 Jun 2014 10:58:51 -0700 Subject: Update Gemfile for .travis.yml defaults --- Gemfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Gemfile b/Gemfile index 9074f1e..e960f7c 100644 --- a/Gemfile +++ b/Gemfile @@ -12,6 +12,12 @@ group :development, :test do gem 'simplecov', :require => false end +if facterversion = ENV['FACTER_GEM_VERSION'] + gem 'facter', facterversion, :require => false +else + gem 'facter', :require => false +end + if puppetversion = ENV['PUPPET_GEM_VERSION'] gem 'puppet', puppetversion, :require => false else -- cgit v1.2.3 From 688c3cad1a277b4cb59445750fdf402a1c1774a3 Mon Sep 17 00:00:00 2001 From: "Joshua B. Bussdieker" Date: Wed, 25 Jun 2014 16:28:04 -0700 Subject: Fix issue with node changing every checkin --- lib/puppet/provider/vcsrepo/git.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 5c878ed..5c5dd07 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -52,7 +52,9 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) return current unless @resource.value(:revision) if tag_revision?(@resource.value(:revision)) - canonical = at_path { git_with_identity('rev-parse', @resource.value(:revision)).chomp } + # git-rev-parse will give you the hash of the tag object itself rather than the commit it points to by default. + # Using tag^0 will return the actual commit. + canonical = at_path { git_with_identity('rev-parse', "#{@resource.value(:revision)}^0").chomp } else # if it's not a tag, look for it as a local ref canonical = at_path { git_with_identity('rev-parse', '--revs-only', @resource.value(:revision)).chomp } -- cgit v1.2.3 From 84e60779f9dd1e1d1d6c07be8b8d5c8109ae0e8c Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Mon, 30 Jun 2014 14:33:17 -0700 Subject: Release 1.0.2 Summary: This supported release adds SLES 11 to the list of compatible OSs and documentation updates for support. --- CHANGELOG | 5 +++++ metadata.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 7ae0fcc..27d9f35 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +2014-06-30 - Supported Release 1.0.2 +Summary: +This supported release adds SLES 11 to the list of compatible OSs and +documentation updates for support. + 2014-06-17 - Supported Release 1.0.1 Summary: diff --git a/metadata.json b/metadata.json index 4772445..5f11fda 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-vcsrepo", - "version": "1.0.1", + "version": "1.0.2", "source": "https://github.com/puppetlabs/puppetlabs-vcsrepo", "author": "Puppet Labs", "license": "GPLv2", -- cgit v1.2.3 From 34cc0c0d4e35fdc5a7b8381033886d160927d501 Mon Sep 17 00:00:00 2001 From: Paul Allen Date: Wed, 2 Jul 2014 12:05:35 +0100 Subject: Update Markdown with missing Perforce details. Fix tabs/spaces in p4.rb --- README.markdown | 10 ++++- lib/puppet/provider/vcsrepo/p4.rb | 56 ++++++++++++++-------------- spec/unit/puppet/provider/vcsrepo/p4_spec.rb | 2 +- 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/README.markdown b/README.markdown index f83c7fd..7ce9657 100644 --- a/README.markdown +++ b/README.markdown @@ -459,6 +459,7 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers * `cvs` - Supports the CVS VCS. (Contains features: `cvs_rsh`, `gzip_compression`, `modules`,`reference_tracking`.) * `dummy` - * `hg` - Supports the Mercurial VCS. (Contains features: `reference_tracking`, `ssh_identity`, `user`.) +* `p4` - Supports the Perforce VCS. (Contains features: `reference_tracking`, `filesystem_types`, `p4config`.) * `svn` - Supports the Subversion VCS. (Contains features: `basic_auth`, `configuration`, `filesystem_types`, `reference_tracking`.) ####Features @@ -477,6 +478,7 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers * `reference_tracking` - The provider supports tracking revision references that can change over time (e.g. some VCS tags and branch names). (Available with `bar`, `cvs`, `git`, `hg`, `svn`.) * `ssh_identity` - The provider supports a configurable SSH identity file. (Available with `git` and `hg`.) * `user` - The provider can run as a different user. (Available with `git` and `hg`.) +* `p4config` - The provider support setting the P4CONFIG environment. (Available with `p4`.) ####Parameters @@ -494,12 +496,13 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers * `identity` - Specifies the SSH identity file. (Requires the `ssh_identity` feature.) * `module` - Specifies the repository module to manage. (Requires the `modules` feature.) * `owner` - Specifies the user/uid that owns the repository files. -* `path` - Specifies the absolute path to the repository. If omitted, the value defaults to the resource's title. +* `path` - Specifies the absolute path to the repository. If omitted, the value defaults to the resource's title. * `provider` - Specifies the backend to use for this vcsrepo resource. * `remote` - Specifies the remote repository to track. (Requires the `multiple_remotes` feature.) * `revision` - Sets the revision of the repository. Values can match /^\S+$/. * `source` - Specifies the source URI for the repository. * `user` - Specifies the user to run as for repository operations. +* `p4config` - Specifies the P4CONFIG environment used for Perforce connection configuration. ####Features and Parameters by Provider @@ -523,6 +526,11 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers **Parameters**: `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `revision`, `source`, `user` +#####`p4` +**Features**: `reference_tracking`, `filesystem_types`, `p4config` + +**Parameters**: `ensure`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `p4config` + #####`svn` **Features**: `basic_auth`, `configuration`, `filesystem_types`, `reference_tracking` diff --git a/lib/puppet/provider/vcsrepo/p4.rb b/lib/puppet/provider/vcsrepo/p4.rb index 4f53415..63d3df2 100644 --- a/lib/puppet/provider/vcsrepo/p4.rb +++ b/lib/puppet/provider/vcsrepo/p4.rb @@ -68,12 +68,12 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d revision = 0 if hash && hash['code'] != 'error' - hash['data'].each do |c| - if c['status'] == 'have' - change = c['change'].to_i - revision = change if change > revision - end - end + hash['data'].each do |c| + if c['status'] == 'have' + change = c['change'].to_i + revision = change if change > revision + end + end end return revision end @@ -180,7 +180,7 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d view = "\nView:\n" hash.keys.sort.each do |k| - v = hash[k] + v = hash[k] next if( k == "code" ) if(k.to_s =~ /View/ ) view += "\t#{v}\n" @@ -251,28 +251,28 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d # helper method as cstat does not Marshal def marshal_cstat(hash) - data = hash['data'] - code = 'error' - - list = Array.new - change = Hash.new - data.each_line do |l| - p = /^\.\.\. (.*) (.*)$/ - m = p.match(l) - if m + data = hash['data'] + code = 'error' + + list = Array.new + change = Hash.new + data.each_line do |l| + p = /^\.\.\. (.*) (.*)$/ + m = p.match(l) + if m change[m[1]] = m[2] - if m[1] == 'status' - code = 'stat' - list.push change - change = Hash.new - end - end - end - - hash = Hash.new - hash.store 'code', code - hash.store 'data', list - return hash + if m[1] == 'status' + code = 'stat' + list.push change + change = Hash.new + end + end + end + + hash = Hash.new + hash.store 'code', code + hash.store 'data', list + return hash end end diff --git a/spec/unit/puppet/provider/vcsrepo/p4_spec.rb b/spec/unit/puppet/provider/vcsrepo/p4_spec.rb index 2d382da..abbd9ec 100644 --- a/spec/unit/puppet/provider/vcsrepo/p4_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/p4_spec.rb @@ -51,7 +51,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:p4) do ENV['P4CLIENT'] = nil path = resource.value(:path) - host = Facter.value('hostname') + host = Facter.value('hostname') default = "puppet-" + Digest::MD5.hexdigest(path + host) provider.expects(:p4).with(['client', '-o', default]).returns({}) -- cgit v1.2.3 From f70ad095f5e1ff1307d902087adf49d68788f067 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 2 Jul 2014 11:08:01 -0700 Subject: Just use metadata now --- Modulefile | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 Modulefile diff --git a/Modulefile b/Modulefile deleted file mode 100644 index 726c13c..0000000 --- a/Modulefile +++ /dev/null @@ -1,4 +0,0 @@ -name 'puppetlabs-vcsrepo' -version '1.0.1' -summary 'Manage repositories from various version control systems' -description 'Manage repositories from various version control systems' -- cgit v1.2.3 From 3ad5203b34c068101d8d47bf70259443e657a4ca Mon Sep 17 00:00:00 2001 From: Peter Souter Date: Thu, 3 Jul 2014 19:04:59 +0100 Subject: (MODULES-1014) Add rspec for noop mode --- spec/acceptance/remove_repo_spec_noop.rb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 spec/acceptance/remove_repo_spec_noop.rb diff --git a/spec/acceptance/remove_repo_spec_noop.rb b/spec/acceptance/remove_repo_spec_noop.rb new file mode 100644 index 0000000..154f25a --- /dev/null +++ b/spec/acceptance/remove_repo_spec_noop.rb @@ -0,0 +1,31 @@ +require 'spec_helper_acceptance' + +tmpdir = default.tmpdir('vcsrepo') + +describe 'does not remove a repo if noop' do + it 'creates a blank repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_noop_deleted": + ensure => present, + provider => git, + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + it 'does not remove a repo if noop' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_noop_deleted": + ensure => absent, + provider => git, + force => true, + } + EOS + + apply_manifest(pp, :catch_failures => true, :noop => true, :verbose => false) + end + + describe file("#{tmpdir}/testrepo_noop_deleted") do + it { should be_directory } + end +end -- cgit v1.2.3 From 1578537eed7f48f40d31f5379fc5b64bdbe50c4f Mon Sep 17 00:00:00 2001 From: Klynton Jessup Date: Wed, 9 Jul 2014 16:28:08 -0700 Subject: Update README.markdown Fixed a missing '*' around the note. --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index f83c7fd..570f166 100644 --- a/README.markdown +++ b/README.markdown @@ -61,7 +61,7 @@ The vcsrepo module works with the following VCSs: * [Perforce (p4)](#perforce) * [Subversion (svn)](#subversion) -**Note:* Git is the only VCS provider officially [supported](https://forge.puppetlabs.com/supported) by Puppet Labs. +**Note:** Git is the only VCS provider officially [supported](https://forge.puppetlabs.com/supported) by Puppet Labs. ###Git -- cgit v1.2.3 From 6624f40651f44e184878a9fbb862bda886d899e8 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 18 Jun 2014 13:54:51 -0700 Subject: (MODULES-660) Correct detached HEAD on latest Previously vcsrepo detached HEAD on checkout which caused further branch revisions to fail. This corrects the behavior, and works on git 1.7, 1.8, 1.9, and 2.0 --- lib/puppet/provider/vcsrepo/git.rb | 172 +++++++++++++++----------- spec/acceptance/modules_660_spec.rb | 89 +++++++++++++ spec/spec_helper_acceptance.rb | 2 +- spec/unit/puppet/provider/vcsrepo/git_spec.rb | 94 +++----------- 4 files changed, 209 insertions(+), 148 deletions(-) create mode 100644 spec/acceptance/modules_660_spec.rb diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 5c5dd07..0a142bb 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -31,69 +31,49 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) FileUtils.rm_rf(@resource.value(:path)) end + # Checks to see if the current revision is equal to the revision on the + # remote (whether on a branch, tag, or reference) + # + # @return [Boolean] Returns true if the repo is on the latest revision def latest? - at_path do - return self.revision == self.latest - end + return revision == latest_revision end + # Just gives the `should` value that we should be setting the repo to if + # latest? returns false + # + # @return [String] Returns the target sha/tag/branch def latest - branch = on_branch? - if !branch - return get_revision('HEAD') - else - return get_revision("#{@resource.value(:remote)}/#{branch}") - end + @resource.value(:revision) end + # Get the current revision of the repo (tag/branch/sha) + # + # @return [String] Returns the branch/tag if the current sha matches the + # remote; otherwise returns the current sha. def revision - update_references - current = at_path { git_with_identity('rev-parse', 'HEAD').chomp } - return current unless @resource.value(:revision) - - if tag_revision?(@resource.value(:revision)) - # git-rev-parse will give you the hash of the tag object itself rather than the commit it points to by default. - # Using tag^0 will return the actual commit. - canonical = at_path { git_with_identity('rev-parse', "#{@resource.value(:revision)}^0").chomp } - else - # if it's not a tag, look for it as a local ref - canonical = at_path { git_with_identity('rev-parse', '--revs-only', @resource.value(:revision)).chomp } - if canonical.empty? - # git rev-parse executed properly but didn't find the ref; - # look for it in the remote - remote_ref = at_path { git_with_identity('ls-remote', '--heads', '--tags', @resource.value(:remote), @resource.value(:revision)).chomp } - if remote_ref.empty? - fail("#{@resource.value(:revision)} is not a local or remote ref") - end - - # $ git ls-remote --heads --tags origin feature/cvs - # 7d4244b35e72904e30130cad6d2258f901c16f1a refs/heads/feature/cvs - canonical = remote_ref.split.first - end - end - - if current == canonical - @resource.value(:revision) - else - current - end + #HEAD is the default, but lets just be explicit here. + get_revision('HEAD') end + # Is passed the desired reference, whether a tag, rev, or branch. Should + # handle transitions from a rev/branch/tag to a rev/branch/tag. Detached + # heads should be treated like bare revisions. + # + # @param [String] desired The desired revision to which the repo should be + # set. def revision=(desired) + #just checkout tags and shas; fetch has already happened so they should be updated. checkout(desired) - if local_branch_revision? - # reset instead of pull to avoid merge conflicts. assuming remote is - # authoritative. - # might be worthwhile to have an allow_local_changes param to decide - # whether to reset or pull when we're ensuring latest. - at_path { - git_with_identity('reset', '--hard', "#{@resource.value(:remote)}/#{desired}") - if detached? - git_with_identity('checkout', "#{@resource.value(:revision)}") - git_with_identity('pull') - end - } + #branches require more work. + if local_branch_revision?(desired) + #reset instead of pull to avoid merge conflicts. assuming remote is + #updated and authoritative. + #TODO might be worthwhile to have an allow_local_changes param to decide + #whether to reset or pull when we're ensuring latest. + at_path { git_with_identity('reset', '--hard', "#{@resource.value(:remote)}/#{desired}") } end + #TODO Would this ever reach here if it is bare? if @resource.value(:ensure) != :bare update_submodules end @@ -132,10 +112,12 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) private + # @!visibility private def bare_git_config_exists? File.exist?(File.join(@resource.value(:path), 'config')) end + # @!visibility private def clone_repository(source, path) check_force args = ['clone'] @@ -158,6 +140,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) end end + # @!visibility private def check_force if path_exists? and not path_empty? if @resource.value(:force) @@ -169,6 +152,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) end end + # @!visibility private def init_repository(path) check_force if @resource.value(:ensure) == :bare && working_copy_exists? @@ -195,6 +179,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) # /.git # to: # / + # @!visibility private def convert_working_copy_to_bare notice "Converting working copy repository to bare repository" FileUtils.mv(File.join(@resource.value(:path), '.git'), tempdir) @@ -208,6 +193,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) # / # to: # /.git + # @!visibility private def convert_bare_to_working_copy notice "Converting bare repository to working copy repository" FileUtils.mv(@resource.value(:path), tempdir) @@ -220,6 +206,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) end end + # @!visibility private def commits_in?(dot_git) Dir.glob(File.join(dot_git, 'objects/info/*'), File::FNM_DOTMATCH) do |e| return true unless %w(. ..).include?(File::basename(e)) @@ -227,26 +214,35 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) false end + # Will checkout a rev/branch/tag using the locally cached versions. Does not + # handle upstream branch changes + # @!visibility private def checkout(revision = @resource.value(:revision)) if !local_branch_revision? && remote_branch_revision? - at_path { git_with_identity('checkout', '-b', revision, '--track', "#{@resource.value(:remote)}/#{revision}") } + #non-locally existant branches (perhaps switching to a branch that has never been checked out) + at_path { git_with_identity('checkout', '--force', '-b', revision, '--track', "#{@resource.value(:remote)}/#{revision}") } else + #tags, locally existant branches (perhaps outdated), and shas at_path { git_with_identity('checkout', '--force', revision) } end end + # @!visibility private def reset(desired) at_path do git_with_identity('reset', '--hard', desired) end end + # @!visibility private def update_submodules at_path do git_with_identity('submodule', 'update', '--init', '--recursive') end end + # Determins if the branch exists at the upstream but has not yet been locally committed + # @!visibility private def remote_branch_revision?(revision = @resource.value(:revision)) # git < 1.6 returns '#{@resource.value(:remote)}/#{revision}' # git 1.6+ returns 'remotes/#{@resource.value(:remote)}/#{revision}' @@ -254,64 +250,93 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) branch unless branch.empty? end + # Determins if the branch is already cached locally + # @!visibility private def local_branch_revision?(revision = @resource.value(:revision)) at_path { branches.include?(revision) } end + # @!visibility private def tag_revision?(revision = @resource.value(:revision)) at_path { tags.include?(revision) } end + # @!visibility private def branches at_path { git_with_identity('branch', '-a') }.gsub('*', ' ').split(/\n/).map { |line| line.strip } end + # @!visibility private def on_branch? at_path { matches = git_with_identity('branch', '-a').match /\*\s+(.*)/ - matches[1] unless matches[1].match /detached/ - } - end - - def detached? - at_path { - git_with_identity('branch', '-a').match /\*\s+\(detached from.*\)/ + matches[1] unless matches[1].match /(\(detached from|\(no branch)/ } end + # @!visibility private def tags at_path { git_with_identity('tag', '-l') }.split(/\n/).map { |line| line.strip } end + # @!visibility private def set_excludes at_path { open('.git/info/exclude', 'w') { |f| @resource.value(:excludes).each { |ex| f.write(ex + "\n") }}} end - def get_revision(rev) - if @resource.value(:force) && working_copy_exists? - create - end - if !working_copy_exists? - create - end - at_path do - update_remote_origin_url - git_with_identity('fetch', @resource.value(:remote)) - git_with_identity('fetch', '--tags', @resource.value(:remote)) + # Finds the latest revision or sha of the current branch if on a branch, or + # of HEAD otherwise. + # @note Calls create which can forcibly destroy and re-clone the repo if + # force => true + # @see get_revision + # + # @!visibility private + # @return [String] Returns the output of get_revision + def latest_revision + #TODO Why is create called here anyway? + create if @resource.value(:force) && working_copy_exists? + create if !working_copy_exists? + + if branch = on_branch? + return get_revision("#{@resource.value(:remote)}/#{branch}") + else + return get_revision end + end + + # Returns the current revision given if the revision is a tag or branch and + # matches the current sha. If the current sha does not match the sha of a tag + # or branch, then it will just return the sha (ie, is not in sync) + # + # @!visibility private + # + # @param [String] rev The revision of which to check if it is current + # @return [String] Returns the tag/branch of the current repo if it's up to + # date; otherwise returns the sha of the requested revision. + def get_revision(rev = 'HEAD') + update_references current = at_path { git_with_identity('rev-parse', rev).strip } if @resource.value(:revision) - if local_branch_revision? + if tag_revision? + # git-rev-parse will give you the hash of the tag object itself rather + # than the commit it points to by default. Using tag^0 will return the + # actual commit. + canonical = at_path { git_with_identity('rev-parse', "#{@resource.value(:revision)}^0").strip } + elsif local_branch_revision? canonical = at_path { git_with_identity('rev-parse', @resource.value(:revision)).strip } elsif remote_branch_revision? - canonical = at_path { git_with_identity('rev-parse', "#{@resource.value(:remote)}/" + @resource.value(:revision)).strip } + canonical = at_path { git_with_identity('rev-parse', "#{@resource.value(:remote)}/#{@resource.value(:revision)}").strip } + else + #look for a sha (could match invalid shas) + canonical = at_path { git_with_identity('rev-parse', '--revs-only', @resource.value(:revision)).strip } end + fail("#{@resource.value(:revision)} is not a local or remote ref") if canonical.nil? or canonical.empty? current = @resource.value(:revision) if current == canonical end - update_owner_and_excludes return current end + # @!visibility private def update_owner_and_excludes if @resource.value(:owner) or @resource.value(:group) set_ownership @@ -321,6 +346,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) end end + # @!visibility private def git_with_identity(*args) if @resource.value(:identity) Tempfile.open('git-helper') do |f| diff --git a/spec/acceptance/modules_660_spec.rb b/spec/acceptance/modules_660_spec.rb new file mode 100644 index 0000000..c45aa28 --- /dev/null +++ b/spec/acceptance/modules_660_spec.rb @@ -0,0 +1,89 @@ +require 'spec_helper_acceptance' + +tmpdir = default.tmpdir('vcsrepo') + +describe 'MODULES-660' do + before(:all) do + # Create testrepo.git + my_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + shell("mkdir -p #{tmpdir}") # win test + scp_to(default, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + shell("cd #{tmpdir} && ./create_git_repo.sh") + + # Configure testrepo.git as upstream of testrepo + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo": + ensure => present, + provider => git, + revision => 'a_branch', + source => "file://#{tmpdir}/testrepo.git", + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + after(:all) do + shell("rm -rf #{tmpdir}/testrepo.git") + end + + shared_examples 'switch to branch/tag/sha' do + it 'pulls the new branch commits' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo": + ensure => latest, + provider => git, + revision => 'a_branch', + source => "file://#{tmpdir}/testrepo.git", + } + EOS + apply_manifest(pp, :expect_changes => true) + apply_manifest(pp, :catch_changes => true) + end + it 'checks out the tag' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo": + ensure => latest, + provider => git, + revision => '0.0.3', + source => "file://#{tmpdir}/testrepo.git", + } + EOS + apply_manifest(pp, :expect_changes => true) + apply_manifest(pp, :catch_changes => true) + end + it 'checks out the sha' do + sha = shell("cd #{tmpdir}/testrepo && git rev-parse origin/master").stdout.chomp + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo": + ensure => latest, + provider => git, + revision => '#{sha}', + source => "file://#{tmpdir}/testrepo.git", + } + EOS + apply_manifest(pp, :expect_changes => true) + apply_manifest(pp, :catch_changes => true) + end + end + + context 'on branch' do + before :each do + shell("cd #{tmpdir}/testrepo && git checkout a_branch") + shell("cd #{tmpdir}/testrepo && git reset --hard 0.0.2") + end + it_behaves_like 'switch to branch/tag/sha' + end + context 'on tag' do + before :each do + shell("cd #{tmpdir}/testrepo && git checkout 0.0.1") + end + it_behaves_like 'switch to branch/tag/sha' + end + context 'on detached head' do + before :each do + shell("cd #{tmpdir}/testrepo && git checkout 0.0.2") + shell("cd #{tmpdir}/testrepo && git checkout HEAD~1") + end + it_behaves_like 'switch to branch/tag/sha' + end +end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index e566a12..d37c169 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,6 +1,6 @@ require 'beaker-rspec' -unless ENV['RS_PROVISION'] == 'no' +unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no' hosts.each do |host| # Install Puppet if host.is_pe? diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index 2fd63f0..3f81cc8 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do - def branch_a_list(include_branch) + def branch_a_list(include_branch = nil?) < Date: Fri, 11 Jul 2014 14:45:10 -0700 Subject: Fix lint errors --- examples/hg/clone_basic_auth.pp | 6 +++--- examples/p4/create_client.pp | 6 +++--- examples/p4/delete_client.pp | 6 +++--- examples/p4/latest_client.pp | 8 ++++---- examples/p4/sync_client.pp | 10 +++++----- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/examples/hg/clone_basic_auth.pp b/examples/hg/clone_basic_auth.pp index 1931e1f..984f8ea 100644 --- a/examples/hg/clone_basic_auth.pp +++ b/examples/hg/clone_basic_auth.pp @@ -1,7 +1,7 @@ vcsrepo { '/path/to/repo': - ensure => latest, - provider => hg, - source => 'http://hg.example.com/myrepo', + ensure => latest, + provider => 'hg', + source => 'http://hg.example.com/myrepo', basic_auth_username => 'hgusername', basic_auth_password => 'hgpassword', } diff --git a/examples/p4/create_client.pp b/examples/p4/create_client.pp index f491701..0f8233a 100644 --- a/examples/p4/create_client.pp +++ b/examples/p4/create_client.pp @@ -1,4 +1,4 @@ -vcsrepo { "/tmp/vcstest/p4_client_root": +vcsrepo { '/tmp/vcstest/p4_client_root': ensure => present, - provider => p4 -} \ No newline at end of file + provider => 'p4', +} diff --git a/examples/p4/delete_client.pp b/examples/p4/delete_client.pp index 239349b..1e305f1 100644 --- a/examples/p4/delete_client.pp +++ b/examples/p4/delete_client.pp @@ -1,4 +1,4 @@ -vcsrepo { "/tmp/vcstest/p4_client_root": +vcsrepo { '/tmp/vcstest/p4_client_root': ensure => absent, - provider => p4 -} \ No newline at end of file + provider => 'p4', +} diff --git a/examples/p4/latest_client.pp b/examples/p4/latest_client.pp index 9dcd68e..a7caeb6 100644 --- a/examples/p4/latest_client.pp +++ b/examples/p4/latest_client.pp @@ -1,5 +1,5 @@ -vcsrepo { "/tmp/vcstest/p4_client_root": +vcsrepo { '/tmp/vcstest/p4_client_root': ensure => latest, - provider => p4, - source => "//depot/..." -} \ No newline at end of file + provider => 'p4', + source => '//depot/...', +} diff --git a/examples/p4/sync_client.pp b/examples/p4/sync_client.pp index 55dc9dc..fc0e29c 100644 --- a/examples/p4/sync_client.pp +++ b/examples/p4/sync_client.pp @@ -1,6 +1,6 @@ -vcsrepo { "/tmp/vcstest/p4_client_root": +vcsrepo { '/tmp/vcstest/p4_client_root': ensure => present, - provider => p4, - source => "//depot/...", - revision => "30" -} \ No newline at end of file + provider => 'p4', + source => '//depot/...', + revision => '30', +} -- cgit v1.2.3 From 3441bc07fedb635e7682e29583d539dd712ea64c Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 11 Jul 2014 15:15:34 -0700 Subject: The helper calls host outside of an each loop --- spec/acceptance/beaker_helper.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/spec/acceptance/beaker_helper.rb b/spec/acceptance/beaker_helper.rb index 05aa4e7..592b15d 100644 --- a/spec/acceptance/beaker_helper.rb +++ b/spec/acceptance/beaker_helper.rb @@ -12,11 +12,13 @@ test_name "Installing Puppet and vcsrepo module" do end step 'Ensure we can install our module' do - # We ask the host to interpolate it's distmoduledir because we don't - # actually know it on Windows until we've let it redirect us (depending - # on whether we're running as a 32/64 bit process on 32/64 bit Windows - moduledir = on(host, "echo #{host['distmoduledir']}").stdout.chomp - on host, "mkdir -p #{moduledir}" + hosts.each do |host| + # We ask the host to interpolate it's distmoduledir because we don't + # actually know it on Windows until we've let it redirect us (depending + # on whether we're running as a 32/64 bit process on 32/64 bit Windows + moduledir = on(host, "echo #{host['distmoduledir']}").stdout.chomp + on host, "mkdir -p #{moduledir}" + end end step 'install module' do -- cgit v1.2.3 From 7eb9ce2a3905f0b825bb4640847498572c70ca76 Mon Sep 17 00:00:00 2001 From: Justin Stoller Date: Mon, 14 Jul 2014 13:45:09 -0700 Subject: (maint) Use `copy_module_to` in `beaker_helper.rb` Previously we were using `puppet_module_install()`. Which was ported from Beaker-RSpec. Unfortunately for our heros that method has been refactored since this was ran last. The method `puppet_module_install()` in Beaker installs from the public forge, while the previous behavior, installing via scp from the current directory, has moved to the method `copy_module_to`. This updates the helper for the beaker tests to use the updated method. --- spec/acceptance/beaker_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/acceptance/beaker_helper.rb b/spec/acceptance/beaker_helper.rb index 592b15d..4d23204 100644 --- a/spec/acceptance/beaker_helper.rb +++ b/spec/acceptance/beaker_helper.rb @@ -25,8 +25,8 @@ test_name "Installing Puppet and vcsrepo module" do hosts.each do |host| proj_root = File.expand_path(File.join(File.dirname(__FILE__),'..','..')) - # This require beaker 1.12.2 I believe - puppet_module_install(:source => proj_root, :module_name => 'vcsrepo') + # This require beaker 1.15 + copy_module_to(host, :source => proj_root, :module_name => 'vcsrepo') case fact_on(host, 'osfamily') when 'RedHat' -- cgit v1.2.3 From da6aeaec88e336792fad4b38052452f837a820b0 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Mon, 14 Jul 2014 16:40:41 -0700 Subject: Fix metadata.json to match checksum --- metadata.json | 143 +++++++++++++++++++++++++++++++--------------------------- 1 file changed, 76 insertions(+), 67 deletions(-) diff --git a/metadata.json b/metadata.json index 5f11fda..4c08b18 100644 --- a/metadata.json +++ b/metadata.json @@ -1,69 +1,78 @@ { - "name": "puppetlabs-vcsrepo", - "version": "1.0.2", - "source": "https://github.com/puppetlabs/puppetlabs-vcsrepo", - "author": "Puppet Labs", - "license": "GPLv2", - "project_page": "https://github.com/puppetlabs/puppetlabs-vcsrepo", - "summary": "Puppet module providing a type to manage repositories from various version control systems", - "operatingsystem_support": [ - { - "operatingsystem": "RedHat", - "operatingsystemrelease": [ - "5", - "6", - "7" - ] - }, - { - "operatingsystem": "CentOS", - "operatingsystemrelease": [ - "5", - "6", - "7" - ] - }, - { - "operatingsystem": "OracleLinux", - "operatingsystemrelease": [ - "5", - "6", - "7" - ] - }, - { - "operatingsystem": "Scientific", - "operatingsystemrelease": [ - "5", - "6", - "7" - ] - }, - { - "operatingsystem": "SLES", - "operatingsystemrelease": [ - "11 SP1" - ] - }, - { - "operatingsystem": "Debian", - "operatingsystemrelease": [ - "6", - "7" - ] - }, - { - "operatingsystem": "Ubuntu", - "operatingsystemrelease": [ - "10.04", - "12.04", - "14.04" - ] - } - ], - "requirements": [ - { "name": "pe", "version_requirement": ">= 3.2.0 < 3.4.0" }, - { "name": "puppet", "version_requirement": "3.x" } - ], - "dependencies": [] + "name": "puppetlabs-vcsrepo", + "version": "1.0.2", + "author": "Puppet Labs", + "summary": "Puppet module providing a type to manage repositories from various version control systems", + "license": "GPLv2", + "source": "https://github.com/puppetlabs/puppetlabs-vcsrepo", + "project_page": "https://github.com/puppetlabs/puppetlabs-vcsrepo", + "issues_url": "https://github.com/puppetlabs/puppetlabs-vcsrepo/issues", + "operatingsystem_support": [ + { + "operatingsystem": "RedHat", + "operatingsystemrelease": [ + "5", + "6", + "7" + ] + }, + { + "operatingsystem": "CentOS", + "operatingsystemrelease": [ + "5", + "6", + "7" + ] + }, + { + "operatingsystem": "OracleLinux", + "operatingsystemrelease": [ + "5", + "6", + "7" + ] + }, + { + "operatingsystem": "Scientific", + "operatingsystemrelease": [ + "5", + "6", + "7" + ] + }, + { + "operatingsystem": "SLES", + "operatingsystemrelease": [ + "11 SP1" + ] + }, + { + "operatingsystem": "Debian", + "operatingsystemrelease": [ + "6", + "7" + ] + }, + { + "operatingsystem": "Ubuntu", + "operatingsystemrelease": [ + "10.04", + "12.04", + "14.04" + ] + } + ], + "requirements": [ + { + "name": "pe", + "version_requirement": ">= 3.2.0 < 3.4.0" + }, + { + "name": "puppet", + "version_requirement": "3.x" + } + ], + "dependencies": [ + + ] } -- cgit v1.2.3 From 4f9a64b38e01cd60396a354cf0cfdf262f0ae342 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Mon, 14 Jul 2014 17:33:34 -0700 Subject: Release 1.1.0 Summary: This release adds a Perforce provider* and corrects the git provider behavior when using `ensure => latest`. *(Only git provider is currently supported.) Features: - New Perforce provider Bugfixes: - (MODULES-660) Fix behavior with `ensure => latest` and detached HEAD - Spec test fixes --- CHANGELOG | 13 +++++++++++++ metadata.json | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 27d9f35..1eefd22 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,16 @@ +2014-07-14 - Supported Release 1.1.0 +Summary: +This release adds a Perforce provider* and corrects the git provider behavior +when using `ensure => latest`. + +*(Only git provider is currently supported.) + +Features: +- New Perforce provider + +Bugfixes: +- (MODULES-660) Fix behavior with `ensure => latest` and detached HEAD +- Spec test fixes 2014-06-30 - Supported Release 1.0.2 Summary: This supported release adds SLES 11 to the list of compatible OSs and diff --git a/metadata.json b/metadata.json index 4c08b18..8f78acd 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-vcsrepo", - "version": "1.0.2", + "version": "1.1.0", "author": "Puppet Labs", "summary": "Puppet module providing a type to manage repositories from various version control systems", "license": "GPLv2", -- cgit v1.2.3 From 27c5d5847504d6d5e295b617b1461b4727ccf1f2 Mon Sep 17 00:00:00 2001 From: Paul Chechetin Date: Wed, 20 Aug 2014 11:47:34 +0400 Subject: Change uid by Puppet execution API --- lib/puppet/provider/vcsrepo/git.rb | 4 +--- lib/puppet/provider/vcsrepo/hg.rb | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 0a142bb..9e0306b 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -3,9 +3,7 @@ require File.join(File.dirname(__FILE__), '..', 'vcsrepo') Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) do desc "Supports Git repositories" - ##TODO modify the commands below so that the su - is included commands :git => 'git' - optional_commands :su => 'su' has_features :bare_repositories, :reference_tracking, :ssh_identity, :multiple_remotes, :user, :depth @@ -365,7 +363,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) return ret end elsif @resource.value(:user) and @resource.value(:user) != Facter['id'].value - su(@resource.value(:user), '-c', "git #{args.join(' ')}" ) + Puppet::Util::Execution.execute("git #{args.join(' ')}", :uid => @resource.value(:user), :failonfail => true) else git(*args) end diff --git a/lib/puppet/provider/vcsrepo/hg.rb b/lib/puppet/provider/vcsrepo/hg.rb index 090f019..294c2a9 100644 --- a/lib/puppet/provider/vcsrepo/hg.rb +++ b/lib/puppet/provider/vcsrepo/hg.rb @@ -4,7 +4,6 @@ Puppet::Type.type(:vcsrepo).provide(:hg, :parent => Puppet::Provider::Vcsrepo) d desc "Supports Mercurial repositories" commands :hg => 'hg' - optional_commands :su => 'su' has_features :reference_tracking, :ssh_identity, :user, :basic_auth @@ -123,7 +122,7 @@ Puppet::Type.type(:vcsrepo).provide(:hg, :parent => Puppet::Provider::Vcsrepo) d end if @resource.value(:user) and @resource.value(:user) != Facter['id'].value args.map! { |a| if a =~ /\s/ then "'#{a}'" else a end } # Adds quotes to arguments with whitespaces. - su(@resource.value(:user), '-c', "hg #{args.join(' ')}") + Puppet::Util::Execution.execute("hg #{args.join(' ')}", :uid => @resource.value(:user), :failonfail => true) else hg(*args) end -- cgit v1.2.3 From fc07485e8b33ba4c8280900f72104e489151dec8 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Thu, 28 Aug 2014 18:46:41 -0400 Subject: Update spec_helper for more consistency --- spec/spec_helper_acceptance.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index d37c169..8ca20a8 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,12 +1,14 @@ require 'beaker-rspec' unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no' + # This will install the latest available package on el and deb based + # systems fail on windows and osx, and install via gem on other *nixes + foss_opts = { :default_action => 'gem_install' } + + if default.is_pe?; then install_pe; else install_puppet( foss_opts ); end + hosts.each do |host| - # Install Puppet - if host.is_pe? - install_pe - else - install_puppet + unless host.is_pe? on hosts, "mkdir -p #{hosts.first['distmoduledir']}" end -- cgit v1.2.3 From 71e516172eff4615308c307e3cc4775a5c4d40ab Mon Sep 17 00:00:00 2001 From: Travis Fields Date: Wed, 10 Sep 2014 10:54:28 -0700 Subject: Fix issue with puppet_module_install, removed and using updated method from beaker core copy_module_to --- spec/spec_helper_acceptance.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index d37c169..06f8271 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -27,11 +27,10 @@ RSpec.configure do |c| # Configure all nodes in nodeset c.before :suite do - # Install module and dependencies on all hosts - puppet_module_install(:source => proj_root, :module_name => 'vcsrepo') # ensure test dependencies are available on all hosts hosts.each do |host| + copy_module_to(host, :source => proj_root, :module_name => 'vcsrepo') case fact_on(host, 'osfamily') when 'RedHat' install_package(host, 'git') -- cgit v1.2.3 From 1a27cd10cb52fe963c864aea9e2b6011a4305872 Mon Sep 17 00:00:00 2001 From: Aaron Stone Date: Sat, 13 Sep 2014 23:34:46 -0700 Subject: Disable simplecov on Ruby 1.8.7 --- spec/spec_helper.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index acfae0c..ccd305b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,10 +1,13 @@ require 'puppetlabs_spec_helper/module_spec_helper' -require 'simplecov' require 'support/filesystem_helpers' require 'support/fixture_helpers' -SimpleCov.start do - add_filter "/spec/" +# SimpleCov does not run on Ruby 1.8.7 +unless RUBY_VERSION.to_f < 1.9 + require 'simplecov' + SimpleCov.start do + add_filter '/spec/' + end end RSpec.configure do |c| -- cgit v1.2.3 From ead1aa855a0a6ff6ca54ffc027c585f0b6dba0f4 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Mon, 15 Sep 2014 16:03:11 -0700 Subject: (MODULES-428) Remove dummy warning Puppet started raising a warning about multiple default providers due to a change in puppet. The dummy provider exists to raise an error when `provider` is not specified because there is no way to declare `provider` as a required attribute in the type. Even passing a `provider` value did not get rid of the "multiple default providers found" warning however. This commit causes the dummy provider to be the defacto default for all resources which do not have an explicit provider declared, as the posix feature is available on basically every operating system on which vcsrepo works. (There is no way to create an "always default" provider.) --- lib/puppet/provider/vcsrepo/dummy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/provider/vcsrepo/dummy.rb b/lib/puppet/provider/vcsrepo/dummy.rb index f7b4e54..27bfbbe 100644 --- a/lib/puppet/provider/vcsrepo/dummy.rb +++ b/lib/puppet/provider/vcsrepo/dummy.rb @@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '..', 'vcsrepo') Puppet::Type.type(:vcsrepo).provide(:dummy, :parent => Puppet::Provider::Vcsrepo) do desc "Dummy default provider" - defaultfor :vcsrepo => :dummy + defaultfor :feature => :posix def working_copy_exists? providers = @resource.class.providers.map{|x| x.to_s}.sort.reject{|x| x == "dummy"}.join(", ") rescue "none" -- cgit v1.2.3 From 96d1cc90cf3caa72f6b9d69f85389b2960c27792 Mon Sep 17 00:00:00 2001 From: Aaron Stone Date: Sat, 13 Sep 2014 22:48:18 -0700 Subject: Remove excess whitespace --- lib/puppet/provider/vcsrepo/p4.rb | 86 ++++++++++++++-------------- spec/unit/puppet/provider/vcsrepo/p4_spec.rb | 10 ++-- 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/lib/puppet/provider/vcsrepo/p4.rb b/lib/puppet/provider/vcsrepo/p4.rb index 63d3df2..b429bcb 100644 --- a/lib/puppet/provider/vcsrepo/p4.rb +++ b/lib/puppet/provider/vcsrepo/p4.rb @@ -4,11 +4,11 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d desc "Supports Perforce depots" has_features :filesystem_types, :reference_tracking, :p4config - + def create - # create or update client + # create or update client create_client(client_name) - + # if source provided, sync client source = @resource.value(:source) if source @@ -22,12 +22,12 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d def working_copy_exists? # Check if the server is there, or raise error p4(['info'], {:marshal => false}) - + # Check if workspace is setup args = ['where'] args.push(@resource.value(:path) + "...") hash = p4(args, {:raise => false}) - + return (hash['code'] != "error") end @@ -49,14 +49,14 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d (rev >= self.latest) else true - end + end end def latest args = ['changes'] args.push('-m1', @resource.value(:source)) hash = p4(args) - + return hash['change'].to_i end @@ -65,7 +65,7 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d args.push(@resource.value(:source)) hash = p4(args, {:marshal => false}) hash = marshal_cstat(hash) - + revision = 0 if hash && hash['code'] != 'error' hash['data'].each do |c| @@ -90,7 +90,7 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d set_ownership end end - + # Sync the client workspace files to head or specified revision. # Params: # +source+:: Depot path to sync @@ -105,16 +105,16 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d end p4(args) end - - # Returns the name of the Perforce client workspace + + # Returns the name of the Perforce client workspace def client_name p4config = @resource.value(:p4config) - + # default (generated) client name path = @resource.value(:path) host = Facter.value('hostname') default = "puppet-" + Digest::MD5.hexdigest(path + host) - + # check config for client name set_client = nil if p4config && File.file?(p4config) @@ -124,10 +124,10 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d set_client = p.match(m)[1] if m end end - + return set_client || ENV['P4CLIENT'] || default end - + # Create (or update) a client workspace spec. # If a client name is not provided then a hash based on the path is used. # Params: @@ -135,13 +135,13 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d # +path+:: The Root location of the Perforce client workspace def create_client(client) Puppet.debug "Creating client: #{client}" - + # fetch client spec hash = parse_client(client) hash['Root'] = @resource.value(:path) hash['Description'] = "Generated by Puppet VCSrepo" - - # check is source is a Stream + + # check is source is a Stream source = @resource.value(:source) if source parts = source.split(/\//) @@ -154,7 +154,7 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d end end end - + # save client spec save_client(hash) end @@ -170,15 +170,15 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d return hash end - - - # Saves the client workspace spec from the given hash + + + # Saves the client workspace spec from the given hash # Params: # +hash+:: hash map of client spec def save_client(hash) spec = String.new view = "\nView:\n" - + hash.keys.sort.each do |k| v = hash[k] next if( k == "code" ) @@ -187,40 +187,40 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d else spec += "#{k.to_s}: #{v.to_s}\n" end - end + end spec += view - + args = ['client'] args.push('-i') p4(args, {:input => spec, :marshal => false}) - end - + end + # Sets Perforce Configuration environment. # P4CLIENT generated, but overwitten if defined in config. def config p4config = @resource.value(:p4config) - + cfg = Hash.new cfg.store 'P4CONFIG', p4config if p4config cfg.store 'P4CLIENT', client_name - return cfg + return cfg end - + def p4(args, options = {}) # Merge custom options with defaults - opts = { + opts = { :raise => true, # Raise errors :marshal => true, # Marshal output }.merge(options) - + cmd = ['p4'] cmd.push '-R' if opts[:marshal] cmd.push args cmd_str = cmd.respond_to?(:join) ? cmd.join(' ') : cmd - + Puppet.debug "environment: #{config}" Puppet.debug "command: #{cmd_str}" - + hash = Hash.new Open3.popen3(config, cmd_str) do |i, o, e, t| # Send input stream if provided @@ -229,13 +229,13 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d i.write opts[:input] i.close end - + if(opts[:marshal]) hash = Marshal.load(o) else - hash['data'] = o.read + hash['data'] = o.read end - + # Raise errors, Perforce or Exec if(opts[:raise] && !e.eof && t.value != 0) raise Puppet::Error, "\nP4: #{e.read}" @@ -244,22 +244,22 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d raise Puppet::Error, "\nP4: #{hash['data']}" end end - + Puppet.debug "hash: #{hash}\n" return hash end - + # helper method as cstat does not Marshal def marshal_cstat(hash) data = hash['data'] code = 'error' - + list = Array.new change = Hash.new data.each_line do |l| p = /^\.\.\. (.*) (.*)$/ m = p.match(l) - if m + if m change[m[1]] = m[2] if m[1] == 'status' code = 'stat' @@ -268,11 +268,11 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d end end end - + hash = Hash.new hash.store 'code', code hash.store 'data', list return hash end - + end diff --git a/spec/unit/puppet/provider/vcsrepo/p4_spec.rb b/spec/unit/puppet/provider/vcsrepo/p4_spec.rb index abbd9ec..e331cae 100644 --- a/spec/unit/puppet/provider/vcsrepo/p4_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/p4_spec.rb @@ -26,7 +26,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:p4) do resource[:source] = 'something' resource[:revision] = '1' ENV['P4CLIENT'] = 'client_ws1' - + provider.expects(:p4).with(['client', '-o', 'client_ws1']).returns({}) provider.expects(:p4).with(['client', '-i'], spec) provider.expects(:p4).with(['sync', resource.value(:source) + "@" + resource.value(:revision)]) @@ -38,7 +38,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:p4) do it "should just execute 'p4 sync' without a revision" do resource[:source] = 'something' ENV['P4CLIENT'] = 'client_ws2' - + provider.expects(:p4).with(['client', '-o', 'client_ws2']).returns({}) provider.expects(:p4).with(['client', '-i'], spec) provider.expects(:p4).with(['sync', resource.value(:source)]) @@ -49,11 +49,11 @@ describe Puppet::Type.type(:vcsrepo).provider(:p4) do context "when a client and source are not given" do it "should execute 'p4 client'" do ENV['P4CLIENT'] = nil - + path = resource.value(:path) host = Facter.value('hostname') default = "puppet-" + Digest::MD5.hexdigest(path + host) - + provider.expects(:p4).with(['client', '-o', default]).returns({}) provider.expects(:p4).with(['client', '-i'], spec) provider.create @@ -64,7 +64,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:p4) do describe 'destroying' do it "it should remove the directory" do ENV['P4CLIENT'] = 'test_client' - + provider.expects(:p4).with(['client', '-d', '-f', 'test_client']) expects_rm_rf provider.destroy -- cgit v1.2.3 From 0e7c0b06e952d5133bd7f9f055d680cb704e213e Mon Sep 17 00:00:00 2001 From: Aaron Stone Date: Sat, 13 Sep 2014 23:27:25 -0700 Subject: Handle both Array/Enumerable and String values for excludes parameter Thanks to @revhazroot for identifying the problem that excludes with a string or single-element array fails on Ruby >= 1.9. --- lib/puppet/provider/vcsrepo/git.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 0a142bb..48bbe7d 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -281,7 +281,16 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) # @!visibility private def set_excludes - at_path { open('.git/info/exclude', 'w') { |f| @resource.value(:excludes).each { |ex| f.write(ex + "\n") }}} + # Excludes may be an Array or a String. + at_path do + open('.git/info/exclude', 'w') do |f| + if @resource.value(:excludes).respond_to?(:each) + @resource.value(:excludes).each { |ex| f.puts ex } + else + f.puts @resource.value(:excludes) + end + end + end end # Finds the latest revision or sha of the current branch if on a branch, or -- cgit v1.2.3 From 1df5570580c1d429a8fed25033a19333fcaffbda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Gali=C4=87?= Date: Mon, 29 Sep 2014 19:19:21 +0200 Subject: Convert specs to RSpec 2.99.2 syntax with Transpec This conversion is done by Transpec 2.3.7 with the following command: transpec * 22 conversions from: it { should ... } to: it { is_expected.to ... } * 19 conversions from: obj.should to: expect(obj).to * 15 conversions from: == expected to: eq(expected) * 5 conversions from: it { should_not ... } to: it { is_expected.not_to ... } * 2 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 2 conversions from: obj.should_not to: expect(obj).not_to * 2 conversions from: proc { }.should to: expect { }.to * 1 conversion from: be_false to: be_falsey * 1 conversion from: be_true to: be_truthy For more details: https://github.com/yujinakayama/transpec#supported-conversions --- spec/acceptance/clone_repo_spec.rb | 49 +++++++++++++++------------ spec/acceptance/create_repo_spec.rb | 8 ++--- spec/acceptance/remove_repo_spec.rb | 2 +- spec/acceptance/remove_repo_spec_noop.rb | 2 +- spec/unit/puppet/provider/vcsrepo/bzr_spec.rb | 8 ++--- spec/unit/puppet/provider/vcsrepo/cvs_spec.rb | 4 +-- spec/unit/puppet/provider/vcsrepo/git_spec.rb | 24 ++++++------- spec/unit/puppet/provider/vcsrepo/hg_spec.rb | 8 ++--- spec/unit/puppet/provider/vcsrepo/svn_spec.rb | 2 +- 9 files changed, 57 insertions(+), 50 deletions(-) diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb index c52a5d2..f3e77db 100644 --- a/spec/acceptance/clone_repo_spec.rb +++ b/spec/acceptance/clone_repo_spec.rb @@ -30,11 +30,11 @@ describe 'clones a remote repo' do end describe file("#{tmpdir}/testrepo/.git") do - it { should be_directory } + it { is_expected.to be_directory } end describe file("#{tmpdir}/testrepo/.git/HEAD") do - it { should contain 'ref: refs/heads/master' } + it { is_expected.to contain 'ref: refs/heads/master' } end end @@ -63,11 +63,11 @@ describe 'clones a remote repo' do end describe file("#{tmpdir}/testrepo_sha/.git") do - it { should be_directory } + it { is_expected.to be_directory } end describe file("#{tmpdir}/testrepo_sha/.git/HEAD") do - it { should contain sha } + it { is_expected.to contain sha } end end @@ -88,7 +88,7 @@ describe 'clones a remote repo' do end describe file("#{tmpdir}/testrepo_tag/.git") do - it { should be_directory } + it { is_expected.to be_directory } end it 'should have the tag as the HEAD' do @@ -113,11 +113,11 @@ describe 'clones a remote repo' do end describe file("#{tmpdir}/testrepo_branch/.git") do - it { should be_directory } + it { is_expected.to be_directory } end describe file("#{tmpdir}/testrepo_branch/.git/HEAD") do - it { should contain 'ref: refs/heads/a_branch' } + it { is_expected.to contain 'ref: refs/heads/a_branch' } end end @@ -183,7 +183,7 @@ describe 'clones a remote repo' do end describe file("#{tmpdir}/testrepo_shallow/.git/shallow") do - it { should be_file } + it { is_expected.to be_file } end end @@ -229,8 +229,8 @@ describe 'clones a remote repo' do end describe file("#{tmpdir}/testrepo_owner") do - it { should be_directory } - it { should be_owned_by 'vagrant' } + it { is_expected.to be_directory } + it { is_expected.to be_owned_by 'vagrant' } end end @@ -259,8 +259,8 @@ describe 'clones a remote repo' do end describe file("#{tmpdir}/testrepo_group") do - it { should be_directory } - it { should be_grouped_into 'vagrant' } + it { is_expected.to be_directory } + it { is_expected.to be_grouped_into 'vagrant' } end end @@ -281,8 +281,15 @@ describe 'clones a remote repo' do end describe file("#{tmpdir}/testrepo_excludes/.git/info/exclude") do - its(:content) { should match /exclude1.txt/ } - its(:content) { should match /exclude2.txt/ } + describe '#content' do + subject { super().content } + it { is_expected.to match /exclude1.txt/ } + end + + describe '#content' do + subject { super().content } + it { is_expected.to match /exclude2.txt/ } + end end end @@ -308,15 +315,15 @@ describe 'clones a remote repo' do end describe file("#{tmpdir}/testrepo_force/folder") do - it { should_not be_directory } + it { is_expected.not_to be_directory } end describe file("#{tmpdir}/testrepo_force/temp.txt") do - it { should_not be_file } + it { is_expected.not_to be_file } end describe file("#{tmpdir}/testrepo_force/.git") do - it { should be_directory } + it { is_expected.to be_directory } end context 'and noop' do @@ -382,13 +389,13 @@ describe 'clones a remote repo' do end describe file("#{tmpdir}/testrepo_user") do - it { should be_directory } - it { should be_owned_by 'testuser' } + it { is_expected.to be_directory } + it { is_expected.to be_owned_by 'testuser' } end describe file("#{tmpdir}/testrepo_user") do - it { should be_directory } - it { should be_grouped_into 'testuser' } + it { is_expected.to be_directory } + it { is_expected.to be_grouped_into 'testuser' } end end diff --git a/spec/acceptance/create_repo_spec.rb b/spec/acceptance/create_repo_spec.rb index 1b46449..db0cd29 100644 --- a/spec/acceptance/create_repo_spec.rb +++ b/spec/acceptance/create_repo_spec.rb @@ -26,7 +26,7 @@ describe 'create a repo' do end describe file("#{tmpdir}/testrepo_blank_repo/.git") do - it { should be_directory } + it { is_expected.to be_directory } end end @@ -45,11 +45,11 @@ describe 'create a repo' do end describe file("#{tmpdir}/testrepo_bare_repo/config") do - it { should contain 'bare = true' } + it { is_expected.to contain 'bare = true' } end describe file("#{tmpdir}/testrepo_bare_repo/.git") do - it { should_not be_directory } + it { is_expected.not_to be_directory } end end @@ -67,7 +67,7 @@ describe 'create a repo' do end describe file("#{tmpdir}/testrepo_bare_repo_rev") do - it { should_not be_directory } + it { is_expected.not_to be_directory } end end end diff --git a/spec/acceptance/remove_repo_spec.rb b/spec/acceptance/remove_repo_spec.rb index d22d9db..d5646b3 100644 --- a/spec/acceptance/remove_repo_spec.rb +++ b/spec/acceptance/remove_repo_spec.rb @@ -25,6 +25,6 @@ describe 'remove a repo' do end describe file("#{tmpdir}/testrepo_deleted") do - it { should_not be_directory } + it { is_expected.not_to be_directory } end end diff --git a/spec/acceptance/remove_repo_spec_noop.rb b/spec/acceptance/remove_repo_spec_noop.rb index 154f25a..f6bd86e 100644 --- a/spec/acceptance/remove_repo_spec_noop.rb +++ b/spec/acceptance/remove_repo_spec_noop.rb @@ -26,6 +26,6 @@ describe 'does not remove a repo if noop' do end describe file("#{tmpdir}/testrepo_noop_deleted") do - it { should be_directory } + it { is_expected.to be_directory } end end diff --git a/spec/unit/puppet/provider/vcsrepo/bzr_spec.rb b/spec/unit/puppet/provider/vcsrepo/bzr_spec.rb index 488ddc0..b5e2f73 100644 --- a/spec/unit/puppet/provider/vcsrepo/bzr_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/bzr_spec.rb @@ -67,14 +67,14 @@ describe Puppet::Type.type(:vcsrepo).provider(:bzr_provider) do it "should return the ref" do resource[:revision] = '2634' provider.expects(:bzr).with('revision-info', '2634').returns("2634 menesis@pov.lt-20100309191856-4wmfqzc803fj300x\n") - provider.revision.should == resource.value(:revision) + expect(provider.revision).to eq(resource.value(:revision)) end end context "when its revid is different than the current revid" do it "should return the current revid" do resource[:revision] = '2636' provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("2635 foo\n") - provider.revision.should == @current_revid + expect(provider.revision).to eq(@current_revid) end end end @@ -84,14 +84,14 @@ describe Puppet::Type.type(:vcsrepo).provider(:bzr_provider) do it "should return it" do resource[:revision] = 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x' provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("1234 #{resource.value(:revision)}\n") - provider.revision.should == resource.value(:revision) + expect(provider.revision).to eq(resource.value(:revision)) end end context "when it is not the same as the current revid" do it "should return the current revid" do resource[:revision] = 'menesis@pov.lt-20100309191856-4wmfqzc803fj300y' provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("2636 foo\n") - provider.revision.should == @current_revid + expect(provider.revision).to eq(@current_revid) end end diff --git a/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb b/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb index efa4b33..f5eebd9 100644 --- a/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb @@ -86,7 +86,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:cvs_provider) do end it "should read CVS/Tag" do File.expects(:read).with(@tag_file).returns("T#{@tag}") - provider.revision.should == @tag + expect(provider.revision).to eq(@tag) end end @@ -95,7 +95,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:cvs_provider) do File.expects(:exist?).with(@tag_file).returns(false) end it "assumes HEAD" do - provider.revision.should == 'HEAD' + expect(provider.revision).to eq('HEAD') end end end diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index 3f81cc8..122eb62 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -134,7 +134,7 @@ branches it "should raise an exception" do provider.expects(:path_exists?).returns(true) provider.expects(:path_empty?).returns(false) - proc { provider.create }.should raise_error(Puppet::Error) + expect { provider.create }.to raise_error(Puppet::Error) end end end @@ -204,7 +204,7 @@ branches provider.expects(:path_exists?).returns(true) provider.expects(:path_empty?).returns(false) provider.expects(:working_copy_exists?).returns(false) - proc { provider.create }.should raise_error(Puppet::Error) + expect { provider.create }.to raise_error(Puppet::Error) end end end @@ -233,14 +233,14 @@ branches context "when its SHA is not different than the current SHA" do it "should return the ref" do provider.expects(:git).with('rev-parse', resource.value(:revision)).returns('currentsha') - provider.revision.should == resource.value(:revision) + expect(provider.revision).to eq(resource.value(:revision)) end end context "when its SHA is different than the current SHA" do it "should return the current SHA" do provider.expects(:git).with('rev-parse', resource.value(:revision)).returns('othersha') - provider.revision.should == resource.value(:revision) + expect(provider.revision).to eq(resource.value(:revision)) end end @@ -248,7 +248,7 @@ branches it "should return the revision" do provider.stubs(:git).with('branch', '-a').returns(" remotes/origin/#{resource.value(:revision)}") provider.expects(:git).with('rev-parse', "origin/#{resource.value(:revision)}").returns("newsha") - provider.revision.should == resource.value(:revision) + expect(provider.revision).to eq(resource.value(:revision)) end end @@ -267,7 +267,7 @@ branches provider.expects(:git).with('config', 'remote.origin.url').returns('old') provider.expects(:git).with('config', 'remote.origin.url', 'git://git@foo.com/bar.git') provider.expects(:git).with('rev-parse', resource.value(:revision)).returns('currentsha') - provider.revision.should == resource.value(:revision) + expect(provider.revision).to eq(resource.value(:revision)) end end end @@ -329,13 +329,13 @@ branches context "when it's listed in 'git branch -a'" do it "should return true" do resource[:revision] = 'feature/foo' - provider.should be_local_branch_revision + expect(provider).to be_local_branch_revision end end context "when it's not listed in 'git branch -a'" do it "should return false" do resource[:revision] = 'feature/notexist' - provider.should_not be_local_branch_revision + expect(provider).not_to be_local_branch_revision end end end @@ -343,13 +343,13 @@ branches context "when it's listed in 'git branch -a' with an 'origin/' prefix" do it "should return true" do resource[:revision] = 'only/remote' - provider.should be_remote_branch_revision + expect(provider).to be_remote_branch_revision end end context "when it's not listed in 'git branch -a' with an 'origin/' prefix" do it "should return false" do resource[:revision] = 'only/local' - provider.should_not be_remote_branch_revision + expect(provider).not_to be_remote_branch_revision end end end @@ -360,14 +360,14 @@ branches it do provider.expects(:revision).returns('testrev') provider.expects(:latest_revision).returns('testrev') - provider.latest?.should be_true + expect(provider.latest?).to be_truthy end end context 'when false' do it do provider.expects(:revision).returns('master') provider.expects(:latest_revision).returns('testrev') - provider.latest?.should be_false + expect(provider.latest?).to be_falsey end end end diff --git a/spec/unit/puppet/provider/vcsrepo/hg_spec.rb b/spec/unit/puppet/provider/vcsrepo/hg_spec.rb index 6b21c1c..65d820d 100644 --- a/spec/unit/puppet/provider/vcsrepo/hg_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/hg_spec.rb @@ -88,14 +88,14 @@ describe Puppet::Type.type(:vcsrepo).provider(:hg) do context "when its SHA is not different than the current SHA" do it "should return the ref" do resource[:revision] = '0.6' - provider.revision.should == '0.6' + expect(provider.revision).to eq('0.6') end end context "when its SHA is different than the current SHA" do it "should return the current SHA" do resource[:revision] = '0.5.3' - provider.revision.should == '34e6012c783a' + expect(provider.revision).to eq('34e6012c783a') end end end @@ -108,7 +108,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:hg) do it "should return it" do resource[:revision] = '34e6012c783a' provider.expects(:hg).with('tags').returns(fixture(:hg_tags)) - provider.revision.should == resource.value(:revision) + expect(provider.revision).to eq(resource.value(:revision)) end end @@ -116,7 +116,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:hg) do it "should return the current SHA" do resource[:revision] = 'not-the-same' provider.expects(:hg).with('tags').returns(fixture(:hg_tags)) - provider.revision.should == '34e6012c783a' + expect(provider.revision).to eq('34e6012c783a') end end end diff --git a/spec/unit/puppet/provider/vcsrepo/svn_spec.rb b/spec/unit/puppet/provider/vcsrepo/svn_spec.rb index f44e314..494da52 100644 --- a/spec/unit/puppet/provider/vcsrepo/svn_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/svn_spec.rb @@ -75,7 +75,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:svn) do end it "should use 'svn info'" do expects_chdir - provider.revision.should == '4' # From 'Revision', not 'Last Changed Rev' + expect(provider.revision).to eq('4') # From 'Revision', not 'Last Changed Rev' end end -- cgit v1.2.3 From 477c19773628c2b68c10d2bfc4dc9d6af019c2a1 Mon Sep 17 00:00:00 2001 From: Justin Stoller Date: Wed, 15 Oct 2014 12:41:46 -0700 Subject: (FM-1951) Ensure Git is installable on EL 5 platforms Git is not installed on EL 5, but it is not in the repos either. With this patch, if we are going to install git on an EL 5 platform we first ensure epel is installed(FM-1951) Ensure Git is installable on EL 5 platforms --- spec/spec_helper_acceptance.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index f37a9b0..9ef826a 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -20,6 +20,7 @@ unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no' end end + RSpec.configure do |c| # Project root proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) @@ -35,9 +36,21 @@ RSpec.configure do |c| copy_module_to(host, :source => proj_root, :module_name => 'vcsrepo') case fact_on(host, 'osfamily') when 'RedHat' + if fact_on(host, 'operatingsystemmajrelease') == '5' + will_install_git = on(host, 'which git', :acceptable_exit_codes => [0,1]).exit_code == 1 + + if will_install_git + on host, puppet('module install stahnma-epel') + apply_manifest_on( host, 'include epel' ) + end + + end + install_package(host, 'git') + when 'Debian' install_package(host, 'git-core') + else if !check_for_package(host, 'git') puts "Git package is required for this module" -- cgit v1.2.3 From ecf02352a371e3c4a9c72bf94297f047bc400aa7 Mon Sep 17 00:00:00 2001 From: Jon Fautley Date: Tue, 28 Oct 2014 16:21:48 +0000 Subject: Add `user` feature support to CVS provider --- README.markdown | 4 ++-- lib/puppet/provider/vcsrepo/cvs.rb | 14 ++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/README.markdown b/README.markdown index 6d03a7c..de6ae9a 100644 --- a/README.markdown +++ b/README.markdown @@ -456,7 +456,7 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers * `git` - Supports the Git VCS. (Contains features: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`.) * `bar` - Supports the Bazaar VCS. (Contains features: `reference_tracking`.) -* `cvs` - Supports the CVS VCS. (Contains features: `cvs_rsh`, `gzip_compression`, `modules`,`reference_tracking`.) +* `cvs` - Supports the CVS VCS. (Contains features: `cvs_rsh`, `gzip_compression`, `modules`, `reference_tracking`, `user`.) * `dummy` - * `hg` - Supports the Mercurial VCS. (Contains features: `reference_tracking`, `ssh_identity`, `user`.) * `p4` - Supports the Perforce VCS. (Contains features: `reference_tracking`, `filesystem_types`, `p4config`.) @@ -477,7 +477,7 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers * `multiple_remotes` - The repository tracks multiple remote repositories. (Available with `git`.) * `reference_tracking` - The provider supports tracking revision references that can change over time (e.g. some VCS tags and branch names). (Available with `bar`, `cvs`, `git`, `hg`, `svn`.) * `ssh_identity` - The provider supports a configurable SSH identity file. (Available with `git` and `hg`.) -* `user` - The provider can run as a different user. (Available with `git` and `hg`.) +* `user` - The provider can run as a different user. (Available with `git`, `hg` and `cvs`.) * `p4config` - The provider support setting the P4CONFIG environment. (Available with `p4`.) ####Parameters diff --git a/lib/puppet/provider/vcsrepo/cvs.rb b/lib/puppet/provider/vcsrepo/cvs.rb index 01094b1..891a5c6 100644 --- a/lib/puppet/provider/vcsrepo/cvs.rb +++ b/lib/puppet/provider/vcsrepo/cvs.rb @@ -4,7 +4,7 @@ Puppet::Type.type(:vcsrepo).provide(:cvs, :parent => Puppet::Provider::Vcsrepo) desc "Supports CVS repositories/workspaces" commands :cvs => 'cvs' - has_features :gzip_compression, :reference_tracking, :modules, :cvs_rsh + has_features :gzip_compression, :reference_tracking, :modules, :cvs_rsh, :user def create if !@resource.value(:source) @@ -125,13 +125,11 @@ Puppet::Type.type(:vcsrepo).provide(:cvs, :parent => Puppet::Provider::Vcsrepo) e = {} end - # The location of withenv changed from Puppet 2.x to 3.x - withenv = Puppet::Util.method(:withenv) if Puppet::Util.respond_to?(:withenv) - withenv = Puppet::Util::Execution.method(:withenv) if Puppet::Util::Execution.respond_to?(:withenv) - fail("Cannot set custom environment #{e}") if e && !withenv - - withenv.call e do - Puppet.debug cvs *args + if @resource.value(:user) and @resource.value(:user) != Facter['id'].value + debug "Running as user " + @resource.value(:user) + Puppet.debug Puppet::Util::Execution.execute("cvs #{args.join(' ')}", :uid => @resource.value(:user), :custom_environment => e) + else + Puppet.debug Puppet::Util::Execution.execute("cvs #{args.join(' ')}", :custom_environment => e) end end end -- cgit v1.2.3 From f40255377ce41653d69f0b91c5b1a8f7d36883c1 Mon Sep 17 00:00:00 2001 From: Jon Fautley Date: Wed, 29 Oct 2014 10:55:42 +0000 Subject: Revamp debugging output --- lib/puppet/provider/vcsrepo/cvs.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/puppet/provider/vcsrepo/cvs.rb b/lib/puppet/provider/vcsrepo/cvs.rb index 891a5c6..7a8f6ef 100644 --- a/lib/puppet/provider/vcsrepo/cvs.rb +++ b/lib/puppet/provider/vcsrepo/cvs.rb @@ -33,13 +33,13 @@ Puppet::Type.type(:vcsrepo).provide(:cvs, :parent => Puppet::Provider::Vcsrepo) end def latest? - debug "Checking for updates because 'ensure => latest'" + Puppet.debug "Checking for updates because 'ensure => latest'" at_path do # We cannot use -P to prune empty dirs, otherwise # CVS would report those as "missing", regardless # if they have contents or updates. is_current = (runcvs('-nq', 'update', '-d').strip == "") - if (!is_current) then debug "There are updates available on the checkout's current branch/tag." end + if (!is_current) then Puppet.debug "There are updates available on the checkout's current branch/tag." end return is_current end end @@ -62,7 +62,7 @@ Puppet::Type.type(:vcsrepo).provide(:cvs, :parent => Puppet::Provider::Vcsrepo) else @rev = 'HEAD' end - debug "Checkout is on branch/tag '#{@rev}'" + Puppet.debug "Checkout is on branch/tag '#{@rev}'" end return @rev end @@ -119,17 +119,17 @@ Puppet::Type.type(:vcsrepo).provide(:cvs, :parent => Puppet::Provider::Vcsrepo) def runcvs(*args) if @resource.value(:cvs_rsh) - debug "Using CVS_RSH = " + @resource.value(:cvs_rsh) + Puppet.debug "Using CVS_RSH = " + @resource.value(:cvs_rsh) e = { :CVS_RSH => @resource.value(:cvs_rsh) } else e = {} end if @resource.value(:user) and @resource.value(:user) != Facter['id'].value - debug "Running as user " + @resource.value(:user) - Puppet.debug Puppet::Util::Execution.execute("cvs #{args.join(' ')}", :uid => @resource.value(:user), :custom_environment => e) + Puppet.debug "Running as user " + @resource.value(:user) + Puppet::Util::Execution.execute([:cvs, *args], :uid => @resource.value(:user), :custom_environment => e) else - Puppet.debug Puppet::Util::Execution.execute("cvs #{args.join(' ')}", :custom_environment => e) + Puppet::Util::Execution.execute([:cvs, *args], :custom_environment => e) end end end -- cgit v1.2.3 From 9cef7c46c98153affbb3cd02e4a26afb43664e6d Mon Sep 17 00:00:00 2001 From: Jon Fautley Date: Wed, 29 Oct 2014 10:59:58 +0000 Subject: Rework spec tests to support new execution method --- spec/unit/puppet/provider/vcsrepo/cvs_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb b/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb index f5eebd9..b146d70 100644 --- a/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb @@ -23,14 +23,14 @@ describe Puppet::Type.type(:vcsrepo).provider(:cvs_provider) do resource[:source] = ':ext:source@example.com:/foo/bar' resource[:revision] = 'an-unimportant-value' expects_chdir('/tmp') - provider.expects(:cvs).with('-d', resource.value(:source), 'checkout', '-r', 'an-unimportant-value', '-d', 'test', 'bar') + Puppet::Util::Execution.expects(:execute).with([:cvs, '-d', resource.value(:source), 'checkout', '-r', 'an-unimportant-value', '-d', 'test', 'bar'], :custom_environment => {}) provider.create end it "should just execute 'cvs checkout' without a revision" do resource[:source] = ':ext:source@example.com:/foo/bar' resource.delete(:revision) - provider.expects(:cvs).with('-d', resource.value(:source), 'checkout', '-d', File.basename(resource.value(:path)), File.basename(resource.value(:source))) + Puppet::Util::Execution.expects(:execute).with([:cvs, '-d', resource.value(:source), 'checkout', '-d', File.basename(resource.value(:path)), File.basename(resource.value(:source))], :custom_environment => {}) provider.create end @@ -39,7 +39,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:cvs_provider) do resource[:source] = ':ext:source@example.com:/foo/bar' resource[:compression] = '3' resource.delete(:revision) - provider.expects(:cvs).with('-d', resource.value(:source), '-z', '3', 'checkout', '-d', File.basename(resource.value(:path)), File.basename(resource.value(:source))) + Puppet::Util::Execution.expects(:execute).with([:cvs, '-d', resource.value(:source), '-z', '3', 'checkout', '-d', File.basename(resource.value(:path)), File.basename(resource.value(:source))], :custom_environment => {}) provider.create end end @@ -48,7 +48,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:cvs_provider) do context "when a source is not given" do it "should execute 'cvs init'" do resource.delete(:source) - provider.expects(:cvs).with('-d', resource.value(:path), 'init') + Puppet::Util::Execution.expects(:execute).with([:cvs, '-d', resource.value(:path), 'init'], :custom_environment => {}) provider.create end end @@ -107,7 +107,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:cvs_provider) do it "should use 'cvs update -dr'" do expects_chdir - provider.expects(:cvs).with('update', '-dr', @tag, '.') + Puppet::Util::Execution.expects(:execute).with([:cvs, 'update', '-dr', @tag, '.'], :custom_environment => {}) provider.revision = @tag end end -- cgit v1.2.3 From 2b927e514a3d8aef5d35094e84dee3d6b47d6bf2 Mon Sep 17 00:00:00 2001 From: Jon Fautley Date: Wed, 29 Oct 2014 11:00:33 +0000 Subject: Add spec test for invokation as a different user --- spec/unit/puppet/provider/vcsrepo/cvs_spec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb b/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb index b146d70..2e18149 100644 --- a/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb @@ -27,6 +27,15 @@ describe Puppet::Type.type(:vcsrepo).provider(:cvs_provider) do provider.create end + it "should execute 'cvs checkout' as user 'muppet'" do + resource[:source] = ':ext:source@example.com:/foo/bar' + resource[:revision] = 'an-unimportant-value' + resource[:user] = 'muppet' + expects_chdir('/tmp') + Puppet::Util::Execution.expects(:execute).with([:cvs, '-d', resource.value(:source), 'checkout', '-r', 'an-unimportant-value', '-d', 'test', 'bar'], :uid => 'muppet', :custom_environment => {}) + provider.create + end + it "should just execute 'cvs checkout' without a revision" do resource[:source] = ':ext:source@example.com:/foo/bar' resource.delete(:revision) -- cgit v1.2.3 From a79d7855e8febc2e4c8527e621f6f162e5f85db8 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 3 Nov 2014 11:56:26 -0800 Subject: 1.2.0 prep --- CHANGELOG | 99 ---------------------------------------------------- CHANGELOG.md | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ metadata.json | 10 +++--- 3 files changed, 116 insertions(+), 103 deletions(-) delete mode 100644 CHANGELOG create mode 100644 CHANGELOG.md diff --git a/CHANGELOG b/CHANGELOG deleted file mode 100644 index 1eefd22..0000000 --- a/CHANGELOG +++ /dev/null @@ -1,99 +0,0 @@ -2014-07-14 - Supported Release 1.1.0 -Summary: -This release adds a Perforce provider* and corrects the git provider behavior -when using `ensure => latest`. - -*(Only git provider is currently supported.) - -Features: -- New Perforce provider - -Bugfixes: -- (MODULES-660) Fix behavior with `ensure => latest` and detached HEAD -- Spec test fixes -2014-06-30 - Supported Release 1.0.2 -Summary: -This supported release adds SLES 11 to the list of compatible OSs and -documentation updates for support. - -2014-06-17 - Supported Release 1.0.1 - -Summary: -This release is the first supported release of vcsrepo. The readme has been -greatly improved. - -Features: -- Updated and expanded readme to follow readme template - -Fixes: -- Remove SLES from compatability metadata -- Unpin rspec development dependencies -- Update acceptance level testing - -2014-06-04 - Version 1.0.0 - -Summary: - -This release focuses on a number of bugfixes, and also has some -new features for Bzr and Git. - -Features: -- Bzr: - - Call set_ownership -- Git: - - Add ability for shallow clones - - Use -a and desired for HARD resets - - Use rev-parse to get tag canonical revision - -Fixes: -- HG: - - Only add ssh options when it's talking to the network -- Git: - - Fix for issue with detached HEAD - - force => true will now destroy and recreate repo - - Actually use the remote parameter - - Use origin/master instead of origin/HEAD when on master -- SVN: - - Fix svnlook behavior with plain directories - -2013-11-13 - Version 0.2.0 - -Summary: - -This release mainly focuses on a number of bugfixes, which should -significantly improve the reliability of Git and SVN. Thanks to -our many contributors for all of these fixes! - -Features: -- Git: - - Add autorequire for Package['git'] -- HG: - - Allow user and identity properties. -- Bzr: - - "ensure => latest" support. -- SVN: - - Added configuration parameter. - - Add support for master svn repositories. -- CVS: - - Allow for setting the CVS_RSH environment variable. - -Fixes: -- Handle Puppet::Util[::Execution].withenv for 2.x and 3.x properly. -- Change path_empty? to not do full directory listing. -- Overhaul spec tests to work with rspec2. -- Git: - - Improve Git SSH usage documentation. - - Add ssh session timeouts to prevent network issues from blocking runs. - - Fix git provider checkout of a remote ref on an existing repo. - - Allow unlimited submodules (thanks to --recursive). - - Use git checkout --force instead of short -f everywhere. - - Update git provider to handle checking out into an existing (empty) dir. -- SVN: - - Handle force property. for svn. - - Adds support for changing upstream repo url. - - Check that the URL of the WC matches the URL from the manifest. - - Changed from using "update" to "switch". - - Handle revision update without source switch. - - Fix svn provider to look for '^Revision:' instead of '^Last Changed Rev:'. -- CVS: - - Documented the "module" attribute. diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..5b8f7d1 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,110 @@ +##2014-11-04 - Supported Release 1.2.0 +###Summary + +This release includes some improvements for git, mercurial, and cvs providers, and fixes the bug where there were warnings about multiple default providers. + +####Features +- Update git and mercurial providers to set UID with `Puppet::Util::Execution.execute` instead of `su` +- Allow git excludes to be string or array +- Add `user` feature to cvs provider + +####Bugfixes +- No more warnings about multiple default providers! (MODULES-428) + +##2014-07-14 - Supported Release 1.1.0 +###Summary +This release adds a Perforce provider* and corrects the git provider behavior +when using `ensure => latest`. + +*(Only git provider is currently supported.) + +####Features +- New Perforce provider + +####Bugfixes +- (MODULES-660) Fix behavior with `ensure => latest` and detached HEAD +- Spec test fixes + +##2014-06-30 - Supported Release 1.0.2 +###Summary +This supported release adds SLES 11 to the list of compatible OSs and +documentation updates for support. + +##2014-06-17 - Supported Release 1.0.1 +###Summary +This release is the first supported release of vcsrepo. The readme has been +greatly improved. + +####Features +- Updated and expanded readme to follow readme template + +####Fixes +- Remove SLES from compatability metadata +- Unpin rspec development dependencies +- Update acceptance level testing + +##2014-06-04 - Version 1.0.0 +###Summary + +This release focuses on a number of bugfixes, and also has some +new features for Bzr and Git. + +####Features +- Bzr: + - Call set_ownership +- Git: + - Add ability for shallow clones + - Use -a and desired for HARD resets + - Use rev-parse to get tag canonical revision + +####Fixes +- HG: + - Only add ssh options when it's talking to the network +- Git: + - Fix for issue with detached HEAD + - force => true will now destroy and recreate repo + - Actually use the remote parameter + - Use origin/master instead of origin/HEAD when on master +- SVN: + - Fix svnlook behavior with plain directories + +##2013-11-13 - Version 0.2.0 +###Summary + +This release mainly focuses on a number of bugfixes, which should +significantly improve the reliability of Git and SVN. Thanks to +our many contributors for all of these fixes! + +####Features +- Git: + - Add autorequire for Package['git'] +- HG: + - Allow user and identity properties. +- Bzr: + - "ensure => latest" support. +- SVN: + - Added configuration parameter. + - Add support for master svn repositories. +- CVS: + - Allow for setting the CVS_RSH environment variable. + +####Fixes +- Handle Puppet::Util[::Execution].withenv for 2.x and 3.x properly. +- Change path_empty? to not do full directory listing. +- Overhaul spec tests to work with rspec2. +- Git: + - Improve Git SSH usage documentation. + - Add ssh session timeouts to prevent network issues from blocking runs. + - Fix git provider checkout of a remote ref on an existing repo. + - Allow unlimited submodules (thanks to --recursive). + - Use git checkout --force instead of short -f everywhere. + - Update git provider to handle checking out into an existing (empty) dir. +- SVN: + - Handle force property. for svn. + - Adds support for changing upstream repo url. + - Check that the URL of the WC matches the URL from the manifest. + - Changed from using "update" to "switch". + - Handle revision update without source switch. + - Fix svn provider to look for '^Revision:' instead of '^Last Changed Rev:'. +- CVS: + - Documented the "module" attribute. diff --git a/metadata.json b/metadata.json index 8f78acd..242583a 100644 --- a/metadata.json +++ b/metadata.json @@ -1,12 +1,12 @@ { "name": "puppetlabs-vcsrepo", - "version": "1.1.0", + "version": "1.2.0", "author": "Puppet Labs", "summary": "Puppet module providing a type to manage repositories from various version control systems", "license": "GPLv2", "source": "https://github.com/puppetlabs/puppetlabs-vcsrepo", "project_page": "https://github.com/puppetlabs/puppetlabs-vcsrepo", - "issues_url": "https://github.com/puppetlabs/puppetlabs-vcsrepo/issues", + "issues_url": "https://tickets.puppetlabs.com/browse/MODULES", "operatingsystem_support": [ { "operatingsystem": "RedHat", @@ -43,7 +43,9 @@ { "operatingsystem": "SLES", "operatingsystemrelease": [ - "11 SP1" + "10 SP4", + "11 SP1", + "12" ] }, { @@ -65,7 +67,7 @@ "requirements": [ { "name": "pe", - "version_requirement": ">= 3.2.0 < 3.4.0" + "version_requirement": "3.x" }, { "name": "puppet", -- cgit v1.2.3 From 2055ea138a8af3dcc3c077687fc216c20bb2a65e Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 3 Nov 2014 14:20:15 -0800 Subject: Add missing doc update. --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index de6ae9a..08b8865 100644 --- a/README.markdown +++ b/README.markdown @@ -489,7 +489,7 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers * `cvs_rsh` - The value to be used for the CVS_RSH environment variable. (Requires the `cvs_rsh` feature.) * `depth` - The value to be used to do a shallow clone. (Requires the `depth` feature.) * `ensure` - Determines the state of the repository. Valid values are 'present', 'bare', 'absent', 'latest'. -* `excludes` - Lists any files to be excluded from the repository. +* `excludes` - Lists any files to be excluded from the repository. Can be an array or string. * `force` - Forces repository creation. Valid values are 'true' and 'false'. **WARNING** Forcing will destroy any files in the path. * `fstype` - Sets the filesystem type. (Requires the `filesystem_types` feature.) * `group` - Determines the group/gid that owns the repository files. -- cgit v1.2.3 From ec7cb205f9b6c7aa82621e0c3143dc0ecb6457b6 Mon Sep 17 00:00:00 2001 From: Lauren Rother Date: Thu, 20 Nov 2014 11:57:00 -0800 Subject: Updates README per MODULES-1425 Adds note to Setup section stating that the module will not create parent directories or install VCS software. --- README.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.markdown b/README.markdown index 08b8865..cefa50b 100644 --- a/README.markdown +++ b/README.markdown @@ -41,6 +41,10 @@ This module provides a single type with providers for each VCS, which can be use ##Setup +Before you begin using vcsrepo, it's worth keeping in mind that this module will not install VCS software for you. If you are going to use this module, you must have already installed your preferred VCS. + +Also, this module, like Puppet generally, will not create parent directories for you. You will need to have your parent directories in place before you begin. + ###Beginning with vcsrepo To get started with the vcsrepo module, you must simply define the type `vcsrepo` with a path to your repository and the [type of VCS](#Usage) you're using in `provider` (in the below example, Git). -- cgit v1.2.3 From 548a96795e7238e1aca4d17b312bee45c2e71618 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Mon, 8 Dec 2014 10:33:44 -0800 Subject: Update .travis.yml, Gemfile, Rakefile, and CONTRIBUTING.md --- .travis.yml | 2 +- CONTRIBUTING.md | 22 ++++------------------ Gemfile | 12 +++++++----- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index c72d5e2..8cfaf23 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ --- language: ruby -bundler_args: --without development +bundler_args: --without system_tests script: "bundle exec rake spec SPEC_OPTS='--format documentation'" matrix: fast_finish: true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e128847..f1cbde4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,11 +41,9 @@ Checklist (and a short version for the impatient) * Pre-requisites: - - Sign the [Contributor License Agreement](https://cla.puppetlabs.com/) - - Make sure you have a [GitHub account](https://github.com/join) - - [Create a ticket](http://projects.puppetlabs.com/projects/modules/issues/new), or [watch the ticket](http://projects.puppetlabs.com/projects/modules/issues) you are patching for. + - [Create a ticket](https://tickets.puppetlabs.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppetlabs.com/browse/) you are patching for. * Preferred method: @@ -94,17 +92,7 @@ The long version whitespace or other "whitespace errors". You can do this by running "git diff --check" on your changes before you commit. - 2. Sign the Contributor License Agreement - - Before we can accept your changes, we do need a signed Puppet - Labs Contributor License Agreement (CLA). - - You can access the CLA via the [Contributor License Agreement link](https://cla.puppetlabs.com/) - - If you have any questions about the CLA, please feel free to - contact Puppet Labs via email at cla-submissions@puppetlabs.com. - - 3. Sending your patches + 2. Sending your patches To submit your changes via a GitHub pull request, we _highly_ recommend that you have them on a topic branch, instead of @@ -124,7 +112,7 @@ The long version in order to open a pull request. - 4. Update the related GitHub issue. + 3. Update the related GitHub issue. If there is a GitHub issue associated with the change you submitted, then you should update the ticket to include the @@ -220,14 +208,12 @@ review. Additional Resources ==================== -* [Getting additional help](http://projects.puppetlabs.com/projects/puppet/wiki/Getting_Help) +* [Getting additional help](http://puppetlabs.com/community/get-help) * [Writing tests](http://projects.puppetlabs.com/projects/puppet/wiki/Development_Writing_Tests) * [Patchwork](https://patchwork.puppetlabs.com) -* [Contributor License Agreement](https://projects.puppetlabs.com/contributor_licenses/sign) - * [General GitHub documentation](http://help.github.com/) * [GitHub pull request documentation](http://help.github.com/send-pull-requests/) diff --git a/Gemfile b/Gemfile index e960f7c..0684f19 100644 --- a/Gemfile +++ b/Gemfile @@ -1,15 +1,17 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" -group :development, :test do +group :development, :unit_tests do gem 'rake', :require => false gem 'rspec-puppet', :require => false gem 'puppetlabs_spec_helper', :require => false - gem 'serverspec', :require => false gem 'puppet-lint', :require => false - gem 'beaker', :require => false - gem 'beaker-rspec', :require => false - gem 'pry', :require => false gem 'simplecov', :require => false + gem 'puppet_facts', :require => false +end + +group :system_tests do + gem 'beaker-rspec', :require => false + gem 'serverspec', :require => false end if facterversion = ENV['FACTER_GEM_VERSION'] -- cgit v1.2.3 From 36484efe09fd6e5f3e511fccf2fb2001baeda265 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Mon, 8 Dec 2014 22:52:42 -0800 Subject: Add json gem The puppet_facts gem implicitly depends on the json gem. On Ruby 1.8.7, json is not built in. On Puppet 2.7, it is not explicitly pulled in by the hiera gem. So we add it here explicitly. --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index 0684f19..12fd363 100644 --- a/Gemfile +++ b/Gemfile @@ -7,6 +7,7 @@ group :development, :unit_tests do gem 'puppet-lint', :require => false gem 'simplecov', :require => false gem 'puppet_facts', :require => false + gem 'json', :require => false end group :system_tests do -- cgit v1.2.3 From 35cfd4b5d46f6c144ccaddfb948203ccde6b9521 Mon Sep 17 00:00:00 2001 From: Farzad FARID Date: Sat, 13 Dec 2014 16:24:49 +0100 Subject: Fix for MODULES-1597: "format" is a file not a directory The "format" entry in a SVN directory is a file, not a directory. --- lib/puppet/provider/vcsrepo/svn.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/provider/vcsrepo/svn.rb b/lib/puppet/provider/vcsrepo/svn.rb index 316a3a1..a1b1714 100644 --- a/lib/puppet/provider/vcsrepo/svn.rb +++ b/lib/puppet/provider/vcsrepo/svn.rb @@ -24,7 +24,7 @@ Puppet::Type.type(:vcsrepo).provide(:svn, :parent => Puppet::Provider::Vcsrepo) if File.directory?(@resource.value(:path)) # :path is an svn checkout return true if File.directory?(File.join(@resource.value(:path), '.svn')) - if File.directory?(File.join(@resource.value(:path), 'format')) + if File.file?(File.join(@resource.value(:path), 'format')) # :path is an svn server return true if svnlook('uuid', @resource.value(:path)) end -- cgit v1.2.3 From 56f25d57dfa26de618416e9bdd4a853296ffcbc1 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 26 Dec 2014 15:27:20 -0800 Subject: MODULES-1596 - Repository repeatedly destroyed/created with force The `retrieve` method was calling `create` and `destroy` on every run with `force => true`. Retrieve should not be making any changes to the system, so removed that code, and updated `working_copy_exists` to make sure that the directory not only contains a `.git` directory, but also if `source` is specified it also matches `#{path}/.git/config` so that it will overwrite a git repo with a different source. Updated tests to not check for the old broken behavior. Added a regression test. --- lib/puppet/provider/vcsrepo/git.rb | 6 +- lib/puppet/type/vcsrepo.rb | 10 --- .../negative/clone_over_different_exiting_repo.rb | 3 +- spec/acceptance/clone_repo_spec.rb | 4 +- spec/acceptance/modules_1596_spec.rb | 72 ++++++++++++++++++++++ spec/unit/puppet/provider/vcsrepo/git_spec.rb | 22 ------- 6 files changed, 79 insertions(+), 38 deletions(-) create mode 100644 spec/acceptance/modules_1596_spec.rb diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 1c6588c..b1e556d 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -83,7 +83,11 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) end def working_copy_exists? - File.directory?(File.join(@resource.value(:path), '.git')) + if @resource.value(:source) and File.exists?(File.join(@resource.value(:path), '.git', 'config')) + File.readlines(File.join(@resource.value(:path), '.git', 'config')).grep(/#{@resource.value(:source)}/).any? + else + File.directory?(File.join(@resource.value(:path), '.git')) + end end def exists? diff --git a/lib/puppet/type/vcsrepo.rb b/lib/puppet/type/vcsrepo.rb index f678389..b8836d4 100644 --- a/lib/puppet/type/vcsrepo.rb +++ b/lib/puppet/type/vcsrepo.rb @@ -100,16 +100,6 @@ Puppet::Type.newtype(:vcsrepo) do prov = @resource.provider if prov if prov.working_copy_exists? - if @resource.value(:force) - if noop - notice "Noop Mode - Would have deleted repository and re-created from latest" - else - notice "Deleting current repository before recloning" - prov.destroy - notice "Create repository from latest" - prov.create - end - end (@should.include?(:latest) && prov.latest?) ? :latest : :present elsif prov.class.feature?(:bare_repositories) and prov.bare_exists? :bare diff --git a/spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb b/spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb index 6826673..1e3b4bb 100644 --- a/spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb +++ b/spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb @@ -35,8 +35,7 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp, :catch_failures => true) - apply_manifest_on(host, pp, :catch_changes => true) + apply_manifest_on(host, pp, :expect_failures => true) end step 'verify original repo was not replaced' do diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb index f3e77db..4e9293b 100644 --- a/spec/acceptance/clone_repo_spec.rb +++ b/spec/acceptance/clone_repo_spec.rb @@ -350,9 +350,7 @@ describe 'clones a remote repo' do } EOS - apply_manifest(pp, :catch_changes => true) do |r| - expect(r.stdout).to match(/Noop Mode/) - end + apply_manifest(pp, :catch_changes => true) end end end diff --git a/spec/acceptance/modules_1596_spec.rb b/spec/acceptance/modules_1596_spec.rb new file mode 100644 index 0000000..fa36285 --- /dev/null +++ b/spec/acceptance/modules_1596_spec.rb @@ -0,0 +1,72 @@ +require 'spec_helper_acceptance' + +tmpdir = default.tmpdir('vcsrepo') + +describe 'clones a remote repo' do + before(:all) do + my_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + shell("mkdir -p #{tmpdir}") # win test + end + + after(:all) do + shell("rm -rf #{tmpdir}/vcsrepo") + end + + context 'force with a remote' do + it 'clones from remote' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/vcsrepo": + ensure => present, + provider => git, + source => 'https://github.com/puppetlabs/puppetlabs-vcsrepo', + force => true, + } + EOS + + # Run it twice to test for idempotency + apply_manifest(pp, :catch_failures => true) + # need to create a file to make sure we aren't destroying the repo + # because fun fact, if you call destroy/create in 'retrieve' puppet won't + # register that any changes happen, because that method isn't supposed to + # be making any changes. + shell("touch #{tmpdir}/vcsrepo/foo") + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/vcsrepo/foo") do + it { is_expected.to be_file } + end + end + + context 'force over an existing repo' do + it 'clones from remote' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/vcsrepo": + ensure => present, + provider => git, + source => 'https://github.com/puppetlabs/puppetlabs-vcsrepo', + force => true, + } + EOS + + pp2 = <<-EOS + vcsrepo { "#{tmpdir}/vcsrepo": + ensure => present, + provider => git, + source => 'https://github.com/puppetlabs/puppetlabs-stdlib', + force => true, + } + EOS + + + apply_manifest(pp, :catch_failures => true) + # create a file to make sure we're destroying the repo + shell("touch #{tmpdir}/vcsrepo/foo") + apply_manifest(pp2, :catch_failures => true) + end + + describe file("#{tmpdir}/vcsrepo/foo") do + it { is_expected.to_not be_file } + end + end +end diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index 122eb62..edc7202 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -175,28 +175,6 @@ branches provider.expects(:git).with('checkout', '--force', resource.value(:revision)) provider.create end - it "should warn about destroying it using force and noop attribute" do - resource[:force] = true - resource[:noop] = true - resource.delete(:revision) - provider.expects(:working_copy_exists?).returns(true) - - provider.expects(:destroy).never - provider.expects(:create).never - Puppet::Type::Vcsrepo::Ensure.any_instance.expects(:send_log).with(:notice, "Noop Mode - Would have deleted repository and re-created from latest") - provider.resource.retrieve - end - it "should warn about destroying it using force and global noop" do - resource[:force] = true - Puppet[:noop] = true - resource.delete(:revision) - provider.expects(:working_copy_exists?).returns(true) - - provider.expects(:destroy).never - provider.expects(:create).never - Puppet::Type::Vcsrepo::Ensure.any_instance.expects(:send_log).with(:notice, "Noop Mode - Would have deleted repository and re-created from latest") - provider.resource.retrieve - end end context "when the path is not empty and not a repository" do -- cgit v1.2.3 From 477666d6ccbf5c882ff0f2ffff117adbe9030779 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Mon, 29 Dec 2014 10:41:26 -0800 Subject: Add IntelliJ files to the ignore list --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index b5b7a00..b5db85e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ spec/fixtures/ .vagrant/ .bundle/ coverage/ +.idea/ +*.iml -- cgit v1.2.3 From 2d4abcd7b92971dba9f00e6422c4f5250a15f716 Mon Sep 17 00:00:00 2001 From: tphoney Date: Tue, 13 Jan 2015 17:06:45 -0800 Subject: removing private tests removing private tests, due to rspec3 not handling private methods --- spec/unit/puppet/provider/vcsrepo/git_spec.rb | 35 --------------------------- 1 file changed, 35 deletions(-) diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index edc7202..116e357 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -298,41 +298,6 @@ branches end end - context "checking if revision" do - before do - expects_chdir - provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a)) - end - context "is a local branch" do - context "when it's listed in 'git branch -a'" do - it "should return true" do - resource[:revision] = 'feature/foo' - expect(provider).to be_local_branch_revision - end - end - context "when it's not listed in 'git branch -a'" do - it "should return false" do - resource[:revision] = 'feature/notexist' - expect(provider).not_to be_local_branch_revision - end - end - end - context "is a remote branch" do - context "when it's listed in 'git branch -a' with an 'origin/' prefix" do - it "should return true" do - resource[:revision] = 'only/remote' - expect(provider).to be_remote_branch_revision - end - end - context "when it's not listed in 'git branch -a' with an 'origin/' prefix" do - it "should return false" do - resource[:revision] = 'only/local' - expect(provider).not_to be_remote_branch_revision - end - end - end - end - describe 'latest?' do context 'when true' do it do -- cgit v1.2.3 From 68fc802b937334eda195f28c645e43b23d3ff061 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 14 Jan 2015 08:47:57 -0800 Subject: Remove let use as variable. Since lets can't be used in before :all any more. --- spec/acceptance/clone_repo_spec.rb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb index 4e9293b..2cca061 100644 --- a/spec/acceptance/clone_repo_spec.rb +++ b/spec/acceptance/clone_repo_spec.rb @@ -327,21 +327,18 @@ describe 'clones a remote repo' do end context 'and noop' do - let(:repo_name) do - 'testrepo_already_exists' - end before(:all) do - shell("mkdir #{tmpdir}/#{repo_name}") - shell("cd #{tmpdir}/#{repo_name} && git init") - shell("cd #{tmpdir}/#{repo_name} && touch a && git add a && git commit -m 'a'") + shell("mkdir #{tmpdir}/testrepo_already_exists") + shell("cd #{tmpdir}/testrepo_already_exists && git init") + shell("cd #{tmpdir}/testrepo_already_exists && touch a && git add a && git commit -m 'a'") end after(:all) do - shell("rm -rf #{tmpdir}/#{repo_name}") + shell("rm -rf #{tmpdir}/testrepo_already_exists") end it 'applies the manifest' do pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": + vcsrepo { "#{tmpdir}/testrepo_already_exists": ensure => present, source => "file://#{tmpdir}/testrepo.git", provider => git, -- cgit v1.2.3 From dfe5f9cc316a43793da2cb1c4adbc66503907460 Mon Sep 17 00:00:00 2001 From: dduvnjak Date: Sun, 18 Jan 2015 10:49:03 +0100 Subject: Add submodules feature to git provider --- README.markdown | 14 ++++++++++++-- lib/puppet/provider/vcsrepo/git.rb | 4 ++-- lib/puppet/type/vcsrepo.rb | 9 +++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/README.markdown b/README.markdown index 08b8865..062f0f7 100644 --- a/README.markdown +++ b/README.markdown @@ -141,6 +141,15 @@ To keep the repository at the latest revision (**WARNING:** this will always ove revision => 'master', } +To clone the repository but skip initialiazing submodules, + + vcsrepo { "/path/to/repo": + ensure => latest, + provider => git, + source => 'git://example.com/repo.git', + submodules => false, + } + #####Sources that use SSH When your source uses SSH, such as 'username@server:…', you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present. @@ -479,6 +488,7 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers * `ssh_identity` - The provider supports a configurable SSH identity file. (Available with `git` and `hg`.) * `user` - The provider can run as a different user. (Available with `git`, `hg` and `cvs`.) * `p4config` - The provider support setting the P4CONFIG environment. (Available with `p4`.) +* `submodules` - The provider supports repository submodules which can be optionally initialized. (Available with `git`.) ####Parameters @@ -507,9 +517,9 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers ####Features and Parameters by Provider #####`git` -**Features**: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user` +**Features**: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`, `submodules` -**Parameters**: `depth`, `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `remote`, `revision`, `source`, `user` +**Parameters**: `depth`, `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `remote`, `revision`, `source`, `user`, `submodules` #####`bzr` **Features**: `reference_tracking` diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 1c6588c..9e1903c 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -5,7 +5,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) commands :git => 'git' - has_features :bare_repositories, :reference_tracking, :ssh_identity, :multiple_remotes, :user, :depth + has_features :bare_repositories, :reference_tracking, :ssh_identity, :multiple_remotes, :user, :depth, :submodules def create if @resource.value(:revision) and @resource.value(:ensure) == :bare @@ -18,7 +18,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) if @resource.value(:revision) checkout end - if @resource.value(:ensure) != :bare + if @resource.value(:ensure) != :bare && @resource.value(:submodules) == :true update_submodules end end diff --git a/lib/puppet/type/vcsrepo.rb b/lib/puppet/type/vcsrepo.rb index f678389..3f34c57 100644 --- a/lib/puppet/type/vcsrepo.rb +++ b/lib/puppet/type/vcsrepo.rb @@ -43,6 +43,9 @@ Puppet::Type.newtype(:vcsrepo) do feature :p4config, "The provider understands Perforce Configuration" + feature :submodules, + "The repository contains submodules which can be optionally initialized" + ensurable do attr_accessor :latest @@ -215,6 +218,12 @@ Puppet::Type.newtype(:vcsrepo) do desc "The Perforce P4CONFIG environment." end + newparam :submodules, :required_features => [:submodules] do + desc "Initialize and update each submodule in the repository." + newvalues(:true, :false) + defaultto true + end + autorequire(:package) do ['git', 'git-core'] end -- cgit v1.2.3 From 5d6ef988af1ff90b4625b0426301cb6fad0268b8 Mon Sep 17 00:00:00 2001 From: Jonathan Tripathy Date: Tue, 20 Jan 2015 23:12:20 -0800 Subject: Implemented multiple remotes feature for git provider. --- README.markdown | 14 ++++++ lib/puppet/provider/vcsrepo/git.rb | 70 ++++++++++++++++++++++++--- spec/acceptance/modules_753_spec.rb | 68 ++++++++++++++++++++++++++ spec/unit/puppet/provider/vcsrepo/git_spec.rb | 32 ++++++++++-- 4 files changed, 172 insertions(+), 12 deletions(-) create mode 100644 spec/acceptance/modules_753_spec.rb diff --git a/README.markdown b/README.markdown index 6c6f0a5..34a51e2 100644 --- a/README.markdown +++ b/README.markdown @@ -154,6 +154,20 @@ To clone the repository but skip initialiazing submodules, submodules => false, } +##### Using multiple remotes with a repository +Instead of specifying a single string in the 'source' property, you can specify a hash with multiple name => URL mappings, + + vcsrepo { "/path/to/repo": + ensure => present, + provider => git, + source => { + "origin" => "https://github.com/puppetlabs/puppetlabs-vcsrepo.git", + "other_remote" => "https://github.com/other_user/puppetlabs-vcsrepo.git" + }, + } + +It is important to note that you must specify a mapping for the remote that is specified in the 'remote' property - this is set to 'origin' by default. + #####Sources that use SSH When your source uses SSH, such as 'username@server:…', you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present. diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 13e0793..9d3f7f3 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -14,13 +14,16 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) if !@resource.value(:source) init_repository(@resource.value(:path)) else - clone_repository(@resource.value(:source), @resource.value(:path)) + clone_repository(default_url, @resource.value(:path)) + update_remotes + if @resource.value(:revision) checkout end if @resource.value(:ensure) != :bare && @resource.value(:submodules) == :true update_submodules end + end update_owner_and_excludes end @@ -82,9 +85,25 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) bare_git_config_exists? && !working_copy_exists? end + # If :source is set to a hash (for supporting multiple remotes), + # we search for the URL for :remote. If it doesn't exist, + # we throw an error. If :source is just a string, we use that + # value for the default URL. + def default_url + if @resource.value(:source).is_a?(Hash) + if @resource.value(:source).has_key?(@resource.value(:remote)) + @resource.value(:source)[@resource.value(:remote)] + else + fail("You must specify the URL for #{@resource.value(:remote)} in the :source hash") + end + else + @resource.value(:source) + end + end + def working_copy_exists? if @resource.value(:source) and File.exists?(File.join(@resource.value(:path), '.git', 'config')) - File.readlines(File.join(@resource.value(:path), '.git', 'config')).grep(/#{@resource.value(:source)}/).any? + File.readlines(File.join(@resource.value(:path), '.git', 'config')).grep(/#{default_url}/).any? else File.directory?(File.join(@resource.value(:path), '.git')) end @@ -94,18 +113,53 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) working_copy_exists? || bare_exists? end - def update_remote_origin_url - current = git_with_identity('config', "remote.#{@resource.value(:remote)}.url") - unless @resource.value(:source).nil? - if current.nil? or current.strip != @resource.value(:source) - git_with_identity('config', "remote.#{@resource.value(:remote)}.url", @resource.value(:source)) + def update_remote_url(remote_name, remote_url) + do_update = false + current = git_with_identity('config', '-l') + + unless remote_url.nil? + # Check if remote exists at all, regardless of URL. + # If remote doesn't exist, add it + if not current.include? "remote.#{remote_name}.url" + git_with_identity('remote','add', remote_name, remote_url) + return true + + # If remote exists, but URL doesn't match, update URL + elsif not current.include? "remote.#{remote_name}.url=#{remote_url}" + git_with_identity('remote','set-url', remote_name, remote_url) + return true + else + return false end end + + end + + def update_remotes + do_update = false + + # If supplied source is a hash of remote name and remote url pairs, then + # we loop around the hash. Otherwise, we assume single url specified + # in source property + if @resource.value(:source).is_a?(Hash) + @resource.value(:source).each do |remote_name, remote_url| + at_path { do_update |= update_remote_url(remote_name, remote_url) } + end + else + at_path { do_update |= update_remote_url(@resource.value(:remote), @resource.value(:source)) } + end + + # If at least one remote was added or updated, then we must + # call the 'git remote update' command + if do_update == true + at_path { git_with_identity('remote','update') } + end + end def update_references at_path do - update_remote_origin_url + update_remotes git_with_identity('fetch', @resource.value(:remote)) git_with_identity('fetch', '--tags', @resource.value(:remote)) update_owner_and_excludes diff --git a/spec/acceptance/modules_753_spec.rb b/spec/acceptance/modules_753_spec.rb new file mode 100644 index 0000000..e4e332b --- /dev/null +++ b/spec/acceptance/modules_753_spec.rb @@ -0,0 +1,68 @@ +require 'spec_helper_acceptance' + +tmpdir = default.tmpdir('vcsrepo') + +describe 'clones a remote repo' do + before(:all) do + my_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + shell("mkdir -p #{tmpdir}") # win test + end + + after(:all) do + shell("rm -rf #{tmpdir}/vcsrepo") + end + + context 'clone with single remote' do + it 'clones from default remote' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/vcsrepo": + ensure => present, + provider => git, + source => "https://github.com/puppetlabs/puppetlabs-vcsrepo.git", + } + EOS + + apply_manifest(pp, :catch_failures => true) + + end + + it "git config output should contain the remote" do + shell("/usr/bin/git config -l -f #{tmpdir}/vcsrepo/.git/config") do |r| + expect(r.stdout).to match(/remote.origin.url=https:\/\/github.com\/puppetlabs\/puppetlabs-vcsrepo.git/) + end + end + + after(:all) do + shell("rm -rf #{tmpdir}/vcsrepo") + end + + end + + context 'clone with multiple remotes' do + it 'clones from default remote and adds 2 remotes to config file' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/vcsrepo": + ensure => present, + provider => git, + source => {"origin" => "https://github.com/puppetlabs/puppetlabs-vcsrepo.git", "test1" => "https://github.com/puppetlabs/puppetlabs-vcsrepo.git"}, + } + EOS + + apply_manifest(pp, :catch_failures => true) + + end + + it "git config output should contain the remotes" do + shell("/usr/bin/git config -l -f #{tmpdir}/vcsrepo/.git/config") do |r| + expect(r.stdout).to match(/remote.origin.url=https:\/\/github.com\/puppetlabs\/puppetlabs-vcsrepo.git/) + expect(r.stdout).to match(/remote.test1.url=https:\/\/github.com\/puppetlabs\/puppetlabs-vcsrepo.git/) + end + end + + after(:all) do + shell("rm -rf #{tmpdir}/vcsrepo") + end + + end + +end diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index 116e357..d0153a1 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -35,6 +35,7 @@ branches Dir.expects(:chdir).with('/tmp/test').at_least_once.yields provider.expects(:git).with('clone', resource.value(:source), resource.value(:path)) provider.expects(:update_submodules) + provider.expects(:update_remote_url).with("origin", resource.value(:source)).returns false provider.expects(:git).with('branch', '-a').returns(branch_a_list(resource.value(:revision))) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) provider.create @@ -48,6 +49,7 @@ branches Dir.expects(:chdir).with('/tmp/test').at_least_once.yields provider.expects(:git).with('clone', '--origin', 'not_origin', resource.value(:source), resource.value(:path)) provider.expects(:update_submodules) + provider.expects(:update_remote_url).with("not_origin", resource.value(:source)).returns false provider.expects(:git).with('branch', '-a').returns(branch_a_list(resource.value(:revision))) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) provider.create @@ -62,6 +64,7 @@ branches Dir.expects(:chdir).with('/tmp/test').at_least_once.yields provider.expects(:git).with('clone', '--depth', '1', resource.value(:source), resource.value(:path)) provider.expects(:update_submodules) + provider.expects(:update_remote_url).with("origin", resource.value(:source)).returns false provider.expects(:git).with('branch', '-a').returns(branch_a_list(resource.value(:revision))) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) provider.create @@ -75,6 +78,7 @@ branches Dir.expects(:chdir).with('/tmp/test').at_least_once.yields provider.expects(:git).with('clone', resource.value(:source), resource.value(:path)) provider.expects(:update_submodules) + provider.expects(:update_remote_url).with("origin", resource.value(:source)).returns false provider.expects(:git).with('branch', '-a').returns(branch_a_list(resource.value(:revision))) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) provider.create @@ -84,6 +88,7 @@ branches resource.delete(:revision) provider.expects(:git).with('clone', resource.value(:source), resource.value(:path)) provider.expects(:update_submodules) + provider.expects(:update_remotes) provider.create end end @@ -100,6 +105,7 @@ branches resource[:ensure] = :bare resource.delete(:revision) provider.expects(:git).with('clone', '--bare', resource.value(:source), resource.value(:path)) + provider.expects(:update_remotes) provider.create end end @@ -171,6 +177,7 @@ branches provider.destroy provider.expects(:git).with('clone',resource.value(:source), resource.value(:path)) provider.expects(:update_submodules) + provider.expects(:update_remote_url).with("origin", resource.value(:source)).returns false provider.expects(:git).with('branch', '-a').returns(branch_a_list(resource.value(:revision))) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) provider.create @@ -211,6 +218,7 @@ branches context "when its SHA is not different than the current SHA" do it "should return the ref" do provider.expects(:git).with('rev-parse', resource.value(:revision)).returns('currentsha') + provider.expects(:update_remotes) expect(provider.revision).to eq(resource.value(:revision)) end end @@ -218,6 +226,7 @@ branches context "when its SHA is different than the current SHA" do it "should return the current SHA" do provider.expects(:git).with('rev-parse', resource.value(:revision)).returns('othersha') + provider.expects(:update_remotes) expect(provider.revision).to eq(resource.value(:revision)) end end @@ -226,6 +235,7 @@ branches it "should return the revision" do provider.stubs(:git).with('branch', '-a').returns(" remotes/origin/#{resource.value(:revision)}") provider.expects(:git).with('rev-parse', "origin/#{resource.value(:revision)}").returns("newsha") + provider.expects(:update_remotes) expect(provider.revision).to eq(resource.value(:revision)) end end @@ -234,7 +244,7 @@ branches it "should fail" do provider.expects(:git).with('branch', '-a').returns(branch_a_list) provider.expects(:git).with('rev-parse', '--revs-only', resource.value(:revision)).returns('') - + provider.expects(:update_remotes) expect { provider.revision }.to raise_error(Puppet::Error, /not a local or remote ref$/) end end @@ -242,12 +252,26 @@ branches context "when the source is modified" do it "should update the origin url" do resource[:source] = 'git://git@foo.com/bar.git' - provider.expects(:git).with('config', 'remote.origin.url').returns('old') - provider.expects(:git).with('config', 'remote.origin.url', 'git://git@foo.com/bar.git') + provider.expects(:git).with('config', '-l').returns("remote.origin.url=git://git@foo.com/foo.git\n") + provider.expects(:git).with('remote', 'set-url', 'origin', 'git://git@foo.com/bar.git') + provider.expects(:git).with('remote','update') provider.expects(:git).with('rev-parse', resource.value(:revision)).returns('currentsha') expect(provider.revision).to eq(resource.value(:revision)) end end + + context "when multiple sources are modified" do + it "should update the urls" do + resource[:source] = {"origin" => "git://git@foo.com/bar.git", "new_remote" => "git://git@foo.com/baz.git"} + provider.expects(:git).at_least_once.with('config', '-l').returns("remote.origin.url=git://git@foo.com/foo.git\n", "remote.origin.url=git://git@foo.com/bar.git\n") + provider.expects(:git).with('remote', 'set-url', 'origin', 'git://git@foo.com/bar.git') + provider.expects(:git).with('remote', 'add', 'new_remote', 'git://git@foo.com/baz.git') + provider.expects(:git).with('remote','update') + provider.expects(:git).with('rev-parse', resource.value(:revision)).returns('currentsha') + expect(provider.revision).to eq(resource.value(:revision)) + end + end + end context "setting the revision property" do @@ -291,7 +315,7 @@ branches it "should use 'git fetch --tags'" do resource.delete(:source) expects_chdir - provider.expects(:git).with('config', 'remote.origin.url').returns('') + provider.expects(:git).with('config', '-l').returns("remote.origin.url=git://git@foo.com/foo.git\n") provider.expects(:git).with('fetch', 'origin') provider.expects(:git).with('fetch', '--tags', 'origin') provider.update_references -- cgit v1.2.3 From 28f8646e4669bacf7a87ffc8694715333355cd32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?W=C5=82odzimierz=20Gajda?= Date: Wed, 22 Oct 2014 10:02:29 +0200 Subject: Use branch parameter --- lib/puppet/provider/vcsrepo/git.rb | 5 ++++- lib/puppet/type/vcsrepo.rb | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 9d3f7f3..8a8c12f 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -5,7 +5,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) commands :git => 'git' - has_features :bare_repositories, :reference_tracking, :ssh_identity, :multiple_remotes, :user, :depth, :submodules + has_features :bare_repositories, :reference_tracking, :ssh_identity, :multiple_remotes, :user, :depth, :branch, :submodules def create if @resource.value(:revision) and @resource.value(:ensure) == :bare @@ -180,6 +180,9 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) if @resource.value(:depth) and @resource.value(:depth).to_i > 0 args.push('--depth', @resource.value(:depth).to_s) end + if @resource.value(:branch) + args.push('--branch', @resource.value(:branch).to_s) + end if @resource.value(:ensure) == :bare args << '--bare' end diff --git a/lib/puppet/type/vcsrepo.rb b/lib/puppet/type/vcsrepo.rb index 3bf4029..fdcf9ab 100644 --- a/lib/puppet/type/vcsrepo.rb +++ b/lib/puppet/type/vcsrepo.rb @@ -40,6 +40,9 @@ Puppet::Type.newtype(:vcsrepo) do feature :depth, "The provider can do shallow clones" + feature :branch, + "The name of the branch" + feature :p4config, "The provider understands Perforce Configuration" @@ -204,6 +207,10 @@ Puppet::Type.newtype(:vcsrepo) do desc "The value to be used to do a shallow clone." end + newparam :branch, :required_features => [:branch] do + desc "The name of the branch to clone." + end + newparam :p4config, :required_features => [:p4config] do desc "The Perforce P4CONFIG environment." end -- cgit v1.2.3 From cf5c8e6e9fb46115d59ec4e3b5d433e29168fe00 Mon Sep 17 00:00:00 2001 From: Ernesto Ruy Sanchez Date: Fri, 30 Jan 2015 10:46:59 -0800 Subject: Added submodules true condition before update_submodules on revision method --- lib/puppet/provider/vcsrepo/git.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 9d3f7f3..e31a76c 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -20,7 +20,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) if @resource.value(:revision) checkout end - if @resource.value(:ensure) != :bare && @resource.value(:submodules) == :true + if @resource.value(:ensure) != :bare && @resource.value(:submodules) == :true && @resource.value(:submodules) == :true update_submodules end @@ -75,7 +75,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) at_path { git_with_identity('reset', '--hard', "#{@resource.value(:remote)}/#{desired}") } end #TODO Would this ever reach here if it is bare? - if @resource.value(:ensure) != :bare + if @resource.value(:ensure) != :bare && @resource.value(:submodules) == :true update_submodules end update_owner_and_excludes -- cgit v1.2.3 From 56852e9cbf93c3f6f5db7dcdd40b3d364b548182 Mon Sep 17 00:00:00 2001 From: Ernesto Ruy Sanchez Date: Fri, 30 Jan 2015 11:01:01 -0800 Subject: Bugfix: removed duplicated condition --- lib/puppet/provider/vcsrepo/git.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index e31a76c..dde9bf0 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -20,7 +20,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) if @resource.value(:revision) checkout end - if @resource.value(:ensure) != :bare && @resource.value(:submodules) == :true && @resource.value(:submodules) == :true + if @resource.value(:ensure) != :bare && @resource.value(:submodules) == :true update_submodules end -- cgit v1.2.3 From 9f129ffd9764e797fe45557a6b04e968f5b4212e Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Wed, 4 Feb 2015 17:00:39 +0100 Subject: Pin rspec gems --- Gemfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 12fd363..62c5693 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,8 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" group :development, :unit_tests do gem 'rake', :require => false - gem 'rspec-puppet', :require => false + gem 'rspec-core', '3.1.7', :require => false + gem 'rspec-puppet', '~> 1.0', :require => false gem 'puppetlabs_spec_helper', :require => false gem 'puppet-lint', :require => false gem 'simplecov', :require => false -- cgit v1.2.3 From 6bf794483ac41d2cffebec338eb926682897cef8 Mon Sep 17 00:00:00 2001 From: Ricky Ng Date: Thu, 12 Feb 2015 14:49:41 -0600 Subject: Update README.markdown Clarified what the parameter 'excludes' is intended to do. --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 34a51e2..9671fc5 100644 --- a/README.markdown +++ b/README.markdown @@ -517,7 +517,7 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers * `cvs_rsh` - The value to be used for the CVS_RSH environment variable. (Requires the `cvs_rsh` feature.) * `depth` - The value to be used to do a shallow clone. (Requires the `depth` feature.) * `ensure` - Determines the state of the repository. Valid values are 'present', 'bare', 'absent', 'latest'. -* `excludes` - Lists any files to be excluded from the repository. Can be an array or string. +* `excludes` - Lists any files to be excluded from being tracked by the repository (similiar to .gitignore). Can be an array or string. * `force` - Forces repository creation. Valid values are 'true' and 'false'. **WARNING** Forcing will destroy any files in the path. * `fstype` - Sets the filesystem type. (Requires the `filesystem_types` feature.) * `group` - Determines the group/gid that owns the repository files. -- cgit v1.2.3 From 7fdfa1b4047e134053f6df95f414cb3fc44796cd Mon Sep 17 00:00:00 2001 From: Daniel DiSisto Date: Fri, 6 Mar 2015 17:01:38 +1100 Subject: (MODULES-1551) Add support for SVN conflict handling --- lib/puppet/provider/vcsrepo/svn.rb | 7 ++++- lib/puppet/type/vcsrepo.rb | 7 +++++ spec/unit/puppet/provider/vcsrepo/svn_spec.rb | 43 +++++++++++++++++++++------ 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/lib/puppet/provider/vcsrepo/svn.rb b/lib/puppet/provider/vcsrepo/svn.rb index a1b1714..905d5ad 100644 --- a/lib/puppet/provider/vcsrepo/svn.rb +++ b/lib/puppet/provider/vcsrepo/svn.rb @@ -7,7 +7,7 @@ Puppet::Type.type(:vcsrepo).provide(:svn, :parent => Puppet::Provider::Vcsrepo) :svnadmin => 'svnadmin', :svnlook => 'svnlook' - has_features :filesystem_types, :reference_tracking, :basic_auth, :configuration + has_features :filesystem_types, :reference_tracking, :basic_auth, :configuration, :conflict def create if !@resource.value(:source) @@ -92,6 +92,11 @@ Puppet::Type.type(:vcsrepo).provide(:svn, :parent => Puppet::Provider::Vcsrepo) else buildargs.push('update', '-r', desired) end + + if @resource.value(:conflict) + args.push('--accept', @resource.value(:conflict)) + end + at_path do svn(*args) end diff --git a/lib/puppet/type/vcsrepo.rb b/lib/puppet/type/vcsrepo.rb index 3bf4029..52eace8 100644 --- a/lib/puppet/type/vcsrepo.rb +++ b/lib/puppet/type/vcsrepo.rb @@ -46,6 +46,9 @@ Puppet::Type.newtype(:vcsrepo) do feature :submodules, "The repository contains submodules which can be optionally initialized" + feature :conflict, + "The provider supports automatic conflict resolution" + ensurable do attr_accessor :latest @@ -214,6 +217,10 @@ Puppet::Type.newtype(:vcsrepo) do defaultto true end + newparam :conflict do + desc "The action to take if conflicts exist between repository and working copy" + end + autorequire(:package) do ['git', 'git-core'] end diff --git a/spec/unit/puppet/provider/vcsrepo/svn_spec.rb b/spec/unit/puppet/provider/vcsrepo/svn_spec.rb index 494da52..77f0e03 100644 --- a/spec/unit/puppet/provider/vcsrepo/svn_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/svn_spec.rb @@ -83,10 +83,22 @@ describe Puppet::Type.type(:vcsrepo).provider(:svn) do before do @revision = '30' end - it "should use 'svn update'" do - expects_chdir - provider.expects(:svn).with('--non-interactive', 'update', '-r', @revision) - provider.revision = @revision + context 'with conflict' do + it "should use 'svn update'" do + resource[:conflict] = 'theirs-full' + expects_chdir + provider.expects(:svn).with('--non-interactive', 'update', + '-r', @revision, + '--accept', resource.value(:conflict)) + provider.revision = @revision + end + end + context 'without conflict' do + it "should use 'svn update'" do + expects_chdir + provider.expects(:svn).with('--non-interactive', 'update', '-r', @revision) + provider.revision = @revision + end end end @@ -94,11 +106,24 @@ describe Puppet::Type.type(:vcsrepo).provider(:svn) do before do @revision = '30' end - it "should use 'svn switch'" do - resource[:source] = 'an-unimportant-value' - expects_chdir - provider.expects(:svn).with('--non-interactive', 'switch', '-r', @revision, 'an-unimportant-value') - provider.revision = @revision + context 'with conflict' do + it "should use 'svn switch'" do + resource[:source] = 'an-unimportant-value' + resource[:conflict] = 'theirs-full' + expects_chdir + provider.expects(:svn).with('--non-interactive', 'switch', + '-r', @revision, 'an-unimportant-value', + '--accept', resource.value(:conflict)) + provider.revision = @revision + end + end + context 'without conflict' do + it "should use 'svn switch'" do + resource[:source] = 'an-unimportant-value' + expects_chdir + provider.expects(:svn).with('--non-interactive', 'switch', '-r', @revision, 'an-unimportant-value') + provider.revision = @revision + end end end -- cgit v1.2.3 From 1089bf192413a9b6f64d1087cc623d6532477337 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Thu, 19 Mar 2015 16:22:07 -0700 Subject: Unpin rspec-puppet and remove unneeded deps puppetlabs_spec_helper takes care of these for us. --- Gemfile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Gemfile b/Gemfile index 62c5693..cc77f38 100644 --- a/Gemfile +++ b/Gemfile @@ -1,11 +1,8 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" group :development, :unit_tests do - gem 'rake', :require => false gem 'rspec-core', '3.1.7', :require => false - gem 'rspec-puppet', '~> 1.0', :require => false gem 'puppetlabs_spec_helper', :require => false - gem 'puppet-lint', :require => false gem 'simplecov', :require => false gem 'puppet_facts', :require => false gem 'json', :require => false -- cgit v1.2.3 From 6ec1fc6a118579c4983aecf5275dbfdd00f59392 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Mon, 23 Mar 2015 12:04:20 -0700 Subject: Keep testing on puppet 2.7 The modulesync config repo is dropping universal support for puppet 2.7, but individual repos should still keep support until the next naturally-occuring major release. --- .sync.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.sync.yml b/.sync.yml index 6fa460a..02c6c83 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,6 +1,11 @@ --- .travis.yml: script: "\"bundle exec rake spec SPEC_OPTS='--format documentation'\"" + extras: + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" Rakefile: unmanaged: true spec/spec_helper.rb: -- cgit v1.2.3 From 7dc0025a0c8f3ddea12bf642a69a62e22daef071 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Mon, 23 Mar 2015 12:30:36 -0700 Subject: Update .travis.yml This commit makes the following changes to the test matrix: - Runs tests on ruby 2.1.5 instead of 2.0.0 - Runs tests on ruby 1.8.7 with puppet 3.x - Adds an environment to run on an intermediate 3.x puppet version instead of latest (specifically 3.4.x) - Adds an environment to run with the future parser on latest puppet. This would affect the test runs for the validate and spec checks. - Runs the tests on docker --- .travis.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8cfaf23..0fc75e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,28 @@ --- +sudo: false language: ruby bundler_args: --without system_tests script: "bundle exec rake spec SPEC_OPTS='--format documentation'" matrix: fast_finish: true include: + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 3.4.0" - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" - - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" + env: PUPPET_GEM_VERSION="~> 3.0" - rvm: 1.9.3 env: PUPPET_GEM_VERSION="~> 3.0" - - rvm: 2.0.0 + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" + - rvm: 2.1.5 env: PUPPET_GEM_VERSION="~> 3.0" + - rvm: 2.1.5 + env: PUPPET_GEM_VERSION="~> 3.4.0" + - rvm: 2.1.5 + env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" notifications: email: false -- cgit v1.2.3 From 76d98c9f1e814accef18002ff3c92fc22bf79b27 Mon Sep 17 00:00:00 2001 From: Alice Nodelman Date: Tue, 24 Mar 2015 15:11:45 -0700 Subject: (BKR-147) add Gemfile setting for BEAKER_VERSION for puppet... puppetdb, etc - support for BEAKER_VERSION and BEAKER_RSPEC_VERSION in gemfile --- Gemfile | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 62c5693..e1ae0fa 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,15 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" +def location_for(place, fake_version = nil) + if place =~ /^(git:[^#]*)#(.*)/ + [fake_version, { :git => $1, :branch => $2, :require => false }].compact + elsif place =~ /^file:\/\/(.*)/ + ['>= 0', { :path => File.expand_path($1), :require => false }] + else + [place, { :require => false }] + end +end + group :development, :unit_tests do gem 'rake', :require => false gem 'rspec-core', '3.1.7', :require => false @@ -11,8 +21,17 @@ group :development, :unit_tests do gem 'json', :require => false end +beaker_version = ENV['BEAKER_VERSION'] +beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] group :system_tests do - gem 'beaker-rspec', :require => false + if beaker_version + gem 'beaker', *location_for(beaker_version) + end + if beaker_rspec_version + gem 'beaker-rspec', *location_for(beaker_rspec_version) + else + gem 'beaker-rspec', :require => false + end gem 'serverspec', :require => false end -- cgit v1.2.3 From d27759141ec5592fd5d76861efa77a55d07c90a8 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Wed, 25 Mar 2015 12:04:16 -0700 Subject: Fix remote hash ordering for unit tests Without this commit, the unit tests for the git provider changing multiple remotes mocks the remotes in a particular order. While in practice it doesn't matter which remote the update_remotes method updates first, the unit tests must be able to mock them in the correct order. For ruby 1.8.7, a Hash will not necessarily produce key value pairs in the same order on each run, which causes intermittent failures in the unit tests. This change sorts the :source property values before trying to update them, and updates the unit tests to expect the values in alphabetical order. --- lib/puppet/provider/vcsrepo/git.rb | 3 ++- spec/unit/puppet/provider/vcsrepo/git_spec.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 9d3f7f3..000032e 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -142,7 +142,8 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) # we loop around the hash. Otherwise, we assume single url specified # in source property if @resource.value(:source).is_a?(Hash) - @resource.value(:source).each do |remote_name, remote_url| + @resource.value(:source).keys.sort.each do |remote_name| + remote_url = @resource.value(:source)[remote_name] at_path { do_update |= update_remote_url(remote_name, remote_url) } end else diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index d0153a1..d33c98a 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -263,7 +263,7 @@ branches context "when multiple sources are modified" do it "should update the urls" do resource[:source] = {"origin" => "git://git@foo.com/bar.git", "new_remote" => "git://git@foo.com/baz.git"} - provider.expects(:git).at_least_once.with('config', '-l').returns("remote.origin.url=git://git@foo.com/foo.git\n", "remote.origin.url=git://git@foo.com/bar.git\n") + provider.expects(:git).at_least_once.with('config', '-l').returns("remote.origin.url=git://git@foo.com/bar.git\n", "remote.origin.url=git://git@foo.com/foo.git\n") provider.expects(:git).with('remote', 'set-url', 'origin', 'git://git@foo.com/bar.git') provider.expects(:git).with('remote', 'add', 'new_remote', 'git://git@foo.com/baz.git') provider.expects(:git).with('remote','update') -- cgit v1.2.3 From a618f2be009b44df5fe91a1d6863bb55bc50020f Mon Sep 17 00:00:00 2001 From: Andrew Grimberg Date: Mon, 6 Apr 2015 12:23:22 -0700 Subject: Clean up puppet lint warnings There were puppet lint warnings due to indentation in several examples. This commit cleans up the warnings. Signed-off-by: Andrew Grimberg --- examples/p4/create_client.pp | 4 ++-- examples/p4/delete_client.pp | 4 ++-- examples/p4/latest_client.pp | 6 +++--- examples/p4/sync_client.pp | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/p4/create_client.pp b/examples/p4/create_client.pp index 0f8233a..3cf9160 100644 --- a/examples/p4/create_client.pp +++ b/examples/p4/create_client.pp @@ -1,4 +1,4 @@ vcsrepo { '/tmp/vcstest/p4_client_root': - ensure => present, - provider => 'p4', + ensure => present, + provider => 'p4', } diff --git a/examples/p4/delete_client.pp b/examples/p4/delete_client.pp index 1e305f1..82c9c95 100644 --- a/examples/p4/delete_client.pp +++ b/examples/p4/delete_client.pp @@ -1,4 +1,4 @@ vcsrepo { '/tmp/vcstest/p4_client_root': - ensure => absent, - provider => 'p4', + ensure => absent, + provider => 'p4', } diff --git a/examples/p4/latest_client.pp b/examples/p4/latest_client.pp index a7caeb6..106ef9e 100644 --- a/examples/p4/latest_client.pp +++ b/examples/p4/latest_client.pp @@ -1,5 +1,5 @@ vcsrepo { '/tmp/vcstest/p4_client_root': - ensure => latest, - provider => 'p4', - source => '//depot/...', + ensure => latest, + provider => 'p4', + source => '//depot/...', } diff --git a/examples/p4/sync_client.pp b/examples/p4/sync_client.pp index fc0e29c..33e4731 100644 --- a/examples/p4/sync_client.pp +++ b/examples/p4/sync_client.pp @@ -1,6 +1,6 @@ vcsrepo { '/tmp/vcstest/p4_client_root': - ensure => present, - provider => 'p4', - source => '//depot/...', - revision => '30', + ensure => present, + provider => 'p4', + source => '//depot/...', + revision => '30', } -- cgit v1.2.3 From 1be44c3b95b8e01ac583661c5f9465c141cf82da Mon Sep 17 00:00:00 2001 From: Bill Weiss Date: Wed, 8 Apr 2015 12:24:28 -0500 Subject: Just bumping the expiration date... --- spec/acceptance/files/server.crt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/acceptance/files/server.crt b/spec/acceptance/files/server.crt index ef1de5a..270f65c 100644 --- a/spec/acceptance/files/server.crt +++ b/spec/acceptance/files/server.crt @@ -1,13 +1,13 @@ -----BEGIN CERTIFICATE----- -MIICATCCAWoCCQCS3fQotV10LzANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJB -VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0 -cyBQdHkgTHRkMB4XDTE0MDQyMzIyMzEyM1oXDTE1MDQyMzIyMzEyM1owRTELMAkG -A1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0 +MIICATCCAWoCCQDRobnOvvkStDANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJB +VTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0 +cyBQdHkgTHRkMB4XDTE1MDQwODE3MjM1NVoXDTI1MDQwNTE3MjM1NVowRTELMAkG +A1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0 IFdpZGdpdHMgUHR5IEx0ZDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAyRTv uX6328aQ5Auc8PI+xNaCiE0UZNYcs+xq3AEkR/Tnz0HGXdx3+PnFG7MIRSS65hXA VGenZk3wP4vNIe9gu+G9jtOFTJOgoOBUnJ/Hcs79Zgcmz3cAWQpqww+CZpyngUDS msZ5HoEbNS+qaIron3IrYCgPsy1BHFs5ze7JrtcCAwEAATANBgkqhkiG9w0BAQUF -AAOBgQA2uLvdc1cf+nt7d8Lmu0SdaoIsCzh6DjVscCpFJKXdDjGT2Ys40iKbLRnY -Tt98wa6uRzEhSKfx+zVi8n3PSkQHlER7jzKFXMVx8NEt2/O/APKXVizmLFjk5WcT -FvGmmbkqX+Nj9TUTuSRZEmF776r5k8U5ABu/VarxvAzyoXAhqA== +AAOBgQCaYVv8WbFbrnLMOcyjE7GjSmVh68fEN+AqntZa1Z5GOv6OQIN9mVSoNxWo +lb/9xmldfMQThgKckHHvB5Q9kf923nMQZOi8yxyaoeYWrkglkFFU/sdF6yuFBdUU +D+rXmHnS754FLTGDzESmlRVUCYuwVgrRdm+P+wu2+lZT3x85VA== -----END CERTIFICATE----- -- cgit v1.2.3 From c858962ef98782f261043c4d5d6dd2ab182afaec Mon Sep 17 00:00:00 2001 From: Rob Nelson Date: Tue, 14 Apr 2015 21:29:37 +0000 Subject: Enforce the style guide's recommendation of single quotes as the default. --- README.markdown | 108 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/README.markdown b/README.markdown index 9671fc5..2433d99 100644 --- a/README.markdown +++ b/README.markdown @@ -49,7 +49,7 @@ Also, this module, like Puppet generally, will not create parent directories for To get started with the vcsrepo module, you must simply define the type `vcsrepo` with a path to your repository and the [type of VCS](#Usage) you're using in `provider` (in the below example, Git). - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => git, } @@ -75,14 +75,14 @@ The vcsrepo module works with the following VCSs: To create a blank repository suitable for use as a central repository, define `vcsrepo` without `source` or `revision`. - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => git, } If you're defining `vcsrepo` for a central or official repository, you may want to make it a bare repository. You do this by setting `ensure` to 'bare' rather than 'present'. - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => bare, provider => git, } @@ -91,17 +91,17 @@ If you're defining `vcsrepo` for a central or official repository, you may want To get the current HEAD on the master branch, - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => git, - source => "git://example.com/repo.git", + source => 'git://example.com/repo.git', } To get a specific revision or branch (can be a commit SHA, tag, or branch name), **SHA** - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => git, source => 'git://example.com/repo.git', @@ -110,7 +110,7 @@ To get a specific revision or branch (can be a commit SHA, tag, or branch name), **Tag** - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => git, source => 'git://example.com/repo.git', @@ -119,7 +119,7 @@ To get a specific revision or branch (can be a commit SHA, tag, or branch name), **Branch name** - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => git, source => 'git://example.com/repo.git', @@ -128,7 +128,7 @@ To get a specific revision or branch (can be a commit SHA, tag, or branch name), To check out a branch as a specific user, - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => git, source => 'git://example.com/repo.git', @@ -138,7 +138,7 @@ To check out a branch as a specific user, To keep the repository at the latest revision (**WARNING:** this will always overwrite local changes to the repository), - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => latest, provider => git, source => 'git://example.com/repo.git', @@ -147,7 +147,7 @@ To keep the repository at the latest revision (**WARNING:** this will always ove To clone the repository but skip initialiazing submodules, - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => latest, provider => git, source => 'git://example.com/repo.git', @@ -157,12 +157,12 @@ To clone the repository but skip initialiazing submodules, ##### Using multiple remotes with a repository Instead of specifying a single string in the 'source' property, you can specify a hash with multiple name => URL mappings, - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => git, source => { - "origin" => "https://github.com/puppetlabs/puppetlabs-vcsrepo.git", - "other_remote" => "https://github.com/other_user/puppetlabs-vcsrepo.git" + origin => 'https://github.com/puppetlabs/puppetlabs-vcsrepo.git', + other_remote => 'https://github.com/other_user/puppetlabs-vcsrepo.git' }, } @@ -187,7 +187,7 @@ For more examples using Git, see `examples/git/`. To create a blank repository suitable for use as a central repository, define `vcsrepo` without `source` or `revision`. - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => bzr, } @@ -196,7 +196,7 @@ define `vcsrepo` without `source` or `revision`. Provide the `source` location to branch from an existing repository. - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => bzr, source => 'lp:myproj', @@ -205,7 +205,7 @@ Provide the `source` location to branch from an existing repository. For a specific revision, use `revision` with a valid revisionspec (see `bzr help revisionspec` for more information on formatting a revision). - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => bzr, source => 'lp:myproj', @@ -228,7 +228,7 @@ For more examples using Bazaar, see `examples/bzr/`. To create a blank repository suitable for use as a central repository, define `vcsrepo` without `source` or `revision`. - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => cvs, } @@ -237,39 +237,39 @@ define `vcsrepo` without `source` or `revision`. To get the current mainline, - vcsrepo { "/path/to/workspace": + vcsrepo { '/path/to/workspace': ensure => present, provider => cvs, - source => ":pserver:anonymous@example.com:/sources/myproj", + source => ':pserver:anonymous@example.com:/sources/myproj', } To get a specific module on the current mainline, - vcsrepo {"/vagrant/lockss-daemon-source": + vcsrepo {'/vagrant/lockss-daemon-source': ensure => present, provider => cvs, - source => ":pserver:anonymous@lockss.cvs.sourceforge.net:/cvsroot/lockss", - module => "lockss-daemon", + source => ':pserver:anonymous@lockss.cvs.sourceforge.net:/cvsroot/lockss', + module => 'lockss-daemon', } You can use the `compression` parameter to set the GZIP compression levels for your repository history. - vcsrepo { "/path/to/workspace": + vcsrepo { '/path/to/workspace': ensure => present, provider => cvs, compression => 3, - source => ":pserver:anonymous@example.com:/sources/myproj", + source => ':pserver:anonymous@example.com:/sources/myproj', } For a specific tag, use `revision`. - vcsrepo { "/path/to/workspace": + vcsrepo { '/path/to/workspace': ensure => present, provider => cvs, compression => 3, - source => ":pserver:anonymous@example.com:/sources/myproj", - revision => "SOMETAG", + source => ':pserver:anonymous@example.com:/sources/myproj', + revision => 'SOMETAG', } #####Sources that use SSH @@ -287,7 +287,7 @@ For for more examples using CVS, see `examples/cvs/`. To create a blank repository suitable for use as a central repository, define `vcsrepo` without `source` or `revision`. - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => hg, } @@ -296,51 +296,51 @@ define `vcsrepo` without `source` or `revision`. To get the default branch tip, - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => hg, - source => "http://hg.example.com/myrepo", + source => 'http://hg.example.com/myrepo', } For a specific changeset, use `revision`. - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => hg, - source => "http://hg.example.com/myrepo", + source => 'http://hg.example.com/myrepo', revision => '21ea4598c962', } You can also set `revision` to a tag. - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => hg, - source => "http://hg.example.com/myrepo", + source => 'http://hg.example.com/myrepo', revision => '1.1.2', } To check out as a specific user, - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => hg, - source => "http://hg.example.com/myrepo", + source => 'http://hg.example.com/myrepo', user => 'user', } To specify an SSH identity key, - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => hg, - source => "ssh://hg@hg.example.com/myrepo", - identity => "/home/user/.ssh/id_dsa, + source => 'ssh://hg@hg.example.com/myrepo', + identity => '/home/user/.ssh/id_dsa', } To specify a username and password for HTTP Basic authentication, - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => latest, provider => hg, source => 'http://hg.example.com/myrepo', @@ -364,7 +364,7 @@ To create an empty Workspace, define a `vcsrepo` without a `source` or `revision Environment variables P4PORT, P4USER, etc... are used to define the Perforce server connection settings. - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => p4 } @@ -378,7 +378,7 @@ A Perforce configuration file can be used by setting the `P4CONFIG` environment defining `p4config`. If a configuration is defined, then the environment variable for `P4CLIENT` is replaced. - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => p4, p4config => '.p4config' @@ -388,7 +388,7 @@ defining `p4config`. If a configuration is defined, then the environment variab To sync a depot path to head, ensure `latest`: - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => latest, provider => p4, source => '//depot/branch/...' @@ -396,7 +396,7 @@ To sync a depot path to head, ensure `latest`: For a specific changelist, ensure `present` and specify a `revision`: - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => p4, source => '//depot/branch/...', @@ -405,7 +405,7 @@ For a specific changelist, ensure `present` and specify a `revision`: You can also set `revision` to a label: - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => p4, source => '//depot/branch/...', @@ -428,7 +428,7 @@ For examples you can run, see `examples/p4/` To create a blank repository suitable for use as a central repository, define `vcsrepo` without `source` or `revision`. - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => svn, } @@ -437,18 +437,18 @@ define `vcsrepo` without `source` or `revision`. Provide a `source` pointing to the branch/tag you want to check out from a repository. - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => svn, - source => "svn://svnrepo/hello/branches/foo", + source => 'svn://svnrepo/hello/branches/foo', } You can also provide a specific revision. - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => svn, - source => "svn://svnrepo/hello/branches/foo", + source => 'svn://svnrepo/hello/branches/foo', revision => '1234', } @@ -456,11 +456,11 @@ You can also provide a specific revision. To use a specific configuration directory, provide a `configuration` parameter which should be a directory path on the local system where your svn configuration files are. Typically, it is '/path/to/.subversion'. - vcsrepo { "/path/to/repo": + vcsrepo { '/path/to/repo': ensure => present, provider => svn, - source => "svn://svnrepo/hello/branches/foo", - configuration => "/path/to/.subversion", + source => 'svn://svnrepo/hello/branches/foo', + configuration => '/path/to/.subversion', } #####Sources that use SSH -- cgit v1.2.3 From b1e0a48fa095aac7d2aea01f616a164890a10c2d Mon Sep 17 00:00:00 2001 From: Pete Soloway Date: Tue, 7 Apr 2015 09:56:10 -0700 Subject: Update README per DOC-1501 1. Remove any "what this affects" sections, except where particularly warranted. 2. Make sure that for each parameter, where applicable, there is a data type and a default value. 3. Make sure that for each parameter that's applicable, there is a note if the parameter is optional. 4. Make sure the links in the README work and are accurate. 5. Update the link in the Contributing section to point here: https://docs.puppetlabs.com/forge/contributing.html 6. General copyediting. --- README.markdown | 1232 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 690 insertions(+), 542 deletions(-) diff --git a/README.markdown b/README.markdown index 9671fc5..924a317 100644 --- a/README.markdown +++ b/README.markdown @@ -1,591 +1,739 @@ -#vcsrepo +#vcsrepo + +####Table of Contents + +1. [Overview](#overview) +2. [Module Description - What the module does and why it is useful](#module-description) +3. [Setup - The basics of getting started with vcsrepo](#setup) + * [Setup requirements](#setup-requirements) + * [Beginning with vcsrepo](#beginning-with-vcsrepo) +4. [Usage - Configuration options and additional functionality](#usage) + * [Git](#git) + * [Bazaar](#bazaar) + * [CVS](#cvs) + * [Mercurial](#mercurial) + * [Perforce](#perforce) + * [Subversion](#subversion) +5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) + * [Type: vcsrepo](#type-vcsrepo) + * [Providers](#providers) + * [Features](#features) + * [Parameters](#parameters) +5. [Limitations - OS compatibility, etc.](#limitations) +6. [Development - Guide for contributing to the module](#development) + +##Overview + +The vcsrepo module lets you use Puppet to easily deploy content from your version control system (VCS). + +##Module Description + +The vcsrepo module provides a single type with providers to support the following version control systems: + +* [Git](#git) +* [Bazaar](#bazaar) +* [CVS](#cvs) +* [Mercurial](#mercurial) +* [Perforce](#perforce) +* [Subversion](#subversion) + +**Note:** `git` is the only vcs provider officially [supported by Puppet Labs](https://forge.puppetlabs.com/supported). + +##Setup + +###Setup Requirements + +The `vcsrepo` module does not install any VCS software for you. You must install a VCS before you can use this module. + +Like Puppet in general, the `vcsrepo` module does not automatically create parent directories for the files it manages. Make sure to set up any needed directory structures before you get started. + +###Beginning with vcsrepo + +To create and manage a blank repository, define the type `vcsrepo` with a path to your repository and supply the `provider` parameter based on the [VCS you're using](#usage). + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => git, +} +~~~ + +##Usage + +**Note:** `git` is the only vcsrepo provider officially [supported by Puppet Labs](https://forge.puppetlabs.com/supported). + +###Git + +####Create a blank repository + +To create a blank repository, suitable for use as a central repository, define `vcsrepo` without `source` or `revision`: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => git, +} +~~~ + +If you're managing a central or official repository, you might want to make it a bare repository. To do this, set `ensure` to 'bare': + +~~~ +vcsrepo { '/path/to/repo': + ensure => bare, + provider => git, +} +~~~ + +####Clone/pull a repository + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => git, + source => 'git://example.com/repo.git', +} +~~~ + +By default, `vcsrepo` will use the HEAD of the source repository's master branch. To use another branch or a specific commit, set `revision` to either a branch name or a commit SHA or tag. + +Branch name: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => git, + source => 'git://example.com/repo.git', + revision => 'development', +} +~~~ + +SHA: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => git, + source => 'git://example.com/repo.git', + revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31', +} +~~~ + +Tag: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => git, + source => 'git://example.com/repo.git', + revision => '1.1.2rc1', +} +~~~ + +To check out a branch as a specific user, supply the `user` parameter: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => git, + source => 'git://example.com/repo.git', + revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31', + user => 'someUser', +} +~~~ + +To keep the repository at the latest revision, set `ensure` to 'latest'. + +**WARNING:** this overwrites any local changes to the repository: + +~~~ +vcsrepo { '/path/to/repo': + ensure => latest, + provider => git, + source => 'git://example.com/repo.git', + revision => 'master', +} +~~~ + +To clone the repository but skip initializing submodules, set `submodules` to 'false': + +~~~ +vcsrepo { '/path/to/repo': + ensure => latest, + provider => git, + source => 'git://example.com/repo.git', + submodules => false, +} +~~~ + +####Use multiple remotes with a repository +In place of a single string, you can set `source` to a hash of one or more name => URL pairs: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => git, + remote => 'origin' + source => { + 'origin' => 'https://github.com/puppetlabs/puppetlabs-vcsrepo.git', + 'other_remote' => 'https://github.com/other_user/puppetlabs-vcsrepo.git' + }, +} +~~~ + +**Note:** if you set `source` to a hash, one of the names you specify must match the value of the `remote` parameter. That remote serves as the upstream of your managed repository. + +####Connect via SSH + +To connect to your source repository via SSH (e.g., 'username@server:…'), we recommend managing your SSH keys with Puppet and using the [`require`](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter to make sure they are present before the `vcsrepo` resource is applied. + +To use SSH keys associated with a user, specify the username in the `user` parameter: + +~~~ +vcsrepo { '/path/to/repo': + ensure => latest, + provider => git, + source => 'git://username@example.com/repo.git', + user => 'toto', #uses toto's $HOME/.ssh setup + require => File['/home/toto/.ssh/id_rsa'], +} +~~~ + +###Bazaar + +####Create a blank repository + +To create a blank repository, suitable for use as a central repository, define `vcsrepo` without `source` or `revision`: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => bzr, +} +~~~ + +####Branch from an existing repository + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => bzr, + source => '/some/path', +} +~~~ + +To branch from a specific revision, set `revision` to a valid [Bazaar revisionspec](http://wiki.bazaar.canonical.com/BzrRevisionSpec): + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => bzr, + source => '/some/path', + revision => 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x', +} +~~~ + +####Connect via SSH + +To connect to your source repository via SSH (e.g., `'bzr+ssh://...'` or `'sftp://...,'`), we recommend using the [`require`](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter to make sure your SSH keys are present before the `vcsrepo` resource is applied: + +~~~ +vcsrepo { '/path/to/repo': + ensure => latest, + provider => bzr, + source => 'bzr+ssh://bzr.example.com/some/path', + user => 'toto', #uses toto's $HOME/.ssh setup + require => File['/home/toto/.ssh/id_rsa'], +} +~~~ + +###CVS + +####Create a blank repository + +To create a blank repository, suitable for use as a central repository, define `vcsrepo` without `source` or `revision`: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => cvs, +} +~~~ + +####Checkout/update from a repository + +~~~ +vcsrepo { '/path/to/workspace': + ensure => present, + provider => cvs, + source => ':pserver:anonymous@example.com:/sources/myproj', +} +~~~ + +To get a specific module on the current mainline, supply the `module` parameter: + +~~~ +vcsrepo {'/vagrant/lockss-daemon-source': + ensure => present, + provider => cvs, + source => ':pserver:anonymous@lockss.cvs.sourceforge.net:/cvsroot/lockss', + module => 'lockss-daemon', +} +~~~ + +To set the GZIP compression levels for your repository history, use the `compression` parameter: + +~~~ +vcsrepo { '/path/to/workspace': + ensure => present, + provider => cvs, + compression => 3, + source => ':pserver:anonymous@example.com:/sources/myproj', +} +~~~ + +To get a specific revision, set `revision` to the revision number. + +~~~ +vcsrepo { '/path/to/workspace': + ensure => present, + provider => cvs, + compression => 3, + source => ':pserver:anonymous@example.com:/sources/myproj', + revision => '1.2', +} +~~~ + +You can also set `revision` to a tag: + +~~~ +vcsrepo { '/path/to/workspace': + ensure => present, + provider => cvs, + compression => 3, + source => ':pserver:anonymous@example.com:/sources/myproj', + revision => 'SOMETAG', +} +~~~ + +####Connect via SSH + +To connect to your source repository via SSH, we recommend using the [`require`](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter to make sure your SSH keys are present before the `vcsrepo` resource is applied: + +~~~ +vcsrepo { '/path/to/repo': + ensure => latest, + provider => cvs, + source => ':pserver:anonymous@example.com:/sources/myproj', + user => 'toto', #uses toto's $HOME/.ssh setup + require => File['/home/toto/.ssh/id_rsa'], +} +~~~ + +###Mercurial + +####Create a blank repository + +To create a blank repository, suitable for use as a central repository, define `vcsrepo` without `source` or `revision`: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => hg, +} +~~~ + +####Clone/pull & update a repository + +To get the default branch tip: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => hg, + source => 'http://hg.example.com/myrepo', +} +~~~ + +For a specific changeset, use `revision`: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => hg, + source => 'http://hg.example.com/myrepo', + revision => '21ea4598c962', +} +~~~ + +You can also set `revision` to a tag: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => hg, + source => 'http://hg.example.com/myrepo', + revision => '1.1.2', +} +~~~ + +To check out as a specific user: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => hg, + source => 'http://hg.example.com/myrepo', + user => 'user', +} +~~~ + +To specify an SSH identity key: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => hg, + source => 'ssh://hg@hg.example.com/myrepo', + identity => '/home/user/.ssh/id_dsa1, +} +~~~ + +To specify a username and password for HTTP Basic authentication: + +~~~ +vcsrepo { '/path/to/repo': + ensure => latest, + provider => hg, + source => 'http://hg.example.com/myrepo', + basic_auth_username => 'hgusername', + basic_auth_password => 'hgpassword', +} +~~~ + +####Connect via SSH + +To connect to your source repository via SSH (e.g., `'ssh://...'`), we recommend using the [`require` metaparameter](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) to make sure your SSH keys are present before the `vcsrepo` resource is applied: + +~~~ +vcsrepo { '/path/to/repo': + ensure => latest, + provider => hg, + source => 'ssh://hg.example.com//path/to/myrepo', + user => 'toto', #uses toto's $HOME/.ssh setup + require => File['/home/toto/.ssh/id_rsa'], +} +~~~ + +###Perforce + +####Create an empty workspace + +To set up the connection to your Perforce service, set `p4config` to the location of a valid Perforce [config file](http://www.perforce.com/perforce/doc.current/manuals/p4guide/chapter.configuration.html#configuration.settings.configfiles) stored on the node: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => p4, + p4config => '/root/.p4config' +} +~~~ + +**Note:** If you don't include the `P4CLIENT` setting in your config file, the provider generates a workspace name based on the digest of `path` and the node's hostname (e.g., `puppet-91bc00640c4e5a17787286acbe2c021c`): + +####Create/update and sync a Perforce workspace + +To sync a depot path to head, set `ensure` to 'latest': + +~~~ +vcsrepo { '/path/to/repo': + ensure => latest, + provider => p4, + source => '//depot/branch/...' +} +~~~ + +To sync to a specific changelist, specify its revision number with the `revision` parameter: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => p4, + source => '//depot/branch/...', + revision => '2341' +} +~~~ + +You can also set `revision` to a label: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => p4, + source => '//depot/branch/...', + revision => 'my_label' +} +~~~ + +###Subversion + +####Create a blank repository + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => svn, +} +~~~ + +####Check out from an existing repository + +Provide a `source` pointing to the branch or tag you want to check out: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => svn, + source => 'svn://svnrepo/hello/branches/foo', +} +~~~ + +You can also designate a specific revision: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => svn, + source => 'svn://svnrepo/hello/branches/foo', + revision => '1234', +} +~~~ + +####Use a specific Subversion configuration directory + +Use the `configuration` parameter to designate the directory that contains your Subversion configuration files (typically, '/path/to/.subversion'): + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => svn, + source => 'svn://svnrepo/hello/branches/foo', + configuration => '/path/to/.subversion', +} +~~~ + +####Connect via SSH + +To connect to your source repository via SSH (e.g., `'svn+ssh://...'`), we recommend using the [`require` metaparameter](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) to make sure your SSH keys are present before the `vcsrepo` resource is applied: + +~~~ +vcsrepo { '/path/to/repo': + ensure => latest, + provider => svn, + source => 'svn+ssh://svnrepo/hello/branches/foo', + user => 'toto', #uses toto's $HOME/.ssh setup + require => File['/home/toto/.ssh/id_rsa'], +} +~~~ + +##Reference + +###Type: vcsrepo + +The vcsrepo module adds only one type with several providers. Each provider abstracts a different VCS, and each provider includes a set of features according to its needs. + +####Providers + +**Note:** Not all features are available with all providers. + +#####`git` - Supports the Git VCS. + +Features: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `submodules`, `user` + +Parameters: `depth`, `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `remote`, `revision`, `source`, `user` + +#####`bzr` - Supports the Bazaar VCS. + +Features: `reference_tracking` + +Parameters: `ensure`, `excludes`, `force`, `group`, `owner`, `path`, `provider`, `revision`, `source` + +#####`cvs` - Supports the CVS VCS. + +Features: `cvs_rsh`, `gzip_compression`, `modules`, `reference_tracking`, `user` + +Parameters: `compression`, `cvs_rsh`, `ensure`, `excludes`, `force`, `group`, `module`, `owner`, `path`, `provider` + +#####`hg` - Supports the Mercurial VCS. + +Features: `reference_tracking`, `ssh_identity`, `user` + +Parameters: `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `revision`, `source`, `user` + +#####`p4` - Supports the Perforce VCS. + +Features: `p4config`, `reference_tracking` + +Parameters: `ensure`, `excludes`, `force`, `group`, `owner`, `p4config`, `path`, `provider`, `revision`, `source` + +#####`svn` - Supports the Subversion VCS. + +Features: `basic_auth`, `configuration`, `conflict`, `filesystem_types`, `reference_tracking` + +Parameters: `basic_auth_password`, `basic_auth_username`, `configuration`, `conflict`, `ensure`, `excludes`, `force`, `fstype`, `group`, `owner`, `path`, `provider`, `revision`, `source` + +####Features + +**Note:** Not all features are available with all providers. + +* `bare_repositories` - Differentiates between bare repositories and those with working copies. (Available with `git`.) +* `basic_auth` - Supports HTTP Basic authentication. (Available with `svn`.) +* `conflict` - Lets you decide how to resolve any conflicts between the source repository and your working copy. (Available with `svn`.) +* `configuration` - Lets you specify the location of your configuration files. (Available with `svn`.) +* `cvs_rsh` - Understands the `CVS_RSH` environment variable. (Available with `cvs`.) +* `depth` - Supports shallow clones. (Available with `git`.) +* `filesystem_types` - Supports multiple types of filesystem. (Available with `svn`.) +* `gzip_compression` - Supports explicit GZip compression levels. (Available with `cvs`.) +* `modules` - Lets you choose a specific repository module. (Available with `cvs`.) +* `multiple_remotes` - Tracks multiple remote repositories. (Available with `git`.) +* `reference_tracking` - Lets you track revision references that can change over time (e.g., some VCS tags and branch names). (Available with all providers) +* `ssh_identity` - Lets you specify an SSH identity file. (Available with `git` and `hg`.) +* `user` - Can run as a different user. (Available with `git`, `hg` and `cvs`.) +* `p4config` - Supports setting the `P4CONFIG` environment. (Available with `p4`.) +* `submodules` - Supports repository submodules which can be optionally initialized. (Available with `git`.) + +####Parameters + +All parameters are optional, except where specified otherwise. + +##### `basic_auth_password` -[![Build Status](https://travis-ci.org/puppetlabs/puppetlabs-vcsrepo.png?branch=master)](https://travis-ci.org/puppetlabs/puppetlabs-vcsrepo) +Specifies the password for HTTP Basic authentication. (Requires the `basic_auth` feature.) Valid options: a string. Default: none. -####Table of Contents +##### `basic_auth_username` -1. [Overview](#overview) -2. [Module Description - What the module does and why it is useful](#module-description) -3. [Setup - The basics of getting started with vcsrepo](#setup) - * [Beginning with vcsrepo](#beginning-with-vcsrepo) -4. [Usage - Configuration options and additional functionality](#usage) - * [Bazaar](#bazaar) - * [CVS](#cvs) - * [Git](#git) - * [Mercurial](#mercurial) - * [Perforce](#perforce) - * [Subversion](#subversion) -5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) - * [Type: vcsrepo](#type-vcsrepo) - * [Providers](#providers) - * [Features](#features) - * [Parameters](#parameters) - * [Features and Parameters by Provider](#features-and-parameters-by-provider) -5. [Limitations - OS compatibility, etc.](#limitations) -6. [Development - Guide for contributing to the module](#development) +Specifies the username for HTTP Basic authentication. (Requires the `basic_auth` feature.) Valid options: a string. Default: none. -##Overview +##### `compression` -The vcsrepo module allows you to use Puppet to easily deploy content from your version control system (VCS). +Sets the GZIP compression level for the repository history. (Requires the `gzip_compression` feature.) Valid options: an integer between 0 and 6. Default: none. -##Module Description +##### `configuration` -This module provides a single type with providers for each VCS, which can be used to describe: +Sets the configuration directory to use. (Requires the `configuration` feature.) Valid options: a string containing an absolute path. Default: none. -* A working copy checked out from a (remote or local) source, at an - arbitrary revision -* A blank working copy not associated with a source (when it makes - sense for the VCS being used) -* A blank central repository (when the distinction makes sense for the VCS - being used) +##### `conflict` -##Setup +Tells Subversion how to resolve any conflicts between the source repository and your working copy. (Requires the `conflict` feature.) Valid options: 'base', 'mine-full', 'theirs-full', and 'working'. Default: none. -Before you begin using vcsrepo, it's worth keeping in mind that this module will not install VCS software for you. If you are going to use this module, you must have already installed your preferred VCS. +##### `cvs_rsh` -Also, this module, like Puppet generally, will not create parent directories for you. You will need to have your parent directories in place before you begin. +Provides a value for the `CVS_RSH` environment variable. (Requires the `cvs_rsh` feature.) Valid options: a string. Default: none. -###Beginning with vcsrepo +##### `depth` -To get started with the vcsrepo module, you must simply define the type `vcsrepo` with a path to your repository and the [type of VCS](#Usage) you're using in `provider` (in the below example, Git). +Sets the number of commits to include when creating a shallow clone. (Requires the `depth` feature.) Valid options: an integer. Default: none. - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - } +##### `ensure` -##Usage +Specifies whether the repository should exist. Valid options: 'present', 'bare', 'absent', and 'latest'. Default: 'present'. -The vcsrepo module works with the following VCSs: +##### `excludes` -* [Git (git)](#git)* -* [Bazaar (bzr)](#bazaar) -* [CVS (cvs)](#cvs) -* [Mercurial (hg)](#mercurial) -* [Perforce (p4)](#perforce) -* [Subversion (svn)](#subversion) +Lists any files the repository shouldn't track (similar to .gitignore). Valid options: a string (separate multiple values with the newline character). Default: none. -**Note:** Git is the only VCS provider officially [supported](https://forge.puppetlabs.com/supported) by Puppet Labs. +##### `force` +Specifies whether to delete any existing files in the repository path if creating a new repository. **Use with care.** Valid options: 'true' and 'false'. Default: 'false'. -###Git +##### `fstype` -#####To create a blank repository +Sets the filesystem type. (Requires the `filesystem_types` feature.) Valid options: 'fsfs' or 'bdb'. Default: none. -To create a blank repository suitable for use as a central repository, -define `vcsrepo` without `source` or `revision`. +##### `group` - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - } +Specifies a group to own the repository files. Valid options: a string containing a group name or GID. Default: none. -If you're defining `vcsrepo` for a central or official repository, you may want to make it a bare repository. You do this by setting `ensure` to 'bare' rather than 'present'. +##### `identity` - vcsrepo { "/path/to/repo": - ensure => bare, - provider => git, - } +Specifies an identity file to use for SSH authentication. (Requires the `ssh_identity` feature.) Valid options: a string containing an absolute path. Default: none. -#####To clone/pull a repository +##### `module` -To get the current HEAD on the master branch, +Specifies the repository module to manage. (Requires the `modules` feature.) Valid options: a string containing the name of a CVS module. Default: none. - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - source => "git://example.com/repo.git", - } +##### `owner` -To get a specific revision or branch (can be a commit SHA, tag, or branch name), +Specifies a user to own the repository files. Valid options: a string containing a username or UID. Default: none. - **SHA** +##### `p4config` - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - source => 'git://example.com/repo.git', - revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31', - } +Specifies a config file that contains settings for connecting to the Perforce service. (Requires the `p4config` feature.) Valid options: a string containing the absolute path to a valid [Perforce config file](http://www.perforce.com/perforce/doc.current/manuals/p4guide/chapter.configuration.html#configuration.settings.configfiles). Default: none. -**Tag** +##### `path` - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - source => 'git://example.com/repo.git', - revision => '1.1.2rc1', - } +Specifies a location for the managed repository. Valid options: a string containing an absolute path. Default: the title of your declared resource. -**Branch name** +##### `provider` - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - source => 'git://example.com/repo.git', - revision => 'development', - } +*Required.* Specifies the backend to use for this vcsrepo resource. Valid options: 'bzr', 'cvs', 'git', 'hg', 'p4', and 'svn'. -To check out a branch as a specific user, +##### `remote` - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - source => 'git://example.com/repo.git', - revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31', - user => 'someUser', - } +Specifies the remote repository to track. (Requires the `multiple_remotes` feature.) Valid options: a string containing one of the remote names specified in `source`. Default: 'origin'. -To keep the repository at the latest revision (**WARNING:** this will always overwrite local changes to the repository), +##### `revision` - vcsrepo { "/path/to/repo": - ensure => latest, - provider => git, - source => 'git://example.com/repo.git', - revision => 'master', - } +Sets the revision of the repository. Valid options vary by provider: -To clone the repository but skip initialiazing submodules, +* `git` - a string containing a Git branch name, or a commit SHA or tag +* `bzr` - a string containing a Bazaar [revisionspec](http://wiki.bazaar.canonical.com/BzrRevisionSpec) +* `cvs` - a string containing a CVS [tag or revision number](http://www.thathost.com/wincvs-howto/cvsdoc/cvs_4.html) +* `hg` - a string containing a Mercurial [changeset ID](http://mercurial.selenic.com/wiki/ChangeSetID) or [tag](http://mercurial.selenic.com/wiki/Tag) +* `p4` - a string containing a Perforce [change number, label name, client name, or date spec](http://www.perforce.com/perforce/r12.1/manuals/cmdref/o.fspecs.html) +* `svn` - a string containing a Subversion [revision number](http://svnbook.red-bean.com/en/1.7/svn.basic.in-action.html#svn.basic.in-action.revs), [revision keyword, or revision date](http://svnbook.red-bean.com/en/1.7/svn.tour.revs.specifiers.html) - vcsrepo { "/path/to/repo": - ensure => latest, - provider => git, - source => 'git://example.com/repo.git', - submodules => false, - } +Default: none. -##### Using multiple remotes with a repository -Instead of specifying a single string in the 'source' property, you can specify a hash with multiple name => URL mappings, +##### `source` - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - source => { - "origin" => "https://github.com/puppetlabs/puppetlabs-vcsrepo.git", - "other_remote" => "https://github.com/other_user/puppetlabs-vcsrepo.git" - }, - } +Specifies a source repository to serve as the upstream for your managed repository. Default: none. Valid options vary by provider: -It is important to note that you must specify a mapping for the remote that is specified in the 'remote' property - this is set to 'origin' by default. +* `git` - a string containing a [Git repository URL](https://www.kernel.org/pub/software/scm/git/docs/git-clone.html#_git_urls_a_id_urls_a) or a hash of name => URL mappings. See also [`remote`](#remote). +* `bzr` - a string containing a Bazaar branch location +* `cvs` - a string containing a CVS root +* `hg` - a string containing the local path or URL of a Mercurial repository +* `p4` - a string containing a Perforce depot path +* `svn` - a string containing a Subversion repository URL -#####Sources that use SSH +Default: none. -When your source uses SSH, such as 'username@server:…', you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present. +##### `submodules` -For SSH keys associated with a user, enter the username in the `user` parameter. Doing so will use that user's keys. +Specifies whether to initialize and update each submodule in the repository. (Requires the `submodules` feature.) Valid options: 'true' and 'false'. Default: 'true'. - user => 'toto' # will use toto's $HOME/.ssh setup +##### `user` -#####Further Examples - -For more examples using Git, see `examples/git/`. - -###Bazaar - -#####Create a blank repository - -To create a blank repository suitable for use as a central repository, -define `vcsrepo` without `source` or `revision`. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => bzr, - } - -#####Branch from an existing repository - -Provide the `source` location to branch from an existing repository. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => bzr, - source => 'lp:myproj', - } - -For a specific revision, use `revision` with a valid revisionspec -(see `bzr help revisionspec` for more information on formatting a revision). - - vcsrepo { "/path/to/repo": - ensure => present, - provider => bzr, - source => 'lp:myproj', - revision => 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x', - } - -#####Sources that use SSH - -When your source uses SSH, for instance 'bzr+ssh://...' or 'sftp://...,' -you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present. - -#####Further examples - -For more examples using Bazaar, see `examples/bzr/`. - -###CVS - -#####To create a blank repository - -To create a blank repository suitable for use as a central repository, -define `vcsrepo` without `source` or `revision`. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => cvs, - } - -#####To checkout/update from a repository - -To get the current mainline, - - vcsrepo { "/path/to/workspace": - ensure => present, - provider => cvs, - source => ":pserver:anonymous@example.com:/sources/myproj", - } - -To get a specific module on the current mainline, - - vcsrepo {"/vagrant/lockss-daemon-source": - ensure => present, - provider => cvs, - source => ":pserver:anonymous@lockss.cvs.sourceforge.net:/cvsroot/lockss", - module => "lockss-daemon", - } - - -You can use the `compression` parameter to set the GZIP compression levels for your repository history. - - vcsrepo { "/path/to/workspace": - ensure => present, - provider => cvs, - compression => 3, - source => ":pserver:anonymous@example.com:/sources/myproj", - } - -For a specific tag, use `revision`. - - vcsrepo { "/path/to/workspace": - ensure => present, - provider => cvs, - compression => 3, - source => ":pserver:anonymous@example.com:/sources/myproj", - revision => "SOMETAG", - } - -#####Sources that use SSH - -When your source uses SSH, you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present. - -#####Further examples - -For for more examples using CVS, see `examples/cvs/`. - -###Mercurial - -#####To create a blank repository - -To create a blank repository suitable for use as a central repository, -define `vcsrepo` without `source` or `revision`. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => hg, - } - -#####To clone/pull & update a repository - -To get the default branch tip, - - vcsrepo { "/path/to/repo": - ensure => present, - provider => hg, - source => "http://hg.example.com/myrepo", - } - -For a specific changeset, use `revision`. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => hg, - source => "http://hg.example.com/myrepo", - revision => '21ea4598c962', - } - -You can also set `revision` to a tag. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => hg, - source => "http://hg.example.com/myrepo", - revision => '1.1.2', - } - -To check out as a specific user, - - vcsrepo { "/path/to/repo": - ensure => present, - provider => hg, - source => "http://hg.example.com/myrepo", - user => 'user', - } - -To specify an SSH identity key, - - vcsrepo { "/path/to/repo": - ensure => present, - provider => hg, - source => "ssh://hg@hg.example.com/myrepo", - identity => "/home/user/.ssh/id_dsa, - } - -To specify a username and password for HTTP Basic authentication, - - vcsrepo { "/path/to/repo": - ensure => latest, - provider => hg, - source => 'http://hg.example.com/myrepo', - basic_auth_username => 'hgusername', - basic_auth_password => 'hgpassword', - } - -#####Sources that use SSH - -When your source uses SSH, such as 'ssh://...', you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present. - -#####Further Examples - -For more examples using Mercurial, see `examples/hg/`. - -###Perforce - -#####To create an empty Workspace - -To create an empty Workspace, define a `vcsrepo` without a `source` or `revision`. The -Environment variables P4PORT, P4USER, etc... are used to define the Perforce server -connection settings. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => p4 - } - -If no `P4CLIENT` environment name is provided a workspace generated name is calculated -based on the Digest of path and hostname. For example: - - puppet-91bc00640c4e5a17787286acbe2c021c - -A Perforce configuration file can be used by setting the `P4CONFIG` environment or -defining `p4config`. If a configuration is defined, then the environment variable for -`P4CLIENT` is replaced. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => p4, - p4config => '.p4config' - } - -#####To create/update and sync a Perforce workspace - -To sync a depot path to head, ensure `latest`: - - vcsrepo { "/path/to/repo": - ensure => latest, - provider => p4, - source => '//depot/branch/...' - } - -For a specific changelist, ensure `present` and specify a `revision`: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => p4, - source => '//depot/branch/...', - revision => '2341' - } - -You can also set `revision` to a label: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => p4, - source => '//depot/branch/...', - revision => 'my_label' - } - -#####To authenticate against the Perforce server - -Either set the environment variables `P4USER` and `P4PASSWD` or use a configuration file. -For secure servers set the `P4PASSWD` with a valid ticket generated using `p4 login -p`. - -#####Further Examples - -For examples you can run, see `examples/p4/` - -###Subversion - -#####To create a blank repository - -To create a blank repository suitable for use as a central repository, -define `vcsrepo` without `source` or `revision`. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => svn, - } - -#####To check out from a repository - -Provide a `source` pointing to the branch/tag you want to check out from a repository. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => svn, - source => "svn://svnrepo/hello/branches/foo", - } - -You can also provide a specific revision. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => svn, - source => "svn://svnrepo/hello/branches/foo", - revision => '1234', - } - -#####Using a specific Subversion configuration directory - -To use a specific configuration directory, provide a `configuration` parameter which should be a directory path on the local system where your svn configuration files are. Typically, it is '/path/to/.subversion'. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => svn, - source => "svn://svnrepo/hello/branches/foo", - configuration => "/path/to/.subversion", - } - -#####Sources that use SSH - -When your source uses SSH, such as 'svn+ssh://...', you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present. - -####Further examples - -For more examples using Subversion, see `examples/svn/`. - -##Reference - -###Type: vcsrepo - -The vcsrepo module is slightly unusual in that it is simply a type and providers. Each provider abstracts a different VCS, and a series of features are available to each provider based on its specific needs. - -####Providers - -**Note**: Not all features are available with all providers. - -* `git` - Supports the Git VCS. (Contains features: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`.) -* `bar` - Supports the Bazaar VCS. (Contains features: `reference_tracking`.) -* `cvs` - Supports the CVS VCS. (Contains features: `cvs_rsh`, `gzip_compression`, `modules`, `reference_tracking`, `user`.) -* `dummy` - -* `hg` - Supports the Mercurial VCS. (Contains features: `reference_tracking`, `ssh_identity`, `user`.) -* `p4` - Supports the Perforce VCS. (Contains features: `reference_tracking`, `filesystem_types`, `p4config`.) -* `svn` - Supports the Subversion VCS. (Contains features: `basic_auth`, `configuration`, `filesystem_types`, `reference_tracking`.) - -####Features - -**Note**: Not all features are available with all providers. - -* `bare_repositories` - The provider differentiates between bare repositories and those with working copies. (Available with `git`.) -* `basic_auth` - The provider supports HTTP Basic Authentication. (Available with `svn`.) -* `configuration` - The provider supports setting the configuration path.(Available with `svn`.) -* `cvs_rsh` - The provider understands the CVS_RSH environment variable. (Available with `cvs`.) -* `depth` - The provider can do shallow clones. (Available with `git`.) -* `filesystem_types` - The provider supports different filesystem types. (Available with `svn`.) -* `gzip_compression` - The provider supports explicit GZip compression levels. (Available with `cvs`.) -* `modules` - The provider allows specific repository modules to be chosen. (Available with `cvs`.) -* `multiple_remotes` - The repository tracks multiple remote repositories. (Available with `git`.) -* `reference_tracking` - The provider supports tracking revision references that can change over time (e.g. some VCS tags and branch names). (Available with `bar`, `cvs`, `git`, `hg`, `svn`.) -* `ssh_identity` - The provider supports a configurable SSH identity file. (Available with `git` and `hg`.) -* `user` - The provider can run as a different user. (Available with `git`, `hg` and `cvs`.) -* `p4config` - The provider support setting the P4CONFIG environment. (Available with `p4`.) -* `submodules` - The provider supports repository submodules which can be optionally initialized. (Available with `git`.) - -####Parameters - -* `basic_auth_password` - Specifies the HTTP Basic Authentication password. (Requires the `basic_auth` feature.) -* `basic_auth_username` - Specifies the HTTP Basic Authentication username. (Requires the `basic_auth` feature.) -* `compression` - Set the GZIP compression levels for your repository history. (Requires the `gzip_compression` feature.) -* `configuration` - Sets the configuration directory to use. (Requires the `configuration` feature.) -* `cvs_rsh` - The value to be used for the CVS_RSH environment variable. (Requires the `cvs_rsh` feature.) -* `depth` - The value to be used to do a shallow clone. (Requires the `depth` feature.) -* `ensure` - Determines the state of the repository. Valid values are 'present', 'bare', 'absent', 'latest'. -* `excludes` - Lists any files to be excluded from being tracked by the repository (similiar to .gitignore). Can be an array or string. -* `force` - Forces repository creation. Valid values are 'true' and 'false'. **WARNING** Forcing will destroy any files in the path. -* `fstype` - Sets the filesystem type. (Requires the `filesystem_types` feature.) -* `group` - Determines the group/gid that owns the repository files. -* `identity` - Specifies the SSH identity file. (Requires the `ssh_identity` feature.) -* `module` - Specifies the repository module to manage. (Requires the `modules` feature.) -* `owner` - Specifies the user/uid that owns the repository files. -* `path` - Specifies the absolute path to the repository. If omitted, the value defaults to the resource's title. -* `provider` - Specifies the backend to use for this vcsrepo resource. -* `remote` - Specifies the remote repository to track. (Requires the `multiple_remotes` feature.) -* `revision` - Sets the revision of the repository. Values can match /^\S+$/. -* `source` - Specifies the source URI for the repository. -* `user` - Specifies the user to run as for repository operations. -* `p4config` - Specifies the P4CONFIG environment used for Perforce connection configuration. - -####Features and Parameters by Provider - -#####`git` -**Features**: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`, `submodules` - -**Parameters**: `depth`, `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `remote`, `revision`, `source`, `user`, `submodules` - -#####`bzr` -**Features**: `reference_tracking` - -**Parameters**: `ensure`, `excludes`, `force`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `user` - -#####`cvs` -**Features**: `cvs_rsh`, `gzip_compression`, `modules`, `reference_tracking`, `revision` - -**Parameters**: `compression`, `cvs_rsh`, `ensure`, `excludes`, `force`, `group`, `module`, `owner`, `path`, `provider`, `revision`, `source`, `user` - -#####`hg` -**Features**: `reference_tracking`, `ssh_identity`, `user` - -**Parameters**: `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `revision`, `source`, `user` - -#####`p4` -**Features**: `reference_tracking`, `filesystem_types`, `p4config` - -**Parameters**: `ensure`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `p4config` - -#####`svn` -**Features**: `basic_auth`, `configuration`, `filesystem_types`, `reference_tracking` - -**Parameters**: `basic_auth_password`, `basic_auth_username`, `configuration`, `ensure`, `excludes`, `force`, `fstype`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `user` - -##Limitations - -Git is the only VCS provider officially [supported](https://forge.puppetlabs.com/supported) by Puppet Labs. - -This module has been built on and tested against Puppet 2.7 and higher. - -The module has been tested on: - -RedHat Enterprise Linux 5/6 -Debian 6/7 -CentOS 5/6 -Ubuntu 12.04 -Gentoo -Arch Linux -FreeBSD - -Testing on other platforms has been light and cannot be guaranteed. - -##Development - -Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve. - -We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. - -You can read the complete module contribution guide on the Puppet Labs wiki. +Specifies the user to run as for repository operations. (Requires the `user` feature.) Valid options: a string containing a username or UID. Default: none. + +##Limitations + +Git is the only VCS provider officially [supported](https://forge.puppetlabs.com/supported) by Puppet Labs. + +This module has been tested with Puppet 2.7 and higher. + +The module has been tested on: + +* Red Hat Enterprise Linux 5/6 +* Debian 6/7 +* CentOS 5/6 +* Ubuntu 12.04 + +Testing on other platforms has been light and cannot be guaranteed. + +##Development + +Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can't access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve. + +We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. + +You can read the complete module contribution guide [on the Puppet Labs wiki.](http://projects.puppetlabs.com/projects/module-site/wiki/Module_contributing) \ No newline at end of file -- cgit v1.2.3 From 3b804b898506660701753bef664cfabd034904cb Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 6 May 2015 14:10:46 -0700 Subject: sync via modulesync --- .travis.yml | 6 ------ Gemfile | 21 +-------------------- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0fc75e3..291ceb3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,18 +6,12 @@ script: "bundle exec rake spec SPEC_OPTS='--format documentation'" matrix: fast_finish: true include: - - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 3.4.0" - rvm: 1.8.7 env: PUPPET_GEM_VERSION="~> 3.0" - rvm: 1.9.3 env: PUPPET_GEM_VERSION="~> 3.0" - - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" - rvm: 2.1.5 env: PUPPET_GEM_VERSION="~> 3.0" - - rvm: 2.1.5 - env: PUPPET_GEM_VERSION="~> 3.4.0" - rvm: 2.1.5 env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" - rvm: 1.8.7 diff --git a/Gemfile b/Gemfile index fcd27d5..cc77f38 100644 --- a/Gemfile +++ b/Gemfile @@ -1,15 +1,5 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" -def location_for(place, fake_version = nil) - if place =~ /^(git:[^#]*)#(.*)/ - [fake_version, { :git => $1, :branch => $2, :require => false }].compact - elsif place =~ /^file:\/\/(.*)/ - ['>= 0', { :path => File.expand_path($1), :require => false }] - else - [place, { :require => false }] - end -end - group :development, :unit_tests do gem 'rspec-core', '3.1.7', :require => false gem 'puppetlabs_spec_helper', :require => false @@ -18,17 +8,8 @@ group :development, :unit_tests do gem 'json', :require => false end -beaker_version = ENV['BEAKER_VERSION'] -beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] group :system_tests do - if beaker_version - gem 'beaker', *location_for(beaker_version) - end - if beaker_rspec_version - gem 'beaker-rspec', *location_for(beaker_rspec_version) - else - gem 'beaker-rspec', :require => false - end + gem 'beaker-rspec', :require => false gem 'serverspec', :require => false end -- cgit v1.2.3 From cf3d3b6f90635fd91173a0f0bd99837f511a50ad Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 6 May 2015 14:31:22 -0700 Subject: sync via modulesync --- Gemfile | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index cc77f38..fb7202c 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,15 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" +def location_for(place, fake_version = nil) + if place =~ /^(git:[^#]*)#(.*)/ + [fake_version, { :git => $1, :branch => $2, :require => false }].compact + elsif place =~ /^file:\/\/(.*)/ + ['>= 0', { :path => File.expand_path($1), :require => false }] + else + [place, { :require => false }] + end +end + group :development, :unit_tests do gem 'rspec-core', '3.1.7', :require => false gem 'puppetlabs_spec_helper', :require => false @@ -9,10 +19,16 @@ group :development, :unit_tests do end group :system_tests do - gem 'beaker-rspec', :require => false + if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] + gem 'beaker-rspec', *location_for(beaker_rspec_version) + else + gem 'beaker-rspec', :require => false + end gem 'serverspec', :require => false end + + if facterversion = ENV['FACTER_GEM_VERSION'] gem 'facter', facterversion, :require => false else -- cgit v1.2.3 From e9ff63ed456fb981bc87a52057ec8e70270954f4 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 6 May 2015 14:33:11 -0700 Subject: beaker gemfile fixes --- Gemfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Gemfile b/Gemfile index fb7202c..2b1b7cd 100644 --- a/Gemfile +++ b/Gemfile @@ -19,6 +19,9 @@ group :development, :unit_tests do end group :system_tests do + if beaker_version = ENV['BEAKER_VERSION'] + gem 'beaker', *location_for(beaker_version) + end if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] gem 'beaker-rspec', *location_for(beaker_rspec_version) else -- cgit v1.2.3 From 7f97a76f4682a7c1d5bfbbc3cd5a6dd9523b1d96 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 13 May 2015 15:39:01 -0700 Subject: (MODULES-821) Don't use /tmp Very often /tmp is mounted noexec for security reasons related to it being writable by all users. This stopped vcsrepo's git provider from working. This pull request uses puppet's statedir as it is not writable by all users and is a good candidate for transient state like the git provider's identity script for the $GIT_SSH command. An alternative in the future that wouldn't require a temporary file is to set $GIT_SSH_COMMAND instead of $GIT_SSH, except this was added in git 2.3 and is too new to depend on. --- lib/puppet/provider/vcsrepo/git.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 8101253..44e4d04 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -418,7 +418,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) # @!visibility private def git_with_identity(*args) if @resource.value(:identity) - Tempfile.open('git-helper') do |f| + Tempfile.open('git-helper', Puppet[:statedir]) do |f| f.puts '#!/bin/sh' f.puts "exec ssh -oStrictHostKeyChecking=no -oPasswordAuthentication=no -oKbdInteractiveAuthentication=no -oChallengeResponseAuthentication=no -oConnectTimeout=120 -i #{@resource.value(:identity)} $*" f.close -- cgit v1.2.3 From f555eaf0e34650b72550055c9fa9d60292e9f276 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 13 May 2015 16:34:37 -0700 Subject: Release 1.3.0 --- CHANGELOG.md | 71 +++++++++++++++++++++++++++++++++++++++-------------------- metadata.json | 2 +- 2 files changed, 48 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b8f7d1..ad10e97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,55 +1,71 @@ -##2014-11-04 - Supported Release 1.2.0 -###Summary +# Change Log +All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [1.3.0] - 2015-05-19 Supported Release +### Summary +This release adds git provider remote handling, svn conflict resolution, and fixes the git provider when /tmp is mounted noexec. + +### Added +- `source` property now takes a hash of sources for the git provider's remotes +- Add `submodules` parameter to skip submodule initialization for git provider +- Add `conflict` to svn provider to resolve conflicts +- Add `branch` parameter to specify clone branch +- Readme rewrite + +### Fixed +- The git provider now works even if `/tmp` is noexec + +## [1.2.0] - 2014-11-04 Supported Release +### Summary This release includes some improvements for git, mercurial, and cvs providers, and fixes the bug where there were warnings about multiple default providers. -####Features +### Added - Update git and mercurial providers to set UID with `Puppet::Util::Execution.execute` instead of `su` - Allow git excludes to be string or array - Add `user` feature to cvs provider -####Bugfixes +### Fixed - No more warnings about multiple default providers! (MODULES-428) -##2014-07-14 - Supported Release 1.1.0 -###Summary -This release adds a Perforce provider* and corrects the git provider behavior +## [1.1.0] - 2014-07-14 Supported Release +### Summary +This release adds a Perforce provider\* and corrects the git provider behavior when using `ensure => latest`. -*(Only git provider is currently supported.) +\*(Only git provider is currently supported.) -####Features +### Added - New Perforce provider -####Bugfixes +### Fixed - (MODULES-660) Fix behavior with `ensure => latest` and detached HEAD - Spec test fixes -##2014-06-30 - Supported Release 1.0.2 -###Summary +## [1.0.2] - 2014-06-30 Supported Release +### Summary This supported release adds SLES 11 to the list of compatible OSs and documentation updates for support. -##2014-06-17 - Supported Release 1.0.1 -###Summary +## [1.0.1] - 2014-06-17 Supported Release +### Summary This release is the first supported release of vcsrepo. The readme has been greatly improved. -####Features +### Added - Updated and expanded readme to follow readme template -####Fixes +### Fixed - Remove SLES from compatability metadata - Unpin rspec development dependencies - Update acceptance level testing -##2014-06-04 - Version 1.0.0 -###Summary +## [1.0.0] - 2014-06-04 +### Summary This release focuses on a number of bugfixes, and also has some new features for Bzr and Git. -####Features +### Added - Bzr: - Call set_ownership - Git: @@ -57,7 +73,7 @@ new features for Bzr and Git. - Use -a and desired for HARD resets - Use rev-parse to get tag canonical revision -####Fixes +### Fixed - HG: - Only add ssh options when it's talking to the network - Git: @@ -68,14 +84,14 @@ new features for Bzr and Git. - SVN: - Fix svnlook behavior with plain directories -##2013-11-13 - Version 0.2.0 -###Summary +## 0.2.0 - 2013-11-13 +### Summary This release mainly focuses on a number of bugfixes, which should significantly improve the reliability of Git and SVN. Thanks to our many contributors for all of these fixes! -####Features +### Added - Git: - Add autorequire for Package['git'] - HG: @@ -88,7 +104,7 @@ our many contributors for all of these fixes! - CVS: - Allow for setting the CVS_RSH environment variable. -####Fixes +### Fixed - Handle Puppet::Util[::Execution].withenv for 2.x and 3.x properly. - Change path_empty? to not do full directory listing. - Overhaul spec tests to work with rspec2. @@ -108,3 +124,10 @@ our many contributors for all of these fixes! - Fix svn provider to look for '^Revision:' instead of '^Last Changed Rev:'. - CVS: - Documented the "module" attribute. + +[1.3.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.2.0...1.3.0 +[1.2.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.1.0...1.2.0 +[1.1.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.0.2...1.1.0 +[1.0.2]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.0.1...1.0.2 +[1.0.1]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.0.0...1.0.1 +[1.0.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/0.2.0...1.0.0 diff --git a/metadata.json b/metadata.json index 242583a..ef74e86 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-vcsrepo", - "version": "1.2.0", + "version": "1.3.0", "author": "Puppet Labs", "summary": "Puppet module providing a type to manage repositories from various version control systems", "license": "GPLv2", -- cgit v1.2.3 From f900efd909155c7a9c1d6d74f63d9e919436ccec Mon Sep 17 00:00:00 2001 From: Pete Soloway Date: Mon, 18 May 2015 13:18:36 -0700 Subject: Last-minute README corrections MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Corrected the list of supported platforms under Limitations * Spelled “revision spec” instead of “revisionspec”. --- README.markdown | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/README.markdown b/README.markdown index 34988bc..badb1ce 100644 --- a/README.markdown +++ b/README.markdown @@ -221,7 +221,7 @@ vcsrepo { '/path/to/repo': } ~~~ -To branch from a specific revision, set `revision` to a valid [Bazaar revisionspec](http://wiki.bazaar.canonical.com/BzrRevisionSpec): +To branch from a specific revision, set `revision` to a valid [Bazaar revision spec](http://wiki.bazaar.canonical.com/BzrRevisionSpec): ~~~ vcsrepo { '/path/to/repo': @@ -686,7 +686,7 @@ Specifies the remote repository to track. (Requires the `multiple_remotes` featu Sets the revision of the repository. Valid options vary by provider: * `git` - a string containing a Git branch name, or a commit SHA or tag -* `bzr` - a string containing a Bazaar [revisionspec](http://wiki.bazaar.canonical.com/BzrRevisionSpec) +* `bzr` - a string containing a Bazaar [revision spec](http://wiki.bazaar.canonical.com/BzrRevisionSpec) * `cvs` - a string containing a CVS [tag or revision number](http://www.thathost.com/wincvs-howto/cvsdoc/cvs_4.html) * `hg` - a string containing a Mercurial [changeset ID](http://mercurial.selenic.com/wiki/ChangeSetID) or [tag](http://mercurial.selenic.com/wiki/Tag) * `p4` - a string containing a Perforce [change number, label name, client name, or date spec](http://www.perforce.com/perforce/r12.1/manuals/cmdref/o.fspecs.html) @@ -723,10 +723,13 @@ This module has been tested with Puppet 2.7 and higher. The module has been tested on: -* Red Hat Enterprise Linux 5/6 -* Debian 6/7 -* CentOS 5/6 -* Ubuntu 12.04 +* CentOS 5/6/7 +* Debian 6/7 +* Oracle 5/6/7 +* Red Hat Enterprise Linux 5/6/7 +* Scientific Linux 5/6/7 +* SLES 10/11/12 +* Ubuntu 10.04/12.04/14.04 Testing on other platforms has been light and cannot be guaranteed. -- cgit v1.2.3 From 8f47c4e744992a70028a4a744ae654d6fd6d7233 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 27 May 2015 08:15:02 -0700 Subject: Add ability to unittest puppet 4 --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 291ceb3..727f6e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,9 +14,14 @@ matrix: env: PUPPET_GEM_VERSION="~> 3.0" - rvm: 2.1.5 env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" + - rvm: 2.1.6 + env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" - rvm: 1.8.7 env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" - rvm: 1.8.7 env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" + allow_failures: + - rvm: 2.1.6 + env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" notifications: email: false -- cgit v1.2.3 From 8d3e112fec38627096e7d18d796e3abeaf677d66 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Fri, 29 May 2015 13:00:42 +0100 Subject: acceptance: Add a test verifying anonymous https cloning In MODULES-891 the question arose whether https sources are supported. This test shows that it works. --- spec/acceptance/clone_repo_spec.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb index 2cca061..c234550 100644 --- a/spec/acceptance/clone_repo_spec.rb +++ b/spec/acceptance/clone_repo_spec.rb @@ -38,6 +38,30 @@ describe 'clones a remote repo' do end end + context 'using a https source on github' do + it 'clones a repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/httpstestrepo": + ensure => present, + provider => git, + source => "https://github.com/puppetlabs/puppetlabs-vcsrepo.git", + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/httpstestrepo/.git") do + it { is_expected.to be_directory } + end + + describe file("#{tmpdir}/httpstestrepo/.git/HEAD") do + it { is_expected.to contain 'ref: refs/heads/master' } + end + end + context 'using a commit SHA' do let (:sha) do shell("git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1").stdout.chomp -- cgit v1.2.3 From a37c388f1b4c7b2d3db12fefe35261d067486f9f Mon Sep 17 00:00:00 2001 From: Justin Stoller Date: Mon, 8 Jun 2015 22:32:54 -0700 Subject: (maint) allow setting PUPPET_VERSION in acceptance --- spec/spec_helper_acceptance.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 9ef826a..78074f7 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -3,7 +3,10 @@ require 'beaker-rspec' unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no' # This will install the latest available package on el and deb based # systems fail on windows and osx, and install via gem on other *nixes - foss_opts = { :default_action => 'gem_install' } + foss_opts = { + :default_action => 'gem_install', + :version => (ENV['PUPPET_VERSION'] || '3.8.1'), + } if default.is_pe?; then install_pe; else install_puppet( foss_opts ); end -- cgit v1.2.3 From 153b27bef2cc146465938a7a168da5ebe439c9f8 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Thu, 11 Jun 2015 15:41:17 -0700 Subject: Add helper to install puppet/pe/puppet-agent --- Gemfile | 1 + spec/spec_helper_acceptance.rb | 25 ++----------------------- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/Gemfile b/Gemfile index 2b1b7cd..bfe64b1 100644 --- a/Gemfile +++ b/Gemfile @@ -28,6 +28,7 @@ group :system_tests do gem 'beaker-rspec', :require => false end gem 'serverspec', :require => false + gem 'beaker-puppet_install_helper', :require => false end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 78074f7..97c43e8 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,28 +1,7 @@ require 'beaker-rspec' +require 'beaker/puppet_install_helper' -unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no' - # This will install the latest available package on el and deb based - # systems fail on windows and osx, and install via gem on other *nixes - foss_opts = { - :default_action => 'gem_install', - :version => (ENV['PUPPET_VERSION'] || '3.8.1'), - } - - if default.is_pe?; then install_pe; else install_puppet( foss_opts ); end - - hosts.each do |host| - unless host.is_pe? - on hosts, "mkdir -p #{hosts.first['distmoduledir']}" - end - - # We ask the host to interpolate it's distmoduledir because we don't - # actually know it on Windows until we've let it redirect us (depending - # on whether we're running as a 32/64 bit process on 32/64 bit Windows - moduledir = on(host, "echo #{host['distmoduledir']}").stdout.chomp - on host, "mkdir -p #{moduledir}" - end -end - +run_puppet_install_helper RSpec.configure do |c| # Project root -- cgit v1.2.3 From ae60f5ccb7c00a0e162a06ba05d247688ffbce4b Mon Sep 17 00:00:00 2001 From: Jonathan Tripathy Date: Mon, 22 Jun 2015 15:22:16 +0100 Subject: MODULES-2131 Git provider now takes account of revision property when using depth property. --- lib/puppet/provider/vcsrepo/git.rb | 3 +++ spec/unit/puppet/provider/vcsrepo/git_spec.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 13e0793..4603029 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -125,6 +125,9 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) args = ['clone'] if @resource.value(:depth) and @resource.value(:depth).to_i > 0 args.push('--depth', @resource.value(:depth).to_s) + if @resource.value(:revision) + args.push('--branch', @resource.value(:revision).to_s) + end end if @resource.value(:ensure) == :bare args << '--bare' diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index 116e357..29c6b3b 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -60,7 +60,7 @@ branches resource[:depth] = 1 Dir.expects(:chdir).with('/').at_least_once.yields Dir.expects(:chdir).with('/tmp/test').at_least_once.yields - provider.expects(:git).with('clone', '--depth', '1', resource.value(:source), resource.value(:path)) + provider.expects(:git).with('clone', '--depth', '1', '--branch', resource.value(:revision),resource.value(:source), resource.value(:path)) provider.expects(:update_submodules) provider.expects(:git).with('branch', '-a').returns(branch_a_list(resource.value(:revision))) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) -- cgit v1.2.3 From b3cddcbd57639acbf0c4a7fa671a70f787e010da Mon Sep 17 00:00:00 2001 From: Samuel Keeley Date: Mon, 29 Jun 2015 12:01:10 -0700 Subject: fix for detached HEAD on git 2.4+ --- lib/puppet/provider/vcsrepo/git.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 8074950..bf11f3d 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -329,11 +329,13 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) at_path { git_with_identity('branch', '-a') }.gsub('*', ' ').split(/\n/).map { |line| line.strip } end + # git < 2.4 returns 'detached from' + # git 2.4+ returns 'HEAD detached at' # @!visibility private def on_branch? at_path { matches = git_with_identity('branch', '-a').match /\*\s+(.*)/ - matches[1] unless matches[1].match /(\(detached from|\(no branch)/ + matches[1] unless matches[1].match /(\(detached from|\(HEAD detached at|\(no branch)/ } end -- cgit v1.2.3 From 2a498ae29cd2d4eeac52fa123bb97e5e2d5b1c90 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Wed, 22 Jul 2015 11:51:37 -0700 Subject: Explitly unset SSH_AUTH_SOCK; it is preferred to the -i flag Even if the -i flag is explicitly passed via the command line, openssh ignores the identity file if an socket exists to an SSH authentication agent. In cases where puppet has been configured to use an explicit identity file, altering behavior based on the calling environment of puppet violates the principle of least surprise, and can lead to inconsistent deployments. Work around this odd corner case of ssh by explicitly unsetting SSH_AUTH_SOCK inside the ssh wrapper. --- lib/puppet/provider/vcsrepo/git.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index bf11f3d..7e921a9 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -425,6 +425,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) if @resource.value(:identity) Tempfile.open('git-helper', Puppet[:statedir]) do |f| f.puts '#!/bin/sh' + f.puts 'export SSH_AUTH_SOCKET=' f.puts "exec ssh -oStrictHostKeyChecking=no -oPasswordAuthentication=no -oKbdInteractiveAuthentication=no -oChallengeResponseAuthentication=no -oConnectTimeout=120 -i #{@resource.value(:identity)} $*" f.close -- cgit v1.2.3 From 03ceba70e71e32a4ed56a06c716d91f7db2783f9 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 24 Jul 2015 15:28:24 -0700 Subject: 1.3.1 prep --- CHANGELOG.md | 11 +++++++++++ metadata.json | 12 ++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad10e97..7d1060c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,16 @@ # Change Log All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [1.3.1] - 2015-07-28 Supported Release +###Summary +This release includes a number of bugfixes along with some test updates. + +### Fixed +- Fix for detached HEAD on git 2.4+ +- Git provider doesn't ignore revision property when depth is used (MODULES-2131) +- Test fixes +- Check if submodules == true before calling update_submodules + ## [1.3.0] - 2015-05-19 Supported Release ### Summary This release adds git provider remote handling, svn conflict resolution, and fixes the git provider when /tmp is mounted noexec. @@ -125,6 +135,7 @@ our many contributors for all of these fixes! - CVS: - Documented the "module" attribute. +[1.3.1]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.3.0...1.3.1 [1.3.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.2.0...1.3.0 [1.2.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.1.0...1.2.0 [1.1.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.0.2...1.1.0 diff --git a/metadata.json b/metadata.json index ef74e86..1552840 100644 --- a/metadata.json +++ b/metadata.json @@ -1,12 +1,15 @@ { "name": "puppetlabs-vcsrepo", - "version": "1.3.0", + "version": "1.3.1", "author": "Puppet Labs", "summary": "Puppet module providing a type to manage repositories from various version control systems", "license": "GPLv2", "source": "https://github.com/puppetlabs/puppetlabs-vcsrepo", "project_page": "https://github.com/puppetlabs/puppetlabs-vcsrepo", "issues_url": "https://tickets.puppetlabs.com/browse/MODULES", + "dependencies": [ + + ], "operatingsystem_support": [ { "operatingsystem": "RedHat", @@ -67,14 +70,11 @@ "requirements": [ { "name": "pe", - "version_requirement": "3.x" + "version_requirement": ">= 3.0.0 < 2015.3.0" }, { "name": "puppet", - "version_requirement": "3.x" + "version_requirement": ">= 3.0.0 < 5.0.0" } - ], - "dependencies": [ - ] } -- cgit v1.2.3 From d68402d1f930d5a30f1ec9224ac3791b6d9d29b9 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 3 Aug 2015 16:49:01 -0700 Subject: MODULES-1800 - fix case where ensure => latest and no revision specified This would explode when revision was unspecified when you were on a branch. Use the branch you're currently on when updating. --- lib/puppet/provider/vcsrepo/git.rb | 8 +++++-- spec/acceptance/modules_1800_spec.rb | 41 ++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 spec/acceptance/modules_1800_spec.rb diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index bf11f3d..f13802b 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -45,7 +45,11 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) # # @return [String] Returns the target sha/tag/branch def latest - @resource.value(:revision) + if not @resource.value(:revision) and branch = on_branch? + return branch + else + return @resource.value(:revision) + end end # Get the current revision of the repo (tag/branch/sha) @@ -281,7 +285,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) # handle upstream branch changes # @!visibility private def checkout(revision = @resource.value(:revision)) - if !local_branch_revision? && remote_branch_revision? + if !local_branch_revision?(revision) && remote_branch_revision?(revision) #non-locally existant branches (perhaps switching to a branch that has never been checked out) at_path { git_with_identity('checkout', '--force', '-b', revision, '--track', "#{@resource.value(:remote)}/#{revision}") } else diff --git a/spec/acceptance/modules_1800_spec.rb b/spec/acceptance/modules_1800_spec.rb new file mode 100644 index 0000000..12415e8 --- /dev/null +++ b/spec/acceptance/modules_1800_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper_acceptance' + +tmpdir = default.tmpdir('vcsrepo') + +describe 'clones a remote repo' do + before(:all) do + my_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + shell("mkdir -p #{tmpdir}") # win test + end + + after(:all) do + shell("rm -rf #{tmpdir}/vcsrepo") + end + + context 'ensure latest with no revision' do + it 'clones from default remote' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/vcsrepo": + ensure => present, + provider => git, + source => "https://github.com/puppetlabs/puppetlabs-vcsrepo.git", + } + EOS + + apply_manifest(pp, :catch_failures => true) + shell("cd #{tmpdir}/vcsrepo; /usr/bin/git reset --hard HEAD~2") + end + + it 'updates' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/vcsrepo": + ensure => latest, + provider => git, + source => "https://github.com/puppetlabs/puppetlabs-vcsrepo.git", + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + end +end -- cgit v1.2.3 From 14c05f5d6c589bebc9f93eb117105c14ce7be6f1 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Thu, 13 Aug 2015 16:02:22 -0700 Subject: MODULES-2125 - Allow revision to be passed without source Will also work with empty repositories. --- lib/puppet/provider/vcsrepo/git.rb | 18 ++++++++++++++++-- spec/acceptance/create_repo_spec.rb | 16 ++++++++++++++++ spec/unit/puppet/provider/vcsrepo/git_spec.rb | 10 +++++++++- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index f13802b..7617b13 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -76,7 +76,11 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) #updated and authoritative. #TODO might be worthwhile to have an allow_local_changes param to decide #whether to reset or pull when we're ensuring latest. - at_path { git_with_identity('reset', '--hard', "#{@resource.value(:remote)}/#{desired}") } + if @resource.value(:source) + at_path { git_with_identity('reset', '--hard', "#{@resource.value(:remote)}/#{desired}") } + else + at_path { git_with_identity('reset', '--hard', "#{desired}") } + end end #TODO Would this ever reach here if it is bare? if @resource.value(:ensure) != :bare && @resource.value(:submodules) == :true @@ -392,7 +396,17 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) # @return [String] Returns the tag/branch of the current repo if it's up to # date; otherwise returns the sha of the requested revision. def get_revision(rev = 'HEAD') - update_references + if @resource.value(:source) + update_references + else + status = at_path { git_with_identity('status')} + is_it_new = status =~ /Initial commit/ + if is_it_new + status =~ /On branch (.*)/ + branch = $1 + return branch + end + end current = at_path { git_with_identity('rev-parse', rev).strip } if @resource.value(:revision) if tag_revision? diff --git a/spec/acceptance/create_repo_spec.rb b/spec/acceptance/create_repo_spec.rb index db0cd29..53a93c9 100644 --- a/spec/acceptance/create_repo_spec.rb +++ b/spec/acceptance/create_repo_spec.rb @@ -30,6 +30,22 @@ describe 'create a repo' do end end + context 'no source but revision provided' do + it 'should not fail (MODULES-2125)' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_blank_with_revision_repo": + ensure => present, + provider => git, + revision => 'master' + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + end + context 'bare repo' do it 'creates a bare repo' do pp = <<-EOS diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index a240b50..87113fa 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -206,7 +206,7 @@ branches before do expects_chdir('/tmp/test') resource[:revision] = 'currentsha' - resource.delete(:source) + resource[:source] = 'http://example.com' provider.stubs(:git).with('config', 'remote.origin.url').returns('') provider.stubs(:git).with('fetch', 'origin') # FIXME provider.stubs(:git).with('fetch', '--tags', 'origin') @@ -272,6 +272,14 @@ branches end end + context "when there's no source" do + it 'should return the revision' do + resource.delete(:source) + provider.expects(:git).with('status') + provider.expects(:git).with('rev-parse', resource.value(:revision)).returns('currentsha') + expect(provider.revision).to eq(resource.value(:revision)) + end + end end context "setting the revision property" do -- cgit v1.2.3 From 6b01539dfee074b798f7e96cb228a42ae6a42c8b Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Sat, 15 Aug 2015 15:45:39 +0200 Subject: Autorequire Package['mercurial'] Along the lines of 2b190756260346931b8f9a0dda8afc0c815710d6, if the Mercurial package is being managed, it stands to reason that the Mercurial package should be installed before trying to potentially manage Mercurial repositories using vcsrepo resources. This commit adds an autorequire to the vcsrepo type that reflects the above premise. --- lib/puppet/type/vcsrepo.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/type/vcsrepo.rb b/lib/puppet/type/vcsrepo.rb index e5dfbb5..ed5d55a 100644 --- a/lib/puppet/type/vcsrepo.rb +++ b/lib/puppet/type/vcsrepo.rb @@ -229,6 +229,6 @@ Puppet::Type.newtype(:vcsrepo) do end autorequire(:package) do - ['git', 'git-core'] + ['git', 'git-core', 'mercurial'] end end -- cgit v1.2.3 From f385df10c57a0a09fa316004e6af18acd56df710 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 17 Aug 2015 12:14:18 -0700 Subject: MODULES-2326 - Run Regexp.escape on the source URL The URL can have special characters, making the regex match fail. --- lib/puppet/provider/vcsrepo/git.rb | 2 +- spec/acceptance/modules_2326_spec.rb | 69 ++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 spec/acceptance/modules_2326_spec.rb diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 7617b13..4623f8e 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -111,7 +111,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) def working_copy_exists? if @resource.value(:source) and File.exists?(File.join(@resource.value(:path), '.git', 'config')) - File.readlines(File.join(@resource.value(:path), '.git', 'config')).grep(/#{default_url}/).any? + File.readlines(File.join(@resource.value(:path), '.git', 'config')).grep(/#{Regexp.escape(default_url)}/).any? else File.directory?(File.join(@resource.value(:path), '.git')) end diff --git a/spec/acceptance/modules_2326_spec.rb b/spec/acceptance/modules_2326_spec.rb new file mode 100644 index 0000000..d62dbb0 --- /dev/null +++ b/spec/acceptance/modules_2326_spec.rb @@ -0,0 +1,69 @@ +require 'spec_helper_acceptance' + +tmpdir = default.tmpdir('vcsrepo') + +describe 'clones with special characters' do + + before(:all) do + my_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + shell("mkdir -p #{tmpdir}") # win test + scp_to(default, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + shell("cd #{tmpdir} && ./create_git_repo.sh") + end + + after(:all) do + shell("rm -rf #{tmpdir}/testrepo.git") + end + + context 'as a user with ssh' do + before(:all) do + # create user + pp = <<-EOS + group { 'testuser-ssh': + ensure => present, + } + user { 'testuser-ssh': + ensure => present, + groups => 'testuser-ssh', + managehome => true, + } + EOS + apply_manifest(pp, :catch_failures => true) + + # create ssh keys + shell('mkdir -p /home/testuser-ssh/.ssh') + shell('ssh-keygen -q -t rsa -f /home/testuser-ssh/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + shell('cat /home/testuser-ssh/.ssh/id_rsa.pub > /home/testuser-ssh/.ssh/authorized_keys') + shell('echo -e "Host localhost\n\tStrictHostKeyChecking no\n" > /home/testuser-ssh/.ssh/config') + shell('chown -R testuser-ssh:testuser-ssh /home/testuser-ssh/.ssh') + shell("chown testuser-ssh:testuser-ssh #{tmpdir}") + end + + it 'applies the manifest' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_user_ssh": + ensure => present, + provider => git, + source => "git+ssh://testuser-ssh@localhost#{tmpdir}/testrepo.git", + user => 'testuser-ssh', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + after(:all) do + pp = <<-EOS + user { 'testuser-ssh': + ensure => absent, + managehome => true, + } + EOS + apply_manifest(pp, :catch_failures => true) + end + end +end -- cgit v1.2.3 From 965f657c48c1855422384dfc6cad5d64a82a5ab6 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Thu, 20 Aug 2015 15:24:28 -0700 Subject: Fix acceptance hang The ssh-keygen is waiting for a 'y' to confirm overwrite, and the test hangs. --- spec/acceptance/modules_2326_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/acceptance/modules_2326_spec.rb b/spec/acceptance/modules_2326_spec.rb index d62dbb0..601c6ff 100644 --- a/spec/acceptance/modules_2326_spec.rb +++ b/spec/acceptance/modules_2326_spec.rb @@ -32,7 +32,7 @@ describe 'clones with special characters' do # create ssh keys shell('mkdir -p /home/testuser-ssh/.ssh') - shell('ssh-keygen -q -t rsa -f /home/testuser-ssh/.ssh/id_rsa -N ""') + shell('echo -e \'y\n\'|ssh-keygen -q -t rsa -f /home/testuser-ssh/.ssh/id_rsa -N ""') # copy public key to authorized_keys shell('cat /home/testuser-ssh/.ssh/id_rsa.pub > /home/testuser-ssh/.ssh/authorized_keys') -- cgit v1.2.3 From d196a2a61deee9290826407ab17b994e0747f0af Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Tue, 25 Aug 2015 16:14:04 -0700 Subject: Remove 2.7 from travis matrix I believe 2.7 in the matrix is an error, this module has never claimed support for 2.7 and 2.7 currently doesn't work (though fails in places that are not unit tested) --- .sync.yml | 6 ------ .travis.yml | 4 ---- 2 files changed, 10 deletions(-) diff --git a/.sync.yml b/.sync.yml index 02c6c83..f4b637c 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,11 +1,5 @@ --- .travis.yml: - script: "\"bundle exec rake spec SPEC_OPTS='--format documentation'\"" - extras: - - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" - - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" Rakefile: unmanaged: true spec/spec_helper.rb: diff --git a/.travis.yml b/.travis.yml index 727f6e7..1155a2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,10 +16,6 @@ matrix: env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" - rvm: 2.1.6 env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" - - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" - - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" allow_failures: - rvm: 2.1.6 env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" -- cgit v1.2.3 From ba9d0cf6c1d98ea70270faa5cf4e70997ea75595 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 24 Aug 2015 17:07:37 -0700 Subject: MODULES-1232 Make sure HOME is set correctly --- lib/puppet/provider/vcsrepo/git.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 4623f8e..a34b154 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -3,7 +3,9 @@ require File.join(File.dirname(__FILE__), '..', 'vcsrepo') Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) do desc "Supports Git repositories" - commands :git => 'git' + has_command(:git, 'git') do + environment({ 'HOME' => ENV['HOME'] }) + end has_features :bare_repositories, :reference_tracking, :ssh_identity, :multiple_remotes, :user, :depth, :branch, :submodules @@ -457,7 +459,8 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) return ret end elsif @resource.value(:user) and @resource.value(:user) != Facter['id'].value - Puppet::Util::Execution.execute("git #{args.join(' ')}", :uid => @resource.value(:user), :failonfail => true) + env = Etc.getpwnam(@resource.value(:user)) + Puppet::Util::Execution.execute("git #{args.join(' ')}", :uid => @resource.value(:user), :failonfail => true, :custom_environment => {'HOME' => env['dir']}) else git(*args) end -- cgit v1.2.3 From dc1f92fe2b4e3dd9a54f3e45e1ae052b9f8e921e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?W=C5=82odzimierz=20Gajda?= Date: Wed, 26 Aug 2015 17:10:56 +0200 Subject: Example how to create a shallow clone with just one commit --- examples/git/shallow-clone-with-just-one-commit.pp | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 examples/git/shallow-clone-with-just-one-commit.pp diff --git a/examples/git/shallow-clone-with-just-one-commit.pp b/examples/git/shallow-clone-with-just-one-commit.pp new file mode 100644 index 0000000..cd5a05d --- /dev/null +++ b/examples/git/shallow-clone-with-just-one-commit.pp @@ -0,0 +1,7 @@ +vcsrepo { '/tmp/git': + ensure => 'present', + provider => 'git', + source => 'https://github.com/git/git.git', + branch => 'v2.2.0', + depth => 1, +} -- cgit v1.2.3 From 7758331f503a9198921362761079cbfd941c625e Mon Sep 17 00:00:00 2001 From: monai Date: Wed, 9 Sep 2015 19:20:58 +0300 Subject: Add feature depth and param trust_server_cert to svn added param trust server cert updated depth feature updated README.markdown trust_server_cert is not feature trust_server_cert default value should be false add test for depth and trust_server_cert --- README.markdown | 300 +++++++++++++------------- lib/puppet/provider/vcsrepo/svn.rb | 14 +- lib/puppet/type/vcsrepo.rb | 8 +- spec/unit/puppet/provider/vcsrepo/svn_spec.rb | 22 ++ 4 files changed, 193 insertions(+), 151 deletions(-) diff --git a/README.markdown b/README.markdown index badb1ce..4c65bbc 100644 --- a/README.markdown +++ b/README.markdown @@ -180,7 +180,7 @@ vcsrepo { '/path/to/repo': } ~~~ -**Note:** if you set `source` to a hash, one of the names you specify must match the value of the `remote` parameter. That remote serves as the upstream of your managed repository. +**Note:** if you set `source` to a hash, one of the names you specify must match the value of the `remote` parameter. That remote serves as the upstream of your managed repository. ####Connect via SSH @@ -196,7 +196,7 @@ vcsrepo { '/path/to/repo': user => 'toto', #uses toto's $HOME/.ssh setup require => File['/home/toto/.ssh/id_rsa'], } -~~~ +~~~ ###Bazaar @@ -235,7 +235,7 @@ vcsrepo { '/path/to/repo': ####Connect via SSH To connect to your source repository via SSH (e.g., `'bzr+ssh://...'` or `'sftp://...,'`), we recommend using the [`require`](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter to make sure your SSH keys are present before the `vcsrepo` resource is applied: - + ~~~ vcsrepo { '/path/to/repo': ensure => latest, @@ -244,7 +244,7 @@ vcsrepo { '/path/to/repo': user => 'toto', #uses toto's $HOME/.ssh setup require => File['/home/toto/.ssh/id_rsa'], } -~~~ +~~~ ###CVS @@ -301,10 +301,10 @@ vcsrepo { '/path/to/workspace': source => ':pserver:anonymous@example.com:/sources/myproj', revision => '1.2', } -~~~ - +~~~ + You can also set `revision` to a tag: - + ~~~ vcsrepo { '/path/to/workspace': ensure => present, @@ -313,12 +313,12 @@ vcsrepo { '/path/to/workspace': source => ':pserver:anonymous@example.com:/sources/myproj', revision => 'SOMETAG', } -~~~ +~~~ ####Connect via SSH To connect to your source repository via SSH, we recommend using the [`require`](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter to make sure your SSH keys are present before the `vcsrepo` resource is applied: - + ~~~ vcsrepo { '/path/to/repo': ensure => latest, @@ -413,7 +413,7 @@ vcsrepo { '/path/to/repo': ####Connect via SSH To connect to your source repository via SSH (e.g., `'ssh://...'`), we recommend using the [`require` metaparameter](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) to make sure your SSH keys are present before the `vcsrepo` resource is applied: - + ~~~ vcsrepo { '/path/to/repo': ensure => latest, @@ -425,11 +425,11 @@ vcsrepo { '/path/to/repo': ~~~ ###Perforce - -####Create an empty workspace - -To set up the connection to your Perforce service, set `p4config` to the location of a valid Perforce [config file](http://www.perforce.com/perforce/doc.current/manuals/p4guide/chapter.configuration.html#configuration.settings.configfiles) stored on the node: - + +####Create an empty workspace + +To set up the connection to your Perforce service, set `p4config` to the location of a valid Perforce [config file](http://www.perforce.com/perforce/doc.current/manuals/p4guide/chapter.configuration.html#configuration.settings.configfiles) stored on the node: + ~~~ vcsrepo { '/path/to/repo': ensure => present, @@ -437,9 +437,9 @@ vcsrepo { '/path/to/repo': p4config => '/root/.p4config' } ~~~ - -**Note:** If you don't include the `P4CLIENT` setting in your config file, the provider generates a workspace name based on the digest of `path` and the node's hostname (e.g., `puppet-91bc00640c4e5a17787286acbe2c021c`): - + +**Note:** If you don't include the `P4CLIENT` setting in your config file, the provider generates a workspace name based on the digest of `path` and the node's hostname (e.g., `puppet-91bc00640c4e5a17787286acbe2c021c`): + ####Create/update and sync a Perforce workspace To sync a depot path to head, set `ensure` to 'latest': @@ -524,7 +524,7 @@ vcsrepo { '/path/to/repo': ####Connect via SSH To connect to your source repository via SSH (e.g., `'svn+ssh://...'`), we recommend using the [`require` metaparameter](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) to make sure your SSH keys are present before the `vcsrepo` resource is applied: - + ~~~ vcsrepo { '/path/to/repo': ensure => latest, @@ -547,7 +547,7 @@ The vcsrepo module adds only one type with several providers. Each provider abst #####`git` - Supports the Git VCS. -Features: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `submodules`, `user` +Features: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `submodules`, `user` Parameters: `depth`, `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `remote`, `revision`, `source`, `user` @@ -555,42 +555,42 @@ Parameters: `depth`, `ensure`, `excludes`, `force`, `group`, `identity`, `owner` Features: `reference_tracking` -Parameters: `ensure`, `excludes`, `force`, `group`, `owner`, `path`, `provider`, `revision`, `source` +Parameters: `ensure`, `excludes`, `force`, `group`, `owner`, `path`, `provider`, `revision`, `source` #####`cvs` - Supports the CVS VCS. Features: `cvs_rsh`, `gzip_compression`, `modules`, `reference_tracking`, `user` - -Parameters: `compression`, `cvs_rsh`, `ensure`, `excludes`, `force`, `group`, `module`, `owner`, `path`, `provider` + +Parameters: `compression`, `cvs_rsh`, `ensure`, `excludes`, `force`, `group`, `module`, `owner`, `path`, `provider` #####`hg` - Supports the Mercurial VCS. -Features: `reference_tracking`, `ssh_identity`, `user` +Features: `reference_tracking`, `ssh_identity`, `user` -Parameters: `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `revision`, `source`, `user` +Parameters: `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `revision`, `source`, `user` #####`p4` - Supports the Perforce VCS. -Features: `p4config`, `reference_tracking` +Features: `p4config`, `reference_tracking` -Parameters: `ensure`, `excludes`, `force`, `group`, `owner`, `p4config`, `path`, `provider`, `revision`, `source` +Parameters: `ensure`, `excludes`, `force`, `group`, `owner`, `p4config`, `path`, `provider`, `revision`, `source` #####`svn` - Supports the Subversion VCS. -Features: `basic_auth`, `configuration`, `conflict`, `filesystem_types`, `reference_tracking` - -Parameters: `basic_auth_password`, `basic_auth_username`, `configuration`, `conflict`, `ensure`, `excludes`, `force`, `fstype`, `group`, `owner`, `path`, `provider`, `revision`, `source` +Features: `basic_auth`, `configuration`, `conflict`, `depth`, `filesystem_types`, `reference_tracking` + +Parameters: `basic_auth_password`, `basic_auth_username`, `configuration`, `conflict`, `ensure`, `excludes`, `force`, `fstype`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `trust_server_cert` ####Features **Note:** Not all features are available with all providers. * `bare_repositories` - Differentiates between bare repositories and those with working copies. (Available with `git`.) -* `basic_auth` - Supports HTTP Basic authentication. (Available with `svn`.) +* `basic_auth` - Supports HTTP Basic authentication. (Available with `svn`.) * `conflict` - Lets you decide how to resolve any conflicts between the source repository and your working copy. (Available with `svn`.) * `configuration` - Lets you specify the location of your configuration files. (Available with `svn`.) * `cvs_rsh` - Understands the `CVS_RSH` environment variable. (Available with `cvs`.) -* `depth` - Supports shallow clones. (Available with `git`.) +* `depth` - Supports shallow clones in `git` or sets scope limit in `svn`. (Available with `git` and `svn`.) * `filesystem_types` - Supports multiple types of filesystem. (Available with `svn`.) * `gzip_compression` - Supports explicit GZip compression levels. (Available with `cvs`.) * `modules` - Lets you choose a specific repository module. (Available with `cvs`.) @@ -603,116 +603,122 @@ Parameters: `basic_auth_password`, `basic_auth_username`, `configuration`, `conf ####Parameters -All parameters are optional, except where specified otherwise. - -##### `basic_auth_password` - -Specifies the password for HTTP Basic authentication. (Requires the `basic_auth` feature.) Valid options: a string. Default: none. - -##### `basic_auth_username` - -Specifies the username for HTTP Basic authentication. (Requires the `basic_auth` feature.) Valid options: a string. Default: none. - -##### `compression` - -Sets the GZIP compression level for the repository history. (Requires the `gzip_compression` feature.) Valid options: an integer between 0 and 6. Default: none. - -##### `configuration` - -Sets the configuration directory to use. (Requires the `configuration` feature.) Valid options: a string containing an absolute path. Default: none. - -##### `conflict` - -Tells Subversion how to resolve any conflicts between the source repository and your working copy. (Requires the `conflict` feature.) Valid options: 'base', 'mine-full', 'theirs-full', and 'working'. Default: none. - -##### `cvs_rsh` - -Provides a value for the `CVS_RSH` environment variable. (Requires the `cvs_rsh` feature.) Valid options: a string. Default: none. - -##### `depth` - -Sets the number of commits to include when creating a shallow clone. (Requires the `depth` feature.) Valid options: an integer. Default: none. - -##### `ensure` - -Specifies whether the repository should exist. Valid options: 'present', 'bare', 'absent', and 'latest'. Default: 'present'. - -##### `excludes` - -Lists any files the repository shouldn't track (similar to .gitignore). Valid options: a string (separate multiple values with the newline character). Default: none. - -##### `force` - -Specifies whether to delete any existing files in the repository path if creating a new repository. **Use with care.** Valid options: 'true' and 'false'. Default: 'false'. - -##### `fstype` - -Sets the filesystem type. (Requires the `filesystem_types` feature.) Valid options: 'fsfs' or 'bdb'. Default: none. - -##### `group` - -Specifies a group to own the repository files. Valid options: a string containing a group name or GID. Default: none. - -##### `identity` - -Specifies an identity file to use for SSH authentication. (Requires the `ssh_identity` feature.) Valid options: a string containing an absolute path. Default: none. - -##### `module` - -Specifies the repository module to manage. (Requires the `modules` feature.) Valid options: a string containing the name of a CVS module. Default: none. - -##### `owner` - -Specifies a user to own the repository files. Valid options: a string containing a username or UID. Default: none. - -##### `p4config` - -Specifies a config file that contains settings for connecting to the Perforce service. (Requires the `p4config` feature.) Valid options: a string containing the absolute path to a valid [Perforce config file](http://www.perforce.com/perforce/doc.current/manuals/p4guide/chapter.configuration.html#configuration.settings.configfiles). Default: none. - -##### `path` - -Specifies a location for the managed repository. Valid options: a string containing an absolute path. Default: the title of your declared resource. - -##### `provider` - -*Required.* Specifies the backend to use for this vcsrepo resource. Valid options: 'bzr', 'cvs', 'git', 'hg', 'p4', and 'svn'. - -##### `remote` - -Specifies the remote repository to track. (Requires the `multiple_remotes` feature.) Valid options: a string containing one of the remote names specified in `source`. Default: 'origin'. - -##### `revision` - -Sets the revision of the repository. Valid options vary by provider: - -* `git` - a string containing a Git branch name, or a commit SHA or tag -* `bzr` - a string containing a Bazaar [revision spec](http://wiki.bazaar.canonical.com/BzrRevisionSpec) -* `cvs` - a string containing a CVS [tag or revision number](http://www.thathost.com/wincvs-howto/cvsdoc/cvs_4.html) -* `hg` - a string containing a Mercurial [changeset ID](http://mercurial.selenic.com/wiki/ChangeSetID) or [tag](http://mercurial.selenic.com/wiki/Tag) -* `p4` - a string containing a Perforce [change number, label name, client name, or date spec](http://www.perforce.com/perforce/r12.1/manuals/cmdref/o.fspecs.html) -* `svn` - a string containing a Subversion [revision number](http://svnbook.red-bean.com/en/1.7/svn.basic.in-action.html#svn.basic.in-action.revs), [revision keyword, or revision date](http://svnbook.red-bean.com/en/1.7/svn.tour.revs.specifiers.html) - -Default: none. - -##### `source` - -Specifies a source repository to serve as the upstream for your managed repository. Default: none. Valid options vary by provider: - -* `git` - a string containing a [Git repository URL](https://www.kernel.org/pub/software/scm/git/docs/git-clone.html#_git_urls_a_id_urls_a) or a hash of name => URL mappings. See also [`remote`](#remote). -* `bzr` - a string containing a Bazaar branch location -* `cvs` - a string containing a CVS root -* `hg` - a string containing the local path or URL of a Mercurial repository -* `p4` - a string containing a Perforce depot path -* `svn` - a string containing a Subversion repository URL - -Default: none. - -##### `submodules` - -Specifies whether to initialize and update each submodule in the repository. (Requires the `submodules` feature.) Valid options: 'true' and 'false'. Default: 'true'. - -##### `user` - +All parameters are optional, except where specified otherwise. + +##### `basic_auth_password` + +Specifies the password for HTTP Basic authentication. (Requires the `basic_auth` feature.) Valid options: a string. Default: none. + +##### `basic_auth_username` + +Specifies the username for HTTP Basic authentication. (Requires the `basic_auth` feature.) Valid options: a string. Default: none. + +##### `compression` + +Sets the GZIP compression level for the repository history. (Requires the `gzip_compression` feature.) Valid options: an integer between 0 and 6. Default: none. + +##### `configuration` + +Sets the configuration directory to use. (Requires the `configuration` feature.) Valid options: a string containing an absolute path. Default: none. + +##### `conflict` + +Tells Subversion how to resolve any conflicts between the source repository and your working copy. (Requires the `conflict` feature.) Valid options: 'base', 'mine-full', 'theirs-full', and 'working'. Default: none. + +##### `cvs_rsh` + +Provides a value for the `CVS_RSH` environment variable. (Requires the `cvs_rsh` feature.) Valid options: a string. Default: none. + +##### `depth` + +In `git` sets the number of commits to include when creating a shallow clone. (Requires the `depth` feature.) Valid options: an integer. Default: none. + +In `svn` instructs Subversion to limit the scope of an operation to a particular tree depth. (Requires the `depth` feature.) Valid options: 'empty', 'files', 'immediates', 'infinity'. Default: none. + +##### `ensure` + +Specifies whether the repository should exist. Valid options: 'present', 'bare', 'absent', and 'latest'. Default: 'present'. + +##### `excludes` + +Lists any files the repository shouldn't track (similar to .gitignore). Valid options: a string (separate multiple values with the newline character). Default: none. + +##### `force` + +Specifies whether to delete any existing files in the repository path if creating a new repository. **Use with care.** Valid options: 'true' and 'false'. Default: 'false'. + +##### `fstype` + +Sets the filesystem type. (Requires the `filesystem_types` feature.) Valid options: 'fsfs' or 'bdb'. Default: none. + +##### `group` + +Specifies a group to own the repository files. Valid options: a string containing a group name or GID. Default: none. + +##### `identity` + +Specifies an identity file to use for SSH authentication. (Requires the `ssh_identity` feature.) Valid options: a string containing an absolute path. Default: none. + +##### `module` + +Specifies the repository module to manage. (Requires the `modules` feature.) Valid options: a string containing the name of a CVS module. Default: none. + +##### `owner` + +Specifies a user to own the repository files. Valid options: a string containing a username or UID. Default: none. + +##### `p4config` + +Specifies a config file that contains settings for connecting to the Perforce service. (Requires the `p4config` feature.) Valid options: a string containing the absolute path to a valid [Perforce config file](http://www.perforce.com/perforce/doc.current/manuals/p4guide/chapter.configuration.html#configuration.settings.configfiles). Default: none. + +##### `path` + +Specifies a location for the managed repository. Valid options: a string containing an absolute path. Default: the title of your declared resource. + +##### `provider` + +*Required.* Specifies the backend to use for this vcsrepo resource. Valid options: 'bzr', 'cvs', 'git', 'hg', 'p4', and 'svn'. + +##### `remote` + +Specifies the remote repository to track. (Requires the `multiple_remotes` feature.) Valid options: a string containing one of the remote names specified in `source`. Default: 'origin'. + +##### `revision` + +Sets the revision of the repository. Valid options vary by provider: + +* `git` - a string containing a Git branch name, or a commit SHA or tag +* `bzr` - a string containing a Bazaar [revision spec](http://wiki.bazaar.canonical.com/BzrRevisionSpec) +* `cvs` - a string containing a CVS [tag or revision number](http://www.thathost.com/wincvs-howto/cvsdoc/cvs_4.html) +* `hg` - a string containing a Mercurial [changeset ID](http://mercurial.selenic.com/wiki/ChangeSetID) or [tag](http://mercurial.selenic.com/wiki/Tag) +* `p4` - a string containing a Perforce [change number, label name, client name, or date spec](http://www.perforce.com/perforce/r12.1/manuals/cmdref/o.fspecs.html) +* `svn` - a string containing a Subversion [revision number](http://svnbook.red-bean.com/en/1.7/svn.basic.in-action.html#svn.basic.in-action.revs), [revision keyword, or revision date](http://svnbook.red-bean.com/en/1.7/svn.tour.revs.specifiers.html) + +Default: none. + +##### `source` + +Specifies a source repository to serve as the upstream for your managed repository. Default: none. Valid options vary by provider: + +* `git` - a string containing a [Git repository URL](https://www.kernel.org/pub/software/scm/git/docs/git-clone.html#_git_urls_a_id_urls_a) or a hash of name => URL mappings. See also [`remote`](#remote). +* `bzr` - a string containing a Bazaar branch location +* `cvs` - a string containing a CVS root +* `hg` - a string containing the local path or URL of a Mercurial repository +* `p4` - a string containing a Perforce depot path +* `svn` - a string containing a Subversion repository URL + +Default: none. + +##### `submodules` + +Specifies whether to initialize and update each submodule in the repository. (Requires the `submodules` feature.) Valid options: 'true' and 'false'. Default: 'true'. + +##### `trust_server_cert` + +Instructs Subversion to accept SSL server certificates issued by unknown certificate authorities. Valid options: 'true' and 'false'. Default: 'false'. + +##### `user` + Specifies the user to run as for repository operations. (Requires the `user` feature.) Valid options: a string containing a username or UID. Default: none. ##Limitations @@ -723,12 +729,12 @@ This module has been tested with Puppet 2.7 and higher. The module has been tested on: -* CentOS 5/6/7 -* Debian 6/7 +* CentOS 5/6/7 +* Debian 6/7 * Oracle 5/6/7 * Red Hat Enterprise Linux 5/6/7 -* Scientific Linux 5/6/7 -* SLES 10/11/12 +* Scientific Linux 5/6/7 +* SLES 10/11/12 * Ubuntu 10.04/12.04/14.04 Testing on other platforms has been light and cannot be guaranteed. @@ -739,4 +745,4 @@ Puppet Labs modules on the Puppet Forge are open projects, and community contrib We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. -You can read the complete module contribution guide [on the Puppet Labs wiki.](http://projects.puppetlabs.com/projects/module-site/wiki/Module_contributing) +You can read the complete module contribution guide [on the Puppet Labs wiki.](http://projects.puppetlabs.com/projects/module-site/wiki/Module_contributing) diff --git a/lib/puppet/provider/vcsrepo/svn.rb b/lib/puppet/provider/vcsrepo/svn.rb index 905d5ad..ba77464 100644 --- a/lib/puppet/provider/vcsrepo/svn.rb +++ b/lib/puppet/provider/vcsrepo/svn.rb @@ -7,7 +7,7 @@ Puppet::Type.type(:vcsrepo).provide(:svn, :parent => Puppet::Provider::Vcsrepo) :svnadmin => 'svnadmin', :svnlook => 'svnlook' - has_features :filesystem_types, :reference_tracking, :basic_auth, :configuration, :conflict + has_features :filesystem_types, :reference_tracking, :basic_auth, :configuration, :conflict, :depth def create if !@resource.value(:source) @@ -15,7 +15,8 @@ Puppet::Type.type(:vcsrepo).provide(:svn, :parent => Puppet::Provider::Vcsrepo) else checkout_repository(@resource.value(:source), @resource.value(:path), - @resource.value(:revision)) + @resource.value(:revision), + @resource.value(:depth)) end update_owner end @@ -62,6 +63,10 @@ Puppet::Type.type(:vcsrepo).provide(:svn, :parent => Puppet::Provider::Vcsrepo) args.push('--config-dir', @resource.value(:configuration)) end + if @resource.value(:trust_server_cert) + args.push('--trust-server-cert') + end + args end @@ -105,11 +110,14 @@ Puppet::Type.type(:vcsrepo).provide(:svn, :parent => Puppet::Provider::Vcsrepo) private - def checkout_repository(source, path, revision) + def checkout_repository(source, path, revision, depth) args = buildargs.push('checkout') if revision args.push('-r', revision) end + if depth + args.push('--depth', depth) + end args.push(source, path) svn(*args) end diff --git a/lib/puppet/type/vcsrepo.rb b/lib/puppet/type/vcsrepo.rb index e5dfbb5..dfc2ec8 100644 --- a/lib/puppet/type/vcsrepo.rb +++ b/lib/puppet/type/vcsrepo.rb @@ -38,7 +38,7 @@ Puppet::Type.newtype(:vcsrepo) do "The provider understands the CVS_RSH environment variable" feature :depth, - "The provider can do shallow clones" + "The provider can do shallow clones or set scope limit" feature :branch, "The name of the branch" @@ -227,6 +227,12 @@ Puppet::Type.newtype(:vcsrepo) do newparam :conflict do desc "The action to take if conflicts exist between repository and working copy" end + + newparam :trust_server_cert do + desc "Trust server certificate" + newvalues(:true, :false) + defaultto false + end autorequire(:package) do ['git', 'git-core'] diff --git a/spec/unit/puppet/provider/vcsrepo/svn_spec.rb b/spec/unit/puppet/provider/vcsrepo/svn_spec.rb index 77f0e03..25951bd 100644 --- a/spec/unit/puppet/provider/vcsrepo/svn_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/svn_spec.rb @@ -52,6 +52,28 @@ describe Puppet::Type.type(:vcsrepo).provider(:svn) do provider.create end end + + context "with depth" do + it "should execute 'svn checkout' with a depth" do + resource[:source] = 'exists' + resource[:depth] = 'infinity' + provider.expects(:svn).with('--non-interactive', 'checkout', '--depth', 'infinity', + resource.value(:source), + resource.value(:path)) + provider.create + end + end + + context "with trust_server_cert" do + it "should execute 'svn checkout' with a trust-server-cert" do + resource[:source] = 'exists' + resource[:trust_server_cert] = true + provider.expects(:svn).with('--non-interactive', '--trust-server-cert', 'checkout', + resource.value(:source), + resource.value(:path)) + provider.create + end + end end describe 'destroying' do -- cgit v1.2.3 From 9a9f343e8358c05766a2899c0e9037fd98df4595 Mon Sep 17 00:00:00 2001 From: tphoney Date: Thu, 17 Sep 2015 18:54:21 +0100 Subject: dos2unix the readme --- README.markdown | 1496 +++++++++++++++++++++++++++---------------------------- 1 file changed, 748 insertions(+), 748 deletions(-) diff --git a/README.markdown b/README.markdown index 4c65bbc..e878891 100644 --- a/README.markdown +++ b/README.markdown @@ -1,748 +1,748 @@ -#vcsrepo - -####Table of Contents - -1. [Overview](#overview) -2. [Module Description - What the module does and why it is useful](#module-description) -3. [Setup - The basics of getting started with vcsrepo](#setup) - * [Setup requirements](#setup-requirements) - * [Beginning with vcsrepo](#beginning-with-vcsrepo) -4. [Usage - Configuration options and additional functionality](#usage) - * [Git](#git) - * [Bazaar](#bazaar) - * [CVS](#cvs) - * [Mercurial](#mercurial) - * [Perforce](#perforce) - * [Subversion](#subversion) -5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) - * [Type: vcsrepo](#type-vcsrepo) - * [Providers](#providers) - * [Features](#features) - * [Parameters](#parameters) -5. [Limitations - OS compatibility, etc.](#limitations) -6. [Development - Guide for contributing to the module](#development) - -##Overview - -The vcsrepo module lets you use Puppet to easily deploy content from your version control system (VCS). - -##Module Description - -The vcsrepo module provides a single type with providers to support the following version control systems: - -* [Git](#git) -* [Bazaar](#bazaar) -* [CVS](#cvs) -* [Mercurial](#mercurial) -* [Perforce](#perforce) -* [Subversion](#subversion) - -**Note:** `git` is the only vcs provider officially [supported by Puppet Labs](https://forge.puppetlabs.com/supported). - -##Setup - -###Setup Requirements - -The `vcsrepo` module does not install any VCS software for you. You must install a VCS before you can use this module. - -Like Puppet in general, the `vcsrepo` module does not automatically create parent directories for the files it manages. Make sure to set up any needed directory structures before you get started. - -###Beginning with vcsrepo - -To create and manage a blank repository, define the type `vcsrepo` with a path to your repository and supply the `provider` parameter based on the [VCS you're using](#usage). - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => git, -} -~~~ - -##Usage - -**Note:** `git` is the only vcsrepo provider officially [supported by Puppet Labs](https://forge.puppetlabs.com/supported). - -###Git - -####Create a blank repository - -To create a blank repository, suitable for use as a central repository, define `vcsrepo` without `source` or `revision`: - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => git, -} -~~~ - -If you're managing a central or official repository, you might want to make it a bare repository. To do this, set `ensure` to 'bare': - -~~~ -vcsrepo { '/path/to/repo': - ensure => bare, - provider => git, -} -~~~ - -####Clone/pull a repository - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => git, - source => 'git://example.com/repo.git', -} -~~~ - -By default, `vcsrepo` will use the HEAD of the source repository's master branch. To use another branch or a specific commit, set `revision` to either a branch name or a commit SHA or tag. - -Branch name: - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => git, - source => 'git://example.com/repo.git', - revision => 'development', -} -~~~ - -SHA: - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => git, - source => 'git://example.com/repo.git', - revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31', -} -~~~ - -Tag: - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => git, - source => 'git://example.com/repo.git', - revision => '1.1.2rc1', -} -~~~ - -To check out a branch as a specific user, supply the `user` parameter: - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => git, - source => 'git://example.com/repo.git', - revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31', - user => 'someUser', -} -~~~ - -To keep the repository at the latest revision, set `ensure` to 'latest'. - -**WARNING:** this overwrites any local changes to the repository: - -~~~ -vcsrepo { '/path/to/repo': - ensure => latest, - provider => git, - source => 'git://example.com/repo.git', - revision => 'master', -} -~~~ - -To clone the repository but skip initializing submodules, set `submodules` to 'false': - -~~~ -vcsrepo { '/path/to/repo': - ensure => latest, - provider => git, - source => 'git://example.com/repo.git', - submodules => false, -} -~~~ - -####Use multiple remotes with a repository -In place of a single string, you can set `source` to a hash of one or more name => URL pairs: - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => git, - remote => 'origin' - source => { - 'origin' => 'https://github.com/puppetlabs/puppetlabs-vcsrepo.git', - 'other_remote' => 'https://github.com/other_user/puppetlabs-vcsrepo.git' - }, -} -~~~ - -**Note:** if you set `source` to a hash, one of the names you specify must match the value of the `remote` parameter. That remote serves as the upstream of your managed repository. - -####Connect via SSH - -To connect to your source repository via SSH (e.g., 'username@server:…'), we recommend managing your SSH keys with Puppet and using the [`require`](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter to make sure they are present before the `vcsrepo` resource is applied. - -To use SSH keys associated with a user, specify the username in the `user` parameter: - -~~~ -vcsrepo { '/path/to/repo': - ensure => latest, - provider => git, - source => 'git://username@example.com/repo.git', - user => 'toto', #uses toto's $HOME/.ssh setup - require => File['/home/toto/.ssh/id_rsa'], -} -~~~ - -###Bazaar - -####Create a blank repository - -To create a blank repository, suitable for use as a central repository, define `vcsrepo` without `source` or `revision`: - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => bzr, -} -~~~ - -####Branch from an existing repository - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => bzr, - source => '/some/path', -} -~~~ - -To branch from a specific revision, set `revision` to a valid [Bazaar revision spec](http://wiki.bazaar.canonical.com/BzrRevisionSpec): - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => bzr, - source => '/some/path', - revision => 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x', -} -~~~ - -####Connect via SSH - -To connect to your source repository via SSH (e.g., `'bzr+ssh://...'` or `'sftp://...,'`), we recommend using the [`require`](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter to make sure your SSH keys are present before the `vcsrepo` resource is applied: - -~~~ -vcsrepo { '/path/to/repo': - ensure => latest, - provider => bzr, - source => 'bzr+ssh://bzr.example.com/some/path', - user => 'toto', #uses toto's $HOME/.ssh setup - require => File['/home/toto/.ssh/id_rsa'], -} -~~~ - -###CVS - -####Create a blank repository - -To create a blank repository, suitable for use as a central repository, define `vcsrepo` without `source` or `revision`: - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => cvs, -} -~~~ - -####Checkout/update from a repository - -~~~ -vcsrepo { '/path/to/workspace': - ensure => present, - provider => cvs, - source => ':pserver:anonymous@example.com:/sources/myproj', -} -~~~ - -To get a specific module on the current mainline, supply the `module` parameter: - -~~~ -vcsrepo {'/vagrant/lockss-daemon-source': - ensure => present, - provider => cvs, - source => ':pserver:anonymous@lockss.cvs.sourceforge.net:/cvsroot/lockss', - module => 'lockss-daemon', -} -~~~ - -To set the GZIP compression levels for your repository history, use the `compression` parameter: - -~~~ -vcsrepo { '/path/to/workspace': - ensure => present, - provider => cvs, - compression => 3, - source => ':pserver:anonymous@example.com:/sources/myproj', -} -~~~ - -To get a specific revision, set `revision` to the revision number. - -~~~ -vcsrepo { '/path/to/workspace': - ensure => present, - provider => cvs, - compression => 3, - source => ':pserver:anonymous@example.com:/sources/myproj', - revision => '1.2', -} -~~~ - -You can also set `revision` to a tag: - -~~~ -vcsrepo { '/path/to/workspace': - ensure => present, - provider => cvs, - compression => 3, - source => ':pserver:anonymous@example.com:/sources/myproj', - revision => 'SOMETAG', -} -~~~ - -####Connect via SSH - -To connect to your source repository via SSH, we recommend using the [`require`](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter to make sure your SSH keys are present before the `vcsrepo` resource is applied: - -~~~ -vcsrepo { '/path/to/repo': - ensure => latest, - provider => cvs, - source => ':pserver:anonymous@example.com:/sources/myproj', - user => 'toto', #uses toto's $HOME/.ssh setup - require => File['/home/toto/.ssh/id_rsa'], -} -~~~ - -###Mercurial - -####Create a blank repository - -To create a blank repository, suitable for use as a central repository, define `vcsrepo` without `source` or `revision`: - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => hg, -} -~~~ - -####Clone/pull & update a repository - -To get the default branch tip: - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => hg, - source => 'http://hg.example.com/myrepo', -} -~~~ - -For a specific changeset, use `revision`: - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => hg, - source => 'http://hg.example.com/myrepo', - revision => '21ea4598c962', -} -~~~ - -You can also set `revision` to a tag: - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => hg, - source => 'http://hg.example.com/myrepo', - revision => '1.1.2', -} -~~~ - -To check out as a specific user: - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => hg, - source => 'http://hg.example.com/myrepo', - user => 'user', -} -~~~ - -To specify an SSH identity key: - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => hg, - source => 'ssh://hg@hg.example.com/myrepo', - identity => '/home/user/.ssh/id_dsa1, -} -~~~ - -To specify a username and password for HTTP Basic authentication: - -~~~ -vcsrepo { '/path/to/repo': - ensure => latest, - provider => hg, - source => 'http://hg.example.com/myrepo', - basic_auth_username => 'hgusername', - basic_auth_password => 'hgpassword', -} -~~~ - -####Connect via SSH - -To connect to your source repository via SSH (e.g., `'ssh://...'`), we recommend using the [`require` metaparameter](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) to make sure your SSH keys are present before the `vcsrepo` resource is applied: - -~~~ -vcsrepo { '/path/to/repo': - ensure => latest, - provider => hg, - source => 'ssh://hg.example.com//path/to/myrepo', - user => 'toto', #uses toto's $HOME/.ssh setup - require => File['/home/toto/.ssh/id_rsa'], -} -~~~ - -###Perforce - -####Create an empty workspace - -To set up the connection to your Perforce service, set `p4config` to the location of a valid Perforce [config file](http://www.perforce.com/perforce/doc.current/manuals/p4guide/chapter.configuration.html#configuration.settings.configfiles) stored on the node: - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => p4, - p4config => '/root/.p4config' -} -~~~ - -**Note:** If you don't include the `P4CLIENT` setting in your config file, the provider generates a workspace name based on the digest of `path` and the node's hostname (e.g., `puppet-91bc00640c4e5a17787286acbe2c021c`): - -####Create/update and sync a Perforce workspace - -To sync a depot path to head, set `ensure` to 'latest': - -~~~ -vcsrepo { '/path/to/repo': - ensure => latest, - provider => p4, - source => '//depot/branch/...' -} -~~~ - -To sync to a specific changelist, specify its revision number with the `revision` parameter: - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => p4, - source => '//depot/branch/...', - revision => '2341' -} -~~~ - -You can also set `revision` to a label: - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => p4, - source => '//depot/branch/...', - revision => 'my_label' -} -~~~ - -###Subversion - -####Create a blank repository - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => svn, -} -~~~ - -####Check out from an existing repository - -Provide a `source` pointing to the branch or tag you want to check out: - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => svn, - source => 'svn://svnrepo/hello/branches/foo', -} -~~~ - -You can also designate a specific revision: - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => svn, - source => 'svn://svnrepo/hello/branches/foo', - revision => '1234', -} -~~~ - -####Use a specific Subversion configuration directory - -Use the `configuration` parameter to designate the directory that contains your Subversion configuration files (typically, '/path/to/.subversion'): - -~~~ -vcsrepo { '/path/to/repo': - ensure => present, - provider => svn, - source => 'svn://svnrepo/hello/branches/foo', - configuration => '/path/to/.subversion', -} -~~~ - -####Connect via SSH - -To connect to your source repository via SSH (e.g., `'svn+ssh://...'`), we recommend using the [`require` metaparameter](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) to make sure your SSH keys are present before the `vcsrepo` resource is applied: - -~~~ -vcsrepo { '/path/to/repo': - ensure => latest, - provider => svn, - source => 'svn+ssh://svnrepo/hello/branches/foo', - user => 'toto', #uses toto's $HOME/.ssh setup - require => File['/home/toto/.ssh/id_rsa'], -} -~~~ - -##Reference - -###Type: vcsrepo - -The vcsrepo module adds only one type with several providers. Each provider abstracts a different VCS, and each provider includes a set of features according to its needs. - -####Providers - -**Note:** Not all features are available with all providers. - -#####`git` - Supports the Git VCS. - -Features: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `submodules`, `user` - -Parameters: `depth`, `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `remote`, `revision`, `source`, `user` - -#####`bzr` - Supports the Bazaar VCS. - -Features: `reference_tracking` - -Parameters: `ensure`, `excludes`, `force`, `group`, `owner`, `path`, `provider`, `revision`, `source` - -#####`cvs` - Supports the CVS VCS. - -Features: `cvs_rsh`, `gzip_compression`, `modules`, `reference_tracking`, `user` - -Parameters: `compression`, `cvs_rsh`, `ensure`, `excludes`, `force`, `group`, `module`, `owner`, `path`, `provider` - -#####`hg` - Supports the Mercurial VCS. - -Features: `reference_tracking`, `ssh_identity`, `user` - -Parameters: `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `revision`, `source`, `user` - -#####`p4` - Supports the Perforce VCS. - -Features: `p4config`, `reference_tracking` - -Parameters: `ensure`, `excludes`, `force`, `group`, `owner`, `p4config`, `path`, `provider`, `revision`, `source` - -#####`svn` - Supports the Subversion VCS. - -Features: `basic_auth`, `configuration`, `conflict`, `depth`, `filesystem_types`, `reference_tracking` - -Parameters: `basic_auth_password`, `basic_auth_username`, `configuration`, `conflict`, `ensure`, `excludes`, `force`, `fstype`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `trust_server_cert` - -####Features - -**Note:** Not all features are available with all providers. - -* `bare_repositories` - Differentiates between bare repositories and those with working copies. (Available with `git`.) -* `basic_auth` - Supports HTTP Basic authentication. (Available with `svn`.) -* `conflict` - Lets you decide how to resolve any conflicts between the source repository and your working copy. (Available with `svn`.) -* `configuration` - Lets you specify the location of your configuration files. (Available with `svn`.) -* `cvs_rsh` - Understands the `CVS_RSH` environment variable. (Available with `cvs`.) -* `depth` - Supports shallow clones in `git` or sets scope limit in `svn`. (Available with `git` and `svn`.) -* `filesystem_types` - Supports multiple types of filesystem. (Available with `svn`.) -* `gzip_compression` - Supports explicit GZip compression levels. (Available with `cvs`.) -* `modules` - Lets you choose a specific repository module. (Available with `cvs`.) -* `multiple_remotes` - Tracks multiple remote repositories. (Available with `git`.) -* `reference_tracking` - Lets you track revision references that can change over time (e.g., some VCS tags and branch names). (Available with all providers) -* `ssh_identity` - Lets you specify an SSH identity file. (Available with `git` and `hg`.) -* `user` - Can run as a different user. (Available with `git`, `hg` and `cvs`.) -* `p4config` - Supports setting the `P4CONFIG` environment. (Available with `p4`.) -* `submodules` - Supports repository submodules which can be optionally initialized. (Available with `git`.) - -####Parameters - -All parameters are optional, except where specified otherwise. - -##### `basic_auth_password` - -Specifies the password for HTTP Basic authentication. (Requires the `basic_auth` feature.) Valid options: a string. Default: none. - -##### `basic_auth_username` - -Specifies the username for HTTP Basic authentication. (Requires the `basic_auth` feature.) Valid options: a string. Default: none. - -##### `compression` - -Sets the GZIP compression level for the repository history. (Requires the `gzip_compression` feature.) Valid options: an integer between 0 and 6. Default: none. - -##### `configuration` - -Sets the configuration directory to use. (Requires the `configuration` feature.) Valid options: a string containing an absolute path. Default: none. - -##### `conflict` - -Tells Subversion how to resolve any conflicts between the source repository and your working copy. (Requires the `conflict` feature.) Valid options: 'base', 'mine-full', 'theirs-full', and 'working'. Default: none. - -##### `cvs_rsh` - -Provides a value for the `CVS_RSH` environment variable. (Requires the `cvs_rsh` feature.) Valid options: a string. Default: none. - -##### `depth` - -In `git` sets the number of commits to include when creating a shallow clone. (Requires the `depth` feature.) Valid options: an integer. Default: none. - -In `svn` instructs Subversion to limit the scope of an operation to a particular tree depth. (Requires the `depth` feature.) Valid options: 'empty', 'files', 'immediates', 'infinity'. Default: none. - -##### `ensure` - -Specifies whether the repository should exist. Valid options: 'present', 'bare', 'absent', and 'latest'. Default: 'present'. - -##### `excludes` - -Lists any files the repository shouldn't track (similar to .gitignore). Valid options: a string (separate multiple values with the newline character). Default: none. - -##### `force` - -Specifies whether to delete any existing files in the repository path if creating a new repository. **Use with care.** Valid options: 'true' and 'false'. Default: 'false'. - -##### `fstype` - -Sets the filesystem type. (Requires the `filesystem_types` feature.) Valid options: 'fsfs' or 'bdb'. Default: none. - -##### `group` - -Specifies a group to own the repository files. Valid options: a string containing a group name or GID. Default: none. - -##### `identity` - -Specifies an identity file to use for SSH authentication. (Requires the `ssh_identity` feature.) Valid options: a string containing an absolute path. Default: none. - -##### `module` - -Specifies the repository module to manage. (Requires the `modules` feature.) Valid options: a string containing the name of a CVS module. Default: none. - -##### `owner` - -Specifies a user to own the repository files. Valid options: a string containing a username or UID. Default: none. - -##### `p4config` - -Specifies a config file that contains settings for connecting to the Perforce service. (Requires the `p4config` feature.) Valid options: a string containing the absolute path to a valid [Perforce config file](http://www.perforce.com/perforce/doc.current/manuals/p4guide/chapter.configuration.html#configuration.settings.configfiles). Default: none. - -##### `path` - -Specifies a location for the managed repository. Valid options: a string containing an absolute path. Default: the title of your declared resource. - -##### `provider` - -*Required.* Specifies the backend to use for this vcsrepo resource. Valid options: 'bzr', 'cvs', 'git', 'hg', 'p4', and 'svn'. - -##### `remote` - -Specifies the remote repository to track. (Requires the `multiple_remotes` feature.) Valid options: a string containing one of the remote names specified in `source`. Default: 'origin'. - -##### `revision` - -Sets the revision of the repository. Valid options vary by provider: - -* `git` - a string containing a Git branch name, or a commit SHA or tag -* `bzr` - a string containing a Bazaar [revision spec](http://wiki.bazaar.canonical.com/BzrRevisionSpec) -* `cvs` - a string containing a CVS [tag or revision number](http://www.thathost.com/wincvs-howto/cvsdoc/cvs_4.html) -* `hg` - a string containing a Mercurial [changeset ID](http://mercurial.selenic.com/wiki/ChangeSetID) or [tag](http://mercurial.selenic.com/wiki/Tag) -* `p4` - a string containing a Perforce [change number, label name, client name, or date spec](http://www.perforce.com/perforce/r12.1/manuals/cmdref/o.fspecs.html) -* `svn` - a string containing a Subversion [revision number](http://svnbook.red-bean.com/en/1.7/svn.basic.in-action.html#svn.basic.in-action.revs), [revision keyword, or revision date](http://svnbook.red-bean.com/en/1.7/svn.tour.revs.specifiers.html) - -Default: none. - -##### `source` - -Specifies a source repository to serve as the upstream for your managed repository. Default: none. Valid options vary by provider: - -* `git` - a string containing a [Git repository URL](https://www.kernel.org/pub/software/scm/git/docs/git-clone.html#_git_urls_a_id_urls_a) or a hash of name => URL mappings. See also [`remote`](#remote). -* `bzr` - a string containing a Bazaar branch location -* `cvs` - a string containing a CVS root -* `hg` - a string containing the local path or URL of a Mercurial repository -* `p4` - a string containing a Perforce depot path -* `svn` - a string containing a Subversion repository URL - -Default: none. - -##### `submodules` - -Specifies whether to initialize and update each submodule in the repository. (Requires the `submodules` feature.) Valid options: 'true' and 'false'. Default: 'true'. - -##### `trust_server_cert` - -Instructs Subversion to accept SSL server certificates issued by unknown certificate authorities. Valid options: 'true' and 'false'. Default: 'false'. - -##### `user` - -Specifies the user to run as for repository operations. (Requires the `user` feature.) Valid options: a string containing a username or UID. Default: none. - -##Limitations - -Git is the only VCS provider officially [supported](https://forge.puppetlabs.com/supported) by Puppet Labs. - -This module has been tested with Puppet 2.7 and higher. - -The module has been tested on: - -* CentOS 5/6/7 -* Debian 6/7 -* Oracle 5/6/7 -* Red Hat Enterprise Linux 5/6/7 -* Scientific Linux 5/6/7 -* SLES 10/11/12 -* Ubuntu 10.04/12.04/14.04 - -Testing on other platforms has been light and cannot be guaranteed. - -##Development - -Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can't access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve. - -We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. - -You can read the complete module contribution guide [on the Puppet Labs wiki.](http://projects.puppetlabs.com/projects/module-site/wiki/Module_contributing) +#vcsrepo + +####Table of Contents + +1. [Overview](#overview) +2. [Module Description - What the module does and why it is useful](#module-description) +3. [Setup - The basics of getting started with vcsrepo](#setup) + * [Setup requirements](#setup-requirements) + * [Beginning with vcsrepo](#beginning-with-vcsrepo) +4. [Usage - Configuration options and additional functionality](#usage) + * [Git](#git) + * [Bazaar](#bazaar) + * [CVS](#cvs) + * [Mercurial](#mercurial) + * [Perforce](#perforce) + * [Subversion](#subversion) +5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) + * [Type: vcsrepo](#type-vcsrepo) + * [Providers](#providers) + * [Features](#features) + * [Parameters](#parameters) +5. [Limitations - OS compatibility, etc.](#limitations) +6. [Development - Guide for contributing to the module](#development) + +##Overview + +The vcsrepo module lets you use Puppet to easily deploy content from your version control system (VCS). + +##Module Description + +The vcsrepo module provides a single type with providers to support the following version control systems: + +* [Git](#git) +* [Bazaar](#bazaar) +* [CVS](#cvs) +* [Mercurial](#mercurial) +* [Perforce](#perforce) +* [Subversion](#subversion) + +**Note:** `git` is the only vcs provider officially [supported by Puppet Labs](https://forge.puppetlabs.com/supported). + +##Setup + +###Setup Requirements + +The `vcsrepo` module does not install any VCS software for you. You must install a VCS before you can use this module. + +Like Puppet in general, the `vcsrepo` module does not automatically create parent directories for the files it manages. Make sure to set up any needed directory structures before you get started. + +###Beginning with vcsrepo + +To create and manage a blank repository, define the type `vcsrepo` with a path to your repository and supply the `provider` parameter based on the [VCS you're using](#usage). + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => git, +} +~~~ + +##Usage + +**Note:** `git` is the only vcsrepo provider officially [supported by Puppet Labs](https://forge.puppetlabs.com/supported). + +###Git + +####Create a blank repository + +To create a blank repository, suitable for use as a central repository, define `vcsrepo` without `source` or `revision`: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => git, +} +~~~ + +If you're managing a central or official repository, you might want to make it a bare repository. To do this, set `ensure` to 'bare': + +~~~ +vcsrepo { '/path/to/repo': + ensure => bare, + provider => git, +} +~~~ + +####Clone/pull a repository + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => git, + source => 'git://example.com/repo.git', +} +~~~ + +By default, `vcsrepo` will use the HEAD of the source repository's master branch. To use another branch or a specific commit, set `revision` to either a branch name or a commit SHA or tag. + +Branch name: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => git, + source => 'git://example.com/repo.git', + revision => 'development', +} +~~~ + +SHA: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => git, + source => 'git://example.com/repo.git', + revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31', +} +~~~ + +Tag: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => git, + source => 'git://example.com/repo.git', + revision => '1.1.2rc1', +} +~~~ + +To check out a branch as a specific user, supply the `user` parameter: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => git, + source => 'git://example.com/repo.git', + revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31', + user => 'someUser', +} +~~~ + +To keep the repository at the latest revision, set `ensure` to 'latest'. + +**WARNING:** this overwrites any local changes to the repository: + +~~~ +vcsrepo { '/path/to/repo': + ensure => latest, + provider => git, + source => 'git://example.com/repo.git', + revision => 'master', +} +~~~ + +To clone the repository but skip initializing submodules, set `submodules` to 'false': + +~~~ +vcsrepo { '/path/to/repo': + ensure => latest, + provider => git, + source => 'git://example.com/repo.git', + submodules => false, +} +~~~ + +####Use multiple remotes with a repository +In place of a single string, you can set `source` to a hash of one or more name => URL pairs: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => git, + remote => 'origin' + source => { + 'origin' => 'https://github.com/puppetlabs/puppetlabs-vcsrepo.git', + 'other_remote' => 'https://github.com/other_user/puppetlabs-vcsrepo.git' + }, +} +~~~ + +**Note:** if you set `source` to a hash, one of the names you specify must match the value of the `remote` parameter. That remote serves as the upstream of your managed repository. + +####Connect via SSH + +To connect to your source repository via SSH (e.g., 'username@server:…'), we recommend managing your SSH keys with Puppet and using the [`require`](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter to make sure they are present before the `vcsrepo` resource is applied. + +To use SSH keys associated with a user, specify the username in the `user` parameter: + +~~~ +vcsrepo { '/path/to/repo': + ensure => latest, + provider => git, + source => 'git://username@example.com/repo.git', + user => 'toto', #uses toto's $HOME/.ssh setup + require => File['/home/toto/.ssh/id_rsa'], +} +~~~ + +###Bazaar + +####Create a blank repository + +To create a blank repository, suitable for use as a central repository, define `vcsrepo` without `source` or `revision`: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => bzr, +} +~~~ + +####Branch from an existing repository + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => bzr, + source => '/some/path', +} +~~~ + +To branch from a specific revision, set `revision` to a valid [Bazaar revision spec](http://wiki.bazaar.canonical.com/BzrRevisionSpec): + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => bzr, + source => '/some/path', + revision => 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x', +} +~~~ + +####Connect via SSH + +To connect to your source repository via SSH (e.g., `'bzr+ssh://...'` or `'sftp://...,'`), we recommend using the [`require`](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter to make sure your SSH keys are present before the `vcsrepo` resource is applied: + +~~~ +vcsrepo { '/path/to/repo': + ensure => latest, + provider => bzr, + source => 'bzr+ssh://bzr.example.com/some/path', + user => 'toto', #uses toto's $HOME/.ssh setup + require => File['/home/toto/.ssh/id_rsa'], +} +~~~ + +###CVS + +####Create a blank repository + +To create a blank repository, suitable for use as a central repository, define `vcsrepo` without `source` or `revision`: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => cvs, +} +~~~ + +####Checkout/update from a repository + +~~~ +vcsrepo { '/path/to/workspace': + ensure => present, + provider => cvs, + source => ':pserver:anonymous@example.com:/sources/myproj', +} +~~~ + +To get a specific module on the current mainline, supply the `module` parameter: + +~~~ +vcsrepo {'/vagrant/lockss-daemon-source': + ensure => present, + provider => cvs, + source => ':pserver:anonymous@lockss.cvs.sourceforge.net:/cvsroot/lockss', + module => 'lockss-daemon', +} +~~~ + +To set the GZIP compression levels for your repository history, use the `compression` parameter: + +~~~ +vcsrepo { '/path/to/workspace': + ensure => present, + provider => cvs, + compression => 3, + source => ':pserver:anonymous@example.com:/sources/myproj', +} +~~~ + +To get a specific revision, set `revision` to the revision number. + +~~~ +vcsrepo { '/path/to/workspace': + ensure => present, + provider => cvs, + compression => 3, + source => ':pserver:anonymous@example.com:/sources/myproj', + revision => '1.2', +} +~~~ + +You can also set `revision` to a tag: + +~~~ +vcsrepo { '/path/to/workspace': + ensure => present, + provider => cvs, + compression => 3, + source => ':pserver:anonymous@example.com:/sources/myproj', + revision => 'SOMETAG', +} +~~~ + +####Connect via SSH + +To connect to your source repository via SSH, we recommend using the [`require`](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter to make sure your SSH keys are present before the `vcsrepo` resource is applied: + +~~~ +vcsrepo { '/path/to/repo': + ensure => latest, + provider => cvs, + source => ':pserver:anonymous@example.com:/sources/myproj', + user => 'toto', #uses toto's $HOME/.ssh setup + require => File['/home/toto/.ssh/id_rsa'], +} +~~~ + +###Mercurial + +####Create a blank repository + +To create a blank repository, suitable for use as a central repository, define `vcsrepo` without `source` or `revision`: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => hg, +} +~~~ + +####Clone/pull & update a repository + +To get the default branch tip: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => hg, + source => 'http://hg.example.com/myrepo', +} +~~~ + +For a specific changeset, use `revision`: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => hg, + source => 'http://hg.example.com/myrepo', + revision => '21ea4598c962', +} +~~~ + +You can also set `revision` to a tag: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => hg, + source => 'http://hg.example.com/myrepo', + revision => '1.1.2', +} +~~~ + +To check out as a specific user: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => hg, + source => 'http://hg.example.com/myrepo', + user => 'user', +} +~~~ + +To specify an SSH identity key: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => hg, + source => 'ssh://hg@hg.example.com/myrepo', + identity => '/home/user/.ssh/id_dsa1, +} +~~~ + +To specify a username and password for HTTP Basic authentication: + +~~~ +vcsrepo { '/path/to/repo': + ensure => latest, + provider => hg, + source => 'http://hg.example.com/myrepo', + basic_auth_username => 'hgusername', + basic_auth_password => 'hgpassword', +} +~~~ + +####Connect via SSH + +To connect to your source repository via SSH (e.g., `'ssh://...'`), we recommend using the [`require` metaparameter](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) to make sure your SSH keys are present before the `vcsrepo` resource is applied: + +~~~ +vcsrepo { '/path/to/repo': + ensure => latest, + provider => hg, + source => 'ssh://hg.example.com//path/to/myrepo', + user => 'toto', #uses toto's $HOME/.ssh setup + require => File['/home/toto/.ssh/id_rsa'], +} +~~~ + +###Perforce + +####Create an empty workspace + +To set up the connection to your Perforce service, set `p4config` to the location of a valid Perforce [config file](http://www.perforce.com/perforce/doc.current/manuals/p4guide/chapter.configuration.html#configuration.settings.configfiles) stored on the node: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => p4, + p4config => '/root/.p4config' +} +~~~ + +**Note:** If you don't include the `P4CLIENT` setting in your config file, the provider generates a workspace name based on the digest of `path` and the node's hostname (e.g., `puppet-91bc00640c4e5a17787286acbe2c021c`): + +####Create/update and sync a Perforce workspace + +To sync a depot path to head, set `ensure` to 'latest': + +~~~ +vcsrepo { '/path/to/repo': + ensure => latest, + provider => p4, + source => '//depot/branch/...' +} +~~~ + +To sync to a specific changelist, specify its revision number with the `revision` parameter: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => p4, + source => '//depot/branch/...', + revision => '2341' +} +~~~ + +You can also set `revision` to a label: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => p4, + source => '//depot/branch/...', + revision => 'my_label' +} +~~~ + +###Subversion + +####Create a blank repository + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => svn, +} +~~~ + +####Check out from an existing repository + +Provide a `source` pointing to the branch or tag you want to check out: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => svn, + source => 'svn://svnrepo/hello/branches/foo', +} +~~~ + +You can also designate a specific revision: + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => svn, + source => 'svn://svnrepo/hello/branches/foo', + revision => '1234', +} +~~~ + +####Use a specific Subversion configuration directory + +Use the `configuration` parameter to designate the directory that contains your Subversion configuration files (typically, '/path/to/.subversion'): + +~~~ +vcsrepo { '/path/to/repo': + ensure => present, + provider => svn, + source => 'svn://svnrepo/hello/branches/foo', + configuration => '/path/to/.subversion', +} +~~~ + +####Connect via SSH + +To connect to your source repository via SSH (e.g., `'svn+ssh://...'`), we recommend using the [`require` metaparameter](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) to make sure your SSH keys are present before the `vcsrepo` resource is applied: + +~~~ +vcsrepo { '/path/to/repo': + ensure => latest, + provider => svn, + source => 'svn+ssh://svnrepo/hello/branches/foo', + user => 'toto', #uses toto's $HOME/.ssh setup + require => File['/home/toto/.ssh/id_rsa'], +} +~~~ + +##Reference + +###Type: vcsrepo + +The vcsrepo module adds only one type with several providers. Each provider abstracts a different VCS, and each provider includes a set of features according to its needs. + +####Providers + +**Note:** Not all features are available with all providers. + +#####`git` - Supports the Git VCS. + +Features: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `submodules`, `user` + +Parameters: `depth`, `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `remote`, `revision`, `source`, `user` + +#####`bzr` - Supports the Bazaar VCS. + +Features: `reference_tracking` + +Parameters: `ensure`, `excludes`, `force`, `group`, `owner`, `path`, `provider`, `revision`, `source` + +#####`cvs` - Supports the CVS VCS. + +Features: `cvs_rsh`, `gzip_compression`, `modules`, `reference_tracking`, `user` + +Parameters: `compression`, `cvs_rsh`, `ensure`, `excludes`, `force`, `group`, `module`, `owner`, `path`, `provider` + +#####`hg` - Supports the Mercurial VCS. + +Features: `reference_tracking`, `ssh_identity`, `user` + +Parameters: `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `revision`, `source`, `user` + +#####`p4` - Supports the Perforce VCS. + +Features: `p4config`, `reference_tracking` + +Parameters: `ensure`, `excludes`, `force`, `group`, `owner`, `p4config`, `path`, `provider`, `revision`, `source` + +#####`svn` - Supports the Subversion VCS. + +Features: `basic_auth`, `configuration`, `conflict`, `depth`, `filesystem_types`, `reference_tracking` + +Parameters: `basic_auth_password`, `basic_auth_username`, `configuration`, `conflict`, `ensure`, `excludes`, `force`, `fstype`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `trust_server_cert` + +####Features + +**Note:** Not all features are available with all providers. + +* `bare_repositories` - Differentiates between bare repositories and those with working copies. (Available with `git`.) +* `basic_auth` - Supports HTTP Basic authentication. (Available with `svn`.) +* `conflict` - Lets you decide how to resolve any conflicts between the source repository and your working copy. (Available with `svn`.) +* `configuration` - Lets you specify the location of your configuration files. (Available with `svn`.) +* `cvs_rsh` - Understands the `CVS_RSH` environment variable. (Available with `cvs`.) +* `depth` - Supports shallow clones in `git` or sets scope limit in `svn`. (Available with `git` and `svn`.) +* `filesystem_types` - Supports multiple types of filesystem. (Available with `svn`.) +* `gzip_compression` - Supports explicit GZip compression levels. (Available with `cvs`.) +* `modules` - Lets you choose a specific repository module. (Available with `cvs`.) +* `multiple_remotes` - Tracks multiple remote repositories. (Available with `git`.) +* `reference_tracking` - Lets you track revision references that can change over time (e.g., some VCS tags and branch names). (Available with all providers) +* `ssh_identity` - Lets you specify an SSH identity file. (Available with `git` and `hg`.) +* `user` - Can run as a different user. (Available with `git`, `hg` and `cvs`.) +* `p4config` - Supports setting the `P4CONFIG` environment. (Available with `p4`.) +* `submodules` - Supports repository submodules which can be optionally initialized. (Available with `git`.) + +####Parameters + +All parameters are optional, except where specified otherwise. + +##### `basic_auth_password` + +Specifies the password for HTTP Basic authentication. (Requires the `basic_auth` feature.) Valid options: a string. Default: none. + +##### `basic_auth_username` + +Specifies the username for HTTP Basic authentication. (Requires the `basic_auth` feature.) Valid options: a string. Default: none. + +##### `compression` + +Sets the GZIP compression level for the repository history. (Requires the `gzip_compression` feature.) Valid options: an integer between 0 and 6. Default: none. + +##### `configuration` + +Sets the configuration directory to use. (Requires the `configuration` feature.) Valid options: a string containing an absolute path. Default: none. + +##### `conflict` + +Tells Subversion how to resolve any conflicts between the source repository and your working copy. (Requires the `conflict` feature.) Valid options: 'base', 'mine-full', 'theirs-full', and 'working'. Default: none. + +##### `cvs_rsh` + +Provides a value for the `CVS_RSH` environment variable. (Requires the `cvs_rsh` feature.) Valid options: a string. Default: none. + +##### `depth` + +In `git` sets the number of commits to include when creating a shallow clone. (Requires the `depth` feature.) Valid options: an integer. Default: none. + +In `svn` instructs Subversion to limit the scope of an operation to a particular tree depth. (Requires the `depth` feature.) Valid options: 'empty', 'files', 'immediates', 'infinity'. Default: none. + +##### `ensure` + +Specifies whether the repository should exist. Valid options: 'present', 'bare', 'absent', and 'latest'. Default: 'present'. + +##### `excludes` + +Lists any files the repository shouldn't track (similar to .gitignore). Valid options: a string (separate multiple values with the newline character). Default: none. + +##### `force` + +Specifies whether to delete any existing files in the repository path if creating a new repository. **Use with care.** Valid options: 'true' and 'false'. Default: 'false'. + +##### `fstype` + +Sets the filesystem type. (Requires the `filesystem_types` feature.) Valid options: 'fsfs' or 'bdb'. Default: none. + +##### `group` + +Specifies a group to own the repository files. Valid options: a string containing a group name or GID. Default: none. + +##### `identity` + +Specifies an identity file to use for SSH authentication. (Requires the `ssh_identity` feature.) Valid options: a string containing an absolute path. Default: none. + +##### `module` + +Specifies the repository module to manage. (Requires the `modules` feature.) Valid options: a string containing the name of a CVS module. Default: none. + +##### `owner` + +Specifies a user to own the repository files. Valid options: a string containing a username or UID. Default: none. + +##### `p4config` + +Specifies a config file that contains settings for connecting to the Perforce service. (Requires the `p4config` feature.) Valid options: a string containing the absolute path to a valid [Perforce config file](http://www.perforce.com/perforce/doc.current/manuals/p4guide/chapter.configuration.html#configuration.settings.configfiles). Default: none. + +##### `path` + +Specifies a location for the managed repository. Valid options: a string containing an absolute path. Default: the title of your declared resource. + +##### `provider` + +*Required.* Specifies the backend to use for this vcsrepo resource. Valid options: 'bzr', 'cvs', 'git', 'hg', 'p4', and 'svn'. + +##### `remote` + +Specifies the remote repository to track. (Requires the `multiple_remotes` feature.) Valid options: a string containing one of the remote names specified in `source`. Default: 'origin'. + +##### `revision` + +Sets the revision of the repository. Valid options vary by provider: + +* `git` - a string containing a Git branch name, or a commit SHA or tag +* `bzr` - a string containing a Bazaar [revision spec](http://wiki.bazaar.canonical.com/BzrRevisionSpec) +* `cvs` - a string containing a CVS [tag or revision number](http://www.thathost.com/wincvs-howto/cvsdoc/cvs_4.html) +* `hg` - a string containing a Mercurial [changeset ID](http://mercurial.selenic.com/wiki/ChangeSetID) or [tag](http://mercurial.selenic.com/wiki/Tag) +* `p4` - a string containing a Perforce [change number, label name, client name, or date spec](http://www.perforce.com/perforce/r12.1/manuals/cmdref/o.fspecs.html) +* `svn` - a string containing a Subversion [revision number](http://svnbook.red-bean.com/en/1.7/svn.basic.in-action.html#svn.basic.in-action.revs), [revision keyword, or revision date](http://svnbook.red-bean.com/en/1.7/svn.tour.revs.specifiers.html) + +Default: none. + +##### `source` + +Specifies a source repository to serve as the upstream for your managed repository. Default: none. Valid options vary by provider: + +* `git` - a string containing a [Git repository URL](https://www.kernel.org/pub/software/scm/git/docs/git-clone.html#_git_urls_a_id_urls_a) or a hash of name => URL mappings. See also [`remote`](#remote). +* `bzr` - a string containing a Bazaar branch location +* `cvs` - a string containing a CVS root +* `hg` - a string containing the local path or URL of a Mercurial repository +* `p4` - a string containing a Perforce depot path +* `svn` - a string containing a Subversion repository URL + +Default: none. + +##### `submodules` + +Specifies whether to initialize and update each submodule in the repository. (Requires the `submodules` feature.) Valid options: 'true' and 'false'. Default: 'true'. + +##### `trust_server_cert` + +Instructs Subversion to accept SSL server certificates issued by unknown certificate authorities. Valid options: 'true' and 'false'. Default: 'false'. + +##### `user` + +Specifies the user to run as for repository operations. (Requires the `user` feature.) Valid options: a string containing a username or UID. Default: none. + +##Limitations + +Git is the only VCS provider officially [supported](https://forge.puppetlabs.com/supported) by Puppet Labs. + +This module has been tested with Puppet 2.7 and higher. + +The module has been tested on: + +* CentOS 5/6/7 +* Debian 6/7 +* Oracle 5/6/7 +* Red Hat Enterprise Linux 5/6/7 +* Scientific Linux 5/6/7 +* SLES 10/11/12 +* Ubuntu 10.04/12.04/14.04 + +Testing on other platforms has been light and cannot be guaranteed. + +##Development + +Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can't access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve. + +We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. + +You can read the complete module contribution guide [on the Puppet Labs wiki.](http://projects.puppetlabs.com/projects/module-site/wiki/Module_contributing) -- cgit v1.2.3 From bf0f40ae4efa9095ca9a877acefdb781e1fbf1cd Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Thu, 15 Oct 2015 10:42:01 -0700 Subject: Fix :false to be default value false is not a valid value; only :false is. --- Gemfile | 1 + lib/puppet/provider/vcsrepo/svn.rb | 2 +- lib/puppet/type/vcsrepo.rb | 2 +- spec/unit/puppet/provider/vcsrepo/svn_spec.rb | 10 +++++++++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index bfe64b1..ee1eb6b 100644 --- a/Gemfile +++ b/Gemfile @@ -16,6 +16,7 @@ group :development, :unit_tests do gem 'simplecov', :require => false gem 'puppet_facts', :require => false gem 'json', :require => false + gem 'pry', :require => false end group :system_tests do diff --git a/lib/puppet/provider/vcsrepo/svn.rb b/lib/puppet/provider/vcsrepo/svn.rb index ba77464..fccfaa5 100644 --- a/lib/puppet/provider/vcsrepo/svn.rb +++ b/lib/puppet/provider/vcsrepo/svn.rb @@ -63,7 +63,7 @@ Puppet::Type.type(:vcsrepo).provide(:svn, :parent => Puppet::Provider::Vcsrepo) args.push('--config-dir', @resource.value(:configuration)) end - if @resource.value(:trust_server_cert) + if @resource.value(:trust_server_cert) != :false args.push('--trust-server-cert') end diff --git a/lib/puppet/type/vcsrepo.rb b/lib/puppet/type/vcsrepo.rb index da1dcde..290bdad 100644 --- a/lib/puppet/type/vcsrepo.rb +++ b/lib/puppet/type/vcsrepo.rb @@ -231,7 +231,7 @@ Puppet::Type.newtype(:vcsrepo) do newparam :trust_server_cert do desc "Trust server certificate" newvalues(:true, :false) - defaultto false + defaultto :false end autorequire(:package) do diff --git a/spec/unit/puppet/provider/vcsrepo/svn_spec.rb b/spec/unit/puppet/provider/vcsrepo/svn_spec.rb index 25951bd..6a37c20 100644 --- a/spec/unit/puppet/provider/vcsrepo/svn_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/svn_spec.rb @@ -65,9 +65,17 @@ describe Puppet::Type.type(:vcsrepo).provider(:svn) do end context "with trust_server_cert" do + it "should execute 'svn checkout' without a trust-server-cert" do + resource[:source] = 'exists' + resource[:trust_server_cert] = :false + provider.expects(:svn).with('--non-interactive', 'checkout', + resource.value(:source), + resource.value(:path)) + provider.create + end it "should execute 'svn checkout' with a trust-server-cert" do resource[:source] = 'exists' - resource[:trust_server_cert] = true + resource[:trust_server_cert] = :true provider.expects(:svn).with('--non-interactive', '--trust-server-cert', 'checkout', resource.value(:source), resource.value(:path)) -- cgit v1.2.3 From 24eda0848e6482b2ca6699501a43b8cf3cfb0403 Mon Sep 17 00:00:00 2001 From: Helen Campbell Date: Mon, 23 Nov 2015 17:56:05 +0000 Subject: Ankeny release for 1.3.2 --- CHANGELOG.md | 5 +++++ metadata.json | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d1060c..2092aa8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +##Supported Release 1.3.2 +###Summary + +Small release for support of newer PE versions. This increments the version of PE in the metadata.json file. + # Change Log All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). diff --git a/metadata.json b/metadata.json index 1552840..8612a98 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-vcsrepo", - "version": "1.3.1", + "version": "1.3.2", "author": "Puppet Labs", "summary": "Puppet module providing a type to manage repositories from various version control systems", "license": "GPLv2", @@ -70,7 +70,7 @@ "requirements": [ { "name": "pe", - "version_requirement": ">= 3.0.0 < 2015.3.0" + "version_requirement": ">= 3.0.0 < 2015.4.0" }, { "name": "puppet", -- cgit v1.2.3 From 7fe9cb225b6458e468469597a54753f1ea621e00 Mon Sep 17 00:00:00 2001 From: godlikeachilles Date: Wed, 2 Dec 2015 15:07:15 +1100 Subject: fix branch existence determintaion functionality this will stop failing in case there is a tag which is a substring of an existing branch name. for example if there is a tag 'release' and a branch 'release/integration' current code will match 'release/integration' with pattern 'release' and decide that a branch checkout is needed. but release branch does not exist so it will fail. this simple fix resolves the issue. --- lib/puppet/provider/vcsrepo/git.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 3b20a83..0249a3c 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -319,7 +319,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) def remote_branch_revision?(revision = @resource.value(:revision)) # git < 1.6 returns '#{@resource.value(:remote)}/#{revision}' # git 1.6+ returns 'remotes/#{@resource.value(:remote)}/#{revision}' - branch = at_path { branches.grep /(remotes\/)?#{@resource.value(:remote)}\/#{revision}/ } + branch = at_path { branches.grep /(remotes\/)?#{@resource.value(:remote)}\/#{revision}$/ } branch unless branch.empty? end -- cgit v1.2.3 From b14c26899fe0171ff994ae7de84adbb49c05c726 Mon Sep 17 00:00:00 2001 From: Bryan Jen Date: Fri, 4 Dec 2015 12:52:47 -0700 Subject: (maint) Update ordering in CHANGELOG --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2092aa8..1e6099f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,11 @@ -##Supported Release 1.3.2 +# Change Log +All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). + +## [1.3.2] - Supported Release ###Summary Small release for support of newer PE versions. This increments the version of PE in the metadata.json file. -# Change Log -All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). - ## [1.3.1] - 2015-07-28 Supported Release ###Summary This release includes a number of bugfixes along with some test updates. -- cgit v1.2.3 From 308533912b5beb26bb881447c8545932cf980a4a Mon Sep 17 00:00:00 2001 From: Bryan Jen Date: Fri, 4 Dec 2015 15:10:06 -0700 Subject: (maint) Another update to the CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e6099f..9aac1e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -140,6 +140,7 @@ our many contributors for all of these fixes! - CVS: - Documented the "module" attribute. +[1.3.2]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.3.1...1.3.2 [1.3.1]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.3.0...1.3.1 [1.3.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.2.0...1.3.0 [1.2.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.1.0...1.2.0 -- cgit v1.2.3 From b8f25cea95317a4b2a622e2799f1aa7ba159bdca Mon Sep 17 00:00:00 2001 From: "Strech (Sergey Fedorov)" Date: Tue, 22 Dec 2015 23:02:26 +0100 Subject: Add mirror option for git cloning Example: vcsrepo { '/path/to/repo': ensure => mirror, provider => git, source => 'git://example.com/repo.git', } --- README.markdown | 10 ++++++++++ lib/puppet/provider/vcsrepo/git.rb | 21 +++++++++++++++----- lib/puppet/type/vcsrepo.rb | 10 +++++++++- spec/unit/puppet/provider/vcsrepo/git_spec.rb | 28 ++++++++++++++++++++++++++- 4 files changed, 62 insertions(+), 7 deletions(-) diff --git a/README.markdown b/README.markdown index e878891..ffc2d7e 100644 --- a/README.markdown +++ b/README.markdown @@ -94,6 +94,16 @@ vcsrepo { '/path/to/repo': } ~~~ +If you want to clone your repository as bare or mirror, you can set `ensure` to 'bare' or 'mirror': + +~~~ +vcsrepo { '/path/to/repo': + ensure => mirror, + provider => git, + source => 'git://example.com/repo.git', +} +~~~ + By default, `vcsrepo` will use the HEAD of the source repository's master branch. To use another branch or a specific commit, set `revision` to either a branch name or a commit SHA or tag. Branch name: diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 0249a3c..63986ab 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -10,10 +10,14 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) has_features :bare_repositories, :reference_tracking, :ssh_identity, :multiple_remotes, :user, :depth, :branch, :submodules def create - if @resource.value(:revision) and @resource.value(:ensure) == :bare + if @resource.value(:revision) and ensure_bare_or_mirror? fail("Cannot set a revision (#{@resource.value(:revision)}) on a bare repository") end if !@resource.value(:source) + if @resource.value(:ensure) == :mirror + fail("Cannot init repository with mirror option, try bare instead") + end + init_repository(@resource.value(:path)) else clone_repository(default_url, @resource.value(:path)) @@ -22,7 +26,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) if @resource.value(:revision) checkout end - if @resource.value(:ensure) != :bare && @resource.value(:submodules) == :true + if !ensure_bare_or_mirror? && @resource.value(:submodules) == :true update_submodules end @@ -85,7 +89,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) end end #TODO Would this ever reach here if it is bare? - if @resource.value(:ensure) != :bare && @resource.value(:submodules) == :true + if !ensure_bare_or_mirror? && @resource.value(:submodules) == :true update_submodules end update_owner_and_excludes @@ -95,6 +99,10 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) bare_git_config_exists? && !working_copy_exists? end + def ensure_bare_or_mirror? + [:bare, :mirror].include? @resource.value(:ensure) + end + # If :source is set to a hash (for supporting multiple remotes), # we search for the URL for :remote. If it doesn't exist, # we throw an error. If :source is just a string, we use that @@ -197,9 +205,12 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) if @resource.value(:branch) args.push('--branch', @resource.value(:branch).to_s) end - if @resource.value(:ensure) == :bare - args << '--bare' + + case @resource.value(:ensure) + when :bare then args << '--bare' + when :mirror then args << '--mirror' end + if @resource.value(:remote) != 'origin' args.push('--origin', @resource.value(:remote)) end diff --git a/lib/puppet/type/vcsrepo.rb b/lib/puppet/type/vcsrepo.rb index 290bdad..e2ef0b7 100644 --- a/lib/puppet/type/vcsrepo.rb +++ b/lib/puppet/type/vcsrepo.rb @@ -69,6 +69,8 @@ Puppet::Type.newtype(:vcsrepo) do end when :bare return is == :bare + when :mirror + return is == :mirror end end @@ -83,6 +85,12 @@ Puppet::Type.newtype(:vcsrepo) do end end + newvalue :mirror, :required_features => [:bare_repositories] do + if !provider.exists? + provider.create + end + end + newvalue :absent do provider.destroy end @@ -227,7 +235,7 @@ Puppet::Type.newtype(:vcsrepo) do newparam :conflict do desc "The action to take if conflicts exist between repository and working copy" end - + newparam :trust_server_cert do desc "Trust server certificate" newvalues(:true, :false) diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index 87113fa..6a8f58f 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -10,7 +10,7 @@ end remote/origin/foo branches - end + end let(:resource) { Puppet::Type.type(:vcsrepo).new({ :name => 'test', :ensure => :present, @@ -111,6 +111,24 @@ branches end end + context "with an ensure of mirror" do + context "with revision" do + it "should raise an error" do + resource[:ensure] = :mirror + expect { provider.create }.to raise_error Puppet::Error, /cannot set a revision.+bare/i + end + end + context "without revision" do + it "should just execute 'git clone --mirror'" do + resource[:ensure] = :mirror + resource.delete(:revision) + provider.expects(:git).with('clone', '--mirror', resource.value(:source), resource.value(:path)) + provider.expects(:update_remotes) + provider.create + end + end + end + context "when a source is not given" do context "when the path does not exist" do it "should execute 'git init'" do @@ -157,6 +175,14 @@ branches provider.expects(:git).with('init', '--bare') provider.create end + + it "should raise an exeption" do + resource[:ensure] = :mirror + resource.delete(:source) + resource.delete(:revision) + + expect { provider.create }.to raise_error Puppet::Error, /cannot init repository with mirror.+try bare/i + end end context "when the path is a working copy repository" do -- cgit v1.2.3 From 20736ba6566854a274a9f9ac95937a843942aca6 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Wed, 27 Jan 2016 10:33:17 +0000 Subject: (FM-4049) Update to current msync configs [2c99161] --- .gitignore | 1 + .rspec | 2 ++ .sync.yml | 6 ---- .travis.yml | 18 ++++------ CONTRIBUTING.md | 6 ++-- Gemfile | 23 ++++++------- Rakefile | 85 +++++------------------------------------------ metadata.json | 2 +- spec/spec_helper.rb | 17 +++------- spec/spec_helper_local.rb | 7 ++++ 10 files changed, 45 insertions(+), 122 deletions(-) create mode 100644 .rspec delete mode 100644 .sync.yml create mode 100644 spec/spec_helper_local.rb diff --git a/.gitignore b/.gitignore index b5db85e..3190277 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,6 @@ spec/fixtures/ .vagrant/ .bundle/ coverage/ +log/ .idea/ *.iml diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..16f9cdb --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--color +--format documentation diff --git a/.sync.yml b/.sync.yml deleted file mode 100644 index f4b637c..0000000 --- a/.sync.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -.travis.yml: -Rakefile: - unmanaged: true -spec/spec_helper.rb: - unmanaged: true diff --git a/.travis.yml b/.travis.yml index 1155a2d..e6314a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,23 +1,19 @@ --- sudo: false language: ruby +cache: bundler bundler_args: --without system_tests -script: "bundle exec rake spec SPEC_OPTS='--format documentation'" +script: "bundle exec rake validate lint spec" matrix: fast_finish: true include: - - rvm: 1.8.7 + - rvm: 2.1.6 + env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" + - rvm: 2.1.5 + env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" + - rvm: 2.1.5 env: PUPPET_GEM_VERSION="~> 3.0" - rvm: 1.9.3 env: PUPPET_GEM_VERSION="~> 3.0" - - rvm: 2.1.5 - env: PUPPET_GEM_VERSION="~> 3.0" - - rvm: 2.1.5 - env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" - - rvm: 2.1.6 - env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" - allow_failures: - - rvm: 2.1.6 - env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" notifications: email: false diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f1cbde4..bfeaa70 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -159,7 +159,7 @@ If you already have those gems installed, make sure they are up-to-date: With all dependencies in place and up-to-date we can now run the tests: ```shell -% rake spec +% bundle exec rake spec ``` This will execute all the [rspec tests](http://rspec-puppet.com/) tests @@ -178,8 +178,8 @@ installed on your system. You can run them by issuing the following command ```shell -% rake spec_clean -% rspec spec/acceptance +% bundle exec rake spec_clean +% bundle exec rspec spec/acceptance ``` This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml), diff --git a/Gemfile b/Gemfile index ee1eb6b..ced190e 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" def location_for(place, fake_version = nil) - if place =~ /^(git:[^#]*)#(.*)/ + if place =~ /^(git[:@][^#]*)#(.*)/ [fake_version, { :git => $1, :branch => $2, :require => false }].compact elsif place =~ /^file:\/\/(.*)/ ['>= 0', { :path => File.expand_path($1), :require => false }] @@ -11,15 +11,16 @@ def location_for(place, fake_version = nil) end group :development, :unit_tests do - gem 'rspec-core', '3.1.7', :require => false - gem 'puppetlabs_spec_helper', :require => false - gem 'simplecov', :require => false - gem 'puppet_facts', :require => false - gem 'json', :require => false - gem 'pry', :require => false + gem 'json', :require => false + gem 'metadata-json-lint', :require => false + gem 'puppet_facts', :require => false + gem 'puppet-blacksmith', :require => false + gem 'puppetlabs_spec_helper', :require => false + gem 'rspec-puppet', '>= 2.3.2', :require => false + gem 'simplecov', :require => false end - group :system_tests do + gem 'beaker-puppet_install_helper', :require => false if beaker_version = ENV['BEAKER_VERSION'] gem 'beaker', *location_for(beaker_version) end @@ -28,12 +29,10 @@ group :system_tests do else gem 'beaker-rspec', :require => false end - gem 'serverspec', :require => false - gem 'beaker-puppet_install_helper', :require => false + gem 'master_manipulator', :require => false + gem 'serverspec', :require => false end - - if facterversion = ENV['FACTER_GEM_VERSION'] gem 'facter', facterversion, :require => false else diff --git a/Rakefile b/Rakefile index cb80def..35ce311 100755 --- a/Rakefile +++ b/Rakefile @@ -1,78 +1,11 @@ +require 'puppet_blacksmith/rake_tasks' +require 'puppet-lint/tasks/puppet-lint' require 'puppetlabs_spec_helper/rake_tasks' -require 'rake' -desc "Run beaker-rspec and beaker tests" -task 'beaker:test:all',[:host,:type] => ["rake:beaker:rspec:test", "rake:beaker:test"] do |t,args| -end - -desc "Run beaker-rspec tests" -task 'beaker:rspec:test',[:host,:type] => [:set_beaker_variables] do |t,args| - Rake::Task['beaker-rspec:test'].invoke(args) -end - -desc "Run beaker tests" -task 'beaker:test',[:host,:type] => [:set_beaker_variables] do |t,args| - sh(build_beaker_command args) -end - -desc "Run beaker rspec tasks against pe" -RSpec::Core::RakeTask.new('beaker-rspec:test',[:host,:type]=>:set_beaker_variables) do |t,args| - t.pattern = 'spec/acceptance' - t.rspec_opts = '--color' - t.verbose = true -end - -desc "Run beaker and beaker-rspec tasks" -task 'beaker:test:pe',:host do |t,args| - args.with_defaults(:type=> 'pe') - Rake::Task['beaker:test'].invoke(args[:host],args[:type]) -end - -task 'beaker:test:git',:host do |t,args| - args.with_defaults({:type=> 'git'}) - Rake::Task['beaker:test'].invoke(args[:host],args[:type]) -end - -task :set_beaker_variables do |t,args| - puts 'Setting environment variables for testing' - if args[:host] - ENV['BEAKER_set'] = args[:host] - puts "Host to test #{ENV['BEAKER_set']}" - end - ENV['BEAKER_IS_PE'] = args[:type] == 'pe'? "true": "false" - if ENV['BEAKER_setfile'] - @hosts_config = ENV['BEAKER_setfile'] - end - if File.exists?(check_args_for_keyfile(args.extras)) - ENV['BEAKER_keyfile'] = check_args_for_keyfile(args.extras) - end -end - -def build_beaker_command(args) - cmd = ["beaker"] - cmd << "--type #{args[:type]}" unless !args[:type] - if File.exists?("./.beaker-#{args[:type]}.cfg") - cmd << "--options-file ./.beaker-#{args[:type]}.cfg" - end - if File.exists?(@hosts_config) - cmd << "--hosts #{@hosts_config}" - end - if File.exists?('./spec/acceptance/beaker_helper.rb') - cmd << "--pre-suite ./spec/acceptance/beaker_helper.rb" - end - if File.exists?("./spec/acceptance/beaker") - cmd << "--tests ./spec/acceptance/beaker" - end - if File.exists?(check_args_for_keyfile(args.extras)) - cmd << "--keyfile #{check_args_for_keyfile(args.extras)}" - end - cmd.join(" ") -end - -def check_args_for_keyfile(extra_args) - keyfile = '' - extra_args.each do |a| - keyfile = a unless (`ssh-keygen -l -f #{a}`.gsub(/\n/,"").match(/is not a .*key file/)) - end - return keyfile -end +PuppetLint.configuration.fail_on_warnings = true +PuppetLint.configuration.send('relative') +PuppetLint.configuration.send('disable_80chars') +PuppetLint.configuration.send('disable_class_inherits_from_params_class') +PuppetLint.configuration.send('disable_documentation') +PuppetLint.configuration.send('disable_single_quote_string_with_variables') +PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] diff --git a/metadata.json b/metadata.json index 8612a98..660953b 100644 --- a/metadata.json +++ b/metadata.json @@ -3,7 +3,7 @@ "version": "1.3.2", "author": "Puppet Labs", "summary": "Puppet module providing a type to manage repositories from various version control systems", - "license": "GPLv2", + "license": "GPL-2.0+", "source": "https://github.com/puppetlabs/puppetlabs-vcsrepo", "project_page": "https://github.com/puppetlabs/puppetlabs-vcsrepo", "issues_url": "https://tickets.puppetlabs.com/browse/MODULES", diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ccd305b..a7f5b4e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,16 +1,7 @@ require 'puppetlabs_spec_helper/module_spec_helper' -require 'support/filesystem_helpers' -require 'support/fixture_helpers' -# SimpleCov does not run on Ruby 1.8.7 -unless RUBY_VERSION.to_f < 1.9 - require 'simplecov' - SimpleCov.start do - add_filter '/spec/' - end -end - -RSpec.configure do |c| - c.include FilesystemHelpers - c.include FixtureHelpers +# put local configuration and setup into spec_helper_local +begin + require 'spec_helper_local' +rescue LoadError end diff --git a/spec/spec_helper_local.rb b/spec/spec_helper_local.rb new file mode 100644 index 0000000..c7d27b5 --- /dev/null +++ b/spec/spec_helper_local.rb @@ -0,0 +1,7 @@ +require 'support/filesystem_helpers' +require 'support/fixture_helpers' + +RSpec.configure do |c| + c.include FilesystemHelpers + c.include FixtureHelpers +end -- cgit v1.2.3 From 4e0338bbd79d5e46ccdf330a0520a75728dba503 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Tue, 16 Feb 2016 16:01:25 +0000 Subject: (FM-4046) Update to current msync configs [006831f] This moves all copyright statements to the NOTICE file in accordance with the ASFs guidelines on applying the Apache-2.0 license. --- .gitattributes | 5 + .gitignore | 1 + .sync.yml | 3 + .travis.yml | 1 + Gemfile | 39 +++--- LICENSE | 348 ++++++++++++++++++++++++++++++++++++++++++++++++++-- NOTICE | 20 +++ Rakefile | 31 +++++ spec/spec_helper.rb | 1 + 9 files changed, 412 insertions(+), 37 deletions(-) create mode 100644 .gitattributes create mode 100644 .sync.yml create mode 100644 NOTICE diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..900ea0c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +#This file is generated by ModuleSync, do not edit. +*.rb eol=lf +*.erb eol=lf +*.pp eol=lf +*.sh eol=lf diff --git a/.gitignore b/.gitignore index 3190277..dd126f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +#This file is generated by ModuleSync, do not edit. pkg/ Gemfile.lock vendor/ diff --git a/.sync.yml b/.sync.yml new file mode 100644 index 0000000..02e2173 --- /dev/null +++ b/.sync.yml @@ -0,0 +1,3 @@ +--- +LICENSE: + unmanaged: true diff --git a/.travis.yml b/.travis.yml index e6314a4..588fb5b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +#This file is generated by ModuleSync, do not edit. --- sudo: false language: ruby diff --git a/Gemfile b/Gemfile index ced190e..e490bc9 100644 --- a/Gemfile +++ b/Gemfile @@ -1,12 +1,14 @@ +#This file is generated by ModuleSync, do not edit. + source ENV['GEM_SOURCE'] || "https://rubygems.org" -def location_for(place, fake_version = nil) +def location_for(place, version = nil) if place =~ /^(git[:@][^#]*)#(.*)/ - [fake_version, { :git => $1, :branch => $2, :require => false }].compact + [version, { :git => $1, :branch => $2, :require => false}].compact elsif place =~ /^file:\/\/(.*)/ - ['>= 0', { :path => File.expand_path($1), :require => false }] + ['>= 0', { :path => File.expand_path($1), :require => false}] else - [place, { :require => false }] + [place, version, { :require => false}].compact end end @@ -20,29 +22,18 @@ group :development, :unit_tests do gem 'simplecov', :require => false end group :system_tests do + gem 'beaker-rspec', *location_for(ENV['BEAKER_RSPEC_VERSION'] || '>= 3.4') + gem 'beaker', *location_for(ENV['BEAKER_VERSION']) + gem 'serverspec', :require => false gem 'beaker-puppet_install_helper', :require => false - if beaker_version = ENV['BEAKER_VERSION'] - gem 'beaker', *location_for(beaker_version) - end - if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] - gem 'beaker-rspec', *location_for(beaker_rspec_version) - else - gem 'beaker-rspec', :require => false - end gem 'master_manipulator', :require => false - gem 'serverspec', :require => false + gem 'beaker-hostgenerator', *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION']) end -if facterversion = ENV['FACTER_GEM_VERSION'] - gem 'facter', facterversion, :require => false -else - gem 'facter', :require => false -end +gem 'facter', *location_for(ENV['FACTER_GEM_VERSION']) +gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION']) -if puppetversion = ENV['PUPPET_GEM_VERSION'] - gem 'puppet', puppetversion, :require => false -else - gem 'puppet', :require => false -end -# vim:ft=ruby +if File.exists? "#{__FILE__}.local" + eval(File.read("#{__FILE__}.local"), binding) +end diff --git a/LICENSE b/LICENSE index 2ee80c8..d159169 100644 --- a/LICENSE +++ b/LICENSE @@ -1,17 +1,339 @@ -Copyright (C) 2010-2012 Puppet Labs Inc. + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 -Puppet Labs can be contacted at: info@puppetlabs.com + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. -This program and entire repository is free software; you can -redistribute it and/or modify it under the terms of the GNU -General Public License as published by the Free Software -Foundation; either version 2 of the License, or any later version. + Preamble -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..7eab165 --- /dev/null +++ b/NOTICE @@ -0,0 +1,20 @@ +vcsrepo puppet module + +Copyright (C) 2010-2012 Puppet Labs Inc. + +Puppet Labs can be contacted at: info@puppetlabs.com + + +This program and entire repository is free software; you can +redistribute it and/or modify it under the terms of the GNU +General Public License as published by the Free Software +Foundation; either version 2 of the License, or any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/Rakefile b/Rakefile index 35ce311..7e9a13d 100755 --- a/Rakefile +++ b/Rakefile @@ -9,3 +9,34 @@ PuppetLint.configuration.send('disable_class_inherits_from_params_class') PuppetLint.configuration.send('disable_documentation') PuppetLint.configuration.send('disable_single_quote_string_with_variables') PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] + +desc 'Generate pooler nodesets' +task :gen_nodeset do + require 'beaker-hostgenerator' + require 'securerandom' + require 'fileutils' + + agent_target = ENV['TEST_TARGET'] + if ! agent_target + STDERR.puts 'TEST_TARGET environment variable is not set' + STDERR.puts 'setting to default value of "redhat-64default."' + agent_target = 'redhat-64default.' + end + + master_target = ENV['MASTER_TEST_TARGET'] + if ! master_target + STDERR.puts 'MASTER_TEST_TARGET environment variable is not set' + STDERR.puts 'setting to default value of "redhat7-64mdcl"' + master_target = 'redhat7-64mdcl' + end + + targets = "#{master_target}-#{agent_target}" + cli = BeakerHostGenerator::CLI.new([targets]) + nodeset_dir = "tmp/nodesets" + nodeset = "#{nodeset_dir}/#{targets}-#{SecureRandom.uuid}.yaml" + FileUtils.mkdir_p(nodeset_dir) + File.open(nodeset, 'w') do |fh| + fh.print(cli.execute) + end + puts nodeset +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a7f5b4e..22d5d68 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,4 @@ +#This file is generated by ModuleSync, do not edit. require 'puppetlabs_spec_helper/module_spec_helper' # put local configuration and setup into spec_helper_local -- cgit v1.2.3 From 16e52ed77ecb683d56d73c6d0a9fa7f93f566999 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Wed, 17 Feb 2016 12:02:54 +0000 Subject: Update metadata to note Debian 8 support --- metadata.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 660953b..c505faa 100644 --- a/metadata.json +++ b/metadata.json @@ -55,7 +55,8 @@ "operatingsystem": "Debian", "operatingsystemrelease": [ "6", - "7" + "7", + "8" ] }, { -- cgit v1.2.3