diff --git a/core/src/epicli/data/common/tests/spec/applications/rabbitmq/rabbitmq.rb b/core/src/epicli/data/common/tests/spec/applications/rabbitmq/rabbitmq.rb index 660e38cc71..8888ba54ef 100644 --- a/core/src/epicli/data/common/tests/spec/applications/rabbitmq/rabbitmq.rb +++ b/core/src/epicli/data/common/tests/spec/applications/rabbitmq/rabbitmq.rb @@ -14,6 +14,7 @@ def callRabbitMQDeploymentTests service_namespace = readDataYaml("configuration/applications")["specification"]["applications"].detect {|i| i["name"] == 'rabbitmq'}["service"]["namespace"] service_name = readDataYaml("configuration/applications")["specification"]["applications"].detect {|i| i["name"] == 'rabbitmq'}["service"]["name"] plugins = readDataYaml("configuration/applications")["specification"]["applications"].detect {|i| i["name"] == 'rabbitmq'}["rabbitmq"]["plugins"] + version = readDataYaml("configuration/applications")["specification"]["applications"].detect {|i| i["name"] == 'rabbitmq'}["image_path"].split(':').last if !readDataYaml("configuration/applications")["specification"]["applications"].detect {|i| i["name"] == 'rabbitmq'}["rabbitmq"]["amqp_port"].nil? rabbitmq_amqp_port = readDataYaml("configuration/applications")["specification"]["applications"].detect {|i| i["name"] == 'rabbitmq'}["rabbitmq"]["amqp_port"] @@ -44,6 +45,15 @@ def callRabbitMQDeploymentTests end end + describe 'Checking RabbitMQ version' do + service_replicas.times do |i| + describe command("kubectl exec --namespace=#{service_namespace} #{service_name}-#{i} -- rabbitmqctl version") do + its(:stdout) { should match /^#{version}$/ } + its(:exit_status) { should eq 0 } + end + end + end + describe 'Checking RabbitMQ ping' do service_replicas.times do |i| describe command("kubectl exec --namespace=#{service_namespace} #{service_name}-#{i} -- rabbitmqctl ping") do @@ -68,7 +78,7 @@ def callRabbitMQDeploymentTests its(:exit_status) { should eq 0 } end describe command("kubectl exec --namespace=#{service_namespace} #{service_name}-#{i} -- rabbitmqctl cluster_status \ - | awk '/running_nodes/,/}/' | grep -o rabbit@ | wc -l") do + | sed -n '/Running Nodes/,/Versions/{/rabbit/p}' | wc -l") do it "is expected to be equal" do expect(subject.stdout.to_i).to eq service_replicas end @@ -100,9 +110,9 @@ def callRabbitMQDeploymentTests end end end - end + end -# # Tests to be run only when RabbitMQ Management Plugin is enabled + # Tests to be run only when RabbitMQ Management Plugin is enabled if plugins.include? "rabbitmq_management" @@ -114,20 +124,20 @@ def callRabbitMQDeploymentTests describe command("kubectl describe service #{service_name} --namespace=#{service_namespace} | grep TargetPort") do its(:stdout) { should match /#{rabbitmq_http_port}/ } end - end + end describe 'Checking node health using RabbitMQ API' do service_replicas.times do |i| describe command("curl -o /dev/null -s -w '%{http_code}' -u #{user}#{i}:#{pass} \ #{host_inventory['hostname']}:#{service_management_port}/api/healthchecks/node/rabbit@$(kubectl describe pods rabbitmq-cluster-#{i} \ - --namespace=#{service_namespace} | grep ^IP: | awk '{print $2}')") do + --namespace=#{service_namespace} | awk '/^IP:/ {print $2}')") do it "is expected to be equal" do expect(subject.stdout.to_i).to eq 200 end end describe command("curl -u #{user}#{i}:#{pass} \ #{host_inventory['hostname']}:#{service_management_port}/api/healthchecks/node/rabbit@$(kubectl describe pods rabbitmq-cluster-#{i} \ - --namespace=#{service_namespace} | grep ^IP: | awk '{print $2}')") do + --namespace=#{service_namespace} | awk '/^IP:/ {print $2}')") do its(:stdout_as_json) { should include('status' => /ok/) } its(:stdout_as_json) { should_not include('status' => /failed/) } its(:exit_status) { should eq 0 } @@ -139,7 +149,7 @@ def callRabbitMQDeploymentTests end end end - end + end describe 'Cleaning up' do service_replicas.times do |i| @@ -150,4 +160,4 @@ def callRabbitMQDeploymentTests end end -end +end diff --git a/core/src/epicli/data/common/tests/spec/rabbitmq/rabbitmq_spec.rb b/core/src/epicli/data/common/tests/spec/rabbitmq/rabbitmq_spec.rb index 35469dc54e..1499d9c6c3 100644 --- a/core/src/epicli/data/common/tests/spec/rabbitmq/rabbitmq_spec.rb +++ b/core/src/epicli/data/common/tests/spec/rabbitmq/rabbitmq_spec.rb @@ -6,6 +6,7 @@ rabbitmq_node_port = rabbitmq_port + 20000 rabbitmq_api_port = 15672 clustered = readDataYaml("configuration/rabbitmq")["specification"]["cluster"]["is_clustered"] +version = readDataYaml("configuration/rabbitmq")["specification"]["version"] user = 'testuser' + SecureRandom.hex(5) pass = SecureRandom.hex @@ -40,7 +41,15 @@ describe port(rabbitmq_node_port) do it { should be_listening } end -end +end + +describe 'Checking RabbitMQ version' do + describe command("rabbitmqctl version") do + let(:disable_sudo) { false } + its(:stdout) { should match /^#{version}$/ } + its(:exit_status) { should eq 0 } + end +end describe 'Checking RabbitMQ ping' do describe command("rabbitmqctl ping") do @@ -48,7 +57,7 @@ its(:stdout) { should match /^Ping succeeded$/ } its(:exit_status) { should eq 0 } end -end +end describe 'Checking the health of the target nodes' do let(:disable_sudo) { false } @@ -76,13 +85,13 @@ if clustered listInventoryHosts("rabbitmq").each do |val| val = val.split(".")[0] - describe command("rabbitmqctl cluster_status | awk '/running_nodes/,/}/'") do + describe command("rabbitmqctl cluster_status | awk '/Running Nodes/,/Versions/'") do its(:stdout) { should match /rabbit@#{val}/ } its(:exit_status) { should eq 0 } end end else - describe command("rabbitmqctl cluster_status | awk '/running_nodes/,/}/'") do + describe command("rabbitmqctl cluster_status | awk '/Running Nodes/,/Versions/'") do its(:stdout) { should match /rabbit@#{host_inventory['hostname']}/ } its(:exit_status) { should eq 0 } end @@ -112,7 +121,7 @@ its(:exit_status) { should eq 0 } end end -end +end # Tests to be run only when RabbitMQ Management Plugin is enabled @@ -123,7 +132,7 @@ describe port(rabbitmq_api_port) do it { should be_listening } end - end + end describe 'Checking nodes health using RabbitMQ API' do let(:disable_sudo) { false }