summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMicah Anderson <micah@leap.se>2015-07-23 11:46:55 -0400
committerMicah Anderson <micah@leap.se>2015-07-23 11:46:55 -0400
commit70b1c648b94e6c007b9241a4661f33881e74485f (patch)
tree999e5dc1f386fc3894889c1cf263094cc748fd41 /tests
parentb429b30bda4dafc78cb02f6ece5d82f08e35de1f (diff)
parent2761fa77394d5a2857812de840e49172d0e486fb (diff)
Merge branch 'develop'
Diffstat (limited to 'tests')
-rw-r--r--tests/helpers/network_helper.rb2
-rw-r--r--tests/white-box/network.rb5
-rw-r--r--tests/white-box/webapp.rb21
3 files changed, 23 insertions, 5 deletions
diff --git a/tests/helpers/network_helper.rb b/tests/helpers/network_helper.rb
index ff92d382..713d57aa 100644
--- a/tests/helpers/network_helper.rb
+++ b/tests/helpers/network_helper.rb
@@ -70,7 +70,7 @@ class LeapTest
#try_tcp_write(socket,1)
#try_tcp_read(socket,1)
rescue StandardError => exc
- fail ["Failed to open socket #{host}:#{port}", exc].join("\n")
+ fail ["Failed to open socket #{host}:#{port}", exc, msg].compact.join("\n")
ensure
socket.close if socket
end
diff --git a/tests/white-box/network.rb b/tests/white-box/network.rb
index f2041710..acb5c5e6 100644
--- a/tests/white-box/network.rb
+++ b/tests/white-box/network.rb
@@ -46,7 +46,10 @@ class Network < LeapTest
assert accept_port = stunnel_conf['accept_port'], "Field `accept` must be present in property `stunnel.servers.#{stunnel_name}`"
assert_tcp_socket('localhost', accept_port)
assert connect_port = stunnel_conf['connect_port'], "Field `connect` must be present in property `stunnel.servers.#{stunnel_name}`"
- assert_tcp_socket('localhost', connect_port)
+ assert_tcp_socket('localhost', connect_port,
+ "The local connect endpoint for stunnel `#{stunnel_name}` is unavailable.\n"+
+ "This is probably caused by a daemon that died or failed to start on\n"+
+ "port `#{connect_port}`, not stunnel itself.")
end
all_stunnel_pids = pgrep('/usr/bin/stunnel').collect{|process| process[:pid]}.uniq
assert_equal good_stunnel_pids.sort, all_stunnel_pids.sort, "There should not be any extra stunnel processes that are not configured in /etc/stunnel"
diff --git a/tests/white-box/webapp.rb b/tests/white-box/webapp.rb
index 1e78c8a5..9956eb35 100644
--- a/tests/white-box/webapp.rb
+++ b/tests/white-box/webapp.rb
@@ -99,18 +99,33 @@ class Webapp < LeapTest
# we try three times, and give up after that.
#
def assert_user_db_exists(user)
+ db_name = "user-#{user.id}"
+ repeatedly_try("/#{db_name}") do |body, response, error|
+ assert false, "Could not find user db `#{db_name}` for test user `#{user.username}`\nuuid=#{user.id}\nHTTP #{response.code} #{error} #{body}"
+ end
+ repeatedly_try("/#{db_name}/_design/docs") do |body, response, error|
+ assert false, "Could not find design docs for user db `#{db_name}` for test user `#{user.username}`\nuuid=#{user.id}\nHTTP #{response.code} #{error} #{body}"
+ end
+ end
+
+ #
+ # tries the URL repeatedly, giving up and yield the last response if
+ # no try returned a 200 http status code.
+ #
+ def repeatedly_try(url, &block)
last_body, last_response, last_error = nil
3.times do
sleep 0.2
- get(couchdb_url("/user-#{user.id}/_design/docs")) do |body, response, error|
+ get(couchdb_url(url)) do |body, response, error|
last_body, last_response, last_error = body, response, error
if response.code.to_i == 200
return
end
end
- sleep 0.5
+ sleep 1
end
- assert false, "Could not find user db for test user #{user.username}\nuuid=#{user.id}\nHTTP #{last_response.code} #{last_error} #{last_body}"
+ yield last_body, last_response, last_error
+ return
end
#