postmodern 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1bc358882bdb3ac6f246d3967ac261076b4c334d
4
- data.tar.gz: 9a3cf7820f70f5271f9ee570be8444bd8305d7e4
3
+ metadata.gz: 11654286ebdd50bde8e215c458a2a9faad3d5deb
4
+ data.tar.gz: afe4ed43d2137580448b21a480fa10193a64071e
5
5
  SHA512:
6
- metadata.gz: 619b48a8a1b7b6c250455c143dbe2ac9465066269aea935760e51f7ac6ca9393aacb92a4234a39000fa230de7edb6a5261916e4ccb20c50af8b75ae329ba4e6b
7
- data.tar.gz: 3e98b9eeaaa9e57886b00c653e871d2b9816024a17c4c96089abe22cdc6b582a4c8762b7490a5acff54483674296a0170e17dd3f092dfa4cd5429b2e3ef3924e
6
+ metadata.gz: 31e5d5befd568bf174b76c644ffbef320a433f9ad287e68f47cf68e608af17f681d1533ac25b340a50d0145c6416e8656e80020c429883d210d2b7d6be44ac07
7
+ data.tar.gz: 0be73e7b01ecd064f19d778b5978976080b3abe358e536ed7a3c163220100d39cbf0fe90e870a439cea19f21a5f2544814b0f3a9eb0cca35fcb9fd8fd0aeb596
data/README.md CHANGED
@@ -44,6 +44,7 @@ Usage: postmodern (vacuum|freeze) <options>
44
44
  -L, --costlimit LIMIT vacuum_cost_limit setting -- default 2000
45
45
 
46
46
  -h, --help Show this message
47
+ -n, --dry-run Perform dry-run, do not vacuum.
47
48
  --version Show version
48
49
  ```
49
50
 
@@ -16,6 +16,7 @@ module Postmodern
16
16
  opts.separator " archive"
17
17
  opts.separator " restore"
18
18
  opts.separator " vacuum"
19
+ opts.separator " freeze"
19
20
  opts.separator ""
20
21
  opts.separator "Options:"
21
22
 
@@ -71,6 +71,10 @@ module Postmodern
71
71
  exit
72
72
  end
73
73
 
74
+ opts.on_tail("-n", "--dry-run", "Perform dry-run, do not vacuum.") do
75
+ self.options[:dryrun] = true
76
+ end
77
+
74
78
  opts.on_tail("--version", "Show version") do
75
79
  require 'postmodern/version'
76
80
  puts Postmodern::VERSION
@@ -99,12 +103,13 @@ module Postmodern
99
103
  def vacuum
100
104
  tables_to_vacuum.each do |table|
101
105
  Postmodern.logger.info "Vacuuming #{table}"
102
- adapter.execute(vacuum_statement(table))
106
+ adapter.execute(vacuum_statement(table)) unless dryrun?
103
107
  if timedout?
104
108
  Postmodern.logger.warn "Vacuuming timed out"
105
109
  break
106
110
  end
107
111
  end
112
+ Postmodern.logger.info "Vacuuming finished"
108
113
  end
109
114
 
110
115
  def vacuum_statement table_name
@@ -115,6 +120,10 @@ module Postmodern
115
120
  Time.now >= start_time + (options[:timeout].to_i * 60)
116
121
  end
117
122
 
123
+ def dryrun?
124
+ !!options[:dryrun]
125
+ end
126
+
118
127
  def tables_to_vacuum
119
128
  table_res = adapter.execute(table_sql)
120
129
  table_res.map{|f| f['full_table_name']}
@@ -1,3 +1,3 @@
1
1
  module Postmodern
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -10,6 +10,7 @@ Available commands:
10
10
  archive
11
11
  restore
12
12
  vacuum
13
+ freeze
13
14
 
14
15
  Options:
15
16
  -h, --help Show this message
@@ -18,6 +18,7 @@ Usage: postmodern (vacuum|freeze) <options>
18
18
  -L, --costlimit LIMIT vacuum_cost_limit setting -- default 2000
19
19
 
20
20
  -h, --help Show this message
21
+ -n, --dry-run Perform dry-run, do not vacuum.
21
22
  --version Show version
22
23
  END
23
24
  end
@@ -18,6 +18,7 @@ Usage: postmodern (vacuum|freeze) <options>
18
18
  -L, --costlimit LIMIT vacuum_cost_limit setting -- default 2000
19
19
 
20
20
  -h, --help Show this message
21
+ -n, --dry-run Perform dry-run, do not vacuum.
21
22
  --version Show version
22
23
  END
23
24
  end
@@ -141,6 +141,14 @@ ORDER BY dead_pct DESC, table_bytes DESC;
141
141
 
142
142
  let(:tables_to_vacuum) { %w(table1 table2 table3) }
143
143
 
144
+ context 'dry run' do
145
+ let(:args) { %w(-d db --dry-run) }
146
+ it 'does not actually execute vacuum' do
147
+ command.vacuum
148
+ expect(adapter).not_to have_received(:execute)
149
+ end
150
+ end
151
+
144
152
  it "vacuums each table" do
145
153
  command.vacuum
146
154
  tables_to_vacuum.each do |table|
@@ -157,6 +165,24 @@ ORDER BY dead_pct DESC, table_bytes DESC;
157
165
  end
158
166
  end
159
167
 
168
+ describe '#dryrun?' do
169
+ context 'with --dry-run' do
170
+ let(:args) { %w(-d db --dry-run) }
171
+
172
+ it 'is true' do
173
+ expect(subject.dryrun?).to be true
174
+ end
175
+ end
176
+
177
+ context 'without --dry-run' do
178
+ let(:args) { %w(-d db) }
179
+
180
+ it 'is false' do
181
+ expect(command.dryrun?).to be false
182
+ end
183
+ end
184
+ end
185
+
160
186
  describe '#timedout?' do
161
187
  let(:time) { Time.now }
162
188
  let(:args) { %w(--d db -t 15) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postmodern
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Saxby