From 7fbbf2535c9a76b23efe6247d4a1cd4cdc299483 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Tue, 16 Feb 2016 15:08:11 +0100 Subject: Bring stderr output to the Puppet visible output --- spec/unit/puppet/provider/vcsrepo/cvs_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'spec') diff --git a/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb b/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb index 2e18149..d7edd1d 100644 --- a/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb @@ -23,7 +23,7 @@ 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') - Puppet::Util::Execution.expects(:execute).with([:cvs, '-d', resource.value(:source), 'checkout', '-r', 'an-unimportant-value', '-d', 'test', 'bar'], :custom_environment => {}) + Puppet::Util::Execution.expects(:execute).with([:cvs, '-d', resource.value(:source), 'checkout', '-r', 'an-unimportant-value', '-d', 'test', 'bar'], :custom_environment => {}, :combine => true) provider.create end @@ -32,14 +32,14 @@ describe Puppet::Type.type(:vcsrepo).provider(:cvs_provider) do 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 => {}) + Puppet::Util::Execution.expects(:execute).with([:cvs, '-d', resource.value(:source), 'checkout', '-r', 'an-unimportant-value', '-d', 'test', 'bar'], :uid => 'muppet', :custom_environment => {}, :combine => true) provider.create end it "should just execute 'cvs checkout' without a revision" do resource[:source] = ':ext:source@example.com:/foo/bar' resource.delete(:revision) - 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 => {}) + 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 => {}, :combine => true) provider.create end @@ -48,7 +48,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:cvs_provider) do resource[:source] = ':ext:source@example.com:/foo/bar' resource[:compression] = '3' resource.delete(:revision) - 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 => {}) + 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 => {}, :combine => true) provider.create end end @@ -57,7 +57,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) - Puppet::Util::Execution.expects(:execute).with([:cvs, '-d', resource.value(:path), 'init'], :custom_environment => {}) + Puppet::Util::Execution.expects(:execute).with([:cvs, '-d', resource.value(:path), 'init'], :custom_environment => {}, :combine => true) provider.create end end @@ -116,7 +116,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:cvs_provider) do it "should use 'cvs update -dr'" do expects_chdir - Puppet::Util::Execution.expects(:execute).with([:cvs, 'update', '-dr', @tag, '.'], :custom_environment => {}) + Puppet::Util::Execution.expects(:execute).with([:cvs, 'update', '-dr', @tag, '.'], :custom_environment => {}, :combine => true) provider.revision = @tag end end -- cgit v1.2.3 From bd4e29a75ff16b91263a7b2b10a57dfdbeaab4a1 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Wed, 13 Apr 2016 20:50:19 +0100 Subject: Update to newest modulesync_configs [9ca280f] --- spec/acceptance/nodesets/centos-59-x64.yml | 10 ---------- spec/acceptance/nodesets/centos-64-x64-pe.yml | 12 ------------ spec/acceptance/nodesets/centos-64-x64.yml | 10 ---------- spec/acceptance/nodesets/centos-65-x64.yml | 10 ---------- spec/acceptance/nodesets/centos-7-x64.yml | 10 ++++++++++ spec/acceptance/nodesets/debian-607-x64.yml | 10 ---------- spec/acceptance/nodesets/debian-73-x64.yml | 10 ---------- spec/acceptance/nodesets/debian-8-x64.yml | 10 ++++++++++ spec/acceptance/nodesets/default.yml | 12 ++++++------ spec/acceptance/nodesets/docker/centos-7.yml | 12 ++++++++++++ spec/acceptance/nodesets/docker/debian-8.yml | 11 +++++++++++ spec/acceptance/nodesets/docker/ubuntu-14.04.yml | 12 ++++++++++++ spec/acceptance/nodesets/ubuntu-server-10044-x64.yml | 10 ---------- spec/acceptance/nodesets/ubuntu-server-12042-x64.yml | 10 ---------- spec/acceptance/nodesets/ubuntu-server-1404-x64.yml | 11 ----------- 15 files changed, 61 insertions(+), 99 deletions(-) delete mode 100644 spec/acceptance/nodesets/centos-59-x64.yml delete mode 100644 spec/acceptance/nodesets/centos-64-x64-pe.yml delete mode 100644 spec/acceptance/nodesets/centos-64-x64.yml delete mode 100644 spec/acceptance/nodesets/centos-65-x64.yml create mode 100644 spec/acceptance/nodesets/centos-7-x64.yml delete mode 100644 spec/acceptance/nodesets/debian-607-x64.yml delete mode 100644 spec/acceptance/nodesets/debian-73-x64.yml create mode 100644 spec/acceptance/nodesets/debian-8-x64.yml create mode 100644 spec/acceptance/nodesets/docker/centos-7.yml create mode 100644 spec/acceptance/nodesets/docker/debian-8.yml create mode 100644 spec/acceptance/nodesets/docker/ubuntu-14.04.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-server-10044-x64.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-server-12042-x64.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-server-1404-x64.yml (limited to 'spec') diff --git a/spec/acceptance/nodesets/centos-59-x64.yml b/spec/acceptance/nodesets/centos-59-x64.yml deleted file mode 100644 index 2ad90b8..0000000 --- a/spec/acceptance/nodesets/centos-59-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index 7d9242f..0000000 --- a/spec/acceptance/nodesets/centos-64-x64-pe.yml +++ /dev/null @@ -1,12 +0,0 @@ -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-64-x64.yml b/spec/acceptance/nodesets/centos-64-x64.yml deleted file mode 100644 index 05540ed..0000000 --- a/spec/acceptance/nodesets/centos-64-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -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/centos-65-x64.yml b/spec/acceptance/nodesets/centos-65-x64.yml deleted file mode 100644 index 4e2cb80..0000000 --- a/spec/acceptance/nodesets/centos-65-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -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/centos-7-x64.yml b/spec/acceptance/nodesets/centos-7-x64.yml new file mode 100644 index 0000000..1a40c89 --- /dev/null +++ b/spec/acceptance/nodesets/centos-7-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-7-x64: + roles: + - agent + - default + platform: redhat-7-x86_64 + hypervisor: vagrant + box: puppetlabs/centos-7.2-64-nocm +CONFIG: + type: foss diff --git a/spec/acceptance/nodesets/debian-607-x64.yml b/spec/acceptance/nodesets/debian-607-x64.yml deleted file mode 100644 index 43df6a5..0000000 --- a/spec/acceptance/nodesets/debian-607-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index 5b87870..0000000 --- a/spec/acceptance/nodesets/debian-73-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -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/debian-8-x64.yml b/spec/acceptance/nodesets/debian-8-x64.yml new file mode 100644 index 0000000..fef6e63 --- /dev/null +++ b/spec/acceptance/nodesets/debian-8-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + debian-8-x64: + roles: + - agent + - default + platform: debian-8-amd64 + hypervisor: vagrant + box: puppetlabs/debian-8.2-64-nocm +CONFIG: + type: foss diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml index 05540ed..dba339c 100644 --- a/spec/acceptance/nodesets/default.yml +++ b/spec/acceptance/nodesets/default.yml @@ -1,10 +1,10 @@ HOSTS: - centos-64-x64: + ubuntu-1404-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 + - agent + - default + platform: ubuntu-14.04-amd64 + hypervisor: vagrant + box: puppetlabs/ubuntu-14.04-64-nocm CONFIG: type: foss diff --git a/spec/acceptance/nodesets/docker/centos-7.yml b/spec/acceptance/nodesets/docker/centos-7.yml new file mode 100644 index 0000000..a3333aa --- /dev/null +++ b/spec/acceptance/nodesets/docker/centos-7.yml @@ -0,0 +1,12 @@ +HOSTS: + centos-7-x64: + platform: el-7-x86_64 + hypervisor: docker + image: centos:7 + docker_preserve_image: true + docker_cmd: '["/usr/sbin/init"]' + # install various tools required to get the image up to usable levels + docker_image_commands: + - 'yum install -y crontabs tar wget openssl sysvinit-tools iproute which initscripts' +CONFIG: + trace_limit: 200 diff --git a/spec/acceptance/nodesets/docker/debian-8.yml b/spec/acceptance/nodesets/docker/debian-8.yml new file mode 100644 index 0000000..df5c319 --- /dev/null +++ b/spec/acceptance/nodesets/docker/debian-8.yml @@ -0,0 +1,11 @@ +HOSTS: + debian-8-x64: + platform: debian-8-amd64 + hypervisor: docker + image: debian:8 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get update && apt-get install -y net-tools wget locales strace lsof && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen' +CONFIG: + trace_limit: 200 diff --git a/spec/acceptance/nodesets/docker/ubuntu-14.04.yml b/spec/acceptance/nodesets/docker/ubuntu-14.04.yml new file mode 100644 index 0000000..b1efa58 --- /dev/null +++ b/spec/acceptance/nodesets/docker/ubuntu-14.04.yml @@ -0,0 +1,12 @@ +HOSTS: + ubuntu-1404-x64: + platform: ubuntu-14.04-amd64 + hypervisor: docker + image: ubuntu:14.04 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + # ensure that upstart is booting correctly in the container + - 'rm /usr/sbin/policy-rc.d && rm /sbin/initctl && dpkg-divert --rename --remove /sbin/initctl && apt-get update && apt-get install -y net-tools wget && locale-gen en_US.UTF-8' +CONFIG: + trace_limit: 200 diff --git a/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml b/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml deleted file mode 100644 index 5ca1514..0000000 --- a/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index d065b30..0000000 --- a/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml +++ /dev/null @@ -1,10 +0,0 @@ -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/nodesets/ubuntu-server-1404-x64.yml b/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml deleted file mode 100644 index cba1cd0..0000000 --- a/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml +++ /dev/null @@ -1,11 +0,0 @@ -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 d022891fb489bccbd1e0d910f3c0467238d94f80 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Thu, 25 Aug 2016 16:14:19 +0200 Subject: Update modulesync_config [0d59329] --- spec/acceptance/nodesets/centos-7-x64.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/acceptance/nodesets/centos-7-x64.yml b/spec/acceptance/nodesets/centos-7-x64.yml index 1a40c89..5eebdef 100644 --- a/spec/acceptance/nodesets/centos-7-x64.yml +++ b/spec/acceptance/nodesets/centos-7-x64.yml @@ -3,7 +3,7 @@ HOSTS: roles: - agent - default - platform: redhat-7-x86_64 + platform: el-7-x86_64 hypervisor: vagrant box: puppetlabs/centos-7.2-64-nocm CONFIG: -- cgit v1.2.3 From 5e46486d3ea2d15984edfb28875471436f466a65 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Thu, 1 Sep 2016 15:47:27 -0400 Subject: Fix bug in ensure => absent The insync? method wasn't accounting for a condition where the state was absent and the desired state was absent. This manifest itself in puppet runs that would constantly output the following after setting ensure => absent. 2016-09-01T16:39:27.314283+00:00 vcstest puppet-agent[1161]: (/Stage[main]/Main/Node[vcstest]/Vcsrepo[/home/vagrant/test]/ensure) created 2016-09-01T16:40:22.583125+00:00 vcstest puppet-agent[1727]: (/Stage[main]/Main/Node[vcstest]/Vcsrepo[/home/vagrant/test]/ensure) created 2016-09-01T16:41:04.031750+00:00 vcstest puppet-agent[2267]: (/Stage[main]/Main/Node[vcstest]/Vcsrepo[/home/vagrant/test]/ensure) created 2016-09-01T16:42:51.779816+00:00 vcstest puppet-agent[2911]: (/Stage[main]/Main/Node[vcstest]/Vcsrepo[/home/vagrant/test]/ensure) created 2016-09-01T16:43:42.189035+00:00 vcstest puppet-agent[3466]: (/Stage[main]/Main/Node[vcstest]/Vcsrepo[/home/vagrant/test]/ensure) created I added unit tests for the vcsrepo type and then fixed the code. --- spec/unit/puppet/type/vcsrepo_spec.rb | 116 ++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100755 spec/unit/puppet/type/vcsrepo_spec.rb (limited to 'spec') diff --git a/spec/unit/puppet/type/vcsrepo_spec.rb b/spec/unit/puppet/type/vcsrepo_spec.rb new file mode 100755 index 0000000..0070f49 --- /dev/null +++ b/spec/unit/puppet/type/vcsrepo_spec.rb @@ -0,0 +1,116 @@ +#! /usr/bin/env ruby +require 'spec_helper' + +describe Puppet::Type.type(:vcsrepo) do + + before :each do + Puppet::Type.type(:vcsrepo).stubs(:defaultprovider).returns(providerclass) + end + + let(:providerclass) do + described_class.provide(:fake_vcsrepo_provider) do + attr_accessor :property_hash + def create; end + def destroy; end + def exists? + get(:ensure) != :absent + end + mk_resource_methods + end + end + + let(:provider) do + providerclass.new(:name => 'fake-vcs') + end + + let(:resource) do + described_class.new(:name => '/repo', + :ensure => :present, + :provider => provider) + end + + let(:ensureprop) do + resource.property(:ensure) + end + + properties = [ :ensure ] + + properties.each do |property| + it "should have a #{property} property" do + expect(described_class.attrclass(property).ancestors).to be_include(Puppet::Property) + end + end + + parameters = [ :ensure ] + + parameters.each do |parameter| + it "should have a #{parameter} parameter" do + expect(described_class.attrclass(parameter).ancestors).to be_include(Puppet::Parameter) + end + end + + describe 'default resource with required params' do + it 'should have a valid name parameter' do + expect(resource[:name]).to eq('/repo') + end + + it 'should have ensure set to present' do + expect(resource[:ensure]).to eq(:present) + end + + it 'should have path set to /repo' do + expect(resource[:path]).to eq('/repo') + end + + defaults = { + :owner => nil, + :group => nil, + :user => nil, + :revision => nil, + } + + defaults.each_pair do |param, value| + it "should have #{param} parameter set to #{value}" do + expect(resource[param]).to eq(value) + end + end + end + + describe 'when changing the ensure' do + it 'should be in sync if it is :absent and should be :absent' do + ensureprop.should = :absent + expect(ensureprop.safe_insync?(:absent)).to eq(true) + end + + it 'should be in sync if it is :present and should be :present' do + ensureprop.should = :present + expect(ensureprop.safe_insync?(:present)).to eq(true) + end + + it 'should be out of sync if it is :absent and should be :present' do + ensureprop.should = :present + expect(ensureprop.safe_insync?(:absent)).not_to eq(true) + end + + it 'should be out of sync if it is :present and should be :absent' do + ensureprop.should = :absent + expect(ensureprop.safe_insync?(:present)).not_to eq(true) + end + end + + describe 'when running the type it should autorequire packages' do + before :each do + @catalog = Puppet::Resource::Catalog.new + ['git', 'git-core', 'mercurial'].each do |pkg| + @catalog.add_resource(Puppet::Type.type(:package).new(:name => pkg)) + end + end + + it 'should require package packages' do + @resource = described_class.new(:name => '/foo', :provider => provider) + @catalog.add_resource(@resource) + req = @resource.autorequire + expect(req.size).to eq(3) + end + end +end -- cgit v1.2.3