Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test fixes for RabbitMQ 3.8.3 #1533

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"

Expand All @@ -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 }
Expand All @@ -139,7 +149,7 @@ def callRabbitMQDeploymentTests
end
end
end
end
end

describe 'Cleaning up' do
service_replicas.times do |i|
Expand All @@ -150,4 +160,4 @@ def callRabbitMQDeploymentTests
end
end

end
end
21 changes: 15 additions & 6 deletions core/src/epicli/data/common/tests/spec/rabbitmq/rabbitmq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -40,15 +41,23 @@
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
let(:disable_sudo) { false }
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 }
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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 }
Expand Down