From 68328b6e15a38a74261ee46b06091b8e63f85499 Mon Sep 17 00:00:00 2001 From: elijah Date: Mon, 9 Dec 2013 23:06:19 -0800 Subject: added initial white-box tests for couchdb and webapp nodes --- tests/white-box/couchdb.rb | 54 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 tests/white-box/couchdb.rb (limited to 'tests/white-box/couchdb.rb') diff --git a/tests/white-box/couchdb.rb b/tests/white-box/couchdb.rb new file mode 100644 index 00000000..0fc4d3b2 --- /dev/null +++ b/tests/white-box/couchdb.rb @@ -0,0 +1,54 @@ +raise SkipTest unless $node["services"].include?("couchdb") + +require 'json' + +class TestCouchdb < LeapTest + + def setup + end + + # + # check to make sure we can get welcome response from local couchdb + # + def test_01_is_running + assert_get(couchdb_url) do |body| + assert_match /"couchdb":"Welcome"/, body, "Could not get welcome message from #{couchdb_url}. Probably couchdb is not running." + end + pass + end + + # + # 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") + neighbors = assert_property('couch.bigcouch.neighbors') + neighbors << assert_property('domain.full') + neighbors.sort! + assert_get(url) do |body| + response = JSON.parse(body) + nodes_in_db = response['rows'].collect{|row| row['id'].sub(/^bigcouch@/, '')}.sort + assert_equal neighbors, nodes_in_db, "The couchdb replication node list is wrong (/nodes/_all_docs)" + end + pass + end + + private + + def couchdb_url(path="", port=nil) + @port ||= begin + assert_property 'couch.port' + $node['couch']['port'] + end + @password ||= begin + assert_property 'couch.users.admin.password' + $node['couch']['users']['admin']['password'] + end + "http://admin:#{@password}@localhost:#{port || @port}#{path}" + end + + def couchdb_admin_url(path="") + couchdb_url(path, "5986") # admin port is hardcoded for now. + end + +end -- cgit v1.2.3 From 0a56b656f8fbfd38ee1a9babdb93fbed39c4a973 Mon Sep 17 00:00:00 2001 From: elijah Date: Fri, 27 Dec 2013 12:27:53 -0800 Subject: improve couchdb test --- tests/white-box/couchdb.rb | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'tests/white-box/couchdb.rb') 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 -- cgit v1.2.3 From d86e34564cda2d28fd42d10e584184af7e8b7553 Mon Sep 17 00:00:00 2001 From: elijah Date: Fri, 27 Dec 2013 15:00:10 -0800 Subject: more couchdb tests --- tests/white-box/couchdb.rb | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'tests/white-box/couchdb.rb') diff --git a/tests/white-box/couchdb.rb b/tests/white-box/couchdb.rb index 6ffc6a4f..3abddefc 100644 --- a/tests/white-box/couchdb.rb +++ b/tests/white-box/couchdb.rb @@ -33,12 +33,18 @@ class TestCouchdb < LeapTest pass end + # + # all configured nodes are in 'cluster_nodes' + # all nodes online and communicating are in 'all_nodes' + # + # this seems backward to me, so it might be the other way around. + # 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'] + nodes_available_but_not_configured = response['all_nodes'] - response['cluster_nodes'] if nodes_configured_but_not_available.any? warn "These nodes are configured but not available:", nodes_configured_but_not_available end @@ -51,6 +57,29 @@ class TestCouchdb < LeapTest end end + def test_04_acl_users_exist + acl_users = ['_design/_auth', 'leap_mx', 'nickserver', 'soledad', 'tapicero', 'webapp'] + url = couchdb_backend_url("/_users/_all_docs") + assert_get(url) do |body| + response = JSON.parse(body) + assert_equal 6, response['total_rows'] + actual_users = response['rows'].map{|row| row['id'].sub(/^org.couchdb.user:/, '') } + assert_equal acl_users, actual_users + end + pass + end + + def test_05_databases_exist + dbs_that_should_exist = ["customers","identities","keycache","sessions","shared","tickets","tokens","users"] + dbs_that_should_exist.each do |db_name| + assert_get(couchdb_url("/"+db_name)) do |body| + assert response = JSON.parse(body) + assert_equal db_name, response['db_name'] + end + end + pass + end + private def couchdb_url(path="", port=nil) -- cgit v1.2.3 From 71f2d1b0b7db6bb35dd6bd9220795aed3174d90b Mon Sep 17 00:00:00 2001 From: elijah Date: Fri, 27 Dec 2013 16:47:57 -0800 Subject: added more network tests and pgrep test helper --- tests/white-box/couchdb.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tests/white-box/couchdb.rb') diff --git a/tests/white-box/couchdb.rb b/tests/white-box/couchdb.rb index 3abddefc..c83e5714 100644 --- a/tests/white-box/couchdb.rb +++ b/tests/white-box/couchdb.rb @@ -3,6 +3,7 @@ raise SkipTest unless $node["services"].include?("couchdb") require 'json' class TestCouchdb < LeapTest + depends_on "TestNetwork" def setup end @@ -10,7 +11,7 @@ class TestCouchdb < LeapTest # # check to make sure we can get welcome response from local couchdb # - def test_01_is_running + def test_01_couch_is_running assert_get(couchdb_url) do |body| assert_match /"couchdb":"Welcome"/, body, "Could not get welcome message from #{couchdb_url}. Probably couchdb is not running." end @@ -39,7 +40,7 @@ class TestCouchdb < LeapTest # # this seems backward to me, so it might be the other way around. # - def test_03_replica_membership + def test_03_replica_membership_is_kosher url = couchdb_url("/_membership") assert_get(url) do |body| response = JSON.parse(body) @@ -64,12 +65,12 @@ class TestCouchdb < LeapTest response = JSON.parse(body) assert_equal 6, response['total_rows'] actual_users = response['rows'].map{|row| row['id'].sub(/^org.couchdb.user:/, '') } - assert_equal acl_users, actual_users + assert_equal acl_users.sort, actual_users.sort end pass end - def test_05_databases_exist + def test_05_required_databases_exist dbs_that_should_exist = ["customers","identities","keycache","sessions","shared","tickets","tokens","users"] dbs_that_should_exist.each do |db_name| assert_get(couchdb_url("/"+db_name)) do |body| -- cgit v1.2.3 From 353475da8d535f2904e68977c3dafa6bb3bb483a Mon Sep 17 00:00:00 2001 From: elijah Date: Mon, 30 Dec 2013 18:04:30 -0800 Subject: tests -- added tests to check that the right processes are running --- tests/white-box/couchdb.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tests/white-box/couchdb.rb') diff --git a/tests/white-box/couchdb.rb b/tests/white-box/couchdb.rb index c83e5714..93551367 100644 --- a/tests/white-box/couchdb.rb +++ b/tests/white-box/couchdb.rb @@ -8,10 +8,17 @@ class TestCouchdb < LeapTest def setup end + def test_00_daemons_running + assert_running 'tapicero' + assert_running 'bin/beam' + assert_running 'bin/epmd' + pass + end + # # check to make sure we can get welcome response from local couchdb # - def test_01_couch_is_running + def test_01_couch_is_working assert_get(couchdb_url) do |body| assert_match /"couchdb":"Welcome"/, body, "Could not get welcome message from #{couchdb_url}. Probably couchdb is not running." end -- cgit v1.2.3 From cd09ed9eb9d183123652a52651a427bab558c496 Mon Sep 17 00:00:00 2001 From: elijah Date: Tue, 18 Mar 2014 00:19:45 -0700 Subject: clean up the names of tests --- tests/white-box/couchdb.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'tests/white-box/couchdb.rb') diff --git a/tests/white-box/couchdb.rb b/tests/white-box/couchdb.rb index 93551367..9d5da94f 100644 --- a/tests/white-box/couchdb.rb +++ b/tests/white-box/couchdb.rb @@ -2,13 +2,13 @@ raise SkipTest unless $node["services"].include?("couchdb") require 'json' -class TestCouchdb < LeapTest - depends_on "TestNetwork" +class CouchDB < LeapTest + depends_on "Network" def setup end - def test_00_daemons_running + def test_00_Are_daemons_running? assert_running 'tapicero' assert_running 'bin/beam' assert_running 'bin/epmd' @@ -18,7 +18,7 @@ class TestCouchdb < LeapTest # # check to make sure we can get welcome response from local couchdb # - def test_01_couch_is_working + def test_01_Is_CouchDB_running? assert_get(couchdb_url) do |body| assert_match /"couchdb":"Welcome"/, body, "Could not get welcome message from #{couchdb_url}. Probably couchdb is not running." end @@ -28,7 +28,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 + def test_02_Is_cluster_membership_ok? url = couchdb_backend_url("/nodes/_all_docs") neighbors = assert_property('couch.bigcouch.neighbors') neighbors << assert_property('domain.full') @@ -47,7 +47,7 @@ class TestCouchdb < LeapTest # # this seems backward to me, so it might be the other way around. # - def test_03_replica_membership_is_kosher + def test_03_Are_configured_nodes_online? url = couchdb_url("/_membership") assert_get(url) do |body| response = JSON.parse(body) @@ -65,7 +65,7 @@ class TestCouchdb < LeapTest end end - def test_04_acl_users_exist + def test_04_Do_ACL_users_exist? acl_users = ['_design/_auth', 'leap_mx', 'nickserver', 'soledad', 'tapicero', 'webapp'] url = couchdb_backend_url("/_users/_all_docs") assert_get(url) do |body| @@ -77,7 +77,7 @@ class TestCouchdb < LeapTest pass end - def test_05_required_databases_exist + def test_05_Do_required_databases_exist? dbs_that_should_exist = ["customers","identities","keycache","sessions","shared","tickets","tokens","users"] dbs_that_should_exist.each do |db_name| assert_get(couchdb_url("/"+db_name)) do |body| -- cgit v1.2.3