From 9326e4237f4d161f297dc4493ab4928ea6e2bf0f Mon Sep 17 00:00:00 2001 From: Feng Pan Date: Mon, 7 Nov 2016 19:22:21 -0500 Subject: Initial Commit. Change-Id: I212ec4be42357edddd931e9e479e33131ccd4bac Signed-off-by: Feng Pan --- spec/classes/fdio_spec.rb | 95 ++++++++++++++++++++++++++++++++++++++++++ spec/classes/honeycomb_spec.rb | 32 ++++++++++++++ 2 files changed, 127 insertions(+) create mode 100644 spec/classes/fdio_spec.rb create mode 100644 spec/classes/honeycomb_spec.rb (limited to 'spec/classes') diff --git a/spec/classes/fdio_spec.rb b/spec/classes/fdio_spec.rb new file mode 100644 index 0000000..0cc065a --- /dev/null +++ b/spec/classes/fdio_spec.rb @@ -0,0 +1,95 @@ +require 'spec_helper' + +describe 'fdio' do + + shared_examples_for 'fdio - default' do + it { should compile } + it { should compile.with_all_deps } + + # Confirm presence of classes + it { should contain_class('fdio') } + it { should contain_class('fdio::params') } + it { should contain_class('fdio::install') } + it { should contain_class('fdio::config') } + it { should contain_class('fdio::service') } + + # Confirm relationships between classes + it { should contain_class('fdio::install').that_comes_before('Class[fdio::config]') } + it { should contain_class('fdio::config').that_requires('Class[fdio::install]') } + it { should contain_class('fdio::config').that_notifies('Class[fdio::service]') } + it { should contain_class('fdio::service').that_subscribes_to('Class[fdio::config]') } + it { should contain_class('fdio::service').that_comes_before('Class[fdio]') } + it { should contain_class('fdio').that_requires('Class[fdio::service]') } + end + + shared_examples_for 'fdio - rpm' do + it { + should contain_yumrepo('fdio-release').with( + 'baseurl' => 'https://nexus.fd.io/content/repositories/fd.io.centos7/', + 'enabled' => 1, + ) + } + it { should contain_package('vpp').that_requires('Yumrepo[fdio-release]') } + + context 'with stable 16.09 branch' do + let(:params) {{:repo_branch => 'stable.1609'}} + + it { + should contain_yumrepo('fdio-stable.1609').with( + 'baseurl' => 'https://nexus.fd.io/content/repositories/fd.io.stable.1609.centos7/', + 'enabled' => 1, + ) + } + it { should contain_package('vpp').that_requires('Yumrepo[fdio-stable.1609]') } + end + end + + shared_examples_for 'fdio - config' do + it { + should contain_file('/etc/vpp/startup.conf').with( + 'path' => '/etc/vpp/startup.conf', + ) + } + it { + should contain_exec('insert_dpdk_kmod').with( + 'command' => 'modprobe uio_pci_generic', + 'unless' => 'lsmod | grep uio_pci_generic', + ) + } + end + + shared_examples_for 'fdio - service' do + it { + should contain_vpp_service('vpp').with( + 'ensure' => 'present', + 'pci_devs' => [], + 'state' => 'up', + ) + } + + context 'with pci dev' do + let(:params) {{:vpp_dpdk_devs => ['0000:00:07.0']}} + + it { + should contain_vpp_service('vpp').with( + 'ensure' => 'present', + 'pci_devs' => ['0000:00:07.0'], + 'state' => 'up', + ) + } + end + end + + context 'on RedHat platforms' do + let(:facts) {{ + :osfamily => 'RedHat', + :operatingsystem => 'CentOS', + :operatingsystemmajrelease => '7', + }} + + it_configures 'fdio - default' + it_configures 'fdio - rpm' + it_configures 'fdio - config' + it_configures 'fdio - service' + end +end \ No newline at end of file diff --git a/spec/classes/honeycomb_spec.rb b/spec/classes/honeycomb_spec.rb new file mode 100644 index 0000000..8ba367a --- /dev/null +++ b/spec/classes/honeycomb_spec.rb @@ -0,0 +1,32 @@ +require 'spec_helper' + +describe 'fdio::honeycomb' do + let(:facts) {{ + :osfamily => 'RedHat', + :operatingsystem => 'CentOS', + :operatingsystemmajrelease => '7', + }} + + it { should compile } + it { should compile.with_all_deps } + it { should contain_class('fdio::honeycomb') } + it { should contain_class('fdio::install').that_comes_before('Class[fdio::config]') } + it { should contain_package('honeycomb').that_requires('Package[vpp]') } + it { should contain_file('honeycomb.json').that_requires('Package[honeycomb]') } + it { should contain_file('honeycomb.json').that_notifies('Service[honeycomb]') } + it { should contain_service('honeycomb').that_requires('Package[honeycomb]') } + it { should contain_service('honeycomb').that_requires('Vpp_service[vpp]') } + + it { should contain_file('honeycomb.json').with( + 'ensure' => 'file', + 'path' => '/opt/honeycomb/config/honeycomb.json', + 'owner' => 'honeycomb', + 'group' => 'honeycomb', + ) + } + it { should contain_service('honeycomb').with( + 'ensure' => 'running', + 'enable' => 'true', + ) + } +end -- cgit 1.2.3-korg