summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/run_tests2
-rw-r--r--tests/helpers/couchdb_helper.rb2
-rw-r--r--tests/white-box/mx.rb39
3 files changed, 27 insertions, 16 deletions
diff --git a/bin/run_tests b/bin/run_tests
index 4cb652db..5733f526 100755
--- a/bin/run_tests
+++ b/bin/run_tests
@@ -279,7 +279,7 @@ class LeapRunner < MiniTest::Unit
def report_line(prefix, klass, meth, e=nil, message=nil)
msg_txt = nil
if message
- message = message.sub(/http:\/\/([a-z_]+):([a-zA-Z0-9_]+)@/, "http://\\1:REDACTED@")
+ message = message.gsub(/http:\/\/([a-z_]+):([a-zA-Z0-9_]+)@/, "http://\\1:REDACTED@")
if $output_format == :human
indent = "\n "
msg_txt = indent + message.split("\n").join(indent)
diff --git a/tests/helpers/couchdb_helper.rb b/tests/helpers/couchdb_helper.rb
index 312e38ac..27dabfcb 100644
--- a/tests/helpers/couchdb_helper.rb
+++ b/tests/helpers/couchdb_helper.rb
@@ -15,6 +15,7 @@ class LeapTest
# connect_port: 15984
#
def couchdb_urls_via_stunnel(path="", options=nil)
+ path = path.gsub('"', '%22')
if options && options[:username] && options[:password]
userpart = "%{username}:%{password}@" % options
else
@@ -46,6 +47,7 @@ class LeapTest
# writable: true
#
def couchdb_url_via_haproxy(path="", options=nil)
+ path = path.gsub('"', '%22')
if options && options[:username] && options[:password]
userpart = "%{username}:%{password}@" % options
else
diff --git a/tests/white-box/mx.rb b/tests/white-box/mx.rb
index 768b561f..57ec9117 100644
--- a/tests/white-box/mx.rb
+++ b/tests/white-box/mx.rb
@@ -39,23 +39,32 @@ class Mx < LeapTest
assert_get(couchdb_url("/identities", url_options)) do |body|
assert response = JSON.parse(body)
doc_count = response['doc_count'].to_i
- if doc_count < 1
- skip "There are no identity records yet."
+ if doc_count <= 1
+ # the design document counts as one document.
+ skip "There are no identity documents yet."
else
- offset = rand(doc_count) # pick a random document
- count_url = couchdb_url("/identities/_all_docs?include_docs=true&limit=1&skip=#{offset}", url_options)
- assert_get(count_url) do |body|
- assert response = JSON.parse(body)
- record = response['rows'].first
- address = record['doc']['address']
- assert address, "address should not be empty"
- url_base = %(/identities/_design/Identity/_view/by_address)
- params = %(?include_docs=true&reduce=false&startkey="#{address}"&endkey="#{address}")
- assert_get(couchdb_url(url_base+params, url_options)) do |body|
+ # try five times to get a valid doc
+ for i in 1..5
+ offset = rand(doc_count) # pick a random document
+ count_url = couchdb_url("/identities/_all_docs?include_docs=true&limit=1&skip=#{offset}", url_options)
+ assert_get(count_url) do |body|
assert response = JSON.parse(body)
- assert record = response['rows'].first
- assert_equal address, record['doc']['address']
- pass
+ record = response['rows'].first
+ if record['id'] =~ /_design/
+ next
+ else
+ address = record['doc']['address']
+ assert address, "Identity document #{record['id']} is missing an address field. #{record['doc'].inspect}"
+ url_base = %(/identities/_design/Identity/_view/by_address)
+ params = %(?include_docs=true&reduce=false&startkey="#{address}"&endkey="#{address}")
+ assert_get(couchdb_url(url_base+params, url_options)) do |body|
+ assert response = JSON.parse(body)
+ assert record = response['rows'].first
+ assert_equal address, record['doc']['address']
+ pass
+ end
+ break
+ end
end
end
end