pseudo_cleaner 0.0.38 → 0.0.39
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +93 -1
- data/lib/pseudo_cleaner/configuration.rb +1 -0
- data/lib/pseudo_cleaner/master_cleaner.rb +2 -1
- data/lib/pseudo_cleaner/redis_cleaner.rb +26 -4
- data/lib/pseudo_cleaner/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTgyNWUyNmQ2ZGE1MDI3YmVhNDNiYmEzNjRhYThlOGY5ZTdiODIxMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmY3MzcyYWE5MDczNDdjMjYyNDljYTMxYmQ4N2FhZTZjZDI2ZDcwYQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OWQ4YmU1YjQ4MGRhMjZlOGJhMTZkMDUyZTczYjAyZWNhNDUxMjJkMTFmMDNi
|
10
|
+
NDBkZDFiNWEzMTUzYjJkMDY4NGY2MDUwNzFkMDk2M2Q5N2U5N2ZkYzNkZmI5
|
11
|
+
ODBkMmE4ZGNmNDZjNThlYWJjYjJiOWE1NmIzM2RiMTdlNTM3ZWM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTRlOThkNmQ0MTk0OWY4ZDVkZGJhYzdlYmY4NDc4NzYyYzJlNmY1OTAxY2Zi
|
14
|
+
YmUzMTViYTE2YTEyNjIyZWQwNmMzYWNkMGQzMjQxNDljMTYyOGUxZGY0ZWEz
|
15
|
+
YzMzMTBhYTE4ZWYyYTA5NDhiZTE0NTQ5NzBkMWY2NzQyMTI2MTg=
|
data/README.md
CHANGED
@@ -145,10 +145,102 @@ Cleaners must also include one or more of the following funcitons:
|
|
145
145
|
|
146
146
|
A Cleaner can adjust when it is called in relation to other cleaners by overriding the instance method `<=>`
|
147
147
|
|
148
|
+
### Redis Cleaner
|
149
|
+
|
150
|
+
The RedisCleaner is a base class for a Custom Cleaner you must create yourself. The RedisCleaner is designed to work
|
151
|
+
by replacing your existing redis class with a tracking redis class. It will track your updates as you make calls and
|
152
|
+
then clean them up when you are done.
|
153
|
+
|
154
|
+
An example implementation where the default redis used by the system is `$redis`. (In other cases, you may want to
|
155
|
+
use mocking to swap out the redis instance...)
|
156
|
+
|
157
|
+
This in the file: db\cleaners\redis_cleaner.rb in the project...
|
158
|
+
|
159
|
+
class RedisCleaner < PseudoCleaner::RedisCleaner
|
160
|
+
attr_reader :test_ignore_regex
|
161
|
+
attr_reader :current_ignore_regex
|
162
|
+
|
163
|
+
BASE_IGNORE =
|
164
|
+
[
|
165
|
+
/rc-analytics::exports:actions:partner_last_run_dates/,
|
166
|
+
/rack\|whitelist_cache\|hash_data/,
|
167
|
+
/SequelModelCache/,
|
168
|
+
/active_sessions/,
|
169
|
+
]
|
170
|
+
|
171
|
+
def ignore_regexes
|
172
|
+
current_ignore_regex
|
173
|
+
end
|
174
|
+
|
175
|
+
def ignore_durring_test(additional_ignore_regexes, &block)
|
176
|
+
orig_test_ignore_regex = test_ignore_regex
|
177
|
+
begin
|
178
|
+
@test_ignore_regex = [*additional_ignore_regexes, *test_ignore_regex]
|
179
|
+
@current_ignore_regex = [*RedisCleaner::BASE_IGNORE, *test_ignore_regex]
|
180
|
+
|
181
|
+
block.yield
|
182
|
+
ensure
|
183
|
+
@test_ignore_regex = orig_test_ignore_regex
|
184
|
+
@current_ignore_regex = [*RedisCleaner::BASE_IGNORE, *test_ignore_regex]
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def initialize(*args)
|
189
|
+
super(*args)
|
190
|
+
|
191
|
+
@current_ignore_regex = RedisCleaner::BASE_IGNORE
|
192
|
+
@test_ignore_regex = []
|
193
|
+
@redis = $redis
|
194
|
+
$redis = self
|
195
|
+
|
196
|
+
Redis.current = $redis
|
197
|
+
Ohm.redis = $redis
|
198
|
+
Redis::Objects.redis = $redis
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
The main point here is that I set the value of @redis to the redis instance I want to use, and then "replace" that
|
203
|
+
redis instance in the code with the RedisCleaner class.
|
204
|
+
|
205
|
+
## Configurations
|
206
|
+
|
207
|
+
As the system evolves, I keep adding new and different options. Here is a summary of what some of them do at least:
|
208
|
+
|
209
|
+
* **output_diagnostics**
|
210
|
+
Output diagnostic information at various points in the process. This would include the level set starting point of
|
211
|
+
a table, what rows were deleted, etc.
|
212
|
+
* **clean_database_before_tests**
|
213
|
+
Delete all data in all tables can call SortedSeeer to re-seed the database before any tests are run. This is
|
214
|
+
defaulted to false because this can be time-consuming and many automated testing systems already do this for you.
|
215
|
+
* **reset_auto_increment**
|
216
|
+
Defaulted to true, this will set the auto-increment value for a table to the highest id + 1 when the system starts.
|
217
|
+
* **post_transaction_analysis**
|
218
|
+
An early version of the peek-data function. This will output information about every table at the end of the test.
|
219
|
+
The data output will match the initial state data if `output_diagnostics` is true.
|
220
|
+
* **peek_data_on_error**
|
221
|
+
Defaulted to true, this will output a dump of all of the new values in the database if an error occured in the test.
|
222
|
+
* **peek_data_not_on_error**
|
223
|
+
If set to true, this will output a dump of all of the new values in the database at the end of every test. This
|
224
|
+
functionality can also be achieved by tagging your test with `:full_data_dump` (RSpec) or `@full_data_dump`
|
225
|
+
(Cucumber and Spinach).
|
226
|
+
* **enable_full_data_dump_tag**
|
227
|
+
Defaulted to true, this allows the `full_data_dump` tag to work. If set to false, the tag will be ignored.
|
228
|
+
* **disable_cornucopia_output**
|
229
|
+
If set to false, this will force all output to be done through the registered logger which defaults to simply
|
230
|
+
outputing data to stdout.
|
231
|
+
|
232
|
+
## Cornucopia integration
|
233
|
+
|
234
|
+
I have another gem that I use a lot called `cornucopia`. I like it because it gives me really useful reports on what
|
235
|
+
happened in my tests.
|
236
|
+
|
237
|
+
I have updated this gem to use Cornucopia to output most of the information to be output by the gem. You can disable
|
238
|
+
this feature by setting `disable_cornucopia_output` to true.
|
239
|
+
|
148
240
|
## Contributing
|
149
241
|
|
150
242
|
1. Fork it
|
151
243
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
152
244
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
153
245
|
4. Push to the branch (`git push origin my-new-feature`)
|
154
|
-
5. Create new Pull Request
|
246
|
+
5. Create new Pull Request
|
@@ -350,7 +350,8 @@ module PseudoCleaner
|
|
350
350
|
|
351
351
|
if Object.const_defined?("Cornucopia", false) &&
|
352
352
|
Cornucopia.const_defined?("Util", false) &&
|
353
|
-
Cornucopia::Util.const_defined?("ReportBuilder", false)
|
353
|
+
Cornucopia::Util.const_defined?("ReportBuilder", false) &&
|
354
|
+
!PseudoCleaner::Configuration.current_instance.disable_cornucopia_output
|
354
355
|
Cornucopia::Util::ReportBuilder.current_report.within_section(options[:description]) do |report|
|
355
356
|
report.within_hidden_table do |outer_report_table|
|
356
357
|
Cornucopia::Util::ReportTable.new(
|
@@ -110,6 +110,7 @@ module PseudoCleaner
|
|
110
110
|
"sunionstore",
|
111
111
|
"zincrby",
|
112
112
|
"zinterstore",
|
113
|
+
"[]=",
|
113
114
|
]
|
114
115
|
READ_COMMANDS =
|
115
116
|
[
|
@@ -159,6 +160,7 @@ module PseudoCleaner
|
|
159
160
|
"zscan",
|
160
161
|
"zscan_each",
|
161
162
|
"zscore",
|
163
|
+
"[]",
|
162
164
|
]
|
163
165
|
|
164
166
|
attr_reader :initial_keys
|
@@ -242,11 +244,24 @@ module PseudoCleaner
|
|
242
244
|
elsif ["exec", "pipelined"].include?(args[0])
|
243
245
|
begin
|
244
246
|
if (!response && @multi_commands.length > 0) || (response && response.length != @multi_commands.length)
|
245
|
-
|
247
|
+
puts "exec response does not match sent commands.\n response: #{response}\n commands: #{@multi_commands}"
|
248
|
+
|
249
|
+
# make the response length match the commands length.
|
250
|
+
# so far the only time this has happened was when a multi returned nil which SHOULD indicate a failure
|
251
|
+
#
|
252
|
+
# I am assuming that the multi failed in this case, but even if so, it is safest for tracking purposes
|
253
|
+
# to assume that redis DID change and record it as such. Even if I am wrong, for the cleaner, it
|
254
|
+
# doesn't matter, and there is no harm.
|
255
|
+
response ||= []
|
256
|
+
@multi_commands.each_with_index do |command, index|
|
257
|
+
if response.length < index
|
258
|
+
response << true
|
259
|
+
end
|
260
|
+
end
|
246
261
|
end
|
247
262
|
|
248
|
-
|
249
|
-
process_command(
|
263
|
+
@multi_commands.each_with_index do |command, index|
|
264
|
+
process_command(response[index], *command)
|
250
265
|
end
|
251
266
|
ensure
|
252
267
|
@in_multi = false
|
@@ -258,7 +273,14 @@ module PseudoCleaner
|
|
258
273
|
elsif WRITE_COMMANDS.include?(args[0])
|
259
274
|
updated_keys.merge(extract_keys(*args))
|
260
275
|
elsif SET_COMMANDS.include?(args[0])
|
261
|
-
|
276
|
+
update_key = true
|
277
|
+
if [true, false].include?(response)
|
278
|
+
update_key = response
|
279
|
+
else
|
280
|
+
update_key = response > 0 rescue true
|
281
|
+
end
|
282
|
+
|
283
|
+
if update_key
|
262
284
|
updated_keys.merge(extract_keys(*args))
|
263
285
|
end
|
264
286
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pseudo_cleaner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.39
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RealNobody
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|