pogo 2.31.2 → 2.32.14
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/pogo +5 -4
- data/lib/heroku.rb +6 -11
- data/lib/heroku/auth.rb +22 -5
- data/lib/heroku/client/heroku_postgresql.rb +52 -22
- data/lib/heroku/client/rendezvous.rb +5 -2
- data/lib/heroku/command.rb +42 -21
- data/lib/heroku/command/apps.rb +2 -2
- data/lib/heroku/command/labs.rb +65 -79
- data/lib/heroku/command/pg.rb +55 -66
- data/lib/heroku/command/pgbackups.rb +29 -9
- data/lib/heroku/command/plugins.rb +1 -1
- data/lib/heroku/command/run.rb +3 -1
- data/lib/heroku/command/status.rb +1 -1
- data/lib/heroku/excon.rb +9 -0
- data/lib/heroku/helpers.rb +4 -0
- data/lib/heroku/helpers/heroku_postgresql.rb +110 -56
- data/lib/heroku/updater.rb +70 -66
- data/lib/heroku/version.rb +1 -1
- data/spec/heroku/client/heroku_postgresql_spec.rb +55 -18
- data/spec/heroku/command/addons_spec.rb +18 -2
- data/spec/heroku/command/labs_spec.rb +10 -9
- data/spec/heroku/command/pg_spec.rb +56 -43
- data/spec/heroku/command/pgbackups_spec.rb +28 -6
- data/spec/heroku/command_spec.rb +2 -2
- data/spec/heroku/helpers/heroku_postgresql_spec.rb +65 -47
- metadata +6 -5
data/lib/heroku/updater.rb
CHANGED
@@ -5,8 +5,8 @@ require 'heroku/helpers'
|
|
5
5
|
module Heroku
|
6
6
|
module Updater
|
7
7
|
|
8
|
-
def self.
|
9
|
-
File.join(Heroku::Helpers.home_directory, ".heroku", "
|
8
|
+
def self.updating_lock_path
|
9
|
+
File.join(Heroku::Helpers.home_directory, ".heroku", "updating")
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.installed_client_path
|
@@ -47,67 +47,72 @@ module Heroku
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
def self.
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
def self.wait_for_lock(path, wait_for=5, check_every=0.5)
|
51
|
+
start = Time.now.to_i
|
52
|
+
while File.exists?(path)
|
53
|
+
sleep check_every
|
54
|
+
if (Time.now.to_i - start) > wait_for
|
55
|
+
Heroku::Helpers.error "Unable to acquire update lock"
|
54
56
|
end
|
55
57
|
end
|
58
|
+
begin
|
59
|
+
FileUtils.touch path
|
60
|
+
ret = yield
|
61
|
+
ensure
|
62
|
+
FileUtils.rm_f path
|
63
|
+
end
|
64
|
+
ret
|
65
|
+
end
|
56
66
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
require "zip/zip"
|
61
|
-
|
62
|
-
latest_version = Heroku::Helpers.json_decode(Excon.get('http://rubygems.org/api/v1/gems/heroku.json', :nonblock => false).body)['version']
|
63
|
-
|
64
|
-
if compare_versions(latest_version, latest_local_version) > 0
|
65
|
-
Dir.mktmpdir do |download_dir|
|
66
|
-
|
67
|
-
# follow redirect, if one exists
|
68
|
-
headers = Excon.head(
|
69
|
-
url,
|
70
|
-
:headers => {
|
71
|
-
'User-Agent' => Heroku.user_agent
|
72
|
-
},
|
73
|
-
:nonblack => false
|
74
|
-
).headers
|
75
|
-
if headers['Location']
|
76
|
-
url = headers['Location']
|
77
|
-
end
|
67
|
+
def self.autoupdate?
|
68
|
+
true
|
69
|
+
end
|
78
70
|
|
79
|
-
|
80
|
-
|
81
|
-
|
71
|
+
def self.update(url, autoupdate=false)
|
72
|
+
wait_for_lock(updating_lock_path, 5) do
|
73
|
+
require "excon"
|
74
|
+
require "heroku"
|
75
|
+
require "heroku/excon"
|
76
|
+
require "tmpdir"
|
77
|
+
require "zip/zip"
|
78
|
+
|
79
|
+
latest_version = Excon.get_with_redirect("http://assets.heroku.com/heroku-client/VERSION", :nonblock => false).body.chomp
|
80
|
+
|
81
|
+
if compare_versions(latest_version, latest_local_version) > 0
|
82
|
+
Dir.mktmpdir do |download_dir|
|
83
|
+
File.open("#{download_dir}/heroku.zip", "wb") do |file|
|
84
|
+
file.print Excon.get_with_redirect(url, :nonblock => false).body
|
85
|
+
end
|
82
86
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
87
|
+
Zip::ZipFile.open("#{download_dir}/heroku.zip") do |zip|
|
88
|
+
zip.each do |entry|
|
89
|
+
target = File.join(download_dir, entry.to_s)
|
90
|
+
FileUtils.mkdir_p File.dirname(target)
|
91
|
+
zip.extract(entry, target) { true }
|
92
|
+
end
|
88
93
|
end
|
89
|
-
end
|
90
94
|
|
91
|
-
|
95
|
+
FileUtils.rm "#{download_dir}/heroku.zip"
|
92
96
|
|
93
|
-
|
94
|
-
|
97
|
+
old_version = latest_local_version
|
98
|
+
new_version = client_version_from_path(download_dir)
|
95
99
|
|
96
|
-
|
97
|
-
|
98
|
-
|
100
|
+
if compare_versions(new_version, old_version) < 0 && !autoupdate
|
101
|
+
Heroku::Helpers.error("Installed version (#{old_version}) is newer than the latest available update (#{new_version})")
|
102
|
+
end
|
99
103
|
|
100
|
-
|
101
|
-
|
102
|
-
|
104
|
+
FileUtils.rm_rf updated_client_path
|
105
|
+
FileUtils.mkdir_p File.dirname(updated_client_path)
|
106
|
+
FileUtils.cp_r download_dir, updated_client_path
|
103
107
|
|
104
|
-
|
108
|
+
new_version
|
109
|
+
end
|
110
|
+
else
|
111
|
+
false # already up to date
|
105
112
|
end
|
106
|
-
else
|
107
|
-
false # already up to date
|
108
113
|
end
|
109
114
|
ensure
|
110
|
-
FileUtils.rm_f(
|
115
|
+
FileUtils.rm_f(updating_lock_path)
|
111
116
|
end
|
112
117
|
|
113
118
|
def self.compare_versions(first_version, second_version)
|
@@ -130,29 +135,28 @@ module Heroku
|
|
130
135
|
background_update!
|
131
136
|
end
|
132
137
|
|
133
|
-
def self.
|
134
|
-
|
138
|
+
def self.last_autoupdate_path
|
139
|
+
File.join(Heroku::Helpers.home_directory, ".heroku", "autoupdate.last")
|
135
140
|
end
|
136
141
|
|
137
142
|
def self.background_update!
|
138
|
-
#
|
139
|
-
|
140
|
-
|
141
|
-
FileUtils.touch(File.join(Heroku::Helpers.home_directory, '.heroku', 'autoupdate'))
|
143
|
+
# if we've updated in the last 300 seconds, dont try again
|
144
|
+
if File.exists?(last_autoupdate_path)
|
145
|
+
return if (Time.now.to_i - File.mtime(last_autoupdate_path).to_i) < 300
|
142
146
|
end
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
exec("heroku update &> #{log_path}")
|
150
|
-
end
|
151
|
-
else
|
152
|
-
spawn(ENV.to_hash.merge({'HEROKU_AUTOUPDATE' => 'true'}), "heroku update", {:err => :out, :out => log_path})
|
147
|
+
log_path = File.join(Heroku::Helpers.home_directory, '.heroku', 'autoupdate.log')
|
148
|
+
FileUtils.mkdir_p File.dirname(log_path)
|
149
|
+
heroku_binary = File.expand_path($0)
|
150
|
+
pid = if defined?(RUBY_VERSION) and RUBY_VERSION =~ /^1\.8\.\d+/
|
151
|
+
fork do
|
152
|
+
exec("\"#{heroku_binary}\" update &> #{log_path} 2>&1")
|
153
153
|
end
|
154
|
-
|
154
|
+
else
|
155
|
+
spawn("\"#{heroku_binary}\" update", {:err => log_path, :out => log_path})
|
155
156
|
end
|
157
|
+
Process.detach(pid)
|
158
|
+
FileUtils.mkdir_p File.dirname(last_autoupdate_path)
|
159
|
+
FileUtils.touch last_autoupdate_path
|
156
160
|
end
|
157
161
|
end
|
158
162
|
end
|
data/lib/heroku/version.rb
CHANGED
@@ -3,32 +3,69 @@ require "heroku/client/heroku_postgresql"
|
|
3
3
|
require "digest"
|
4
4
|
|
5
5
|
describe Heroku::Client::HerokuPostgresql do
|
6
|
-
|
7
6
|
include Heroku::Helpers
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
before do
|
9
|
+
Heroku::Auth.stub :user => 'user@example.com', :password => 'apitoken'
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:attachment) { double('attachment', :resource_name => 'something-something-42', :starter_plan? => false) }
|
13
|
+
let(:client) { Heroku::Client::HerokuPostgresql.new(attachment) }
|
14
|
+
|
15
|
+
describe 'api choosing' do
|
16
|
+
it "sends an ingress request to the client for production plans" do
|
17
|
+
attachment.stub! :starter_plan? => false
|
18
|
+
host = 'postgres-api.heroku.com'
|
19
|
+
url = "https://user@example.com:apitoken@#{host}/client/v11/databases/#{attachment.resource_name}/ingress"
|
20
|
+
|
21
|
+
stub_request(:put, url).to_return(
|
22
|
+
:body => json_encode({"message" => "ok"}),
|
23
|
+
:status => 200
|
24
|
+
)
|
12
25
|
|
13
|
-
|
14
|
-
url = "https://shogun.heroku.com/client/v10/databases/#{url_sha}/ingress"
|
26
|
+
client.ingress
|
15
27
|
|
16
|
-
|
17
|
-
|
18
|
-
:status => 200
|
19
|
-
)
|
28
|
+
a_request(:put, url).should have_been_made.once
|
29
|
+
end
|
20
30
|
|
21
|
-
client
|
31
|
+
it "sends an ingress request to the client for production plans" do
|
32
|
+
attachment.stub! :starter_plan? => true
|
33
|
+
host = 'postgres-starter-api.heroku.com'
|
34
|
+
url = "https://user@example.com:apitoken@#{host}/client/v11/databases/#{attachment.resource_name}/ingress"
|
22
35
|
|
23
|
-
|
36
|
+
stub_request(:put, url).to_return(
|
37
|
+
:body => json_encode({"message" => "ok"}),
|
38
|
+
:status => 200
|
39
|
+
)
|
40
|
+
|
41
|
+
client.ingress
|
42
|
+
|
43
|
+
a_request(:put, url).should have_been_made.once
|
44
|
+
end
|
24
45
|
end
|
25
46
|
|
26
|
-
|
27
|
-
url
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
47
|
+
describe '#get_database' do
|
48
|
+
let(:url) { "https://user@example.com:apitoken@postgres-api.heroku.com/client/v11/databases/#{attachment.resource_name}" }
|
49
|
+
|
50
|
+
it 'works without the extended option' do
|
51
|
+
stub_request(:get, url).to_return :body => '{}'
|
52
|
+
client.get_database
|
53
|
+
a_request(:get, url).should have_been_made.once
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'works with the extended option' do
|
57
|
+
url2 = url + '?extended=true'
|
58
|
+
stub_request(:get, url2).to_return :body => '{}'
|
59
|
+
client.get_database(true)
|
60
|
+
a_request(:get, url2).should have_been_made.once
|
61
|
+
end
|
62
|
+
|
63
|
+
it "retries on error, then raises" do
|
64
|
+
stub_request(:get, url).to_return(:body => "error", :status => 500)
|
65
|
+
client.stub(:sleep)
|
66
|
+
lambda { client.get_database }.should raise_error RestClient::InternalServerError
|
67
|
+
a_request(:get, url).should have_been_made.times(4)
|
68
|
+
end
|
32
69
|
end
|
33
70
|
|
34
71
|
end
|
@@ -195,9 +195,25 @@ STDOUT
|
|
195
195
|
|
196
196
|
it "should translate --fork and --follow" do
|
197
197
|
%w{fork follow}.each do |switch|
|
198
|
-
@addons.stub!(:app_config_vars).and_return({
|
198
|
+
@addons.stub!(:app_config_vars).and_return({})
|
199
|
+
@addons.stub!(:app_attachments).and_return([Heroku::Helpers::HerokuPostgresql::Attachment.new({
|
200
|
+
'config_var' => 'HEROKU_POSTGRESQL_RED_URL',
|
201
|
+
'resource' => {'name' => 'loudly-yelling-1232',
|
202
|
+
'value' => 'postgres://red_url',
|
203
|
+
'type' => 'heroku-postgresql:ronin' }})
|
204
|
+
])
|
199
205
|
@addons.stub!(:args).and_return("heroku-postgresql --#{switch} HEROKU_POSTGRESQL_RED".split)
|
200
|
-
@addons.heroku.should_receive(:install_addon).with('myapp', 'heroku-postgresql', {switch => '
|
206
|
+
@addons.heroku.should_receive(:install_addon).with('myapp', 'heroku-postgresql', {switch => 'postgres://red_url'})
|
207
|
+
@addons.add
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
it "should NOT translate --fork and --follow if passed in a full postgres url even if there are no databases" do
|
212
|
+
%w{fork follow}.each do |switch|
|
213
|
+
@addons.stub!(:app_config_vars).and_return({})
|
214
|
+
@addons.stub!(:app_attachments).and_return([])
|
215
|
+
@addons.stub!(:args).and_return("heroku-postgresql --#{switch} postgres://foo:yeah@awesome.com:234/bestdb".split)
|
216
|
+
@addons.heroku.should_receive(:install_addon).with('myapp', 'heroku-postgresql', {switch => 'postgres://foo:yeah@awesome.com:234/bestdb'})
|
201
217
|
@addons.add
|
202
218
|
end
|
203
219
|
end
|
@@ -18,13 +18,12 @@ module Heroku::Command
|
|
18
18
|
stderr, stdout = execute("labs:list")
|
19
19
|
stderr.should == ""
|
20
20
|
stdout.should == <<-STDOUT
|
21
|
-
===
|
22
|
-
|
23
|
-
user_env_compile: Add user config vars to the environment during slug compilation
|
24
|
-
|
25
|
-
=== User Available Features
|
26
|
-
sumo-rankings: Heroku Sumo ranks and visualizes the scale of your app, and suggests the optimum combination of dynos and add-ons to take it to the next level.
|
21
|
+
=== User Features (email@example.com)
|
22
|
+
[ ] sumo-rankings Heroku Sumo ranks and visualizes the scale of your app, and suggests the optimum combination of dynos and add-ons to take it to the next level.
|
27
23
|
|
24
|
+
=== App Features (myapp)
|
25
|
+
[+] sigterm-all When stopping a dyno, send SIGTERM to all processes rather than only to the root process.
|
26
|
+
[ ] user_env_compile Add user config vars to the environment during slug compilation
|
28
27
|
STDOUT
|
29
28
|
end
|
30
29
|
|
@@ -33,10 +32,12 @@ STDOUT
|
|
33
32
|
stderr, stdout = execute("labs")
|
34
33
|
stderr.should == ""
|
35
34
|
stdout.should == <<-STDOUT
|
36
|
-
===
|
37
|
-
|
35
|
+
=== User Features (email@example.com)
|
36
|
+
[ ] sumo-rankings Heroku Sumo ranks and visualizes the scale of your app, and suggests the optimum combination of dynos and add-ons to take it to the next level.
|
38
37
|
|
39
|
-
|
38
|
+
=== App Features (myapp)
|
39
|
+
[+] sigterm-all When stopping a dyno, send SIGTERM to all processes rather than only to the root process.
|
40
|
+
[ ] user_env_compile Add user config vars to the environment during slug compilation
|
40
41
|
STDOUT
|
41
42
|
end
|
42
43
|
|
@@ -9,9 +9,30 @@ module Heroku::Command
|
|
9
9
|
api.post_app "name" => "myapp"
|
10
10
|
api.put_config_vars "myapp", {
|
11
11
|
"DATABASE_URL" => "postgres://database_url",
|
12
|
-
"SHARED_DATABASE_URL" => "postgres://
|
12
|
+
"SHARED_DATABASE_URL" => "postgres://shared_database_url",
|
13
|
+
"HEROKU_POSTGRESQL_IVORY_URL" => "postgres://database_url",
|
13
14
|
"HEROKU_POSTGRESQL_RONIN_URL" => "postgres://ronin_database_url"
|
14
15
|
}
|
16
|
+
|
17
|
+
any_instance_of(Heroku::Command::Pg) do |pg|
|
18
|
+
stub(pg).app_attachments.returns([
|
19
|
+
Heroku::Helpers::HerokuPostgresql::Attachment.new({
|
20
|
+
'config_var' => 'HEROKU_POSTGRESQL_IVORY_URL',
|
21
|
+
'resource' => {'name' => 'loudly-yelling-1232',
|
22
|
+
'value' => 'postgres://database_url',
|
23
|
+
'type' => 'heroku-postgresql:ronin' }}),
|
24
|
+
Heroku::Helpers::HerokuPostgresql::Attachment.new({
|
25
|
+
'config_var' => 'HEROKU_POSTGRESQL_RONIN_URL',
|
26
|
+
'resource' => {'name' => 'softly-mocking-123',
|
27
|
+
'value' => 'postgres://ronin_database_url',
|
28
|
+
'type' => 'heroku-postgresql:ronin' }}),
|
29
|
+
Heroku::Helpers::HerokuPostgresql::Attachment.new({
|
30
|
+
'config_var' => 'HEROKU_POSTGRESQL_FOLLOW_URL',
|
31
|
+
'resource' => {'name' => 'whatever-somethign-2323',
|
32
|
+
'value' => 'postgres://follow_database_url',
|
33
|
+
'type' => 'heroku-postgresql:ronin' }})
|
34
|
+
])
|
35
|
+
end
|
15
36
|
end
|
16
37
|
|
17
38
|
after do
|
@@ -24,7 +45,7 @@ module Heroku::Command
|
|
24
45
|
stderr, stdout = execute("pg:reset RONIN --confirm myapp")
|
25
46
|
stderr.should == ""
|
26
47
|
stdout.should == <<-STDOUT
|
27
|
-
Resetting
|
48
|
+
Resetting HEROKU_POSTGRESQL_RONIN_URL... done
|
28
49
|
STDOUT
|
29
50
|
end
|
30
51
|
|
@@ -63,14 +84,33 @@ STDERR
|
|
63
84
|
{"name"=>"PG Version", "values"=>["9.1.4"]},
|
64
85
|
{"name"=>"Fork/Follow", "values"=>["Available"]},
|
65
86
|
{"name"=>"Created", "values"=>["2011-12-13 00:00 UTC"]},
|
66
|
-
{"name"=>"Conn Info", "values"=>["[Deprecated] Please use `heroku pg:credentials HEROKU_POSTGRESQL_RONIN` to view connection info"]},
|
67
87
|
{"name"=>"Maintenance", "values"=>["not required"]}
|
68
88
|
])
|
69
89
|
|
70
90
|
stderr, stdout = execute("pg")
|
71
91
|
stderr.should == ""
|
72
92
|
stdout.should == <<-STDOUT
|
73
|
-
===
|
93
|
+
=== HEROKU_POSTGRESQL_FOLLOW_URL
|
94
|
+
Plan: Ronin
|
95
|
+
Status: available
|
96
|
+
Data Size: 1 MB
|
97
|
+
Tables: 1
|
98
|
+
PG Version: 9.1.4
|
99
|
+
Fork/Follow: Available
|
100
|
+
Created: 2011-12-13 00:00 UTC
|
101
|
+
Maintenance: not required
|
102
|
+
|
103
|
+
=== HEROKU_POSTGRESQL_IVORY_URL (DATABASE_URL)
|
104
|
+
Plan: Ronin
|
105
|
+
Status: available
|
106
|
+
Data Size: 1 MB
|
107
|
+
Tables: 1
|
108
|
+
PG Version: 9.1.4
|
109
|
+
Fork/Follow: Available
|
110
|
+
Created: 2011-12-13 00:00 UTC
|
111
|
+
Maintenance: not required
|
112
|
+
|
113
|
+
=== HEROKU_POSTGRESQL_RONIN_URL
|
74
114
|
Plan: Ronin
|
75
115
|
Status: available
|
76
116
|
Data Size: 1 MB
|
@@ -78,7 +118,6 @@ Tables: 1
|
|
78
118
|
PG Version: 9.1.4
|
79
119
|
Fork/Follow: Available
|
80
120
|
Created: 2011-12-13 00:00 UTC
|
81
|
-
Conn Info: [Deprecated] Please use `heroku pg:credentials HEROKU_POSTGRESQL_RONIN` to view connection info
|
82
121
|
Maintenance: not required
|
83
122
|
|
84
123
|
=== SHARED_DATABASE
|
@@ -99,14 +138,13 @@ STDOUT
|
|
99
138
|
{"name"=>"Fork/Follow", "values"=>["Available"]},
|
100
139
|
{"name"=>"Forked From", "values"=>["postgres://username:password@postgreshost.com:5432/database_name"], "resolve_db_name" => "true"},
|
101
140
|
{"name"=>"Created", "values"=>["2011-12-13 00:00 UTC"]},
|
102
|
-
{"name"=>"Conn Info", "values"=>["[Deprecated] Please use `heroku pg:credentials HEROKU_POSTGRESQL_RONIN` to view connection info"]},
|
103
141
|
{"name"=>"Maintenance", "values"=>["not required"]}
|
104
142
|
])
|
105
143
|
|
106
144
|
stderr, stdout = execute("pg:info RONIN")
|
107
145
|
stderr.should == ""
|
108
146
|
stdout.should == <<-STDOUT
|
109
|
-
===
|
147
|
+
=== HEROKU_POSTGRESQL_RONIN_URL
|
110
148
|
Plan: Ronin
|
111
149
|
Status: available
|
112
150
|
Data Size: 1 MB
|
@@ -115,7 +153,6 @@ PG Version: 9.1.4
|
|
115
153
|
Fork/Follow: Available
|
116
154
|
Forked From: Database on postgreshost.com:5432/database_name
|
117
155
|
Created: 2011-12-13 00:00 UTC
|
118
|
-
Conn Info: [Deprecated] Please use `heroku pg:credentials HEROKU_POSTGRESQL_RONIN` to view connection info
|
119
156
|
Maintenance: not required
|
120
157
|
|
121
158
|
STDOUT
|
@@ -127,19 +164,11 @@ STDOUT
|
|
127
164
|
stderr, stdout = execute("pg:promote RONIN --confirm myapp")
|
128
165
|
stderr.should == ""
|
129
166
|
stdout.should == <<-STDOUT
|
130
|
-
Promoting
|
167
|
+
Promoting HEROKU_POSTGRESQL_RONIN_URL to DATABASE_URL... done
|
131
168
|
STDOUT
|
132
169
|
api.get_config_vars("myapp").body["DATABASE_URL"].should == "postgres://ronin_database_url"
|
133
170
|
end
|
134
171
|
|
135
|
-
it "promotes the specified database url case-sensitively" do
|
136
|
-
stderr, stdout = execute("pg:promote postgres://john:S3nsit1ve@my.example.com/db_name --confirm=myapp")
|
137
|
-
stderr.should == ""
|
138
|
-
stdout.should == <<-STDOUT
|
139
|
-
Promoting Custom URL to DATABASE_URL... done
|
140
|
-
STDOUT
|
141
|
-
end
|
142
|
-
|
143
172
|
it "fails if no database is specified" do
|
144
173
|
stderr, stdout = execute("pg:promote")
|
145
174
|
stderr.should == <<-STDERR
|
@@ -151,20 +180,13 @@ STDERR
|
|
151
180
|
end
|
152
181
|
|
153
182
|
context "credential resets" do
|
154
|
-
before do
|
155
|
-
api.put_config_vars "myapp", {
|
156
|
-
"DATABASE_URL" => "postgres:///to_reset_credentials",
|
157
|
-
"HEROKU_POSTGRESQL_RESETME_URL" => "postgres:///to_reset_credentials"
|
158
|
-
}
|
159
|
-
end
|
160
|
-
|
161
183
|
it "resets credentials and promotes to DATABASE_URL if it's the main DB" do
|
162
184
|
stub_pg.rotate_credentials
|
163
|
-
stderr, stdout = execute("pg:credentials
|
164
|
-
stderr.should
|
185
|
+
stderr, stdout = execute("pg:credentials iv --reset")
|
186
|
+
stderr.should == ''
|
165
187
|
stdout.should == <<-STDOUT
|
166
|
-
Resetting credentials for
|
167
|
-
Promoting
|
188
|
+
Resetting credentials for HEROKU_POSTGRESQL_IVORY_URL (DATABASE_URL)... done
|
189
|
+
Promoting HEROKU_POSTGRESQL_IVORY_URL (DATABASE_URL)... done
|
168
190
|
STDOUT
|
169
191
|
end
|
170
192
|
|
@@ -174,26 +196,17 @@ STDOUT
|
|
174
196
|
"DATABASE_URL" => "postgres://to_reset_credentials",
|
175
197
|
"HEROKU_POSTGRESQL_RESETME_URL" => "postgres://something_else"
|
176
198
|
}
|
177
|
-
stderr, stdout = execute("pg:credentials
|
178
|
-
stderr.should
|
199
|
+
stderr, stdout = execute("pg:credentials follo --reset")
|
200
|
+
stderr.should == ''
|
179
201
|
stdout.should_not include("Promoting")
|
180
202
|
end
|
181
203
|
|
182
204
|
end
|
183
205
|
|
184
206
|
context "unfollow" do
|
185
|
-
before do
|
186
|
-
api.put_config_vars "myapp", {
|
187
|
-
"DATABASE_URL" => "postgres://database_url",
|
188
|
-
"SHARED_DATABASE_URL" => "postgres://other_database_url",
|
189
|
-
"HEROKU_POSTGRESQL_RONIN_URL" => "postgres://ronin_database_url",
|
190
|
-
"HEROKU_POSTGRESQL_OTHER_URL" => "postgres://other_database_url"
|
191
|
-
}
|
192
|
-
end
|
193
|
-
|
194
207
|
it "sends request to unfollow" do
|
195
208
|
hpg_client = double('Heroku::Client::HerokuPostgresql')
|
196
|
-
Heroku::Client::HerokuPostgresql.should_receive(:new).twice.
|
209
|
+
Heroku::Client::HerokuPostgresql.should_receive(:new).twice.and_return(hpg_client)
|
197
210
|
hpg_client.should_receive(:unfollow)
|
198
211
|
hpg_client.should_receive(:get_database).and_return(
|
199
212
|
:following => 'postgresql://user:pass@roninhost/database',
|
@@ -209,12 +222,12 @@ STDOUT
|
|
209
222
|
{"name"=>"Maintenance", "values"=>["not required"]}
|
210
223
|
]
|
211
224
|
)
|
212
|
-
stderr, stdout = execute("pg:unfollow
|
225
|
+
stderr, stdout = execute("pg:unfollow HEROKU_POSTGRESQL_FOLLOW_URL --confirm myapp")
|
213
226
|
stderr.should == ""
|
214
227
|
stdout.should == <<-STDOUT
|
215
|
-
!
|
228
|
+
! HEROKU_POSTGRESQL_FOLLOW_URL will become writable and no longer
|
216
229
|
! follow Database on roninhost:5432/database. This cannot be undone.
|
217
|
-
Unfollowing
|
230
|
+
Unfollowing HEROKU_POSTGRESQL_FOLLOW_URL... done
|
218
231
|
STDOUT
|
219
232
|
end
|
220
233
|
end
|