diff options
-rw-r--r-- | provider_base/lib/macros/haproxy.rb | 8 | ||||
-rw-r--r-- | provider_base/services/mx.json | 2 | ||||
-rw-r--r-- | provider_base/services/webapp.json | 2 | ||||
m--------- | puppet/modules/couchdb | 0 | ||||
-rw-r--r-- | puppet/modules/site_haproxy/templates/couch.erb | 4 | ||||
-rw-r--r-- | puppet/modules/tapicero/templates/tapicero.yaml.erb | 6 | ||||
-rw-r--r-- | tests/white-box/couchdb.rb | 10 | ||||
-rw-r--r-- | tests/white-box/webapp.rb | 15 |
8 files changed, 29 insertions, 18 deletions
diff --git a/provider_base/lib/macros/haproxy.rb b/provider_base/lib/macros/haproxy.rb index c0f9ede5..602ae726 100644 --- a/provider_base/lib/macros/haproxy.rb +++ b/provider_base/lib/macros/haproxy.rb @@ -39,6 +39,10 @@ module LeapCli # create the first pass of the servers hash servers = node_list.values.inject(Config::ObjectList.new) do |hsh, node| + # make sure we have a port to talk to + unless accept_ports[node.name] + error "haproxy needs a local port to talk to when connecting to #{node.name}" + end weight = default_weight try { weight = local_weight if self.location.name == node.location.name @@ -46,7 +50,7 @@ module LeapCli hsh[node.name] = Config::Object[ 'backup', false, 'host', 'localhost', - 'port', accept_ports[node.name] || 0, + 'port', accept_ports[node.name], 'weight', weight ] if node.services.include?('couchdb') @@ -66,4 +70,4 @@ module LeapCli end end -end
\ No newline at end of file +end diff --git a/provider_base/services/mx.json b/provider_base/services/mx.json index 1f0e613e..32a93638 100644 --- a/provider_base/services/mx.json +++ b/provider_base/services/mx.json @@ -7,7 +7,7 @@ "haproxy": { "couch": { "listen_port": 4096, - "servers": "= haproxy_servers(nodes_like_me[:services => :couchdb], stunnel.clients.couch_client)" + "servers": "= haproxy_servers(nodes_like_me[:services => :couchdb], stunnel.clients.couch_client, 5984)" } }, "couchdb_leap_mx_user": { diff --git a/provider_base/services/webapp.json b/provider_base/services/webapp.json index 3af0dade..1af95022 100644 --- a/provider_base/services/webapp.json +++ b/provider_base/services/webapp.json @@ -40,7 +40,7 @@ "haproxy": { "couch": { "listen_port": 4096, - "servers": "= haproxy_servers(nodes_like_me[:services => :couchdb], stunnel.clients.couch_client, global.services[:couchdb].couch.port)" + "servers": "= haproxy_servers(nodes_like_me[:services => :couchdb], stunnel.clients.couch_client, global.services[:couchdb].couch.port, 5984)" } }, "definition_files": { diff --git a/puppet/modules/couchdb b/puppet/modules/couchdb -Subproject 8bc5ed434c124457b7467140152602c67a9547c +Subproject f01b3586215bdc10f0067fa0f6d940be8e88bce diff --git a/puppet/modules/site_haproxy/templates/couch.erb b/puppet/modules/site_haproxy/templates/couch.erb index baa31486..f42e8368 100644 --- a/puppet/modules/site_haproxy/templates/couch.erb +++ b/puppet/modules/site_haproxy/templates/couch.erb @@ -4,8 +4,8 @@ frontend couch option httplog option dontlognull option http-server-close # use client keep-alive, but close server connection. - use_backend couch_write if METH_POST - default_backend couch_read + use_backend couch_read if METH_GET + default_backend couch_write backend couch_write mode http diff --git a/puppet/modules/tapicero/templates/tapicero.yaml.erb b/puppet/modules/tapicero/templates/tapicero.yaml.erb index 182a6aa6..d6ea56fa 100644 --- a/puppet/modules/tapicero/templates/tapicero.yaml.erb +++ b/puppet/modules/tapicero/templates/tapicero.yaml.erb @@ -1,3 +1,5 @@ +<%- require 'json' -%> + # # Default configuration options for Tapicero # @@ -25,7 +27,9 @@ options: # prefix for per user databases: db_prefix: "user-" mode: <%= @couchdb_mode %> - replication: <%= @couchdb_replication %> +<%- if @couchdb_replication %> + replication: <%= @couchdb_replication.to_json %> +<%- end -%> # security settings to be used for the per user databases security: diff --git a/tests/white-box/couchdb.rb b/tests/white-box/couchdb.rb index 74bd47bf..6d3a7452 100644 --- a/tests/white-box/couchdb.rb +++ b/tests/white-box/couchdb.rb @@ -71,7 +71,7 @@ class CouchDB < LeapTest def test_04_Do_ACL_users_exist? acl_users = ['_design/_auth', 'leap_mx', 'nickserver', 'soledad', 'tapicero', 'webapp', 'replication'] - url = couchdb_backend_url("/_users/_all_docs") + url = couchdb_backend_url("/_users/_all_docs", :user => 'admin') assert_get(url) do |body| response = JSON.parse(body) assert_equal acl_users.count, response['total_rows'] @@ -84,7 +84,8 @@ class CouchDB < LeapTest 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| + url = couchdb_url("/"+db_name, :user => 'admin') + assert_get(url) do |body| assert response = JSON.parse(body) assert_equal db_name, response['db_name'] end @@ -129,9 +130,10 @@ class CouchDB < LeapTest url end - def couchdb_backend_url(path="") + def couchdb_backend_url(path="", options={}) # TODO: admin port is hardcoded for now but should be configurable. - couchdb_url(path, multimaster? && "5986") + options = {port: multimaster? && "5986"}.merge options + couchdb_url(path, options) end def multimaster? diff --git a/tests/white-box/webapp.rb b/tests/white-box/webapp.rb index 05b86a41..7df57fd7 100644 --- a/tests/white-box/webapp.rb +++ b/tests/white-box/webapp.rb @@ -14,15 +14,16 @@ class Webapp < LeapTest # example properties: # # stunnel: - # couch_client: - # couch1_5984: - # accept_port: 4000 - # connect: couch1.bitmask.i - # connect_port: 15984 + # clients: + # couch_client: + # couch1_5984: + # accept_port: 4000 + # connect: couch1.bitmask.i + # connect_port: 15984 # def test_01_Can_contact_couchdb? - assert_property('stunnel.couch_client') - $node['stunnel']['couch_client'].values.each do |stunnel_conf| + assert_property('stunnel.clients.couch_client') + $node['stunnel']['clients']['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}" remote_ip_address = TCPSocket.gethostbyname(stunnel_conf['connect']).last |