snapshot_reload 1.0.2 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,13 @@
1
+ Feature: Make sure there is no reload if sql file is empty
2
+ In order to ensure the database doesn't get deleted accidently
3
+ As a tester
4
+ I want an error to occur when the source file is empty
5
+
6
+ Scenario: specify an empty gzipped source file
7
+ Given a file named "testdata/empty.sql.gz" exists
8
+ When I run `snapshot_reload --log-level debug --verbose --source ../../testdata/empty.sql.gz ../../testdata/config.yml`
9
+ Then the exit status should not be 0
10
+ And the output should contain "empty.sql.gz is empty!!"
11
+
12
+
13
+
@@ -37,12 +37,12 @@ Feature: save the existing data in the target database before reloading
37
37
  And the output should contain "<message>"
38
38
 
39
39
  Scenarios: test data for save option
40
- | saveoption | exit | message | dryrun |
41
- | -x | 64 | ERROR -- : parse error: 'config' is required |
42
- | -x dumpfile | 0 |saving to file dumpfile.sql.gz|
43
- | --save | 64 | ERROR -- : parse error: 'config' is required |
44
- | --save dumpfile | 0 |saving to file dumpfile.sql.gz|
45
- | --save dumpfile | 0 |saving to file dumpfile.sql.gz|
40
+ | saveoption | exit | message | dryrun |
41
+ | -x | 64 | ERROR -- : parse error: 'config' is required | -n |
42
+ | -x dumpfile | 0 | saving to file dumpfile.sql.gz | -n |
43
+ | --save | 64 | ERROR -- : parse error: 'config' is required | -n |
44
+ | --save dumpfile | 0 | saving to file dumpfile.sql.gz | -n |
45
+ | --save dumpfile | 0 | saving to file dumpfile.sql.gz | -n |
46
46
 
47
47
 
48
48
 
@@ -25,7 +25,7 @@ Feature: Live testing of application
25
25
  And the output should match /.*Command issued: gunzip .* | mysql .* drop.*/
26
26
 
27
27
  Scenarios: test data
28
- | config | creds | bucket | folder | file | save |
29
- | testdata/config.yml | testdata/my-aws-cred | tam-test-2 | db-backups | novu-2012-12-11.sql.gz | |
30
- | testdata/config.yml | testdata/my-aws-cred | tam-test-2 | db-backups | novu-2012-12-11.sql.gz | --save /tmp/dumpfile |
28
+ | config | creds | bucket | folder | file | save |
29
+ | testdata/config.yml | testdata/my-personal-aws-creds | tam-test-2 | db-backups | novu-2012-12-11.sql.gz | |
30
+ | testdata/config.yml | testdata/my-personal-aws-creds | tam-test-2 | db-backups | novu-2012-12-11.sql.gz | --save /tmp/dumpfile |
31
31
 
@@ -28,5 +28,6 @@ module SnapshotReload
28
28
  ENOOBJECT = 13
29
29
  ENOS3FILES = 14
30
30
  ENOSAVEFILE = 15
31
+ EEMPTYSQL = 16
31
32
 
32
33
  end
@@ -47,6 +47,7 @@ module SnapshotReload
47
47
  def load_db
48
48
  passopt = @password.present? ? "--password=#{@password}" : ''
49
49
  fetch_snapshot
50
+ check_sql_file
50
51
  cmd = "gunzip < #{self.sql_file} | mysql --host=#{@host} --user=#{@username} #{passopt} #{@database}"
51
52
  run_it(cmd)
52
53
  end
@@ -58,6 +59,17 @@ module SnapshotReload
58
59
  run_it(cmd)
59
60
  end # mysqladmin_go method
60
61
 
62
+ # want to see if the sql file is good
63
+ def check_sql_file
64
+ unzipped_file = '/tmp/' + File.basename(self.sql_file.gsub(/\.gz$/,''))
65
+ cmd = "gunzip < #{self.sql_file} > #{unzipped_file}"
66
+ run_it(cmd)
67
+ unless File.size?(unzipped_file) or @dry_run
68
+ fatal("#{self.sql_file} is empty!!")
69
+ exit(EEMPTYSQL)
70
+ end
71
+ # File.unlink(unzipped_file)
72
+ end
61
73
 
62
74
  def run_it(cmd)
63
75
  info("Dry-run, no commands will be executed.") if @dry_run and @verbose
@@ -11,7 +11,7 @@
11
11
 
12
12
 
13
13
  module SnapshotReload
14
- VERSION = "1.0.2"
14
+ VERSION = "1.0.4"
15
15
  SUMMARY = %q{Redeploy the obfuscated data from production to other servers}
16
16
  DESCRIPTION = %q{Take the obfuscated production data from it's nightly backup and place it into a working database. This script is run nightly to put obfuscated data into the Q* test server environments.}
17
17
 
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snapshot_reload
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-14 00:00:00.000000000 Z
12
+ date: 2012-12-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdoc
@@ -127,6 +127,7 @@ files:
127
127
  - README.rdoc
128
128
  - Rakefile
129
129
  - bin/snapshot_reload
130
+ - features/empty_sql_file.feature
130
131
  - features/save_option.feature
131
132
  - features/snapshot_live.feature
132
133
  - features/snapshot_reload.feature
@@ -172,6 +173,7 @@ signing_key:
172
173
  specification_version: 3
173
174
  summary: Redeploy the obfuscated data from production to other servers
174
175
  test_files:
176
+ - features/empty_sql_file.feature
175
177
  - features/save_option.feature
176
178
  - features/snapshot_live.feature
177
179
  - features/snapshot_reload.feature