ey_cloud_server 1.4.51 → 1.4.54

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d033b573b265b7527713823edd15040a173062ab
4
- data.tar.gz: 1a9fb374f6637aed866db0ef7e144ea6428b34d5
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZTdlYWY2NzRmNzI0YjA2ODVlNzBhYWM5ZTQyZTIzODJjMjEyMmJjYw==
5
+ data.tar.gz: !binary |-
6
+ ZDkxZjUxMjA5Njc3MTI3NmViNmEwYmJhMDZlZjgwNTMyNTBkNWIzOQ==
5
7
  SHA512:
6
- metadata.gz: 6742eba6a8c2c2d616d327449976198d15b0c3af0ad331eab0013ab2e96dcc05e8545abca6c3aff855ea74b7ff2fdd8a6a32926e1dcddfba1d482d879e3424b1
7
- data.tar.gz: 6c0ed455138c48e338f5f58f21e6798a39422da374385df8f04d9d9445b8c30ccb3760033aec5ff5fdfc5a9530e007f52912861384f157da3c9aa71b58868041
8
+ metadata.gz: !binary |-
9
+ YmQ1MDQwODBkMWNlYTFkMmI5NzM0YzdhM2UyYzVkNDQyZmNlODJjOTdkNDc0
10
+ YWM3ZjliNjFiZDhhMjc2MmFlZTRjMzU5MjUzY2FhNzQ0ZjkyYTUyZDQzMzM2
11
+ YTQwZjI3MzZmYTZhNTNlYTgzZDg2ZDFiNWNkMzg5ZDZlZDBjMzc=
12
+ data.tar.gz: !binary |-
13
+ MDQwZWY0MzgzMGI4NTI2MTgyMGQ0ZWQ5MzRlM2EzOTI5ZWFlY2EzMzAxMmRi
14
+ MTAwNDI3YzI0ODU4YmY3YzliZTcxNmFlNmNjMWM0Y2I3YzYzMDNkODdmODEx
15
+ ZWM4YTk3NTM3NTM1MGMwZjcxYTc1ODYyM2Q5ZWY5YTRkZTg0YTQ=
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require 'rspec/core/rake_task'
7
7
  desc "Run unit specifications"
8
8
  RSpec::Core::RakeTask.new do |t|
9
9
  t.pattern = 'spec/**/*_spec.rb'
10
- t.rspec_opts = %w(-fs --color --backtrace)
10
+ t.rspec_opts = %w(-fp --color --backtrace)
11
11
  end
12
12
 
13
13
  require 'cucumber/rake/task'
@@ -4,9 +4,11 @@ Feature:
4
4
  And backups for mysql are run
5
5
  When backup "0" for the "first" database is downloaded
6
6
  Then there is a backup file for the "first" database
7
+ And the "first" mysql database is dropped
7
8
 
8
9
  Scenario: no database backup
9
10
  Given there is a mysql database (first)
10
11
  When backup "0" for the "first" database is downloaded
11
12
  Then there is no backup file for the "first" database
12
13
  And stderr contains "No backup found for database"
14
+ And the "first" mysql database is dropped
@@ -3,6 +3,7 @@ Feature:
3
3
  Given there is a postgresql database (first)
4
4
  When listing the backups for the "first" postgresql database
5
5
  Then the output contains "0 backup(s) found"
6
+ And the "first" postgresql database is dropped
6
7
 
7
8
  Scenario: a single backup run
8
9
  Given there is a postgresql database (first)
@@ -10,3 +11,4 @@ Feature:
10
11
  When listing the backups for the "first" postgresql database
11
12
  Then the output contains "1 backup(s) found"
12
13
  And the output contains "0:%s" substituting the "first" postgresql database
14
+ And the "first" postgresql database is dropped
@@ -3,10 +3,12 @@ Feature:
3
3
  Given there is a postgresql database (first)
4
4
  When backup "0" for the "first" database is restored
5
5
  Then stderr contains "No backup found for database"
6
+ And the "first" postgresql database is dropped
6
7
 
7
8
  Scenario: with a backup
8
9
  Given there is a postgresql database (first)
9
10
  And backups for postgresql are run
10
- And the "first" database is dropped
11
+ And the "first" postgresql database is dropped
11
12
  When backup "0" for the "first" database is restored
12
13
  Then the "first" postgresql database exists
14
+ And the "first" postgresql database is dropped
@@ -28,7 +28,7 @@ When \
28
28
  db_name = created_postgresql_dbs[db_key]
29
29
  capturing_stdio do
30
30
  EY::Backup.logger = EY::Backup::Logger.new
31
- EY::Backup.run(["-e", "postgresql", "-r", "#{index}:#{db_name}", "-c", backup_config_file ])
31
+ EY::Backup.run(["-e", "postgresql", "-r", "#{index}:#{db_name}", "-c", backup_config_file, '--force' ])
32
32
  end
33
33
  end
34
34
 
@@ -2,3 +2,9 @@ Given \
2
2
  /^there is a mysql database \(([^\)]*)\)$/ do |db_key|
3
3
  create_mysql_database(db_key)
4
4
  end
5
+
6
+ Given \
7
+ /^the "([^\"]*)" mysql database is dropped$/ do |db_key|
8
+ db_name = created_mysql_dbs[db_key]
9
+ drop_mysql_database(db_name)
10
+ end
@@ -10,6 +10,7 @@ Then \
10
10
  end
11
11
 
12
12
  Given \
13
- /^the "([^\"]*)" database is dropped$/ do |db_key|
14
- drop_postgresql_database(db_key)
13
+ /^the "([^\"]*)" postgresql database is dropped$/ do |db_key|
14
+ db_name = created_postgresql_dbs[db_key]
15
+ drop_postgresql_database(db_name)
15
16
  end
@@ -15,7 +15,7 @@ module EY
15
15
  def start_upload(filenames, environment_name, database_name)
16
16
  filenames.each do |filename|
17
17
  begin
18
- object_name = "#{environment_name}.#{database_name}/#{File.basename(filename)}"
18
+ object_name = File.join("#{environment_name}.#{database_name}", "#{File.basename(filename)}")
19
19
  info "Starting upload: #{filename}"
20
20
  @s3.put_object(@bucket_minder.bucket_name, object_name, File.open(filename,'r'))
21
21
  info "Successful upload: #{filename}"
@@ -38,10 +38,10 @@ module EY
38
38
 
39
39
  backups = databases.map{ |db| db.backups }.flatten
40
40
 
41
- info "#{backups.size} backup(s) found"
41
+ puts "#{backups.size} backup(s) found"
42
42
 
43
43
  backups.each_with_index do |backup_set, i|
44
- info "#{i}:#{backup_set.database_name} #{backup_set.normalized_name}"
44
+ puts "#{i}:#{backup_set.database_name} #{backup_set.normalized_name}"
45
45
  end
46
46
 
47
47
  backups
@@ -80,6 +80,7 @@ module EY
80
80
  @keys.each do |key|
81
81
  info "Downloading #{key} to #{@database.base_path}"
82
82
  remote_filename = File.join(@database.base_path, normalize(key))
83
+ puts "Filename: #{remote_filename}"
83
84
  File.open(remote_filename, 'wb') do |f|
84
85
  @database.bucket_minder.stream(key) do |chunk, remaining_size, total_size|
85
86
  f.write(chunk)
data/lib/ey_backup/cli.rb CHANGED
@@ -36,9 +36,8 @@ module EY
36
36
 
37
37
  opts = OptionParser.new do |opts|
38
38
  opts.version = EY::CloudServer::VERSION
39
- puts '' # add a blank line
40
39
 
41
- opts.banner = "Usage: eybackup [-flag] [argument]"
40
+ opts.banner = "\nUsage: eybackup [-flag] [argument]"
42
41
  opts.define_head " eybackup: manage dump (mysqldump/pg_dump) style backups of your database."
43
42
  opts.separator '*'*80
44
43
 
@@ -39,7 +39,7 @@ module EY
39
39
  end
40
40
 
41
41
  def generate_basename
42
- "#{@base_path}/#{@name}.#{timestamp}"
42
+ File.join(@base_path, "#{@name}.#{timestamp}")
43
43
  end
44
44
 
45
45
  def timestamp
@@ -73,27 +73,24 @@ module EY
73
73
  end
74
74
 
75
75
  def db_has_myisam?(database_name)
76
- query, stdout = "SELECT 1 FROM information_schema.tables WHERE table_schema='#{database_name}' AND engine='MyISAM' LIMIT 1;", StringIO.new
77
- spawn(%Q{mysql #{username_option} #{host_option} -N -e"#{query}"}, stdout)
78
- stdout.string.strip == '1'
76
+ query = "SELECT 1 FROM information_schema.tables WHERE table_schema='#{database_name}' AND engine='MyISAM' LIMIT 1;"
77
+ stdout = %x{mysql #{username_option} #{host_option} -N -e"#{query}"}
78
+ stdout.strip == '1'
79
79
  end
80
80
 
81
81
  def db_replicating?
82
- stdout = StringIO.new
83
- spawn(%Q{mysql #{username_option} #{host_option} -BN -e"show slave status"|wc -l}, stdout)
84
- stdout.string.to_i > 0
82
+ stdout = %x{mysql #{username_option} #{host_option} -BN -e"show slave status"|wc -l}
83
+ stdout.to_i > 0
85
84
  end
86
85
 
87
86
  def read_only_on?
88
- stdout = StringIO.new
89
- spawn(%Q{mysql #{username_option} #{host_option} -BN -e"select @@global.read_only"}, stdout)
90
- stdout.string.to_i == 1
87
+ stdout = %x{mysql #{username_option} #{host_option} -BN -e"select @@global.read_only"}
88
+ stdout.to_i == 1
91
89
  end
92
90
 
93
91
  def log_bin_on?
94
- stdout = StringIO.new
95
- spawn(%Q{mysql #{username_option} #{host_option} -BN -e"select @@global.log_bin"}, stdout)
96
- stdout.string.to_i == 1
92
+ stdout = %x{mysql #{username_option} #{host_option} -BN -e"select @@global.log_bin"}
93
+ stdout.to_i == 1
97
94
  end
98
95
 
99
96
  def cycle_database(database_name)
@@ -35,10 +35,9 @@ module EY
35
35
  end
36
36
 
37
37
  def check_connections(database_name)
38
- stdout = StringIO.new()
39
- active_connections = spawn(%Q{PGPASSWORD='#{password}' psql -U postgres -h #{host} -t -c "select count(*) from pg_stat_activity where datname='#{database_name}';"}, stdout)
38
+ active_connections = %x{PGPASSWORD='#{password}' psql -U postgres -h #{host} -t -c "select count(*) from pg_stat_activity where datname='#{database_name}';"}
40
39
 
41
- if stdout.string.to_i > 0
40
+ if active_connections.to_i > 0
42
41
  res = ''
43
42
  unless force
44
43
  puts "There are currently #{stdout.string.to_i} connections on database: '#{database_name}'; can I kill these to continue (Y/n):"
@@ -56,31 +55,32 @@ module EY
56
55
  end
57
56
 
58
57
  def cancel_connections(database_name)
59
- spawn(%Q{psql -U postgres -h #{host} -c"SELECT pg_terminate_backend(pg_stat_activity.pid)
58
+ %x{psql -U postgres -h #{host} -c"SELECT pg_terminate_backend(pg_stat_activity.pid)
60
59
  FROM pg_stat_activity
61
- WHERE pg_stat_activity.datname = '#{database_name}';"})
60
+ WHERE pg_stat_activity.datname = '#{database_name}';"}
62
61
  end
63
62
 
64
63
  def drop_database(database_name)
65
- spawn("PGPASSWORD='#{password}' dropdb -h #{host} -Upostgres #{database_name}")
64
+ command = "PGPASSWORD='#{password}' dropdb -h #{host} -Upostgres #{database_name}"
65
+ verbose "Dropping Database with: #{command}"
66
+ %x{#{command}}
66
67
  end
67
68
 
68
69
  def create_database(database_name)
69
- spawn("PGPASSWORD='#{password}' createdb -U#{username} -h #{host} #{database_name}")
70
+ command = "PGPASSWORD='#{password}' createdb -U#{username} -h #{host} #{database_name}"
71
+ verbose "Creating Database with: #{command}"
72
+ %x{#{command}}
70
73
  end
71
74
 
72
75
  def check_if_replica
73
- stdout = StringIO.new()
74
- spawn(%Q{PGPASSWORD='#{password}' psql -U postgres -h #{host} -t -c "select pg_is_in_recovery()"| head -n 1}, stdout)
75
- unless stdout.string.chomp =~ /^\W*f$/
76
+ stdout = %x{PGPASSWORD='#{password}' psql -U postgres -h #{host} -t -c "select pg_is_in_recovery()"| head -n 1}
77
+ unless stdout.chomp =~ /^\W*f$/
76
78
  EY::Backup.logger.fatal(%Q{ERROR: Target host: '#{host}' is currently a replica in recovery mode; restore operations need to be processed against the master.})
77
79
  end
78
80
  end
79
81
 
80
82
  def create_command(database_name)
81
- stdout = StringIO.new()
82
-
83
- spawn(%Q{PGPASSWORD='#{password}' psql -U postgres -h #{host} -t -c "SELECT 'CREATE DATABASE ' || datname ||
83
+ %x{PGPASSWORD='#{password}' psql -U postgres -h #{host} -t -c "SELECT 'CREATE DATABASE ' || datname ||
84
84
  ' WITH OWNER ' || pg_user.usename ||
85
85
  CASE (select pg_encoding_to_char(encoding) from pg_database where datname='template1')
86
86
  WHEN pg_encoding_to_char(encoding)
@@ -95,8 +95,7 @@ module EY
95
95
  INNER JOIN pg_user
96
96
  ON pg_user.usesysid = pg_database.datdba
97
97
  WHERE datname = '#{database_name}'"
98
- }, stdout)
99
- stdout.string
98
+ }
100
99
  end
101
100
 
102
101
  def cycle_database(database_name)
@@ -106,7 +105,7 @@ module EY
106
105
  else
107
106
  check_connections(database_name)
108
107
  drop_database(database_name)
109
- spawn(%Q{PGPASSWORD='#{password}' psql -U postgres -h #{host} -t -c "#{create_cmd}"})
108
+ %x{PGPASSWORD='#{password}' psql -U postgres -h #{host} -t -c "#{create_cmd}"}
110
109
  end
111
110
  end
112
111
 
@@ -34,6 +34,8 @@ module EY
34
34
 
35
35
  def join(input_files)
36
36
  filename = input_files.first.sub(/\.part\d+$/, '')
37
+
38
+ verbose "Filename: #{filename}"
37
39
 
38
40
  File.open(filename, 'w') do |output|
39
41
  sort(input_files).each do |input|
@@ -1,3 +1,5 @@
1
+ require 'shellwords'
2
+
1
3
  module EY
2
4
  module Backup
3
5
  module Spawner
@@ -28,20 +30,27 @@ module EY
28
30
  # This is to detect failures anywhere in the pipeline.
29
31
  wrapper = <<-EOT
30
32
  status=0
31
- set -o pipefail
32
33
  #{command}
33
34
  status=$?
34
35
 
35
36
  if [ $status -gt 0 ]; then exit 1; fi
36
37
  EOT
37
38
 
39
+ escaped_command = Shellwords.escape(wrapper)
40
+
38
41
  verbose "Running command: #{command}"
39
- pid, *_ = Open4.popen4(wrapper)
42
+ pid, stdin, stdout, stderr = Open4.popen4("bash -o pipefail -c #{escaped_command}")
40
43
  pid, status = Process::waitpid2(pid)
41
44
 
45
+ verbose "stdout: #{stdout.read}"
46
+ verbose "stderr: #{stderr.read}"
47
+ verbose "status: #{status}"
48
+
42
49
  if ! status.success?
43
- dumperr = File.read("/tmp/eybackup.#{pid}.dumperr")
44
- error("DB dump failed. The error returned was: #{dumperr}", db)
50
+ dumperr = File.exists?("/tmp/eybackup.#{pid}.dumperr") ? File.read("/tmp/eybackup.#{pid}.dumperr") : status
51
+ err_msg = "DB dump failed. The error returned was: #{dumperr}"
52
+ verbose "#{db} backup failed: #{err_msg}"
53
+ error(err_msg, db)
45
54
  end
46
55
 
47
56
  # Clean up:
@@ -1,5 +1,5 @@
1
1
  module EY
2
2
  module CloudServer
3
- VERSION = '1.4.51'
3
+ VERSION = '1.4.54'
4
4
  end
5
5
  end
@@ -6,3 +6,4 @@ module EY
6
6
  end
7
7
 
8
8
  require 'ey_cloud_server/version'
9
+ require 'ey_cloud_server/mysql_start'
data/spec/config.yml CHANGED
@@ -5,7 +5,7 @@ mysql_user: root
5
5
  mysql_password:
6
6
  mysql_host: localhost
7
7
  postgresql_user: postgres
8
- postgresql_password: ketchup
8
+ postgresql_password: grew152
9
9
  postgresql_host: localhost
10
10
  aws_secret_id: 'AKIAIDNXVLT3THIWYMNQ'
11
11
  aws_secret_key: 'DZBOcAI1qpYF0V+ZL2SeA7Jzt15boFxIo+BD7vda'
@@ -4,21 +4,25 @@ describe EY::Backup do
4
4
  before(:each) do
5
5
  @db_name = create_mysql_database('first')
6
6
  end
7
+
8
+ after(:each) do
9
+ drop_mysql_database(@db_name)
10
+ end
7
11
 
8
12
  describe "#list" do
9
13
 
10
14
  it 'prints the database to be listed first' do
11
- EY::Backup.run([ "-c", backup_config_file ])
15
+ EY::Backup.run([ "-c", backup_config_file])
12
16
 
13
17
  reset_logger
14
18
 
15
19
  EY::Backup.run(["-c", backup_config_file, "-l", @db_name])
16
20
 
17
- stdout.should =~ /\AListing database backups for #{@db_name}$/
21
+ stdout.should =~ /Listing database backups for #{@db_name}$/
18
22
  end
19
23
 
20
24
  it 'conforms to the /^\d:#{db_name} #{db_name}\.#{timestamp}\.#{ext}$/ line output' do
21
- EY::Backup.run([ "-c", backup_config_file ])
25
+ EY::Backup.run([ "-c", backup_config_file])
22
26
 
23
27
  reset_logger
24
28
 
@@ -32,7 +36,7 @@ describe EY::Backup do
32
36
  it 'prints all the database names' do
33
37
  @db_name2 = create_mysql_database('second')
34
38
 
35
- EY::Backup.run([ "-c", backup_config_file ])
39
+ EY::Backup.run([ "-c", backup_config_file])
36
40
 
37
41
  reset_logger
38
42
 
@@ -40,6 +44,7 @@ describe EY::Backup do
40
44
 
41
45
  stdout.should =~ /^\d+:#{@db_name}/
42
46
  stdout.should =~ /^\d+:#{@db_name2}/
47
+ drop_mysql_database(@db_name2)
43
48
  end
44
49
  end
45
50
 
@@ -4,6 +4,10 @@ describe "MySQL Backups" do
4
4
  before(:each) do
5
5
  @db_name = create_mysql_database('first')
6
6
  end
7
+
8
+ after(:each) do
9
+ drop_mysql_database(@db_name)
10
+ end
7
11
 
8
12
  describe "--quiet" do
9
13
  it "does not print anything to STDOUT" do
@@ -11,8 +15,11 @@ describe "MySQL Backups" do
11
15
  reset_logger
12
16
  EY::Backup.run(["-c", backup_config_file, '--quiet'])
13
17
  end
18
+
19
+ possibly = last_stdout
20
+ puts "last_stdout == '#{possibly}'"
21
+ possibly.should be_empty
14
22
 
15
- last_stdout.should be_empty
16
23
  end
17
24
 
18
25
  it 'does print to STDOUT without the flag' do
@@ -3,10 +3,18 @@ require File.dirname(__FILE__) + '/spec_helper'
3
3
  describe "MySQL Backups" do
4
4
  before(:each) do
5
5
  @db_name = create_mysql_database('first')
6
+ mk_tmp
7
+ end
8
+
9
+ after(:each) do
10
+ drop_mysql_database(@db_name)
6
11
  end
7
12
 
8
13
  it "makes a backup" do
9
- EY::Backup.run(["-c", backup_config_file ])
14
+ result = capturing_stdio do
15
+ EY::Backup.run(["-c", backup_config_file])
16
+ end
17
+ puts "MySQL Command: #{result}"
10
18
 
11
19
  reset_logger
12
20
 
@@ -35,7 +43,7 @@ describe "MySQL Backups" do
35
43
  run_sql("CREATE TABLE `foo` (`id` int(11) NOT NULL auto_increment, PRIMARY KEY(`id`));", @db_name).should be_true
36
44
  run_sql("CREATE TABLE `bar` (`id` int(11) NOT NULL auto_increment, PRIMARY KEY(`id`));", @db_name).should be_true
37
45
 
38
- EY::Backup.run(["-c", backup_config_file ])
46
+ EY::Backup.run(["-c", backup_config_file, '-v' ])
39
47
 
40
48
  run_sql("DROP TABLE `bar`;", @db_name).should be_true
41
49
  run_sql("SELECT * FROM `bar`;", @db_name).should be_false
@@ -46,7 +54,7 @@ describe "MySQL Backups" do
46
54
 
47
55
  stdout.should include("1 backup(s) found")
48
56
 
49
- EY::Backup.run(["-c", backup_config_file, "-r", "0:#{@db_name}"])
57
+ EY::Backup.run(["-c", backup_config_file, "-r", "0:#{@db_name}", "--force"])
50
58
 
51
59
  run_sql("SELECT * FROM `foo`;", @db_name).should be_true
52
60
  run_sql("SELECT * FROM `bar`;", @db_name).should be_true
@@ -68,7 +76,7 @@ describe "MySQL Backups" do
68
76
 
69
77
  stdout.should include("1 backup(s) found")
70
78
 
71
- EY::Backup.run(["-c", backup_config_file, "-r", "0:#{@db_name}"])
79
+ EY::Backup.run(["-c", backup_config_file, "-r", "0:#{@db_name}", '--force'])
72
80
 
73
81
  run_sql("SELECT * FROM `foo`;", @db_name).should be_true
74
82
  run_sql("SELECT * FROM `bar`;", @db_name).should be_true
@@ -123,6 +131,12 @@ describe "MySQL Backups" do
123
131
  before(:each) do
124
132
  @dbs = [create_mysql_database('first'), create_mysql_database('second')]
125
133
  end
134
+
135
+ after(:each) do
136
+ @dbs.each do |db|
137
+ drop_mysql_database(db)
138
+ end
139
+ end
126
140
 
127
141
  it "makes a backup" do
128
142
  EY::Backup.run(["-c", backup_config_file ])
@@ -141,6 +155,10 @@ describe "a multi-region backup" do
141
155
  before(:each) do
142
156
  @db_name = create_mysql_database('speaking_japanese', 'ap-northeast-1')
143
157
  end
158
+
159
+ after(:each) do
160
+ drop_mysql_database(@db_name)
161
+ end
144
162
 
145
163
  it "makes a split backup" do
146
164
  EY::Backup.run(["-c", backup_config_file, "-s", "100"])
@@ -165,7 +183,7 @@ describe "a multi-region backup" do
165
183
 
166
184
  stdout.should include("1 backup(s) found")
167
185
 
168
- EY::Backup.run(["-c", backup_config_file, "-r", "0:#{@db_name}"])
186
+ EY::Backup.run(["-c", backup_config_file, "-r", "0:#{@db_name}", '--force'])
169
187
 
170
188
  run_sql("SELECT * FROM `foo`;", @db_name).should be_true
171
189
  run_sql("SELECT * FROM `bar`;", @db_name).should be_true
@@ -176,6 +194,10 @@ describe "a multi-region backup" do
176
194
  before(:each) do
177
195
  @db_name = create_mysql_database('speaking_esperanto', 'eu-west-1')
178
196
  end
197
+
198
+ after(:each) do
199
+ drop_mysql_database(@db_name)
200
+ end
179
201
 
180
202
  it "makes a split backup" do
181
203
  EY::Backup.run(["-c", backup_config_file, "-s", "100"])
@@ -200,7 +222,7 @@ describe "a multi-region backup" do
200
222
 
201
223
  stdout.should include("1 backup(s) found")
202
224
 
203
- EY::Backup.run(["-c", backup_config_file, "-r", "0:#{@db_name}"])
225
+ EY::Backup.run(["-c", backup_config_file, "-r", "0:#{@db_name}", '--force'])
204
226
 
205
227
  run_sql("SELECT * FROM `foo`;", @db_name).should be_true
206
228
  run_sql("SELECT * FROM `bar`;", @db_name).should be_true
@@ -4,6 +4,10 @@ describe "Postgres Backups" do
4
4
  before(:each) do
5
5
  @db_name = create_postgresql_database('first')
6
6
  end
7
+
8
+ after(:each) do
9
+ drop_postgresql_database(@db_name)
10
+ end
7
11
 
8
12
  it "makes a custom format backup" do
9
13
  EY::Backup.run(["-c", backup_config_file, "-e", "postgresql"])
@@ -47,7 +51,7 @@ describe "Postgres Backups" do
47
51
 
48
52
  stdout.should include("1 backup(s) found")
49
53
 
50
- EY::Backup.run(["-c", backup_config_file, "-r", "0:#{@db_name}", '-e', 'postgresql'])
54
+ EY::Backup.run(["-c", backup_config_file, "-r", "0:#{@db_name}", '-e', 'postgresql', '--force'])
51
55
 
52
56
  run_psql("SELECT * FROM foo;", @db_name).should be_true
53
57
  run_psql("SELECT * FROM bar;", @db_name).should be_true
@@ -66,9 +70,9 @@ describe "Postgres Backups" do
66
70
  EY::Backup.run(["-c", backup_config_file, "-l", @db_name, '-e', 'postgresql'])
67
71
 
68
72
  stdout.should include("1 backup(s) found")
69
-
70
- EY::Backup.run(["-c", backup_config_file, "-r", "0:#{@db_name}", '-e', 'postgresql'])
71
-
73
+
74
+ EY::Backup.run(["-c", backup_config_file, "-r", "0:#{@db_name}", '-e', 'postgresql', '--force'])
75
+
72
76
  run_psql("SELECT * FROM foo;", @db_name).should be_true
73
77
  run_psql("SELECT * FROM bar;", @db_name).should be_true
74
78
  end
@@ -92,6 +96,12 @@ describe "Postgresql Backups" do
92
96
  before(:each) do
93
97
  @dbs = [create_postgresql_database('first'), create_postgresql_database('second')]
94
98
  end
99
+
100
+ after(:each) do
101
+ @dbs.each do |db|
102
+ drop_postgresql_database(db)
103
+ end
104
+ end
95
105
 
96
106
  it "makes multiple backup" do
97
107
  EY::Backup.run(["-c", backup_config_file, "-e", "postgresql"])
data/spec/helpers.rb CHANGED
@@ -80,13 +80,17 @@ module Helpers
80
80
  def backup_config_file
81
81
  "#{tmp_dir}/spec_backups.yml"
82
82
  end
83
+
84
+ def mk_tmp
85
+ FileUtils.mkdir_p("/tmp")
86
+ end
83
87
 
84
88
  def mysql_password_option
85
89
  mysql_password.nil? ? "" : "-p#{mysql_password}"
86
90
  end
87
91
 
88
92
  def generate_database_name(type)
89
- "ey_flex_#{type}_db_#{/\w{5,7}/.gen}"
93
+ "ey_flex_#{type}_db_#{/\w{5,7}/.gen}".downcase
90
94
  end
91
95
 
92
96
  def create_mysql_database(db_key, region = 'us-east-1')
@@ -94,13 +98,20 @@ module Helpers
94
98
  system(%Q{mysql -u#{mysql_user} -h#{mysql_host} #{mysql_password_option} -e "drop database if exists #{db_name};"})
95
99
  system(%Q{mysql -u#{mysql_user} -h#{mysql_host} #{mysql_password_option} -e "create database #{db_name};"}) || raise("Could not create db: #{db_name}")
96
100
  created_mysql_dbs[db_key] = db_name
101
+ puts "*** MySQL DB Created: #{db_name}"
97
102
  write_database_config('mysql', mysql_user, mysql_password, mysql_host, created_mysql_dbs.values, region)
98
103
  db_name
99
104
  end
105
+
106
+ def drop_mysql_database(db_name)
107
+ command = %Q{mysql -u#{mysql_user} -h#{mysql_host} #{mysql_password_option} -e "drop database if exists #{db_name};"}
108
+ puts "*** MySQL Drop Command: #{command}"
109
+ system(command)
110
+ end
100
111
 
101
- def drop_postgresql_database(db_key)
102
- db_name = created_postgresql_dbs[db_key]
112
+ def drop_postgresql_database(db_name)
103
113
  command = %Q{ PGPASSWORD='#{postgresql_password}' dropdb -U #{postgresql_user} -h #{postgresql_host} #{db_name} }
114
+ puts "Postgres Drop Command: #{command}"
104
115
  system(command)
105
116
  end
106
117
 
@@ -113,7 +124,7 @@ module Helpers
113
124
  def create_postgresql_database(db_key, region = 'us-east-1')
114
125
  db_name = generate_database_name('postgresql')
115
126
  created_postgresql_dbs[db_key] = db_name
116
- drop_postgresql_database(db_key)
127
+ drop_postgresql_database(db_name)
117
128
  command = %Q{ PGPASSWORD='#{postgresql_password}' createdb -U #{postgresql_user} -h #{postgresql_host} #{db_name} }
118
129
  system(command) || raise("Could not create db: #{db_name} with command:\n #{command}")
119
130
  write_database_config('postgresql', postgresql_user, postgresql_password, postgresql_host, created_postgresql_dbs.values, region)
metadata CHANGED
@@ -1,127 +1,237 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ey_cloud_server
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.51
4
+ version: 1.4.54
5
5
  platform: ruby
6
6
  authors:
7
7
  - EngineYard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-19 00:00:00.000000000 Z
11
+ date: 2017-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - ! '>='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.8.3
19
+ version: 1.5.5
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - ! '>='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.8.3
26
+ version: 1.5.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: open4
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.3.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.3.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: nokogiri
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - ! '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: 1.6.6.2
48
+ - - <=
49
+ - !ruby/object:Gem::Version
50
+ version: 1.6.8.1
48
51
  type: :runtime
49
52
  prerelease: false
50
53
  version_requirements: !ruby/object:Gem::Requirement
51
54
  requirements:
52
- - - ">="
55
+ - - ! '>='
53
56
  - !ruby/object:Gem::Version
54
57
  version: 1.6.6.2
58
+ - - <=
59
+ - !ruby/object:Gem::Version
60
+ version: 1.6.8.1
61
+ - !ruby/object:Gem::Dependency
62
+ name: mime-types
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '1.16'
68
+ - - <
69
+ - !ruby/object:Gem::Version
70
+ version: '3.0'
71
+ type: :runtime
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '1.16'
78
+ - - <
79
+ - !ruby/object:Gem::Version
80
+ version: '3.0'
55
81
  - !ruby/object:Gem::Dependency
56
82
  name: aws-s3
57
83
  requirement: !ruby/object:Gem::Requirement
58
84
  requirements:
59
- - - "~>"
85
+ - - ! '>='
60
86
  - !ruby/object:Gem::Version
61
87
  version: 0.6.3
62
88
  type: :runtime
63
89
  prerelease: false
64
90
  version_requirements: !ruby/object:Gem::Requirement
65
91
  requirements:
66
- - - "~>"
92
+ - - ! '>='
67
93
  - !ruby/object:Gem::Version
68
94
  version: 0.6.3
69
95
  - !ruby/object:Gem::Dependency
70
96
  name: fog-aws
71
97
  requirement: !ruby/object:Gem::Requirement
72
98
  requirements:
73
- - - ">="
99
+ - - ! '>='
74
100
  - !ruby/object:Gem::Version
75
101
  version: 0.3.0
76
102
  type: :runtime
77
103
  prerelease: false
78
104
  version_requirements: !ruby/object:Gem::Requirement
79
105
  requirements:
80
- - - ">="
106
+ - - ! '>='
81
107
  - !ruby/object:Gem::Version
82
108
  version: 0.3.0
83
109
  - !ruby/object:Gem::Dependency
84
110
  name: ey_enzyme
85
111
  requirement: !ruby/object:Gem::Requirement
86
112
  requirements:
87
- - - ">="
113
+ - - ! '>='
88
114
  - !ruby/object:Gem::Version
89
- version: 1.1.7
115
+ version: 1.1.10
90
116
  type: :runtime
91
117
  prerelease: false
92
118
  version_requirements: !ruby/object:Gem::Requirement
93
119
  requirements:
94
- - - ">="
120
+ - - ! '>='
95
121
  - !ruby/object:Gem::Version
96
- version: 1.1.7
122
+ version: 1.1.10
97
123
  - !ruby/object:Gem::Dependency
98
124
  name: ey_instance_api_client
99
125
  requirement: !ruby/object:Gem::Requirement
100
126
  requirements:
101
- - - "~>"
127
+ - - ~>
102
128
  - !ruby/object:Gem::Version
103
129
  version: 0.1.11
104
130
  type: :runtime
105
131
  prerelease: false
106
132
  version_requirements: !ruby/object:Gem::Requirement
107
133
  requirements:
108
- - - "~>"
134
+ - - ~>
109
135
  - !ruby/object:Gem::Version
110
136
  version: 0.1.11
111
137
  - !ruby/object:Gem::Dependency
112
138
  name: rake
113
139
  requirement: !ruby/object:Gem::Requirement
114
140
  requirements:
115
- - - ">="
141
+ - - ~>
142
+ - !ruby/object:Gem::Version
143
+ version: 10.4.2
144
+ type: :development
145
+ prerelease: false
146
+ version_requirements: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ~>
149
+ - !ruby/object:Gem::Version
150
+ version: 10.4.2
151
+ - !ruby/object:Gem::Dependency
152
+ name: rspec
153
+ requirement: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: '2.0'
158
+ type: :development
159
+ prerelease: false
160
+ version_requirements: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ~>
163
+ - !ruby/object:Gem::Version
164
+ version: '2.0'
165
+ - !ruby/object:Gem::Dependency
166
+ name: randexp
167
+ requirement: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ~>
170
+ - !ruby/object:Gem::Version
171
+ version: 0.1.7
172
+ type: :development
173
+ prerelease: false
174
+ version_requirements: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ~>
177
+ - !ruby/object:Gem::Version
178
+ version: 0.1.7
179
+ - !ruby/object:Gem::Dependency
180
+ name: cucumber
181
+ requirement: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ~>
184
+ - !ruby/object:Gem::Version
185
+ version: 2.4.0
186
+ type: :development
187
+ prerelease: false
188
+ version_requirements: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ~>
191
+ - !ruby/object:Gem::Version
192
+ version: 2.4.0
193
+ - !ruby/object:Gem::Dependency
194
+ name: fakeweb
195
+ requirement: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - '='
198
+ - !ruby/object:Gem::Version
199
+ version: 1.2.6.ninjas
200
+ type: :development
201
+ prerelease: false
202
+ version_requirements: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - '='
205
+ - !ruby/object:Gem::Version
206
+ version: 1.2.6.ninjas
207
+ - !ruby/object:Gem::Dependency
208
+ name: fakefs
209
+ requirement: !ruby/object:Gem::Requirement
210
+ requirements:
211
+ - - '='
212
+ - !ruby/object:Gem::Version
213
+ version: 0.0.1.ninjas
214
+ type: :development
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ requirements:
218
+ - - '='
219
+ - !ruby/object:Gem::Version
220
+ version: 0.0.1.ninjas
221
+ - !ruby/object:Gem::Dependency
222
+ name: bundler
223
+ requirement: !ruby/object:Gem::Requirement
224
+ requirements:
225
+ - - ~>
116
226
  - !ruby/object:Gem::Version
117
- version: '0'
227
+ version: 1.13.7
118
228
  type: :development
119
229
  prerelease: false
120
230
  version_requirements: !ruby/object:Gem::Requirement
121
231
  requirements:
122
- - - ">="
232
+ - - ~>
123
233
  - !ruby/object:Gem::Version
124
- version: '0'
234
+ version: 1.13.7
125
235
  description: Miscellaneous EY server utilities
126
236
  email:
127
237
  - engineering@engineyard.com
@@ -192,17 +302,17 @@ require_paths:
192
302
  - lib
193
303
  required_ruby_version: !ruby/object:Gem::Requirement
194
304
  requirements:
195
- - - ">="
305
+ - - ! '>='
196
306
  - !ruby/object:Gem::Version
197
307
  version: '0'
198
308
  required_rubygems_version: !ruby/object:Gem::Requirement
199
309
  requirements:
200
- - - ">="
310
+ - - ! '>='
201
311
  - !ruby/object:Gem::Version
202
312
  version: '0'
203
313
  requirements: []
204
314
  rubyforge_project:
205
- rubygems_version: 2.4.5.1
315
+ rubygems_version: 2.6.8
206
316
  signing_key:
207
317
  specification_version: 4
208
318
  summary: Server side components for Engine Yard's cloud