From 0785d6cbb33c890d38e85d2323b7a285f41c45bf Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Thu, 13 Jan 2022 01:22:26 +0900 Subject: [PATCH] Assert the exec resource to restart ovs service This change implements unit tests for the exec resource which was added by [1]. [1] 1fe71cf5e359c8f83f11b2673620be822423bf47 Change-Id: I1dd62d917783f66b11e953ab1c8be6a259553782 --- spec/classes/vswitch_dpdk_spec.rb | 8 +++++++- spec/classes/vswitch_ovs_spec.rb | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/spec/classes/vswitch_dpdk_spec.rb b/spec/classes/vswitch_dpdk_spec.rb index c2b5a691..bf9ee507 100644 --- a/spec/classes/vswitch_dpdk_spec.rb +++ b/spec/classes/vswitch_dpdk_spec.rb @@ -57,7 +57,13 @@ describe 'vswitch::dpdk' do is_expected.to contain_vs_config('other_config:vlan-limit').with( :value => nil, :wait => true, ) - + end + it 'restarts the service when needed' do + is_expected.to contain_exec('restart openvswitch').with( + :path => ['/sbin', '/usr/sbin', '/bin', '/usr/bin'], + :command => "systemctl -q restart %s.service" % platform_params[:ovs_service_name], + :refreshonly => true + ) end end diff --git a/spec/classes/vswitch_ovs_spec.rb b/spec/classes/vswitch_ovs_spec.rb index 4821da26..158c2ac8 100644 --- a/spec/classes/vswitch_ovs_spec.rb +++ b/spec/classes/vswitch_ovs_spec.rb @@ -55,6 +55,14 @@ describe 'vswitch::ovs' do :before => 'Service[openvswitch]' ) end + + it 'restarts the service when needed' do + is_expected.to contain_exec('restart openvswitch').with( + :path => ['/sbin', '/usr/sbin', '/bin', '/usr/bin'], + :command => "systemctl -q restart %s.service" % platform_params[:ovs_service_name], + :refreshonly => true + ) + end end context 'custom parameters' do