Implement remaining unit tests
Added unit tests for the remainder of the module as it stands today. Also fixed missing dependency for the ovs module. Change-Id: I498f7d4d2b18a66b782ddb64b5a9f125ea58e416
This commit is contained in:
parent
8266fb6dd5
commit
4423dccf22
@ -1,5 +1,6 @@
|
||||
fixtures:
|
||||
repositories:
|
||||
'stdlib': 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
|
||||
'vswitch': 'git://github.com/openstack/puppet-vswitch'
|
||||
symlinks:
|
||||
"n1k_vsm": "#{source_dir}"
|
||||
|
@ -1,4 +1,4 @@
|
||||
[gerrit]
|
||||
host=review.openstack.org
|
||||
port=29418
|
||||
project=stackforge/puppet-n1k-vsm.git
|
||||
project=openstack/puppet-n1k-vsm.git
|
||||
|
156
spec/classes/n1kv_vsm_deploy_spec.rb
Normal file
156
spec/classes/n1kv_vsm_deploy_spec.rb
Normal file
@ -0,0 +1,156 @@
|
||||
#
|
||||
# Copyright (C) 2015 Cisco Systems Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'n1k_vsm::deploy' do
|
||||
|
||||
let :params do
|
||||
{ }
|
||||
end
|
||||
|
||||
shared_examples_for 'n1k vsm deploy' do
|
||||
|
||||
context 'for primary role' do
|
||||
let :pre_condition do
|
||||
"class { 'n1k_vsm':
|
||||
phy_gateway => '1.1.1.3',
|
||||
vsm_domain_id => '1',
|
||||
vsm_admin_passwd => 'secrete',
|
||||
vsm_mgmt_ip => '1.1.1.1',
|
||||
vsm_mgmt_netmask => '255.255.255.0',
|
||||
vsm_mgmt_gateway => '1.1.1.2',
|
||||
vsm_role => 'primary',
|
||||
pacemaker_control => false,
|
||||
}"
|
||||
end
|
||||
|
||||
it 'creates disk' do
|
||||
is_expected.to contain_exec('Exec_create_disk').with(
|
||||
'creates' => '/var/spool/cisco/vsm/primary_disk',
|
||||
)
|
||||
end
|
||||
|
||||
it 'creates xml' do
|
||||
is_expected.to contain_file('File_Target_XML_File').with(
|
||||
'path' => '/var/spool/cisco/vsm/vsm_primary_deploy.xml',
|
||||
)
|
||||
end
|
||||
|
||||
it 'defines vsm' do
|
||||
is_expected.to contain_exec('Exec_Define_VSM').with(
|
||||
'command' => '/usr/bin/virsh define /var/spool/cisco/vsm/vsm_primary_deploy.xml',
|
||||
)
|
||||
end
|
||||
|
||||
it 'launches vsm' do
|
||||
is_expected.to contain_exec('Exec_Launch_VSM').with(
|
||||
'command' => '/usr/bin/virsh start vsm-p',
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'for secondary role' do
|
||||
let :pre_condition do
|
||||
"class { 'n1k_vsm':
|
||||
phy_gateway => '1.1.1.3',
|
||||
vsm_domain_id => '1',
|
||||
vsm_admin_passwd => 'secrete',
|
||||
vsm_mgmt_ip => '1.1.1.1',
|
||||
vsm_mgmt_netmask => '255.255.255.0',
|
||||
vsm_mgmt_gateway => '1.1.1.2',
|
||||
vsm_role => 'secondary',
|
||||
pacemaker_control => false,
|
||||
}"
|
||||
end
|
||||
|
||||
it 'creates disk' do
|
||||
is_expected.to contain_exec('Exec_create_disk').with(
|
||||
'creates' => '/var/spool/cisco/vsm/secondary_disk',
|
||||
)
|
||||
end
|
||||
|
||||
it 'creates xml' do
|
||||
is_expected.to contain_file('File_Target_XML_File').with(
|
||||
'path' => '/var/spool/cisco/vsm/vsm_secondary_deploy.xml',
|
||||
)
|
||||
end
|
||||
|
||||
it 'defines vsm' do
|
||||
is_expected.to contain_exec('Exec_Define_VSM').with(
|
||||
'command' => '/usr/bin/virsh define /var/spool/cisco/vsm/vsm_secondary_deploy.xml',
|
||||
)
|
||||
end
|
||||
|
||||
it 'launches vsm' do
|
||||
is_expected.to contain_exec('Exec_Launch_VSM').with(
|
||||
'command' => '/usr/bin/virsh start vsm-s',
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'for pacemaker controlled' do
|
||||
let :pre_condition do
|
||||
"class { 'n1k_vsm':
|
||||
phy_gateway => '1.1.1.3',
|
||||
vsm_domain_id => '1',
|
||||
vsm_admin_passwd => 'secrete',
|
||||
vsm_mgmt_ip => '1.1.1.1',
|
||||
vsm_mgmt_netmask => '255.255.255.0',
|
||||
vsm_mgmt_gateway => '1.1.1.2',
|
||||
vsm_role => 'primary',
|
||||
pacemaker_control => true,
|
||||
}"
|
||||
end
|
||||
|
||||
it 'creates disk' do
|
||||
is_expected.to contain_exec('Exec_create_disk').with(
|
||||
'creates' => '/var/spool/cisco/vsm/primary_disk',
|
||||
)
|
||||
end
|
||||
|
||||
it 'creates xml' do
|
||||
is_expected.to contain_file('File_Target_XML_File').with(
|
||||
'path' => '/var/spool/cisco/vsm/vsm_primary_deploy.xml',
|
||||
)
|
||||
end
|
||||
|
||||
it 'creates secondary disk' do
|
||||
is_expected.to contain_exec('Exec_create_disk_Secondary').with(
|
||||
'creates' => '/var/spool/cisco/vsm/secondary_disk',
|
||||
)
|
||||
end
|
||||
|
||||
it 'creates secondary xml' do
|
||||
is_expected.to contain_file('File_Target_XML_File_Secondary').with(
|
||||
'path' => '/var/spool/cisco/vsm/vsm_secondary_deploy.xml',
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
it_configures 'n1k vsm deploy'
|
||||
end
|
||||
|
||||
end
|
||||
|
126
spec/classes/n1kv_vsm_pkgprep_ovscfg_spec.rb
Normal file
126
spec/classes/n1kv_vsm_pkgprep_ovscfg_spec.rb
Normal file
@ -0,0 +1,126 @@
|
||||
#
|
||||
# Copyright (C) 2015 Cisco Systems Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'n1k_vsm::pkgprep_ovscfg' do
|
||||
|
||||
let :params do
|
||||
{ }
|
||||
end
|
||||
|
||||
shared_examples_for 'n1k vsm pkgprep_ovscfg' do
|
||||
|
||||
context 'for default values' do
|
||||
let :pre_condition do
|
||||
"class { 'n1k_vsm':
|
||||
phy_if_bridge => 'eth0',
|
||||
phy_gateway => '1.1.1.3',
|
||||
vsm_domain_id => '1',
|
||||
vsm_admin_passwd => 'secrete',
|
||||
vsm_mgmt_ip => '1.1.1.1',
|
||||
vsm_mgmt_netmask => '255.255.255.0',
|
||||
vsm_mgmt_gateway => '1.1.1.2',
|
||||
existing_bridge => false,
|
||||
}"
|
||||
end
|
||||
|
||||
it 'should require vswitch::ovs' do
|
||||
is_expected.to contain_class('vswitch::ovs')
|
||||
end
|
||||
|
||||
it 'create ovs bridge' do
|
||||
is_expected.to contain_augeas('Augeas_modify_ifcfg-ovsbridge').with(
|
||||
'name' => 'vsm-br',
|
||||
'context' => '/files/etc/sysconfig/network-scripts/ifcfg-vsm-br',
|
||||
)
|
||||
end
|
||||
|
||||
it 'flap bridge' do
|
||||
is_expected.to contain_exec('Flap_n1kv_bridge').with(
|
||||
'command' => '/sbin/ifdown vsm-br && /sbin/ifup vsm-br',
|
||||
)
|
||||
end
|
||||
|
||||
it 'attach phy if port to bridge' do
|
||||
is_expected.to contain_augeas('Augeas_modify_ifcfg-phy_if_bridge').with(
|
||||
'name' => 'eth0',
|
||||
'context' => '/files/etc/sysconfig/network-scripts/ifcfg-eth0',
|
||||
)
|
||||
end
|
||||
|
||||
it 'flap port' do
|
||||
is_expected.to contain_exec('Flap_n1kv_phy_if').with(
|
||||
'command' => '/sbin/ifdown eth0 && /sbin/ifup eth0',
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'for existing bridge' do
|
||||
let :pre_condition do
|
||||
"class { 'n1k_vsm':
|
||||
phy_if_bridge => 'br-ex',
|
||||
phy_gateway => '1.1.1.3',
|
||||
vsm_domain_id => '1',
|
||||
vsm_admin_passwd => 'secrete',
|
||||
vsm_mgmt_ip => '1.1.1.1',
|
||||
vsm_mgmt_netmask => '255.255.255.0',
|
||||
vsm_mgmt_gateway => '1.1.1.2',
|
||||
existing_bridge => true,
|
||||
}"
|
||||
end
|
||||
|
||||
it 'should require vswitch::ovs' do
|
||||
is_expected.to contain_class('vswitch::ovs')
|
||||
end
|
||||
|
||||
it 'create ovs bridge' do
|
||||
is_expected.to contain_augeas('Augeas_modify_ifcfg-ovsbridge').with(
|
||||
'name' => 'vsm-br',
|
||||
'context' => '/files/etc/sysconfig/network-scripts/ifcfg-vsm-br',
|
||||
)
|
||||
end
|
||||
|
||||
it 'flap bridge' do
|
||||
is_expected.to contain_exec('Flap_n1kv_bridge').with(
|
||||
'command' => '/sbin/ifdown vsm-br && /sbin/ifup vsm-br',
|
||||
)
|
||||
end
|
||||
|
||||
it 'create patch port on existing bridge' do
|
||||
is_expected.to contain_exec('Create_patch_port_on_existing_bridge').with(
|
||||
'command' => '/bin/ovs-vsctl --may-exist add-port br-ex br-ex-vsm-br -- set Interface br-ex-vsm-br type=patch options:peer=vsm-br-br-ex'
|
||||
)
|
||||
end
|
||||
|
||||
it 'create patch port on vsm bridge' do
|
||||
is_expected.to contain_exec('Create_patch_port_on_vsm_bridge').with(
|
||||
'command' => '/bin/ovs-vsctl --may-exist add-port vsm-br vsm-br-br-ex -- set Interface vsm-br-br-ex type=patch options:peer=br-ex-vsm-br'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
it_configures 'n1k vsm pkgprep_ovscfg'
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2015 eNovance SAS <licensing@enovance.com>
|
||||
# Copyright (C) 2015 Cisco Systems Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
@ -24,27 +24,7 @@ describe 'n1k_vsm::vsmprep' do
|
||||
|
||||
shared_examples_for 'n1k vsm prep' do
|
||||
|
||||
context 'with default values' do
|
||||
let :pre_condition do
|
||||
"class { 'n1k_vsm':
|
||||
phy_gateway => '1.1.1.3',
|
||||
vsm_domain_id => '1',
|
||||
vsm_admin_passwd => 'secrete',
|
||||
vsm_mgmt_ip => '1.1.1.1',
|
||||
vsm_mgmt_netmask => '255.255.255.0',
|
||||
vsm_mgmt_gateway => '1.1.1.2',
|
||||
}"
|
||||
end
|
||||
|
||||
# Currently we always just check if VSM is present
|
||||
it 'installs latest n1kv sofware' do
|
||||
is_expected.to contain_package('nexus-1000v-iso').with(
|
||||
:ensure => 'present',
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with custom values' do
|
||||
context 'get vsm from file' do
|
||||
let :pre_condition do
|
||||
"class { 'n1k_vsm':
|
||||
phy_gateway => '1.1.1.3',
|
||||
@ -54,6 +34,72 @@ describe 'n1k_vsm::vsmprep' do
|
||||
vsm_mgmt_netmask => '255.255.255.0',
|
||||
vsm_mgmt_gateway => '1.1.1.2',
|
||||
n1kv_version => '5.2.1.SK3.2.2a-1',
|
||||
n1kv_source => 'vsm_test',
|
||||
vsm_role => 'primary',
|
||||
}"
|
||||
end
|
||||
|
||||
it 'gets vsm from file' do
|
||||
is_expected.to contain_file('/var/spool/cisco/vsm/vsm_test').with(
|
||||
'source' => 'puppet:///modules/n1k_vsm/vsm_test',
|
||||
)
|
||||
end
|
||||
|
||||
it 'runs repackage iso script' do
|
||||
is_expected.to contain_exec('Exec_VSM_Repackage_Script').with(
|
||||
:command => '/tmp/repackiso.py -i/var/spool/cisco/vsm/n1000v-dk9.5.2.1.SK3.2.2a-1.iso -d1 -nvsm-p -m1.1.1.1 -s255.255.255.0 -g1.1.1.2 -psecrete -rprimary -f/var/spool/cisco/vsm/primary_repacked.iso',
|
||||
:creates => '/var/spool/cisco/vsm/primary_repacked.iso'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'get vsm from specified repo' do
|
||||
let :pre_condition do
|
||||
"class { 'n1k_vsm':
|
||||
phy_gateway => '1.1.1.3',
|
||||
vsm_domain_id => '1',
|
||||
vsm_admin_passwd => 'secrete',
|
||||
vsm_mgmt_ip => '1.1.1.1',
|
||||
vsm_mgmt_netmask => '255.255.255.0',
|
||||
vsm_mgmt_gateway => '1.1.1.2',
|
||||
n1kv_version => '5.2.1.SK3.2.2a-1',
|
||||
n1kv_source => 'http://vsm_test',
|
||||
vsm_role => 'primary',
|
||||
}"
|
||||
end
|
||||
|
||||
it 'configures specified repo' do
|
||||
is_expected.to contain_yumrepo('cisco-vsm-repo').with(
|
||||
'baseurl' => 'http://vsm_test',
|
||||
'gpgkey' => 'http://vsm_test/RPM-GPG-KEY'
|
||||
)
|
||||
end
|
||||
|
||||
# Currently we always just check if VSM is present
|
||||
it 'installs latest n1kv sofware' do
|
||||
is_expected.to contain_package('nexus-1000v-iso').with(
|
||||
:ensure => 'present',
|
||||
)
|
||||
end
|
||||
it 'runs repackage iso script' do
|
||||
is_expected.to contain_exec('Exec_VSM_Repackage_Script').with(
|
||||
:command => '/tmp/repackiso.py -i/opt/cisco/vsm/n1000v-dk9.5.2.1.SK3.2.2a-1.iso -d1 -nvsm-p -m1.1.1.1 -s255.255.255.0 -g1.1.1.2 -psecrete -rprimary -f/var/spool/cisco/vsm/primary_repacked.iso',
|
||||
:creates => '/var/spool/cisco/vsm/primary_repacked.iso'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'get vsm from pre-configured repo' do
|
||||
let :pre_condition do
|
||||
"class { 'n1k_vsm':
|
||||
phy_gateway => '1.1.1.3',
|
||||
vsm_domain_id => '1',
|
||||
vsm_admin_passwd => 'secrete',
|
||||
vsm_mgmt_ip => '1.1.1.1',
|
||||
vsm_mgmt_netmask => '255.255.255.0',
|
||||
vsm_mgmt_gateway => '1.1.1.2',
|
||||
n1kv_version => '5.2.1.SK3.2.2a-1',
|
||||
vsm_role => 'primary',
|
||||
}"
|
||||
end
|
||||
|
||||
@ -63,8 +109,79 @@ describe 'n1k_vsm::vsmprep' do
|
||||
:ensure => 'present',
|
||||
)
|
||||
end
|
||||
|
||||
it 'runs repackage iso script' do
|
||||
is_expected.to contain_exec('Exec_VSM_Repackage_Script').with(
|
||||
:command => '/tmp/repackiso.py -i/opt/cisco/vsm/n1000v-dk9.5.2.1.SK3.2.2a-1.iso -d1 -nvsm-p -m1.1.1.1 -s255.255.255.0 -g1.1.1.2 -psecrete -rprimary -f/var/spool/cisco/vsm/primary_repacked.iso',
|
||||
:creates => '/var/spool/cisco/vsm/primary_repacked.iso'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'get vsm from pre-configured repo secondary' do
|
||||
let :pre_condition do
|
||||
"class { 'n1k_vsm':
|
||||
phy_gateway => '1.1.1.3',
|
||||
vsm_domain_id => '1',
|
||||
vsm_admin_passwd => 'secrete',
|
||||
vsm_mgmt_ip => '1.1.1.1',
|
||||
vsm_mgmt_netmask => '255.255.255.0',
|
||||
vsm_mgmt_gateway => '1.1.1.2',
|
||||
n1kv_version => '5.2.1.SK3.2.2a-1',
|
||||
vsm_role => 'secondary',
|
||||
}"
|
||||
end
|
||||
|
||||
# Currently we always just check if VSM is present
|
||||
it 'installs latest n1kv sofware' do
|
||||
is_expected.to contain_package('nexus-1000v-iso').with(
|
||||
:ensure => 'present',
|
||||
)
|
||||
end
|
||||
|
||||
it 'runs repackage iso script' do
|
||||
is_expected.to contain_exec('Exec_VSM_Repackage_Script').with(
|
||||
:command => '/tmp/repackiso.py -i/opt/cisco/vsm/n1000v-dk9.5.2.1.SK3.2.2a-1.iso -d1 -nvsm-s -m0.0.0.0 -s0.0.0.0 -g0.0.0.0 -psecrete -rsecondary -f/var/spool/cisco/vsm/secondary_repacked.iso',
|
||||
:creates => '/var/spool/cisco/vsm/secondary_repacked.iso'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'get vsm from pre-configured repo pacemaker controlled' do
|
||||
let :pre_condition do
|
||||
"class { 'n1k_vsm':
|
||||
phy_gateway => '1.1.1.3',
|
||||
vsm_domain_id => '1',
|
||||
vsm_admin_passwd => 'secrete',
|
||||
vsm_mgmt_ip => '1.1.1.1',
|
||||
vsm_mgmt_netmask => '255.255.255.0',
|
||||
vsm_mgmt_gateway => '1.1.1.2',
|
||||
n1kv_version => '5.2.1.SK3.2.2a-1',
|
||||
pacemaker_control => true,
|
||||
}"
|
||||
end
|
||||
|
||||
# Currently we always just check if VSM is present
|
||||
it 'installs latest n1kv sofware' do
|
||||
is_expected.to contain_package('nexus-1000v-iso').with(
|
||||
:ensure => 'present',
|
||||
)
|
||||
end
|
||||
|
||||
it 'runs repackage iso script' do
|
||||
is_expected.to contain_exec('Exec_VSM_Repackage_Script').with(
|
||||
:command => '/tmp/repackiso.py -i/opt/cisco/vsm/n1000v-dk9.5.2.1.SK3.2.2a-1.iso -d1 -nvsm-p -m1.1.1.1 -s255.255.255.0 -g1.1.1.2 -psecrete -rprimary -f/var/spool/cisco/vsm/primary_repacked.iso',
|
||||
:creates => '/var/spool/cisco/vsm/primary_repacked.iso'
|
||||
)
|
||||
end
|
||||
|
||||
it 'runs repackage iso script secondary' do
|
||||
is_expected.to contain_exec('Exec_VSM_Repackage_Script_secondary').with(
|
||||
:command => '/tmp/repackiso.py -i/opt/cisco/vsm/n1000v-dk9.5.2.1.SK3.2.2a-1.iso -d1 -nvsm-s -m1.1.1.1 -s255.255.255.0 -g1.1.1.2 -psecrete -rsecondary -f/var/spool/cisco/vsm/secondary_repacked.iso',
|
||||
:creates => '/var/spool/cisco/vsm/secondary_repacked.iso'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
|
Loading…
x
Reference in New Issue
Block a user