From 7c137a4e1585c93fb478751168d3ddd279b63043 Mon Sep 17 00:00:00 2001 From: Claudia Beresford and Gerhard Lazu Date: Fri, 14 Aug 2015 16:23:17 +0100 Subject: [PATCH] Deploy without a CF This is a great bosh MySQL release that might not always be deployed alongisde a CloudFoundry. All CF components are still in the release, but we want to create a manifest that disables them without breaking the deployment. The mysql-stub-spiff-3-node.yml can be used on a clean bosh-lite, without any CF and it will just work. We'll try this on AWS next and come back with manifest additions if required. Also relates to cloudfoundry-incubator/cf-mysql-acceptance-tests#2 --- bosh-lite/mysql-stub-spiff-3-node.yml | 41 ++++++++++++ jobs/acceptance-tests/spec | 3 + jobs/acceptance-tests/templates/errand.sh.erb | 66 ++++++++----------- .../templates/registrar_settings.yml.erb | 2 + .../templates/route-registrar_ctl.erb | 5 ++ jobs/proxy/templates/route-registrar.yml.erb | 2 + jobs/proxy/templates/route-registrar_ctl.erb | 5 ++ scripts/create_integration_test_config | 4 +- templates/cf-mysql-template.yml | 39 +++++------ 9 files changed, 102 insertions(+), 65 deletions(-) create mode 100644 bosh-lite/mysql-stub-spiff-3-node.yml diff --git a/bosh-lite/mysql-stub-spiff-3-node.yml b/bosh-lite/mysql-stub-spiff-3-node.yml new file mode 100644 index 00000000..0335e0b2 --- /dev/null +++ b/bosh-lite/mysql-stub-spiff-3-node.yml @@ -0,0 +1,41 @@ +--- +name: cf-warden-mysql +director_uuid: PLACEHOLDER-DIRECTOR-UUID +releases: + - name: cf-mysql + version: latest + +properties: + domain: (( merge || "" )) + +jobs: + - name: mysql_z1 + instances: 1 + networks: + - name: mysql1 + static_ips: + - 10.244.7.2 + properties: + <<: (( merge || nil )) + admin_password: password + cluster_ips: (( jobs.mysql_z1.networks.[0].static_ips )) + - name: mysql_z2 + instances: 1 + - name: mysql_z3 + instances: 1 + - name: cf-mysql-broker_z1 + instances: 0 + - name: cf-mysql-broker_z2 + instances: 0 + - name: proxy_z1 + properties: + <<: (( merge || nil )) + proxy: + <<: (( merge || nil )) + api_username: username + api_password: password + - name: proxy_z2 + instances: 1 + - name: acceptance-tests + properties: + no_cf: true diff --git a/jobs/acceptance-tests/spec b/jobs/acceptance-tests/spec index 86785dbb..df6a009c 100644 --- a/jobs/acceptance-tests/spec +++ b/jobs/acceptance-tests/spec @@ -40,6 +40,9 @@ properties: smoke_tests_only: description: 'Instead of running the full acceptance test suite, only run a shorter smoke test' default: true + no_cf: + description: 'If this release has been deployed without CF, only run the proxy tests' + default: false proxy.external_host: description: 'Proxy external host (e.g. p-mysql.example.com => proxy-0.p-mysql.example.com)' diff --git a/jobs/acceptance-tests/templates/errand.sh.erb b/jobs/acceptance-tests/templates/errand.sh.erb index 236ee8bb..c20277a7 100644 --- a/jobs/acceptance-tests/templates/errand.sh.erb +++ b/jobs/acceptance-tests/templates/errand.sh.erb @@ -1,52 +1,38 @@ #!/bin/bash set -e -x +<% if p('no_cf') %> +exit 0 +<% end %> + cd /var/vcap/packages/acceptance-tests/src/github.com/cloudfoundry-incubator/cf-mysql-acceptance-tests -cat > integration_config.json <", - "apps_domain": "<%= p('cf.apps_domain') %>", - "admin_user": "<%= p('cf.admin_username') %>", - "broker_host": "<%= p('broker.host') %>", - "service_name": "<%= p('service.name') %>", - <% if p('org_name') %> - "org_name": "<%= p('org_name') %>", - <% end %> - "plans": [ - <% plans = p('service.plans') - plans.each do |plan| %> - { - "plan_name": "<%= plan['plan_name'] %>", - "max_storage_mb": <%= plan['max_storage_mb'] %>, - "max_user_connections": <%= plan['max_user_connections'] || p('service.max_user_connections_default')%> - <% if plan != plans.last %> - }, - <% else %> - } - <% end - end%> - ], - "skip_ssl_validation": <%= p('cf.skip_ssl_validation') %>, - "proxy": { - "external_host": "<%= p('proxy.external_host') %>", - "api_username": "<%= p('proxy.api_username') %>", - "api_password": "<%= p('proxy.api_password') %>", - "api_force_https": <%= p('proxy.api_force_https') %>, - "skip_ssl_validation": <%= p('proxy.skip_ssl_validation') %> - }, - "timeout_scale": <%= p('timeout_scale') %>, -EOF +<% +integration_config = properties.cf.to_h +integration_config[:proxy] = properties.proxy.to_h +integration_config[:timeout_scale] = properties.timeout_scale + +integration_config[:org_name] = properties.org_name if properties.org_name +integration_config[:api] = properties.cf.api_url if properties.cf +integration_config[:admin_user] = properties.cf.admin_username if properties.cf +integration_config[:broker_host] = properties.broker.host if properties.broker +if properties.service + integration_config[:service_name] = properties.service.name + integration_config[:plans] = properties.service.plans.map do |plan| + { max_user_connections: properties.service.max_user_connections_default }.merge(plan.to_h) + end +end +%> # don't expose passwords set +x - -cat >> integration_config.json <" -} +cat > integration_config.json < EOF - -# set -x +set -x export GOPATH=/var/vcap/packages/acceptance-tests export GOROOT=/var/vcap/packages/golang diff --git a/jobs/cf-mysql-broker/templates/registrar_settings.yml.erb b/jobs/cf-mysql-broker/templates/registrar_settings.yml.erb index 877e3eb9..7e472e16 100644 --- a/jobs/cf-mysql-broker/templates/registrar_settings.yml.erb +++ b/jobs/cf-mysql-broker/templates/registrar_settings.yml.erb @@ -1,3 +1,4 @@ +<% if_p('nats.machines') do |_| %> message_bus_servers: <% p('nats.machines').each do |ip| %> - host: <%= ip %>:<%= p('nats.port') %> @@ -11,3 +12,4 @@ health_checker: name: script interval_in_seconds: 10 healthcheck_script_path: /var/vcap/jobs/cf-mysql-broker/bin/healthcheck.sh +<% end %> diff --git a/jobs/cf-mysql-broker/templates/route-registrar_ctl.erb b/jobs/cf-mysql-broker/templates/route-registrar_ctl.erb index 574349ff..4b08973c 100644 --- a/jobs/cf-mysql-broker/templates/route-registrar_ctl.erb +++ b/jobs/cf-mysql-broker/templates/route-registrar_ctl.erb @@ -23,10 +23,15 @@ start) pid_guard $PIDFILE $JOB_NAME +<% if_p('nats.machines') { |_| %> /var/vcap/packages/route-registrar/bin/route-registrar \ -pidfile=$PIDFILE \ -configPath=$CONFIG_FILE \ >>$LOG_DIR/route-registrar.stdout.log 2>>$LOG_DIR/route-registrar.stderr.log& +<% }.else { %> + echo $$ > $PIDFILE + kill -STOP $$ +<% } %> ;; stop) diff --git a/jobs/proxy/templates/route-registrar.yml.erb b/jobs/proxy/templates/route-registrar.yml.erb index aa8fd697..f546222e 100644 --- a/jobs/proxy/templates/route-registrar.yml.erb +++ b/jobs/proxy/templates/route-registrar.yml.erb @@ -1,3 +1,4 @@ +<% if_p('nats.machines') do |_| %> message_bus_servers: <% p('nats.machines').each do |ip| %> - host: <%= ip %>:<%= p('nats.port') %> @@ -7,3 +8,4 @@ message_bus_servers: external_host: proxy-<%= index %>.<%= p('external_host') %> external_ip: <%= spec.networks.send(p('network_name')).ip %> port: <%= p('proxy.api_port') %> +<% end %> diff --git a/jobs/proxy/templates/route-registrar_ctl.erb b/jobs/proxy/templates/route-registrar_ctl.erb index 6fb2ae87..c43f6922 100644 --- a/jobs/proxy/templates/route-registrar_ctl.erb +++ b/jobs/proxy/templates/route-registrar_ctl.erb @@ -23,10 +23,15 @@ start) pid_guard $PIDFILE $JOB_NAME +<% if_p('nats.machines') { |_| %> /var/vcap/packages/route-registrar/bin/route-registrar \ -pidfile=$PIDFILE \ -configPath=$CONFIG_FILE \ >>$LOG_DIR/route-registrar.stdout.log 2>>$LOG_DIR/route-registrar.stderr.log& +<% }.else { %> + echo $$ > $PIDFILE + kill -STOP $$ +<% } %> ;; stop) diff --git a/scripts/create_integration_test_config b/scripts/create_integration_test_config index 3525a6c1..4f748121 100755 --- a/scripts/create_integration_test_config +++ b/scripts/create_integration_test_config @@ -54,12 +54,12 @@ cat > ${CONFIG_LOCATION} <