From f5aea420391b1e384256e1feb406eb4eb9350e6b Mon Sep 17 00:00:00 2001
From: Takashi Kajinami <kajinamit@oss.nttdata.com>
Date: Mon, 30 Sep 2024 12:11:11 +0900
Subject: [PATCH] Fix ignored unit test cases

The unit test cases for notification parameters have been ignored. Fix
the problem and also refactor test definitions for easier maintenance.

Change-Id: Ib53377f0316f25781017cc5c394162a77bc17f49
---
 spec/classes/neutron_init_spec.rb | 70 ++++++++++++-------------------
 1 file changed, 26 insertions(+), 44 deletions(-)

diff --git a/spec/classes/neutron_init_spec.rb b/spec/classes/neutron_init_spec.rb
index 64fe181c0..70645b493 100644
--- a/spec/classes/neutron_init_spec.rb
+++ b/spec/classes/neutron_init_spec.rb
@@ -13,25 +13,9 @@ describe 'neutron' do
   shared_examples 'neutron' do
     it_behaves_like 'a neutron base installation'
 
-    context 'with rabbitmq heartbeat configured' do
-      before { params.merge!( 
-        :rabbit_heartbeat_timeout_threshold => '60',
-        :rabbit_heartbeat_rate => '10',
-        :rabbit_heartbeat_in_pthread => true,
-      ) }
-      it_behaves_like 'rabbit with heartbeat configured'
-    end
-
-    context 'with rabbitmq durable queues configured' do
-      before { params.merge!( :amqp_durable_queues => true ) }
-      it_behaves_like 'rabbit with durable queues'
-    end
-
-    context 'with rabbitmq non default transient_queues_ttl' do
-      before { params.merge!( :rabbit_transient_queues_ttl => 20 ) }
-      it_behaves_like 'rabbit with non default transient_queues_ttl'
-    end
-
+    it_behaves_like 'with rabbit parameters configured'
+    it_behaves_like 'with notification parameters configured'
+    it_behaves_like 'with SSL enabled without kombu'
     it_behaves_like 'with SSL enabled with kombu'
     it_behaves_like 'with SSL enabled without kombu'
     it_behaves_like 'with SSL disabled'
@@ -131,41 +115,39 @@ describe 'neutron' do
     end
   end
 
-  shared_examples 'rabbit with heartbeat configured' do
+  shared_examples 'with rabbit parameters configured' do
+    before do
+      params.merge!(
+        :rabbit_heartbeat_timeout_threshold => 60,
+        :rabbit_heartbeat_rate              => 10,
+        :rabbit_heartbeat_in_pthread        => true,
+        :amqp_durable_queues                => true,
+        :rabbit_ha_queues                   => true,
+        :rabbit_transient_queues_ttl        => 20,
+      )
+    end
+
     it 'in neutron.conf' do
       should contain_oslo__messaging__rabbit('neutron_config').with(
-        :heartbeat_timeout_threshold => '60',
-        :heartbeat_rate              => '10',
+        :heartbeat_timeout_threshold => 60,
+        :heartbeat_rate              => 10,
         :heartbeat_in_pthread        => true,
+        :amqp_durable_queues         => true,
+        :rabbit_ha_queues            => true,
+        :rabbit_transient_queues_ttl => 20,
       )
     end
   end
 
-  shared_examples 'rabbit with durable queues' do
-    it 'in neutron.conf' do
-      should contain_oslo__messaging__rabbit('neutron_config').with(
-        :amqp_durable_queues => true
+  shared_examples 'with notification parameters configured' do
+    before do
+      params.merge!(
+        :notification_transport_url => 'rabbit://rabbit_user:password@localhost:5673',
+        :notification_driver        => 'mesagingv2',
+        :notification_topics        => 'notifications',
       )
     end
-  end
 
-  shared_examples 'rabbit with non default transient_queues_ttl' do
-    it 'in neutron.conf' do
-      should contain_oslo__messaging__rabbit('neutron_config').with(
-        :rabbit_transient_queues_ttl => 20
-      )
-    end
-  end
-
-  shared_examples 'rabbit_ha_queues set to false' do
-    it 'in neutron.conf' do
-      should contain_oslo__messaging__rabbit('neutron_config').with(
-        :rabbit_ha_queues => true
-      )
-    end
-  end
-
-  shared_examples 'notification_driver and notification_topics' do
     it 'in neutron.conf' do
       should contain_oslo__messaging__notifications('neutron_config').with(
         :transport_url => params[:notification_transport_url],