Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(MODULES-3275) Chocolatey module testing #26

Merged
merged 1 commit into from
Jul 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ Gemfile:
- gem: beaker
- gem: master_manipulator
version: '~> 1.2'
- gem: beaker-windows
version: '~> 0.6'
Rakefile:
unmanaged: true
spec/spec_helper.rb:
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ end
group :system_tests do
gem 'beaker', *location_for(ENV['BEAKER_VERSION'] || '~> 2.20')
gem 'master_manipulator', '~> 1.2', :require => false
gem 'beaker-windows', '~> 0.6', :require => false
end

# The recommendation is for PROJECT_GEM_VERSION, although there are older ways
Expand Down
2 changes: 1 addition & 1 deletion tests/configs/windows-2012r2-64a
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ HOSTS:
roles:
- agent
platform: windows-2012r2-x86_64
template: Delivery/Quality Assurance/Templates/vCloud/win-2012r2-wmf5-x86_64
template: Delivery/Quality Assurance/Templates/vCloud/win-2012r2-x86_64
hypervisor: vcloud
CONFIG:
masterless: true
Expand Down
2 changes: 1 addition & 1 deletion tests/configs/windows-2012r2-64mda
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ HOSTS:
roles:
- agent
platform: windows-2012r2-x86_64
template: Delivery/Quality Assurance/Templates/vCloud/win-2012r2-wmf5-x86_64
template: Delivery/Quality Assurance/Templates/vCloud/win-2012r2-x86_64
hypervisor: vcloud
CONFIG:
nfs_server: none
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
require 'chocolatey_helper'
require 'beaker-windows'
test_name 'MODULES-3037 - 97729 Install known good package via manifest and remove via manifest'
confine(:to, :platform => 'windows')

# arrange
package_name = 'vlc'
package_exe_path = %{C:\\'Program Files\\VideoLAN\\VLC\\vlc.exe'}
package_uninstall_command = %{cmd.exe /C C:\\'Program Files\\VideoLAN\\VLC\\uninstall.exe' /S}

chocolatey_package_manifest = <<-PP
package { "#{package_name}":
ensure => present,
provider => chocolatey,
source => 'http://nexus.delivery.puppetlabs.net/service/local/nuget/choco-pipeline-tests/'
}
PP

# teardown
teardown do
on(agent, exec_ps_cmd("test-path #{package_exe_path}")) do |result|
if (result.output =~ /True/i)
on(agent, exec_ps_cmd(package_uninstall_command))
end
end
on(agent, exec_ps_cmd("test-path #{package_exe_path}")) do |result|
assert_match(/False/i, result.output, "#{package_name} was present after uninstall command called.")
end
end

#validate
step "should not have valid version of #{package_name}"
on(agent, exec_ps_cmd("test-path #{package_exe_path}")) do |result|
assert_match(/False/i, result.output, "#{package_name} was present before application of manifest.")
end


#act
step 'Apply manifest'
apply_manifest(chocolatey_package_manifest, :catch_failures => true) do |result|
assert_match(/Notice\: \/Stage\[main\]\/Main\/Package\[#{package_name}\]\/ensure\: created/, result.stdout, "stdout did not report package creation of #{package_name}")
end

#validate
step "should have valid version of #{package_name}"
on(agent, exec_ps_cmd("test-path #{package_exe_path}")) do |result|
assert_match(/True/i, result.output, "#{package_name} was not present after application of manifest.")
end

#arrange
chocolatey_package_manifest = <<-PP
package { "#{package_name}":
ensure => absent,
provider => chocolatey,
}
PP

#act
step "Uninstall #{package_name} package via manifest"
apply_manifest(chocolatey_package_manifest, :catch_failures => true) do |result|
#validate
assert_match(/Stage\[main\]\/Main\/Package\[#{package_name}\]\/ensure\: removed/, result.stdout, "stdout did not report package removal of #{package_name}")
end

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
require 'chocolatey_helper'
require 'beaker-windows'
test_name 'MODULES-3037 - C97738 Install known good package with utf-8 via manifest and remove via manifest'
confine(:to, :platform => 'windows')

# arrange
package_name = '竹ChocolateyGUIÖ'
package_exe_path = %{C:\\'Program Files (x86)\\ChocolateyGUI\\ChocolateyGUI.exe'}
package_uninstall_command = %{msiexec /x C:\\ProgramData\\chocolatey\\lib\\竹ChocolateyGUIÖ\\tools\\竹ChocolateyGUIÖ.msi /q}.force_encoding("ASCII-8BIT")

chocolatey_package_manifest = <<-PP
package { "#{package_name}":
ensure => present,
provider => chocolatey,
source => 'http://nexus.delivery.puppetlabs.net/service/local/nuget/choco-pipeline-tests/'
}
PP

# teardown
teardown do
on(agent, exec_ps_cmd("test-path #{package_exe_path}")) do |result|
if (result.output =~ /True/i)
on(agent, exec_ps_cmd(package_uninstall_command))
end
end
on(agent, exec_ps_cmd("test-path #{package_exe_path}")) do |result|
assert_match(/False/i, result.output, "#{package_name} was present after uninstall.")
end
end

#validate
step "should not have valid version of #{package_name}"
on(agent, exec_ps_cmd("test-path #{package_exe_path}")) do |result|
assert_match(/False/i, result.output, "#{package_name} was present before application of manifest.")
end


#act
step 'Apply manifest'
apply_manifest(chocolatey_package_manifest, :catch_failures => true) do |result|
assert_match(/Notice\: \/Stage\[main\]\/Main\/Package\[#{package_name}\]\/ensure\: created/, result.stdout, "stdout did not report package creation of #{package_name}")
end

#validate
step "should have valid version of #{package_name}"
on(agent, exec_ps_cmd("test-path #{package_exe_path}")) do |result|
assert_match(/True/i, result.output, "#{package_name} was not present after application of manifest.")
end

#arrange
chocolatey_package_manifest = <<-PP
package { "#{package_name}":
ensure => absent,
provider => chocolatey,
}
PP

#act
step "Uninstall #{package_name} package via manifest"
apply_manifest(chocolatey_package_manifest, :catch_failures => true) do |result|
#validate
expect_failure('Expected to fail because of MODULES-3541') do
assert_match(/Stage\[main\]\/Main\/Package\[#{package_name}\]\/ensure\: removed/, result.stdout, "stdout did not report package removal of #{package_name}")
end
end
7 changes: 0 additions & 7 deletions tests/reference/tests/hello.rb

This file was deleted.