Refactor spec-tests

and add workarounds for run tests under OSx platform

Also change fixtures for more optimal usage.

Change-Id: Iaac54e16f9a5b2b540f636768635fa5d4ff782eb
Closes-bug: #1544638
Partial-Bug: #1539975
This commit is contained in:
Sergey Vasilenko 2016-02-11 15:15:29 +03:00
parent 46ddfa166d
commit 5300060d16
13 changed files with 49 additions and 31 deletions

View File

@ -1,3 +1,16 @@
# For a standalone version should be:
#
# fixtures:
# forge_modules:
# stdlib:
# repo: "puppetlabs/stdlib"
# ref: "4.9.0"
# filemapper:
# repo: "adrien/filemapper"
# ref: "1.1.3"
# symlinks:
# l23network: "#{source_dir}"
fixtures:
symlinks:
l23network: "#{source_dir}"

View File

@ -13,9 +13,7 @@ lib/bundler/man
pkg
rdoc
spec/reports
spec/fixtures/modules/filemapper
spec/fixtures/modules/stdlib
spec/fixtures/modules/sysctl
spec/fixtures/modules
test/tmp
test/version_tmp
tmp

View File

@ -3,6 +3,13 @@ class l23network::examples::run_network_scheme (
$settings_yaml
){
include ::l23network::params
# this is a workaround for run spec tests not only on Linux platform
if $::l23network::params::network_manager_name != undef {
Package<| title == $::l23network::params::network_manager_name |> { provider => apt }
}
class {'::l23network': }
$config = parseyaml($settings_yaml)

View File

@ -116,20 +116,24 @@ class l23network (
Anchor['l23network::l2::init'] -> Anchor['l23network::init']
anchor { 'l23network::init': }
unless $network_manager {
package{$::l23network::params::network_manager_name:
ensure => 'purged',
if ! $network_manager {
if $::l23network::params::network_manager_name != undef {
package{$::l23network::params::network_manager_name:
ensure => 'purged',
}
Package[$::l23network::params::network_manager_name] -> Anchor['l23network::init']
}
Package[$::l23network::params::network_manager_name] -> Anchor['l23network::init']
# It is not enough to just remove package, we have to stop the service as well.
# Because SystemD continues running the service after package removing,
# with Upstart - all is ok.
if $::l23_os =~ /(?i:redhat7|centos7)/ {
if $::l23_os =~ /(?i)redhat7|centos7/ {
service{$::l23network::params::network_manager_name:
ensure => 'stopped',
}
Package[$::l23network::params::network_manager_name] ~> Service[$::l23network::params::network_manager_name]
if $::l23network::params::network_manager_name != undef {
Package[$::l23network::params::network_manager_name] ~> Service[$::l23network::params::network_manager_name]
}
Service[$::l23network::params::network_manager_name] -> Anchor['l23network::init']
}
}

View File

@ -19,7 +19,7 @@ class l23network::params {
$network_manager_name = 'network-manager'
$extra_tools = 'iputils-arping'
}
/(?i:redhat|centos)/: {
/(?i)redhat|centos/: {
$interfaces_dir = '/etc/sysconfig/network-scripts'
$interfaces_file = undef
$ovs_service_name = 'openvswitch'
@ -44,10 +44,11 @@ class l23network::params {
$lnx_bridge_tools = undef
$ovs_datapath_package_name = undef
$ovs_common_package_name = undef
$ovs_kern_module_name = unedf
$ovs_kern_module_name = undef
$network_manager_name = undef
}
default: {
fail("Unsupported OS: ${::l23_os}/${::operatingsystem}")
fail("Unsupported OS: ${l23_os}/${::operatingsystem}")
}
}
}

View File

@ -14,7 +14,7 @@
"operatingsystem_support": [
{
"operatingsystem": "RedHat",
"operatingsystemrelease": ["6.5"]
"operatingsystemrelease": ["6.5", "7.0", "7.1"]
},
{
"operatingsystem": "Ubuntu",
@ -24,7 +24,6 @@
"description": "Configure network features for 2nd and 3d network level.",
"dependencies": [
{ "name": "puppetlabs/stdlib", "version_requirement": ">=4.0.0 <5.0.0" },
{ "name": "duritong/sysctl", "version_requirement": ">=0.0.1 <1.0.0" },
{ "name": "adrien/filemapper", "version_requirement": ">=1.1.3" }
]
}

View File

@ -15,10 +15,7 @@ describe 'l23network', :type => :class do
puppet_debug_override()
end
it do
should compile.with_all_deps
end
it { should compile.with_all_deps }
it { should contain_package('bridge-utils').with_ensure('present') }
it { should contain_package('ethtool').with_ensure('present') }
it { should contain_package('ifenslave').with_ensure('present') }
@ -28,6 +25,7 @@ describe 'l23network', :type => :class do
it { should contain_anchor('l23network::l2::init').that_requires('Package[vlan]') }
it { should contain_anchor('l23network::l2::init').that_requires('Package[ifenslave]') }
it { should contain_anchor('l23network::l2::init').that_requires('Package[ethtool]') }
end
context 'default init of l23network module(CentOS6)' do
@ -42,10 +40,7 @@ describe 'l23network', :type => :class do
puppet_debug_override()
end
it do
should compile.with_all_deps
end
it { should compile.with_all_deps }
it { should contain_package('bridge-utils').with_ensure('present') }
it { should contain_package('ethtool').with_ensure('present') }
it { should_not contain_package('ifenslave').with_ensure('present') }
@ -69,10 +64,7 @@ describe 'l23network', :type => :class do
puppet_debug_override()
end
it do
should compile.with_all_deps
end
it { should compile.with_all_deps }
it { should contain_package('bridge-utils').with_ensure('present') }
it { should contain_package('ethtool').with_ensure('present') }
it { should_not contain_package('ifenslave').with_ensure('present') }
@ -80,6 +72,7 @@ describe 'l23network', :type => :class do
it { should contain_package('NetworkManager').with_ensure('purged') }
it { should contain_service('NetworkManager').with_ensure('stopped') }
it { should contain_anchor('l23network::l2::init').that_comes_before('Anchor[l23network::init]') }
end
context 'init l23network module with enabled OVS' do

View File

@ -1 +1,7 @@
include ::l23network::params
# this is a workaround for run spec tests not only on Linux platform
if $::l23network::params::network_manager_name != undef {
Package<| title == $::l23network::params::network_manager_name |> { provider => apt }
}
###

View File

@ -1 +0,0 @@
../../../../lib

View File

@ -1 +0,0 @@
../../../../manifests

View File

@ -1 +0,0 @@
../../../../templates

View File

@ -109,7 +109,7 @@ describe Puppet::Type.type(:l23_stored_config).provider(:ovs_centos7) do
context 'three bridges patch error' do
subject { providers[:ovs2lnx_bad_patch] }
it { expect{ subject.class.format_file('filepath', [subject])
}.to raise_error(Puppet::Error, %r{Patch\s+ovs2lnx-bpatch\s+has\s+more\s+than\s+2\s+bridges:\s+\["ovs-br",\s+"lnx-br",\s+"br-fake"].\s+Patch\s+can\s+connect\s+\*ONLY\*\s+2\s+bridges!}) }
}.to raise_error(Puppet::Error, %r{Patch\s+ovs2lnx-bpatch\s+has\s+more\s+than\s+2\s+bridges:\s+\["ovs-br",\s+"lnx-br",\s+"br-fake"\].\s+Patch\s+can\s+connect\s+\*ONLY\*\s+2\s+bridges!}) }
end
context 'the same provider of bridges error' do

View File

@ -109,7 +109,7 @@ describe Puppet::Type.type(:l23_stored_config).provider(:ovs_redhat7) do
context 'three bridges patch error' do
subject { providers[:ovs2lnx_bad_patch] }
it { expect{ subject.class.format_file('filepath', [subject])
}.to raise_error(Puppet::Error, %r{Patch\s+ovs2lnx-bpatch\s+has\s+more\s+than\s+2\s+bridges:\s+\["ovs-br",\s+"lnx-br",\s+"br-fake"].\s+Patch\s+can\s+connect\s+\*ONLY\*\s+2\s+bridges!}) }
}.to raise_error(Puppet::Error, %r{Patch\s+ovs2lnx-bpatch\s+has\s+more\s+than\s+2\s+bridges:\s+\["ovs-br",\s+"lnx-br",\s+"br-fake"\].\s+Patch\s+can\s+connect\s+\*ONLY\*\s+2\s+bridges!}) }
end
context 'the same provider of bridges error' do