summaryrefslogtreecommitdiff
path: root/tests/white-box/webapp.rb
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2013-12-09 23:06:19 -0800
committerelijah <elijah@riseup.net>2013-12-09 23:06:19 -0800
commit68328b6e15a38a74261ee46b06091b8e63f85499 (patch)
treedc8328e92113d5ceaa4bbea00048eb8b13f65b80 /tests/white-box/webapp.rb
parente23dc7849d1118ed2dfe7f37a6109ffbeefa959c (diff)
added initial white-box tests for couchdb and webapp nodes
Diffstat (limited to 'tests/white-box/webapp.rb')
-rw-r--r--tests/white-box/webapp.rb53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/white-box/webapp.rb b/tests/white-box/webapp.rb
new file mode 100644
index 00000000..65f3217b
--- /dev/null
+++ b/tests/white-box/webapp.rb
@@ -0,0 +1,53 @@
+raise SkipTest unless $node["services"].include?("webapp")
+
+class TestWebapp < LeapTest
+ depends_on "TestNetwork"
+
+ HAPROXY_CONFIG = '/etc/haproxy/haproxy.cfg'
+
+ def setup
+ end
+
+ #
+ # example properties:
+ #
+ # stunnel:
+ # couch_client:
+ # couch1_5984:
+ # accept_port: 4000
+ # connect: couch1.bitmask.i
+ # connect_port: 15984
+ #
+ def test_01_stunnel_is_working
+ assert_property('stunnel.couch_client')
+ $node['stunnel']['couch_client'].values.each do |stunnel_conf|
+ assert port = stunnel_conf['accept_port'], 'Field `accept_port` must be present in `stunnel` property.'
+ local_stunnel_url = "http://localhost:#{port}"
+ assert_get(local_stunnel_url) do |body|
+ assert_match /"couchdb":"Welcome"/, body, "Request to #{local_stunnel_url} should return couchdb welcome message."
+ end
+ end
+ pass
+ end
+
+ #
+ # example properties:
+ #
+ # haproxy:
+ # servers:
+ # couch1:
+ # backup: false
+ # host: localhost
+ # port: 4000
+ # weight: 10
+ #
+ def test_02_haproxy_is_working
+ port = file_match(HAPROXY_CONFIG, /^ bind localhost:(\d+)$/)
+ url = "http://localhost:#{port}"
+ assert_get(url) do |body|
+ assert_match /"couchdb":"Welcome"/, body, "Request to #{url} should return couchdb welcome message."
+ end
+ pass
+ end
+
+end