Showing with 62 additions and 38 deletions.
  1. +5 −0 CHANGELOG.md
  2. +6 −0 Gemfile
  3. +8 −0 Rakefile
  4. +2 −2 metadata.json
  5. +5 −17 spec/acceptance/exec_powershell_spec.rb
  6. +36 −19 spec/spec_helper_acceptance.rb
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
##2014-08-25 - Supported Release 1.0.3
###Summary

This release updates the tests to verify that powershell continues to function on x64-native ruby.

##2014-07-15 - Supported Release 1.0.2
###Summary

Expand Down
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ gem "puppet", *location_for(ENV['PUPPET_LOCATION'] || '~> 3.4.0')
gem "facter", *location_for(ENV['FACTER_LOCATION'] || '~> 1.6')
gem "hiera", *location_for(ENV['HIERA_LOCATION'] || '~> 1.0')

beaker_version = ENV['BEAKER_VERSION']
group :development, :test do
gem 'rspec'
gem 'mocha'
Expand All @@ -25,6 +26,11 @@ group :development, :test do
gem 'puppet-lint', :require => false
gem 'pry', :require => false
gem 'simplecov', :require => false
if beaker_version
gem 'beaker', *location_for(beaker_version)
else
gem 'beaker', :require => false, :platforms => :ruby
end
gem 'beaker-rspec', :require => false, :platforms => :ruby
end

Expand Down
8 changes: 8 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@ RSpec::Core::RakeTask.new('beaker:rspec:test:pe',:host) do |t,args|
t.rspec_opts = '--color'
t.verbose = true
end

RSpec::Core::RakeTask.new('beaker:rspec:test:git',:host) do |t,args|
args.with_defaults({:host => 'default'})
ENV['BEAKER_set'] = args[:host]
t.pattern = 'spec/acceptance'
t.rspec_opts = '--color'
t.verbose = true
end
4 changes: 2 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppetlabs-powershell",
"version": "1.0.2",
"version": "1.0.3",
"author": "Puppet Labs",
"summary": "A PowerShell provider for puppet.",
"license": "Apache-2.0",
Expand All @@ -25,7 +25,7 @@
"requirements": [
{
"name": "pe",
"version_requirement": ">= 3.2.0 < 3.4.0"
"version_requirement": "3.x"
},
{
"name": "puppet",
Expand Down
22 changes: 5 additions & 17 deletions spec/acceptance/exec_powershell_spec.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
require 'spec_helper_acceptance'

describe 'powershell provider:', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
shared_context 'powershell plugin sync' do
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '../..'))
copy_root_module_to(master, {:module_name => 'powershell', :source => proj_root})
on agents, puppet("plugin download --server #{master}")
end

describe 'powershell provider:' do #, :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
shared_examples 'should fail' do |manifest, error_check|
it 'should throw an error' do
expect { apply_manifest(manifest, :catch_failures => true) }.to raise_error(error_check)
Expand All @@ -20,7 +14,7 @@
end

describe 'should run successfully' do
include_context 'powershell plugin sync'

p1 = <<-MANIFEST
exec{'TestPowershell':
command => 'Get-Process > c:/process.txt',
Expand All @@ -38,7 +32,7 @@
end

describe 'should be able to access the files after execution' do
include_context 'powershell plugin sync'

p2 = <<-MANIFEST
exec{"TestPowershell":
command => 'Get-Service *puppet* | Out-File -FilePath C:/services.txt -Encoding UTF8',
Expand All @@ -54,7 +48,6 @@
end

describe 'should catch and rethrow exceptions up to puppet' do
include_context 'powershell plugin sync'
pexception = <<-MANIFEST
exec{'PowershellException':
provider => powershell,
Expand All @@ -65,7 +58,6 @@
end

describe 'should be able to execute a ps1 file provided' do
include_context 'powershell plugin sync'
p2 = <<-MANIFEST
file{'c:/services.ps1':
content => '#{File.open(File.join(File.dirname(__FILE__), 'files/services.ps1')).read()}'
Expand All @@ -84,10 +76,9 @@
end

describe 'passing parameters to the ps1 file' do
include_context 'powershell plugin sync'
outfile = 'C:/temp/svchostprocess.txt'
outfile = 'C:/temp/svchostprocess.txt'
processName = 'svchost'
pp = <<-MANIFEST
pp = <<-MANIFEST
$process = '#{processName}'
$outFile = '#{outfile}'
file{'c:/param_script.ps1':
Expand All @@ -107,7 +98,6 @@
end

describe 'should execute using 64 bit powershell' do
include_context 'powershell plugin sync'
p3 = <<-MANIFEST
$maxArchNumber = $::architecture? {
/(?i)(i386|i686|x86)$/ => 4,
Expand Down Expand Up @@ -135,7 +125,6 @@
end

describe 'test admin rights' do
include_context 'powershell plugin sync'
ps1 = <<-PS1
$id = [Security.Principal.WindowsIdentity]::GetCurrent()
$pr = New-Object Security.Principal.WindowsPrincipal $id
Expand All @@ -145,7 +134,6 @@
end

describe 'test import-module' do
include_context 'powershell plugin sync'
pimport = <<-PS1
$mods = Get-Module -ListAvailable | Sort
if($mods.Length -lt 1) {
Expand Down
55 changes: 36 additions & 19 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
@@ -1,33 +1,50 @@
require 'beaker-rspec'
require 'rspec'
require 'beaker-rspec/spec_helper'
require 'beaker-rspec/helpers/serverspec'


UNSUPPORTED_PLATFORMS = ['debian', 'ubuntu', 'Solaris']

unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no'
is_foss = (ENV['IS_PE'] == 'no' || ENV['IS_PE'] == 'false') ? true : false
if hosts.first.is_pe? && !is_foss
install_pe
else
version = ENV['PUPPET_VERSION'] || '3.6.2'
download_url = ENV['WIN_DOWNLOAD_URL'] || 'http://downloads.puppetlabs.com/windows/'
hosts.each do |host|
if host['platform'] =~ /windows/i
install_puppet_from_msi(host,
{
:win_download_url => download_url,
:version => version
})
end
end
end

step "Install Powershell to default host"
on default, "mkdir -p #{default['distmoduledir']}/powershell"
result = on default, "echo #{default['distmoduledir']}/powershell"
target = result.raw_output.chomp
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
%w(lib metadata.json).each do |file|
scp_to default, "#{proj_root}/#{file}", target
end
end

RSpec.configure do |c|
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
hosts.each do |host|
shell("/bin/touch #{default['puppetpath']}/hiera.yaml")
end
shell("/bin/touch #{default['puppetpath']}/hiera.yaml")
end
c.after :suite do
absent_files = 'file{["c:/services.txt","c:/process.txt"]: ensure => absent }'
apply_manifest(absent_files)
end
end

UNSUPPORTED_PLATFORMS = [ 'debian','ubuntu', 'Solaris' ]

unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no'
if hosts.first.is_pe?
install_pe
else
install_puppet
end
hosts.each do |host|
on hosts, "mkdir -p #{host['distmoduledir']}"
end
end