Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

assert_proxies_disabled: Fix failures #6304

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
25 changes: 11 additions & 14 deletions node/test/gear_functional/multi_ha_func_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,27 +81,24 @@ def test_ha_enable
@api.assert_scales_to(app_name, @framework_cartridge, 6)
assert_proxies_not_disabled(proxy_entries)
@api.assert_scales_to(app_name, @framework_cartridge, 7)
assert_proxies_disabled(proxy_entries)
assert_proxies_disabled(proxy_entries)
end

def assert_proxies_status(proxy_entries, status)
proxy_entries.values.each do |proxy|
logger.info "Checking target gears " +
proxy_entries.values.map {|p| p.dns}.join(', ') +
" status from proxy #{proxy.dns}"
@api.assert_gear_status_in_proxy(proxy, proxy_entries.values, status)
end
end

def assert_proxies_disabled(proxy_entries)
proxy_entries.values.each do |target_gear|
proxy_entries.values.each do |proxy|
logger.info "Checking target gear #{target_gear.dns} status from proxy #{proxy.dns}"
@api.assert_gear_status_in_proxy(proxy, target_gear, 'MAINT')
end
end
assert_proxies_status(proxy_entries, 'MAINT')
end

def assert_proxies_not_disabled(proxy_entries)
proxy_entries.values.each do |target_gear|
proxy_entries.values.each do |proxy|
logger.info "Checking target gear #{target_gear.dns} status from proxy #{proxy.dns}"
@api.assert_gear_status_in_proxy(proxy, target_gear, 'UP')
end
end
assert_proxies_status(proxy_entries, 'UP')
end

end
37 changes: 17 additions & 20 deletions node/test/support/functional_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -404,38 +404,35 @@ def cloud_domain
::OpenShift::Config.new.get('CLOUD_DOMAIN')
end

def assert_gear_status_in_proxy(proxy, target_gear, status)
def assert_gear_status_in_proxy(proxy, target_gears, status)
passed = false
names = target_gears.inject({ "local-gear" => false}) do |h, gear|
h["gear-" + gear.dns.split('.')[0]] = false
h
end

num_tries = 3
(1..num_tries).each do |i|
proxy_status_csv = `curl "http://#{proxy.dns}/haproxy-status/;csv" 2>/dev/null`

if proxy.uuid == target_gear.uuid
names = [ 'local-gear' ]
else
gear_name = target_gear.dns.split('-')[0]
names = [ "gear-#{gear_name}-#{target_gear.namespace}" ]
gear_name = proxy.dns.split('-')[0]
names << "gear-#{gear_name}-#{target_gear.namespace}"
end

proxy_status_csv = `curl 'http://#{proxy.dns}/haproxy-status/;csv' 2>/dev/null`
proxy_status_csv.split("\n").each do |line|
names.each do |name|
names.keys.each do |name|
if line =~ /#{name}/
if line =~ /#{status}/
passed = true
elsif i == num_tries
assert_match /#{status}/, line
end
break
names[name] = line =~ /#{status}/
end
end
end
passed = target_gears.length == names.inject(0) do |len, (k, v)|
v ? len+1 : len
end
break if passed
sleep 2
end

flunk("Target gear #{target_gear.name} did not have expected status #{status}") unless passed
if !passed
failed = names.inject([]) {|list, (k, v)| list << k if !v; list }
flunk("Target gears " + failed.join(', ') +
" did not have expected status #{status}")
end
end

def restart_cartridge(app_name, cartridge)
Expand Down