diff options
author | Feng Pan <fpan@redhat.com> | 2017-02-19 15:14:40 -0500 |
---|---|---|
committer | Feng Pan <fpan@redhat.com> | 2017-02-20 10:53:29 -0500 |
commit | ac2d7693e02a11d80879ccd80dc33a4f213295e6 (patch) | |
tree | ba4d6cb546b1db34af796b065be9b625c676cc31 /spec | |
parent | 32ce2b41b1ca0b6224b45d8bf79039db5e15e997 (diff) |
Add support for inline config changes
This patch changes VPP configuration from file template to inline
change directly. This prevents issue with overwriting existing
VPP config.
Change-Id: I4133be8ebe689d9288e3a8e64cca43afd7e42e64
Signed-off-by: Feng Pan <fpan@redhat.com>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/acceptance/fdio_spec.rb | 1 | ||||
-rw-r--r-- | spec/classes/fdio_spec.rb | 25 | ||||
-rw-r--r-- | spec/classes/honeycomb_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/provider/vpp_config/vpp_spec.rb | 37 | ||||
-rw-r--r-- | spec/unit/provider/vpp_service/vpp_spec.rb | 44 | ||||
-rw-r--r-- | spec/unit/type/vpp_config_spec.rb | 15 | ||||
-rw-r--r-- | spec/unit/type/vpp_service_spec.rb | 56 |
7 files changed, 60 insertions, 120 deletions
diff --git a/spec/acceptance/fdio_spec.rb b/spec/acceptance/fdio_spec.rb index 5c30de1..168c085 100644 --- a/spec/acceptance/fdio_spec.rb +++ b/spec/acceptance/fdio_spec.rb @@ -20,7 +20,6 @@ describe 'fdio' do describe file('/etc/vpp/startup.conf') do it { is_expected.to exist } its(:content) { should match /uio-driver\s+uio_pci_generic/ } - its(:content) { should_not match /dev/ } end describe service('vpp') do diff --git a/spec/classes/fdio_spec.rb b/spec/classes/fdio_spec.rb index 0cc065a..4b65779 100644 --- a/spec/classes/fdio_spec.rb +++ b/spec/classes/fdio_spec.rb @@ -46,9 +46,10 @@ describe 'fdio' do shared_examples_for 'fdio - config' do it { - should contain_file('/etc/vpp/startup.conf').with( - 'path' => '/etc/vpp/startup.conf', - ) + should contain_vpp_config('dpdk/uio-driver').with_value('uio_pci_generic') + should contain_vpp_config('dpdk/dev/default') + should contain_vpp_config('cpu/main-core') + should contain_vpp_config('cpu/corelist-workers') } it { should contain_exec('insert_dpdk_kmod').with( @@ -60,24 +61,12 @@ describe 'fdio' do shared_examples_for 'fdio - service' do it { - should contain_vpp_service('vpp').with( - 'ensure' => 'present', - 'pci_devs' => [], - 'state' => 'up', + should contain_service('vpp').with( + 'ensure' => 'running', + 'enable' => true, ) } - 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 diff --git a/spec/classes/honeycomb_spec.rb b/spec/classes/honeycomb_spec.rb index 8ba367a..fcd31f6 100644 --- a/spec/classes/honeycomb_spec.rb +++ b/spec/classes/honeycomb_spec.rb @@ -15,7 +15,7 @@ describe 'fdio::honeycomb' do 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_service('honeycomb').that_requires('Service[vpp]') } it { should contain_file('honeycomb.json').with( 'ensure' => 'file', diff --git a/spec/unit/provider/vpp_config/vpp_spec.rb b/spec/unit/provider/vpp_config/vpp_spec.rb new file mode 100644 index 0000000..913d795 --- /dev/null +++ b/spec/unit/provider/vpp_config/vpp_spec.rb @@ -0,0 +1,37 @@ +require 'puppet' +require 'puppet/provider/vpp_config/vpp' +require 'spec_helper' + +provider_class = Puppet::Type.type(:vpp_config).provider(:vpp) + +describe 'Puppet::Type.type(:vpp_config).provider(:vpp)' do + + let :vpp_attrs do + { + :setting => 'dpdk/dev/0000:00:07.0', + :ensure => 'present', + } + end + + let :resource do + Puppet::Type::Vpp_config.new(vpp_attrs) + end + + let :provider do + provider_class.new(resource) + end + + describe 'on create' do + it 'should call add_setting' do + provider.expects(:add_setting) + provider.create + end + end + + describe "when changing value" do + it 'should change value' do + provider.expects(:add_setting).with('vlan-strip-offload on') + provider.value = 'vlan-strip-offload on' + end + end +end
\ No newline at end of file diff --git a/spec/unit/provider/vpp_service/vpp_spec.rb b/spec/unit/provider/vpp_service/vpp_spec.rb deleted file mode 100644 index f75f80c..0000000 --- a/spec/unit/provider/vpp_service/vpp_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -require 'puppet' -require 'puppet/provider/vpp_service/vpp' -require 'spec_helper' - -provider_class = Puppet::Type.type(:vpp_service).provider(:vpp) - -describe 'Puppet::Type.type(:vpp_service).provider(:vpp)' do - - let :vpp_attrs do - { - :name => 'vpp service config', - :pci_devs => '0000:00:07.0', - :ensure => 'present', - :state => 'up', - :copy_kernel_nic_ip => 'false', - } - end - - let :resource do - Puppet::Type::Vpp_service.new(vpp_attrs) - end - - let :provider do - provider_class.new(resource) - end - - describe 'on create' do - it 'should call service restart' do - provider.expects(:vpp_pre_config) - provider.expects(:configure_vpp_interfaces) - provider.expects(:systemctlcmd).with('restart', 'vpp') - provider.expects(:systemctlcmd).with('enable', 'vpp') - provider.create - end - end - - describe "when changing state" do - it 'should change state' do - provider.stubs(:get_int_prefix).returns('GigabitEthernet0/7/0') - provider.expects(:vppctlcmd).with('set int state', 'GigabitEthernet0/7/0', 'down') - provider.state = 'down' - end - end -end
\ No newline at end of file diff --git a/spec/unit/type/vpp_config_spec.rb b/spec/unit/type/vpp_config_spec.rb new file mode 100644 index 0000000..d25061f --- /dev/null +++ b/spec/unit/type/vpp_config_spec.rb @@ -0,0 +1,15 @@ +require 'puppet' +require 'puppet/type/vpp_config' +require 'spec_helper' + +describe 'Puppet::Type.type(:vpp_config)' do + + before :each do + @vpp_conf = Puppet::Type.type(:vpp_config).new(:setting => 'dpdk/test_setting') + end + + it 'should accept value' do + Puppet::Type.type(:vpp_config).new(:setting => 'dpdk/test_setting', :value => 'test_value') + end + +end diff --git a/spec/unit/type/vpp_service_spec.rb b/spec/unit/type/vpp_service_spec.rb deleted file mode 100644 index 9b08ffa..0000000 --- a/spec/unit/type/vpp_service_spec.rb +++ /dev/null @@ -1,56 +0,0 @@ -require 'puppet' -require 'puppet/type/vpp_service' -require 'spec_helper' - -describe 'Puppet::Type.type(:neutron_config)' do - - before :each do - @vpp_service = Puppet::Type.type(:vpp_service).new(:name => 'vpp service config') - end - - it 'should have default values' do - expect(@vpp_service[:state]).to eq(:up) - expect(@vpp_service[:copy_kernel_nic_ip]).to eq(:true) - end - - it 'should accept a single pci dev' do - Puppet::Type.type(:vpp_service).new(:name => 'vpp service config', :pci_devs => '0000:00:07.0') - end - - it 'should accept array of pci devs' do - Puppet::Type.type(:vpp_service).new(:name => 'vpp service config', :pci_devs => ['0000:00:07.0', '0000:00:08.0']) - end - - it 'should not accept invalid pci dev format' do - expect { - Puppet::Type.type(:vpp_service).new(:name => 'vpp service config', :pci_devs => ['0/7/0', '0000:00:08.0']) - }.to raise_error(Puppet::Error, /Incorrect PCI dev address/) - end - - it 'should accept valid states' do - @vpp_service[:state] = :up - expect(@vpp_service[:state]).to eq(:up) - @vpp_service[:state] = :down - expect(@vpp_service[:state]).to eq(:down) - end - - it 'should not accept invalid state' do - expect { - @vpp_service[:state] = :shut - }.to raise_error(Puppet::Error, /Invalid value/) - end - - it 'should accept valid copy_kernel_nic_ip' do - @vpp_service[:copy_kernel_nic_ip] = :true - expect(@vpp_service[:copy_kernel_nic_ip]).to eq(:true) - @vpp_service[:copy_kernel_nic_ip] = :false - expect(@vpp_service[:copy_kernel_nic_ip]).to eq(:false) - end - - it 'should not accept invalid copy_kernel_nic_ip' do - expect { - @vpp_service[:copy_kernel_nic_ip] = :yes - }.to raise_error(Puppet::Error, /Invalid value/) - end - -end |