pcf_blue_green 0.38 → 0.41

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5a4b01fd2e2906620666e420eee9f96b88a3550
4
- data.tar.gz: 3532f96e58df630b0c81c4da1af33c5bac15d8b8
3
+ metadata.gz: ce9a0ff7f133579929ed18fe91e3a65268e3636e
4
+ data.tar.gz: 5278c466264ea93c6b5109abb631ff43dcffacee
5
5
  SHA512:
6
- metadata.gz: e3597d5a968b161ec9b8b5a3f40fcf42cb5a93b11e3399caddce117fe542862c0960c0d2175fc0092bcb2120e2ef588d8624de7b4c019c2611f455dedf51d5f9
7
- data.tar.gz: 0e8d217a163109db34000150e0082dc3160049e9bd55ade7d9bd6fe8a23a03c32a460c6cc977283b183601b1a66c90b75c5410cbe8d58eca97cba026ac881331
6
+ metadata.gz: 0822749fe7e78ecb9aba92babd9fa3924af5a4238fdf4932708e3366f9688a72af996912beb37e0d2643ad63cc7749179b9a397f4dff07291b2046e8d9c14a71
7
+ data.tar.gz: 6f36118d59fa0b4705661a263965e139b93f6da3a63db82f3bbd2d1f752ab08aa02465db0db556a082f8d6edf7f558ed70b2a20723d584cc0ab983cea114d13a
@@ -1,3 +1,3 @@
1
1
  module PcfBlueGreen
2
- VERSION = "0.38"
2
+ VERSION = "0.41"
3
3
  end
@@ -4,13 +4,9 @@ require 'shellwords'
4
4
  require "json"
5
5
 
6
6
  module PcfBlueGreen
7
- class BlueGreenDeployFailed < StandardError
7
+ class BlueGreenDeploymentFailed < StandardError
8
8
  end
9
9
 
10
- class CleanupBlueFailed < StandardError
11
- end
12
-
13
-
14
10
  class Routing
15
11
 
16
12
  def initialize(url, user, pass, org, space, call_login = false, opts = {})
@@ -33,43 +29,115 @@ module PcfBlueGreen
33
29
  def cleanup_blue
34
30
  remap_routes
35
31
  status = bash("#{@source_cmd} && remove-blue")
36
- raise PcfBlueGreen::CleanupBlueFailed unless status
32
+ raise PcfBlueGreen::BlueGreenDeploymentFailed unless status
33
+ remove_routes
37
34
  bash("#{@source_cmd} && announce-success")
38
35
  end
39
36
 
37
+ def remove_routes
38
+ removed_routes = []
39
+ if entity = entity_for(ENV['green'])
40
+ routes_stdout(entity)['resources'].each do |resource|
41
+ domain_url = resource['entity']['domain_url']
42
+ domain = domain_for(domain_url)
43
+ if resource['entity']['path'].empty?
44
+ cmd = "#{delete_route_command} #{domain} -n #{resource['entity']['host']} -f"
45
+ else
46
+ cmd = "#{delete_route_command} #{domain} -n #{resource['entity']['host']} --path #{resource['entity']['path']} -f"
47
+ end
48
+ puts cmd
49
+ shell = Mixlib::ShellOut.new(cmd)
50
+ shell.run_command
51
+ removed_routes += shell.stdout.split("\n")
52
+
53
+ unless shell.stderr.empty?
54
+ puts shell.stderr
55
+ raise PcfBlueGreen::BlueGreenDeploymentFailed
56
+ end
57
+ end
58
+ end
59
+ puts "Removed routes: #{removed_routes.uniq.join(', ')} "
60
+ removed_routes.uniq.join(",\n")
61
+ end
62
+
40
63
  def remap_routes
41
64
  puts "Remapping routes..."
42
65
  puts "cf_app is #{ENV['cf_app']}"
43
66
  puts "green is #{ENV['green']}"
44
-
45
67
  mapped_routes = []
46
-
47
- if ENV['handle_all_paths']
48
- cmd = "#{cf_routes_output} | tail -n +4 | awk '($5==ENVIRON[\"cf_app\"]) {print $3\" -n \"$2 \" --path \"substr($4,2) }' | xargs -n 5 #{map_route_command} #{ENV['green']}"
49
- puts cmd
50
- shell = Mixlib::ShellOut.new(cmd)
51
- shell.run_command
52
- unless shell.stderr.empty?
53
- puts shell.stderr
54
- raise PcfBlueGreen::CleanupBlueFailed
68
+ if entity = entity_for(ENV['cf_app'])
69
+ routes_stdout(entity)['resources'].each do |resource|
70
+ domain_url = resource['entity']['domain_url']
71
+ domain = domain_for(domain_url)
72
+ if resource['entity']['path'].empty?
73
+ cmd = "#{map_route_command} #{ENV['green']} #{domain} -n #{resource['entity']['host']}"
74
+ else
75
+ cmd = "#{map_route_command} #{ENV['green']} #{domain} -n #{resource['entity']['host']} --path #{resource['entity']['path']}"
76
+ end
77
+ puts cmd
78
+ shell = Mixlib::ShellOut.new(cmd)
79
+ shell.run_command
80
+ mapped_routes += shell.stdout.split("\n")
81
+ unless shell.stderr.empty?
82
+ puts shell.stderr
83
+ raise PcfBlueGreen::BlueGreenDeploymentFailed
84
+ end
55
85
  end
56
- mapped_routes += shell.stdout.split("\n")
57
- end
58
- cmd = "#{cf_routes_output} | tail -n +4 | awk '($4==ENVIRON[\"cf_app\"]) {print $3\" -n \" $2}' | xargs -n 3 #{map_route_command} #{ENV['green']}"
59
- puts cmd
60
- shell = Mixlib::ShellOut.new(cmd)
61
- shell.run_command
62
- unless shell.stderr.empty?
63
- puts shell.stderr
64
- raise PcfBlueGreen::CleanupBlueFailed
65
86
  end
66
- mapped_routes += shell.stdout.split("\n")
67
87
  puts "Mappped routes: #{mapped_routes.uniq.join(', ')} "
68
88
  mapped_routes.uniq.join(",\n")
69
89
  end
70
90
 
71
91
  private
72
92
 
93
+ def entity_for(app_name)
94
+ app_data_cmd = "cf curl \"/v2/apps\" -X GET -H \"Content-Type: application/x-www-form-urlencoded\" -d 'q=name:#{app_name}'"
95
+ app_data_shell = Mixlib::ShellOut.new(app_data_cmd)
96
+ app_data_shell.run_command
97
+ app_stdout = JSON.parse(app_data_shell.stdout)
98
+ app_stdout['resources'].each do |resource|
99
+ if resource['entity']['name'] == app_name && resource['entity']['space_guid'] == fetch_space_guid
100
+ @entity = resource['entity']
101
+ end
102
+ end
103
+
104
+ unless app_data_shell.stderr.empty?
105
+ puts app_data_shell.stderr
106
+ raise PcfBlueGreen::BlueGreenDeploymentFailed
107
+ end
108
+ @entity
109
+ end
110
+
111
+ def routes_stdout(entity)
112
+ routes_url = entity['routes_url']
113
+ app_routes_cmd = "cf curl #{routes_url}"
114
+ app_routes_shell = Mixlib::ShellOut.new(app_routes_cmd)
115
+ app_routes_shell.run_command
116
+ JSON.parse(app_routes_shell.stdout)
117
+ end
118
+
119
+ def domain_for(domain_url)
120
+ app_domain_cmd = "cf curl #{domain_url}"
121
+ app_domain_shell = Mixlib::ShellOut.new(app_domain_cmd)
122
+ app_domain_shell.run_command
123
+ domain_stdout = JSON.parse(app_domain_shell.stdout)
124
+ domain_stdout['entity']['name']
125
+ end
126
+
127
+ def fetch_space_guid
128
+ command = 'cf curl /v2/spaces'
129
+ shell = Mixlib::ShellOut.new(command)
130
+ shell.run_command
131
+ space_guid = nil
132
+ raise Csaa::Pcf::Unauthorized unless space_guid_json(shell.stdout)['resources']
133
+ space_guid_json(shell.stdout)['resources'].each do |resource|
134
+ if resource['entity']['name'] == @space
135
+ space_guid = resource['metadata']['guid']
136
+ end
137
+ end
138
+ space_guid
139
+ end
140
+
73
141
  def login
74
142
  puts "Logging in to #{@url}"
75
143
  cf_login = "cf login -a #{@url} -u #{@user} -p '#{@pass}' -o #{@org} -s #{@space} #{@login_options} > /dev/null"
@@ -78,8 +146,8 @@ module PcfBlueGreen
78
146
  shell.run_command
79
147
  end
80
148
 
81
- def cf_routes_output
82
- "cf routes"
149
+ def delete_route_command
150
+ "cf delete-route"
83
151
  # cmd = "cf routes"
84
152
  # shell = Mixlib::ShellOut.new(cmd)
85
153
  # shell.run_command
@@ -90,6 +158,7 @@ module PcfBlueGreen
90
158
  "cf map-route"
91
159
  end
92
160
 
161
+
93
162
  def bash(command)
94
163
  escaped_command = Shellwords.escape(command)
95
164
  system "bash -c #{escaped_command}"
@@ -109,7 +178,7 @@ module PcfBlueGreen
109
178
 
110
179
  def blue_green_deploy
111
180
  status = bash("#{@source_cmd} && blue-green")
112
- raise PcfBlueGreen::BlueGreenDeployFailed unless status
181
+ raise PcfBlueGreen::BlueGreenDeploymentFailed unless status
113
182
  end
114
183
 
115
184
  def env_var_manifest_update
@@ -140,7 +209,10 @@ module PcfBlueGreen
140
209
  def bash(command)
141
210
  escaped_command = Shellwords.escape(command)
142
211
  system "bash -c #{escaped_command}"
143
- end
212
+ end
144
213
 
214
+ def space_guid_json(stdout)
215
+ JSON.parse(stdout)
216
+ end
145
217
  end
146
218
  end
@@ -69,32 +69,18 @@ function cf-push {
69
69
  function check-health {
70
70
  local app_url=$1
71
71
  announce-task "Checking health"
72
- cf_output=$(echo $(cf env ${cf_app})| grep -o 'User-Provided:.*')
73
- echo "Executing curl of ${app_url}\n\n"
74
- if echo $cf_output| egrep -o 'MAINTENANCE_ENABLED: \S*'
75
- then
76
- kv=$(echo $cf_output| egrep -o 'MAINTENANCE_ENABLED: \S*')
77
- arrkv=(${kv// / })
78
- if [ ${arrkv[1]} == true ] ; then
79
- status=$(curl -sSIL -X GET -o /dev/null -w "%{http_code}" ${app_url} --insecure)
80
- if [ $status == 503 ] ; then
81
- echo -e "${BGre}curl of ${app_url} 503 OK"
82
- else
83
- echo ERROR: Expecting 503 status
84
- exit 1
85
- fi
72
+ maitenance_enabled=$(echo $(cf curl '/v2/apps' -X GET -H 'Content-Type: application/x-www-form-urlencoded' -d "q=name:$cf_app" | jq '.resources[0].entity.environment_json.MAINTENANCE_ENABLED'))
73
+ maitenance_enabled=$(echo ${maitenance_enabled//\"} | awk '{ print tolower($1) }')
74
+ if [ $maitenance_enabled == "true" ] ; then
75
+ status=$(curl -sSIL --header "x-digital-auth: ${JWT}" -X GET -o /dev/null -w "%{http_code}" ${app_url} --insecure)
76
+ if [ $status == 503 ] ; then
77
+ echo -e "${BGre}curl of ${app_url} 503 OK"
86
78
  else
87
- curl -fsSIL --header "x-digital-auth: ${JWT}" --user "${BASIC_AUTH_USERNAME}:${BASIC_AUTH_PASSWORD}" ${app_url} --insecure
88
- status=$(curl -sSIL --header "x-digital-auth: ${JWT}" -X GET -o /dev/null -w "%{http_code}" ${app_url} --insecure)
89
- if [ $status == 200 ] ; then
90
- echo -e "${BGre}curl of ${app_url} 200 OK"
91
- else
92
- echo -e "${BGre}curl of ${app_url} ${status} ERR"
79
+ echo ERROR: Expecting 503 status
93
80
  exit 1
94
- fi
95
81
  fi
96
82
  else
97
- curl -fsSIL -X GET --header "x-digital-auth: ${JWT}" --user "${BASIC_AUTH_USERNAME}:${BASIC_AUTH_PASSWORD}" ${app_url} --insecure
83
+ curl -fsSIL --header "x-digital-auth: ${JWT}" --user "${BASIC_AUTH_USERNAME}:${BASIC_AUTH_PASSWORD}" ${app_url} --insecure
98
84
  status=$(curl -sSIL --header "x-digital-auth: ${JWT}" -X GET -o /dev/null -w "%{http_code}" ${app_url} --insecure)
99
85
  if [ $status == 200 ] ; then
100
86
  echo -e "${BGre}curl of ${app_url} 200 OK"
@@ -125,53 +111,9 @@ function generate-manifest {
125
111
  fi
126
112
  }
127
113
 
128
- function remap-routes {
129
- announce-task "Remapping routes..."
130
- echo "cf_app is ${cf_app}"
131
- echo "green is ${green}"
132
- set -x
133
- run-cmd cf routes
134
-
135
- # Variables used:
136
-
137
- # Some applications have extra routes that contain paths. If that's the case
138
- # then handle_all_paths environmental variable is used to manage paths.
139
- # to a different hostname
140
-
141
- # Code logic:
142
-
143
- # execute the code below:
144
- if [ -z ${handle_all_paths+x} ]; then
145
- run-cmd cf routes | tail -n +4 | grep ${cf_app} | awk '{print $3" -n "$2}'
146
- cf routes | tail -n +4 | grep ${cf_app} | awk '{print $3" -n "$2}' | xargs -n 3 cf map-route ${green}
147
- fi
148
-
149
- # if map_main_route environmental variable is set then the main route gets mapped:
150
- if [ -n "$map_main_route" ]; then
151
- run-cmd cf routes | awk '($4==ENVIRON["cf_app"]) {print $3" -n " $2 }' | xargs -n 3 cf map-route ${green}
152
- fi
153
-
154
- # if handle_all_paths variable is set then
155
- # 1. routes that's app name is cf_app are found
156
- # 2. paths are mapped to the green app
157
- if [ -n "$handle_all_paths" ]; then
158
- run-cmd cf routes | tail -n +4 | awk '($5==ENVIRON["cf_app"]) {print $3" -n "$2 " --path "substr($4,2) }'
159
- cf routes | tail -n +4 | awk '($5==ENVIRON["cf_app"]) {print $3" -n "$2 " --path "substr($4,2) }' | xargs -n 5 cf map-route ${green}
160
- fi
161
- set +x
162
- }
163
-
164
114
  function remove-blue {
165
115
  run-cmd cf delete ${blue} -f
166
116
  run-cmd cf rename $green $blue
167
- run-cmd cf routes | awk '($2==ENVIRON["green"]) {print $3" -n " $2 " -f"}' | xargs -n 4 cf delete-route
168
-
169
- if [ -n "$handle_all_paths" ]; then
170
- set -x
171
- run-cmd cf routes | tail -n +4 | awk '($2==ENVIRON["green"]) {print $3" -n "$2 " --path "substr($4,2)" -f"}' | xargs -n 6
172
- cf routes | tail -n +4 | awk '($2==ENVIRON["green"]) {print $3" -n "$2 " --path "substr($4,2)" -f"}' | xargs -n 6 cf delete-route
173
- set +x
174
- fi
175
117
  }
176
118
 
177
119
  function get-domain {
@@ -0,0 +1,43 @@
1
+ {
2
+ "resources": [
3
+ {
4
+ "metadata": {
5
+ "guid": "ddbc3214-eg68-44ed-836a-a2defae75547",
6
+ "url": "/v2/routes/XXXXXXXXXXXXXXXXXXXX",
7
+ "created_at": "2017-02-08T16:28:08Z",
8
+ "updated_at": null
9
+ },
10
+ "entity": {
11
+ "host": "app-prod",
12
+ "path": "",
13
+ "domain_url": "/v2/shared_domains/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
14
+ }
15
+ },
16
+ {
17
+ "metadata": {
18
+ "guid": "ddsc3214-eg38-44ed-836a-a2defae75547",
19
+ "url": "/v2/routes/XXXXXXXXXXXXXXXXXXXX",
20
+ "created_at": "2017-02-08T16:28:08Z",
21
+ "updated_at": null
22
+ },
23
+ "entity": {
24
+ "host": "app-prod",
25
+ "path": "/some_path",
26
+ "domain_url": "/v2/shared_domains/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
27
+ }
28
+ },
29
+ {
30
+ "metadata": {
31
+ "guid": "dd3c3214-eg68-44ed-836a-a2defae74547",
32
+ "url": "/v2/routes/XXXXXXXXXXXXXXXXXXXX",
33
+ "created_at": "2017-02-08T16:28:08Z",
34
+ "updated_at": null
35
+ },
36
+ "entity": {
37
+ "host": "app-prod",
38
+ "path": "/other_domain_path",
39
+ "domain_url": "/v2/shared_domains/YYYYYYYYYYYYYYYYYYYYYYYYYYYY"
40
+ }
41
+ }
42
+ ]
43
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "app-prod",
3
+ "production": false,
4
+ "detected_buildpack_guid": null,
5
+ "environment_json": {
6
+ },
7
+ "ports": [
8
+ 8080
9
+ ],
10
+ "space_url": "/v2/spaces/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
11
+ "stack_url": "/v2/stacks/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
12
+ "routes_url": "/v2/apps/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/routes",
13
+ "events_url": "/v2/apps/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/events",
14
+ "service_bindings_url": "/v2/apps/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/service_bindings",
15
+ "route_mappings_url": "/v2/apps/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/route_mappings"
16
+ }
@@ -5,11 +5,42 @@ describe PcfBlueGreen do
5
5
  expect(PcfBlueGreen::VERSION).not_to be nil
6
6
  end
7
7
 
8
- describe "blue green deploy clean-up" do
9
- context 'main route domain' do
10
- it 're-maps routes correctly for simple routes' do
8
+ describe "blue green deploy remap_routes" do
9
+ it 're-maps routes correctly for an application' do
10
+ expected_routes = %{simpleapp-app-space-green app.domain.com -n app-prod,
11
+ simpleapp-app-space-green app.domain.com -n app-prod --path /some_path,
12
+ simpleapp-app-space-green app.domain.com -n app-prod --path /other_domain_path}
13
+
14
+ ENV['APP_SPACE'] = 'app-space'
15
+ ENV['APP_NAME'] = 'simpleapp'
16
+ ENV['cf_app'] = 'simpleapp'
17
+ ENV['cf_api'] = 'https://api.sys.sandbox.test.com'
18
+ ENV['cf_user'] = 'testuser'
19
+ ENV['cf_password'] = 'password'
20
+ ENV['cf_org'] = 'ds'
21
+ ENV['green'] = 'simpleapp-app-space-green'
11
22
 
12
- expected_routes = %{simpleapp-app-space-green apps.prod.domain.com -n simpleapp}
23
+ space = ENV['APP_SPACE']
24
+ api_url = ENV['cf_api']
25
+ username = ENV['cf_user']
26
+ password = ENV['cf_password']
27
+ org = ENV['cf_org']
28
+
29
+
30
+ @pcf_blue_green = PcfBlueGreen::Routing.new(api_url, username, password, org, space, login = false)
31
+ @pcf_blue_green.stub(:entity_for).and_return(JSON.parse(File.read('spec/mocks/simple_entity.json')))
32
+ @pcf_blue_green.stub(:routes_stdout).and_return(JSON.parse(File.read('spec/mocks/routes_stdout.json')))
33
+ @pcf_blue_green.stub(:domain_for).and_return("app.domain.com")
34
+ @pcf_blue_green.stub(:map_route_command).and_return('echo')
35
+
36
+ expect(expected_routes).to eq(@pcf_blue_green.remap_routes)
37
+ end
38
+ end
39
+ describe "blue green deploy remove_routes" do
40
+ it 'removes routes correctly for an application' do
41
+ expected_routes = %{app.domain.com -n app-prod -f,
42
+ app.domain.com -n app-prod --path /some_path -f,
43
+ app.domain.com -n app-prod --path /other_domain_path -f}
13
44
 
14
45
  ENV['APP_SPACE'] = 'app-space'
15
46
  ENV['APP_NAME'] = 'simpleapp'
@@ -21,7 +52,6 @@ describe PcfBlueGreen do
21
52
  ENV['green'] = 'simpleapp-app-space-green'
22
53
 
23
54
  space = ENV['APP_SPACE']
24
- app = ENV['APP_NAME']
25
55
  api_url = ENV['cf_api']
26
56
  username = ENV['cf_user']
27
57
  password = ENV['cf_password']
@@ -29,139 +59,12 @@ describe PcfBlueGreen do
29
59
 
30
60
 
31
61
  @pcf_blue_green = PcfBlueGreen::Routing.new(api_url, username, password, org, space, login = false)
32
- @pcf_blue_green.stub(:cf_routes_output).and_return('cat spec/mocks/simple_routes.txt')
33
- @pcf_blue_green.stub(:map_route_command).and_return('echo')
34
- expect(expected_routes).to eq(@pcf_blue_green.remap_routes)
35
- end
36
-
37
- it "it doesn't re-map routes with a path. Also doesn't re-map routes for other applications. Even with the same hostname" do
38
-
39
- expected_routes = %{customapp-app-space-green apps.prod.domain.com -n customapp,
40
- customapp-app-space-green apps.prod.domain.com -n otherapp}
62
+ @pcf_blue_green.stub(:entity_for).and_return(JSON.parse(File.read('spec/mocks/simple_entity.json')))
63
+ @pcf_blue_green.stub(:routes_stdout).and_return(JSON.parse(File.read('spec/mocks/routes_stdout.json')))
64
+ @pcf_blue_green.stub(:domain_for).and_return("app.domain.com")
65
+ @pcf_blue_green.stub(:delete_route_command).and_return('echo')
41
66
 
42
-
43
- ENV['APP_SPACE'] = 'app-space'
44
- ENV['APP_NAME'] = 'customapp'
45
- ENV['cf_app'] = 'customapp'
46
- ENV['cf_api'] = 'https://api.sys.sandbox.test.com'
47
- ENV['cf_user'] = 'testuser'
48
- ENV['cf_password'] = 'password'
49
- ENV['cf_org'] = 'ds'
50
- ENV['green'] = 'customapp-app-space-green'
51
-
52
- space = ENV['APP_SPACE']
53
- app = ENV['APP_NAME']
54
- api_url = ENV['cf_api']
55
- username = ENV['cf_user']
56
- password = ENV['cf_password']
57
- org = ENV['cf_org']
58
-
59
-
60
- @pcf_blue_green = PcfBlueGreen::Routing.new(api_url, username, password, org, space, login = false)
61
- @pcf_blue_green.stub(:cf_routes_output).and_return('cat spec/mocks/custom_routes.txt')
62
- @pcf_blue_green.stub(:map_route_command).and_return('echo')
63
- expect(expected_routes).to eq(@pcf_blue_green.remap_routes)
67
+ expect(expected_routes).to eq(@pcf_blue_green.remove_routes)
64
68
  end
65
69
  end
66
-
67
- context 'handle_all_paths' do
68
- it "re-maps the application routes including paths and custom domains" do
69
-
70
- expected_routes = %{customapp-app-space-green apps.prod.domain.com -n customapp --path somepath1,
71
- customapp-app-space-green apps.prod.domain.com -n otherapp --path somepath2,
72
- customapp-app-space-green apps.prod.domain.com -n otherapp --path somepath3,
73
- customapp-app-space-green apps.prod.domain.com -n customapp,
74
- customapp-app-space-green apps.prod.domain.com -n otherapp}
75
-
76
-
77
- ENV['APP_SPACE'] = 'app-space'
78
- ENV['APP_NAME'] = 'customapp'
79
- ENV['cf_app'] = 'customapp'
80
- ENV['cf_api'] = 'https://api.sys.sandbox.test.com'
81
- ENV['cf_user'] = 'testuser'
82
- ENV['cf_password'] = 'password'
83
- ENV['cf_org'] = 'ds'
84
- ENV['green'] = 'customapp-app-space-green'
85
- ENV['handle_all_paths'] = 'true'
86
-
87
- space = ENV['APP_SPACE']
88
- app = ENV['APP_NAME']
89
- api_url = ENV['cf_api']
90
- username = ENV['cf_user']
91
- password = ENV['cf_password']
92
- org = ENV['cf_org']
93
-
94
-
95
- @pcf_blue_green = PcfBlueGreen::Routing.new(api_url, username, password, org, space, login = false)
96
- @pcf_blue_green.stub(:cf_routes_output).and_return('cat spec/mocks/custom_routes.txt')
97
- @pcf_blue_green.stub(:map_route_command).and_return('echo')
98
- expect(expected_routes).to eq(@pcf_blue_green.remap_routes)
99
- end
100
- it "re-maps application routes including paths" do
101
-
102
- expected_routes = %{second-app-app-space-green apps.prod.domain.com.com -n third-app --path firstapp-path1,
103
- second-app-app-space-green apps.prod.domain.com.com -n third-app --path firstapp-path2,
104
- second-app-app-space-green apps.prod.domain.com.com -n third-app --path firstapp-path3,
105
- second-app-app-space-green apps.prod.domain.com.com -n third-app --path firstapp-path4,
106
- second-app-app-space-green apps.prod.domain.com.com -n third-app --path firstapp-path5,
107
- second-app-app-space-green apps.prod.domain.com.com -n third-app --path secondapp-path,
108
- second-app-app-space-green apps.prod.domain.com.com -n second-app}
109
-
110
-
111
- ENV['APP_SPACE'] = 'app-space'
112
- ENV['APP_NAME'] = 'second-app'
113
- ENV['cf_app'] = 'second-app'
114
- ENV['cf_api'] = 'https://api.sys.sandbox.test.com'
115
- ENV['cf_user'] = 'testuser'
116
- ENV['cf_password'] = 'password'
117
- ENV['cf_org'] = 'ds'
118
- ENV['green'] = 'second-app-app-space-green'
119
- ENV['handle_all_paths'] = 'true'
120
-
121
- space = ENV['APP_SPACE']
122
- app = ENV['APP_NAME']
123
- api_url = ENV['cf_api']
124
- username = ENV['cf_user']
125
- password = ENV['cf_password']
126
- org = ENV['cf_org']
127
-
128
-
129
- @pcf_blue_green = PcfBlueGreen::Routing.new(api_url, username, password, org, space, login = false)
130
- @pcf_blue_green.stub(:cf_routes_output).and_return('cat spec/mocks/custom_routes_domain_host.txt')
131
- @pcf_blue_green.stub(:map_route_command).and_return('echo')
132
- expect(expected_routes).to eq(@pcf_blue_green.remap_routes)
133
- end
134
-
135
- it "re-maps application routes including paths. Also true for custom domain and host" do
136
-
137
- expected_routes = %{third-app-app-space-green apps.prod.domain.com.com -n third-app,
138
- third-app-app-space-green apps.prod.otherdomain.com -n third-app,
139
- third-app-app-space-green apps.prod.otherdomain.com -n third-app-other-host}
140
-
141
-
142
- ENV['APP_SPACE'] = 'app-space'
143
- ENV['APP_NAME'] = 'third-app'
144
- ENV['cf_app'] = 'third-app'
145
- ENV['cf_api'] = 'https://api.sys.sandbox.test.com'
146
- ENV['cf_user'] = 'testuser'
147
- ENV['cf_password'] = 'password'
148
- ENV['cf_org'] = 'ds'
149
- ENV['green'] = 'third-app-app-space-green'
150
- ENV['handle_all_paths'] = 'true'
151
-
152
- space = ENV['APP_SPACE']
153
- app = ENV['APP_NAME']
154
- api_url = ENV['cf_api']
155
- username = ENV['cf_user']
156
- password = ENV['cf_password']
157
- org = ENV['cf_org']
158
-
159
-
160
- @pcf_blue_green = PcfBlueGreen::Routing.new(api_url, username, password, org, space, login = false)
161
- @pcf_blue_green.stub(:cf_routes_output).and_return('cat spec/mocks/custom_routes_domain_host.txt')
162
- @pcf_blue_green.stub(:map_route_command).and_return('echo')
163
- expect(expected_routes).to eq(@pcf_blue_green.remap_routes)
164
- end
165
- end
166
- end
167
- end
70
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pcf_blue_green
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.38'
4
+ version: '0.41'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pawel Bardzinski
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-30 00:00:00.000000000 Z
11
+ date: 2017-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout
@@ -108,7 +108,8 @@ files:
108
108
  - pcf_blue_green.gemspec
109
109
  - spec/mocks/custom_routes.txt
110
110
  - spec/mocks/custom_routes_domain_host.txt
111
- - spec/mocks/simple_routes.txt
111
+ - spec/mocks/routes_stdout.json
112
+ - spec/mocks/simple_entity.json
112
113
  - spec/pcf_blue_green_spec.rb
113
114
  - spec/spec_helper.rb
114
115
  homepage: https://github.com/aaa-ncnu-ie/pcf_blue_green
@@ -1,6 +0,0 @@
1
-
2
-
3
- space host domain port path type apps service
4
- app-space simpleapp apps.prod.domain.com simpleapp
5
- app-space otherapp apps.prod.domain.com otherapp
6
- app-space otherapp apps.prod.domain.com /validate otherapp