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/network.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tests/white-box/network.rb (limited to 'tests/white-box/network.rb') diff --git a/tests/white-box/network.rb b/tests/white-box/network.rb new file mode 100644 index 00000000..9680cb5f --- /dev/null +++ b/tests/white-box/network.rb @@ -0,0 +1,13 @@ +class TestNetwork < LeapTest + + def setup + end + + # + # TODO: write an actual test to confirm the network is up and working. + # + def test_working + pass + end + +end -- cgit v1.2.3 From 34678e895a5a40da6f444199983fee3f8ce518ee Mon Sep 17 00:00:00 2001 From: elijah Date: Fri, 27 Dec 2013 02:43:24 -0800 Subject: added some network tests for stunnel --- tests/white-box/network.rb | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'tests/white-box/network.rb') diff --git a/tests/white-box/network.rb b/tests/white-box/network.rb index 9680cb5f..8ca56ffd 100644 --- a/tests/white-box/network.rb +++ b/tests/white-box/network.rb @@ -1,12 +1,31 @@ +require 'socket' + +raise SkipTest if $node["dummy"] + class TestNetwork < LeapTest def setup end # - # TODO: write an actual test to confirm the network is up and working. + # example properties: + # + # stunnel: + # couch_client: + # couch1_5984: + # accept_port: 4000 + # connect: couch1.bitmask.i + # connect_port: 15984 # - def test_working + def test_01_stunnel_is_running + if $node['stunnel'] + $node['stunnel'].values.each do |stunnel_type| + stunnel_type.values.each do |stunnel_conf| + assert port = stunnel_conf['accept_port'], 'Field `accept_port` must be present in `stunnel` property.' + assert_tcp_socket('localhost', port) + end + end + end pass end -- cgit v1.2.3 From f1ba024e9c529b5f9ac988d6600931f914ec1d31 Mon Sep 17 00:00:00 2001 From: elijah Date: Fri, 27 Dec 2013 10:32:10 -0800 Subject: improved stunnel test --- tests/white-box/network.rb | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'tests/white-box/network.rb') diff --git a/tests/white-box/network.rb b/tests/white-box/network.rb index 8ca56ffd..02eb80ca 100644 --- a/tests/white-box/network.rb +++ b/tests/white-box/network.rb @@ -11,18 +11,30 @@ class TestNetwork < LeapTest # example properties: # # stunnel: - # couch_client: - # couch1_5984: - # accept_port: 4000 - # connect: couch1.bitmask.i - # connect_port: 15984 + # ednp_clients: + # elk_9002: + # accept_port: 4003 + # connect: elk.dev.bitmask.i + # connect_port: 19002 + # couch_server: + # accept: 15984 + # connect: "127.0.0.1:5984" # def test_01_stunnel_is_running if $node['stunnel'] - $node['stunnel'].values.each do |stunnel_type| - stunnel_type.values.each do |stunnel_conf| - assert port = stunnel_conf['accept_port'], 'Field `accept_port` must be present in `stunnel` property.' - assert_tcp_socket('localhost', port) + $node['stunnel'].each do |stunnel_type, stunnel_configs| + if stunnel_type =~ /_clients?$/ + stunnel_configs.values.each do |stunnel_conf| + assert port = stunnel_conf['accept_port'], 'Field `accept_port` must be present in `stunnel` property.' + assert_tcp_socket('localhost', port) + end + elsif stunnel_type =~ /_server$/ + assert accept = stunnel_configs['accept'], "Field `accept` must be present in property `stunnel.#{stunnel_type}`" + assert_tcp_socket('localhost', accept) + assert connect = stunnel_configs['connect'], "Field `connect` must be present in property `stunnel.#{stunnel_type}`" + assert_tcp_socket(*connect.split(':')) + else + skip "Unknown stunnel type `#{stunnel_type}`" end end end -- 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/network.rb | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'tests/white-box/network.rb') diff --git a/tests/white-box/network.rb b/tests/white-box/network.rb index 02eb80ca..53df80dc 100644 --- a/tests/white-box/network.rb +++ b/tests/white-box/network.rb @@ -7,6 +7,11 @@ class TestNetwork < LeapTest def setup end + def test_01_can_connect_to_internet + assert_get('http://www.google.com/images/srpr/logo11w.png') + pass + end + # # example properties: # @@ -20,15 +25,24 @@ class TestNetwork < LeapTest # accept: 15984 # connect: "127.0.0.1:5984" # - def test_01_stunnel_is_running + def test_02_stunnel_is_running if $node['stunnel'] + good_stunnel_pids = [] $node['stunnel'].each do |stunnel_type, stunnel_configs| if stunnel_type =~ /_clients?$/ - stunnel_configs.values.each do |stunnel_conf| + stunnel_configs.each do |stunnel_name, stunnel_conf| + config_file_name = "/etc/stunnel/#{stunnel_name}.conf" + processes = pgrep(config_file_name) + assert_equal 6, processes.length, "There should be six stunnel processes running for `#{config_file_name}`" + good_stunnel_pids += processes.map{|ps| ps[:pid]} assert port = stunnel_conf['accept_port'], 'Field `accept_port` must be present in `stunnel` property.' assert_tcp_socket('localhost', port) end elsif stunnel_type =~ /_server$/ + config_file_name = "/etc/stunnel/#{stunnel_type}.conf" + processes = pgrep(config_file_name) + assert_equal 6, processes.length, "There should be six stunnel processes running for `#{config_file_name}`" + good_stunnel_pids += processes.map{|ps| ps[:pid]} assert accept = stunnel_configs['accept'], "Field `accept` must be present in property `stunnel.#{stunnel_type}`" assert_tcp_socket('localhost', accept) assert connect = stunnel_configs['connect'], "Field `connect` must be present in property `stunnel.#{stunnel_type}`" @@ -37,6 +51,8 @@ class TestNetwork < LeapTest skip "Unknown stunnel type `#{stunnel_type}`" end 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" end pass 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/network.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/white-box/network.rb') diff --git a/tests/white-box/network.rb b/tests/white-box/network.rb index 53df80dc..14de2eac 100644 --- a/tests/white-box/network.rb +++ b/tests/white-box/network.rb @@ -2,12 +2,12 @@ require 'socket' raise SkipTest if $node["dummy"] -class TestNetwork < LeapTest +class Network < LeapTest def setup end - def test_01_can_connect_to_internet + def test_01_Can_connect_to_internet? assert_get('http://www.google.com/images/srpr/logo11w.png') pass end @@ -25,7 +25,7 @@ class TestNetwork < LeapTest # accept: 15984 # connect: "127.0.0.1:5984" # - def test_02_stunnel_is_running + def test_02_Is_stunnel_running? if $node['stunnel'] good_stunnel_pids = [] $node['stunnel'].each do |stunnel_type, stunnel_configs| -- cgit v1.2.3 From 7451213d5e0772d0d6cba4613bf66792da495909 Mon Sep 17 00:00:00 2001 From: elijah Date: Wed, 26 Mar 2014 10:25:29 -0700 Subject: minor: fix message on stunnel test. --- tests/white-box/network.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/white-box/network.rb') diff --git a/tests/white-box/network.rb b/tests/white-box/network.rb index 53df80dc..57002beb 100644 --- a/tests/white-box/network.rb +++ b/tests/white-box/network.rb @@ -53,8 +53,8 @@ class TestNetwork < LeapTest 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" + pass end - pass end end -- cgit v1.2.3