summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2013-12-27 12:27:53 -0800
committerelijah <elijah@riseup.net>2013-12-27 12:27:53 -0800
commit0a56b656f8fbfd38ee1a9babdb93fbed39c4a973 (patch)
tree6481dada78c575f99a2c976be59e3f99d4c418f9
parentf1ba024e9c529b5f9ac988d6600931f914ec1d31 (diff)
improve couchdb test
-rwxr-xr-xbin/run_tests20
-rw-r--r--tests/white-box/couchdb.rb24
-rw-r--r--tests/white-box/dummy.rb11
3 files changed, 49 insertions, 6 deletions
diff --git a/bin/run_tests b/bin/run_tests
index 89fbdb24..86a72f26 100755
--- a/bin/run_tests
+++ b/bin/run_tests
@@ -43,6 +43,11 @@ class LeapTest < MiniTest::Unit::TestCase
class Pass < MiniTest::Assertion
end
+ def initialize(name)
+ super(name)
+ io # << calling this will suppress the marching ants
+ end
+
#
# Test class dependencies
#
@@ -69,6 +74,11 @@ class LeapTest < MiniTest::Unit::TestCase
assert(false, msg)
end
+ def warn(*msg)
+ method_name = caller.first.split('`').last.gsub(/(block in |')/,'')
+ MiniTest::Unit.runner.report_line("WARN", self.class, method_name, nil, msg.join("\n"))
+ end
+
# Always runs test methods within a test class in alphanumeric order
#
def self.test_order
@@ -295,16 +305,18 @@ class LeapRunner < MiniTest::Unit
output.puts format % [test_count, assertion_count, passes, failures, errors, skips]
end
- private
-
#
# returns a string for a PASS, SKIP, or FAIL error
#
def report_line(prefix, klass, meth, e=nil, message=nil)
- if e && message
+ if message
indent = "\n "
msg_txt = indent + message.split("\n").join(indent)
+ end
+ if e && message
output.puts "#{prefix}: #{readable(klass.name)} > #{readable(meth)} [#{File.basename(location(e))}]:#{msg_txt}"
+ elsif message
+ output.puts "#{prefix}: #{readable(klass.name)} > #{readable(meth)}:#{msg_txt}"
else
output.puts "#{prefix}: #{readable(klass.name)} > #{readable(meth)}"
end
@@ -312,6 +324,8 @@ class LeapRunner < MiniTest::Unit
sleep(0.0001) # keep lines from being joined together by the logger. output.flush doesn't.
end
+ private
+
#
# Converts snake_case and CamelCase to something more pleasant for humans to read.
#
diff --git a/tests/white-box/couchdb.rb b/tests/white-box/couchdb.rb
index 0fc4d3b2..6ffc6a4f 100644
--- a/tests/white-box/couchdb.rb
+++ b/tests/white-box/couchdb.rb
@@ -21,7 +21,7 @@ class TestCouchdb < LeapTest
# compare the configured nodes to the nodes that are actually listed in bigcouch
#
def test_02_nodes_are_in_replication_database
- url = couchdb_admin_url("/nodes/_all_docs")
+ url = couchdb_backend_url("/nodes/_all_docs")
neighbors = assert_property('couch.bigcouch.neighbors')
neighbors << assert_property('domain.full')
neighbors.sort!
@@ -33,6 +33,24 @@ class TestCouchdb < LeapTest
pass
end
+ def test_03_replica_membership
+ url = couchdb_url("/_membership")
+ assert_get(url) do |body|
+ response = JSON.parse(body)
+ nodes_configured_but_not_available = response['cluster_nodes'] - response['all_nodes']
+ nodes_available_but_not_configured = response['cluster_nodes'] - response['all_nodes']
+ if nodes_configured_but_not_available.any?
+ warn "These nodes are configured but not available:", nodes_configured_but_not_available
+ end
+ if nodes_available_but_not_configured.any?
+ warn "These nodes are available but not configured:", nodes_available_but_not_configured
+ end
+ if response['cluster_nodes'] == response['all_nodes']
+ pass
+ end
+ end
+ end
+
private
def couchdb_url(path="", port=nil)
@@ -47,8 +65,8 @@ class TestCouchdb < LeapTest
"http://admin:#{@password}@localhost:#{port || @port}#{path}"
end
- def couchdb_admin_url(path="")
- couchdb_url(path, "5986") # admin port is hardcoded for now.
+ def couchdb_backend_url(path="")
+ couchdb_url(path, "5986") # TODO: admin port is hardcoded for now but should be configurable.
end
end
diff --git a/tests/white-box/dummy.rb b/tests/white-box/dummy.rb
index 6ca49754..a3e8ad68 100644
--- a/tests/white-box/dummy.rb
+++ b/tests/white-box/dummy.rb
@@ -41,6 +41,17 @@ class TestDummy < LeapTest
pass
end
+ def test_warn
+ block_test do
+ warn "not everything", "is a success or failure"
+ end
+ end
+
+ # used to test extracting the proper caller even when in a block
+ def block_test
+ yield
+ end
+
def test_socket_success
fork {
Socket.tcp_server_loop('localhost', 12345) do |sock, client_addrinfo|