govdelivery-proctor 1.3 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +17 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +30 -8
- data/README.md +8 -4
- data/lib/govdelivery/proctor/base.rb +22 -19
- data/lib/govdelivery/proctor/version.rb +1 -1
- data/proctor.gemspec +4 -2
- data/test/test_helper.rb +2 -1
- data/test/test_proctor.rb +17 -7
- metadata +52 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91a9b90149544728c77ca574a3aea6c8a9e38562
|
4
|
+
data.tar.gz: d20eeee7b30bb5d9d27a721830c2f5c1633647a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f78e93e3d88422f8e54e12c0e81c6e68ac7b38584bd548fc92e195c445265f5ba6e0f076e00bdf86f6f667183fbf16c050e0758f4c224e7c194bd5bb0d593c6f
|
7
|
+
data.tar.gz: 45599c8cc3c0e03332b7f8675a17a8fa74eac2f61754a53fb83eb6a8d612c68896af89eba665524a2828d74c2ff6b58b9934479417a1ea066ffb45f247128739
|
data/.gitlab-ci.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
before_script:
|
2
|
+
- rbenv install -s
|
3
|
+
- bundle -v || gem install bundler
|
4
|
+
- bundle install --quiet --path .bundle
|
5
|
+
|
6
|
+
stages:
|
7
|
+
- Test
|
8
|
+
|
9
|
+
cache:
|
10
|
+
key: bundle_files
|
11
|
+
paths:
|
12
|
+
- .bundle/
|
13
|
+
|
14
|
+
Test:
|
15
|
+
stage: Test
|
16
|
+
script:
|
17
|
+
- bundle exec rake test
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
jruby-1.7.25
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file.
|
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
|
5
5
|
[How to use a CHANGELOG](http://keepachangelog.com/)
|
6
|
+
## [1.3.1]
|
7
|
+
### Fixed
|
8
|
+
- Changes made as part of 1.3.0 caused an error to be thrown when ActiveSupport::Duration was used for `limit` or `inc` arguments of accelerating_check
|
9
|
+
- Reverted `Math.log` formula for accelerating_check in favor of a more simple formula because the former was worse than the latter
|
10
|
+
- Live logging amount of time an operation will be sleeping before sleep occurs
|
6
11
|
## [1.3.0]
|
7
12
|
### Added
|
8
13
|
- Say hello to steady_check which sleeps for the increment passed to it
|
data/Gemfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,33 +1,55 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
govdelivery-proctor (1.
|
4
|
+
govdelivery-proctor (1.3.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
|
9
|
+
activesupport (4.2.7.1)
|
10
|
+
i18n (~> 0.7)
|
11
|
+
json (~> 1.7, >= 1.7.7)
|
12
|
+
minitest (~> 5.1)
|
13
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
14
|
+
tzinfo (~> 1.1)
|
10
15
|
coderay (1.1.1)
|
16
|
+
ffi (1.9.14-java)
|
17
|
+
i18n (0.7.0)
|
18
|
+
json (1.8.3)
|
19
|
+
json (1.8.3-java)
|
11
20
|
method_source (0.8.2)
|
12
|
-
|
21
|
+
minitest (5.10.1)
|
22
|
+
power_assert (0.4.1)
|
13
23
|
pry (0.10.4)
|
14
24
|
coderay (~> 1.1.0)
|
15
25
|
method_source (~> 0.8.1)
|
16
26
|
slop (~> 3.4)
|
17
|
-
pry
|
18
|
-
|
19
|
-
|
27
|
+
pry (0.10.4-java)
|
28
|
+
coderay (~> 1.1.0)
|
29
|
+
method_source (~> 0.8.1)
|
30
|
+
slop (~> 3.4)
|
31
|
+
spoon (~> 0.0)
|
32
|
+
rake (11.3.0)
|
20
33
|
slop (3.6.0)
|
21
|
-
|
34
|
+
spoon (0.0.6)
|
35
|
+
ffi
|
36
|
+
test-unit (3.2.3)
|
22
37
|
power_assert
|
38
|
+
thread_safe (0.3.5)
|
39
|
+
thread_safe (0.3.5-java)
|
40
|
+
tzinfo (1.2.2)
|
41
|
+
thread_safe (~> 0.1)
|
23
42
|
|
24
43
|
PLATFORMS
|
44
|
+
java
|
25
45
|
ruby
|
26
46
|
|
27
47
|
DEPENDENCIES
|
48
|
+
activesupport (~> 4.0)
|
28
49
|
bundler (~> 1.7)
|
29
50
|
govdelivery-proctor!
|
30
|
-
pry
|
51
|
+
pry
|
52
|
+
rake
|
31
53
|
test-unit
|
32
54
|
|
33
55
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -78,16 +78,20 @@ end
|
|
78
78
|
## Development
|
79
79
|
### Get Dev Dependencies
|
80
80
|
|
81
|
-
|
81
|
+
$ bundle install
|
82
82
|
|
83
83
|
### Build
|
84
84
|
|
85
|
-
|
85
|
+
$ gem build proctor.gemspec
|
86
86
|
|
87
87
|
### Install locally
|
88
88
|
|
89
|
-
|
89
|
+
$ gem install govdelivery-proctor-1.3.1.gem
|
90
90
|
|
91
91
|
### Test
|
92
92
|
|
93
|
-
|
93
|
+
$ rake test
|
94
|
+
|
95
|
+
### Push to rubygems
|
96
|
+
|
97
|
+
$ gem push govdelivery-proctor-1.3.1.gem
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module GovDelivery::Proctor
|
2
2
|
class CheckTimeExceeded < StandardError; end
|
3
3
|
|
4
|
-
def self.backoff_check(limit, desc = 'Backoff check', inc =
|
4
|
+
def self.backoff_check(limit, desc = 'Backoff check', inc = 20)
|
5
5
|
raise 'Check requires a block' unless block_given?
|
6
6
|
check(limit, 'backoff', desc, inc) do
|
7
7
|
yield
|
@@ -10,14 +10,14 @@ module GovDelivery::Proctor
|
|
10
10
|
|
11
11
|
# Sometimes you want to reverse backoff because as time
|
12
12
|
# passes it is more likely your condition is true
|
13
|
-
def self.accelerating_check(limit, desc = '
|
13
|
+
def self.accelerating_check(limit, desc = 'Accelerating check', inc = 20)
|
14
14
|
raise 'Check requires a block' unless block_given?
|
15
15
|
check(limit, 'accelerate', desc, inc) do
|
16
16
|
yield
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
def self.steady_check(limit, desc = 'Steady check', inc =
|
20
|
+
def self.steady_check(limit, desc = 'Steady check', inc = 10)
|
21
21
|
raise 'Check requires a block' unless block_given?
|
22
22
|
check(limit, 'steady', desc, inc) do
|
23
23
|
yield
|
@@ -25,22 +25,24 @@ module GovDelivery::Proctor
|
|
25
25
|
end
|
26
26
|
|
27
27
|
# if backoff, double the wait time each time
|
28
|
-
# if
|
28
|
+
# if accelerate, halve the wait time each time based on limit
|
29
|
+
# and use increment only for minimum wait time
|
29
30
|
# if steady, just keep it steady
|
31
|
+
# to_i used to make ActiveSupport::Durations safe
|
30
32
|
def self.sleep_time(check_type, limit, increment, iteration)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
33
|
+
limit = limit.to_i
|
34
|
+
increment = increment.to_i
|
35
|
+
sleep_time = case check_type
|
36
|
+
when 'steady'
|
37
|
+
increment
|
38
|
+
when 'backoff'
|
39
|
+
(2**iteration) * increment
|
40
|
+
when 'accelerate'
|
41
|
+
[(limit / 2) / (iteration + 1), increment].max
|
42
|
+
else
|
43
|
+
raise "Check type #{check_type} invalid: choose accelerate, backoff, or steady."
|
44
|
+
end
|
45
|
+
[sleep_time, limit].min
|
44
46
|
end
|
45
47
|
|
46
48
|
def self.check(limit, check_type, desc, inc)
|
@@ -50,7 +52,8 @@ module GovDelivery::Proctor
|
|
50
52
|
x = 0
|
51
53
|
response = nil
|
52
54
|
Kernel.loop do
|
53
|
-
sleep_time = sleep_time(check_type, limit, inc,
|
55
|
+
sleep_time = sleep_time(check_type, limit, inc, x)
|
56
|
+
getStandardLogger.info("sleeping for #{sleep_time} seconds")
|
54
57
|
sleep(sleep_time)
|
55
58
|
slept_time += sleep_time
|
56
59
|
response = yield
|
@@ -59,9 +62,9 @@ module GovDelivery::Proctor
|
|
59
62
|
fail_message = "#{desc} has taken too long. Have waited #{slept_time} seconds\nlog: #{@backBuffer.string}"
|
60
63
|
raise CheckTimeExceeded, fail_message
|
61
64
|
end
|
65
|
+
x += 1
|
62
66
|
# We're doing this twice, once for standard out so you can see it's still
|
63
67
|
# working, and then again inside the logged output if it fails.
|
64
|
-
|
65
68
|
getStandardLogger.info("Still waiting while #{desc}, current time=#{slept_time}")
|
66
69
|
log.info("Still waiting while #{desc}, current time=#{slept_time}")
|
67
70
|
end
|
data/proctor.gemspec
CHANGED
@@ -18,7 +18,9 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency 'test-unit'
|
22
21
|
spec.add_development_dependency 'bundler', '~> 1.7'
|
23
|
-
spec.add_development_dependency 'pry
|
22
|
+
spec.add_development_dependency 'pry'
|
23
|
+
spec.add_development_dependency 'rake'
|
24
|
+
spec.add_development_dependency 'test-unit'
|
25
|
+
spec.add_development_dependency 'activesupport', '~>4.0'
|
24
26
|
end
|
data/test/test_helper.rb
CHANGED
data/test/test_proctor.rb
CHANGED
@@ -17,20 +17,30 @@ class TestProctor < Test::Unit::TestCase
|
|
17
17
|
assert_equal 480, GovDelivery::Proctor.sleep_time('backoff', 600, 30, 4)
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
21
|
-
assert_equal
|
20
|
+
def test_sleep_time_accelerate_default_to_limit
|
21
|
+
assert_equal 1, GovDelivery::Proctor.sleep_time('accelerate', 1, 10, 2)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_sleep_time_accelerate_default_to_limit_with_ActiveSupport_Duration
|
25
|
+
assert_equal 1, GovDelivery::Proctor.sleep_time('accelerate', 1.second, 10.seconds, 2)
|
22
26
|
end
|
23
27
|
|
24
28
|
def test_sleep_time_accelerate_iteration_one
|
25
|
-
assert_equal
|
29
|
+
assert_equal 150, GovDelivery::Proctor.sleep_time('accelerate', 600, 10, 1)
|
26
30
|
end
|
27
31
|
|
28
32
|
def test_sleep_time_accelerate_iteration_four
|
29
|
-
assert_equal
|
33
|
+
assert_equal 60, GovDelivery::Proctor.sleep_time('accelerate', 600, 10, 4)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_sleep_time_accelerate_respect_increment
|
37
|
+
assert_equal 45, GovDelivery::Proctor.sleep_time('accelerate', 60, 45, 4)
|
30
38
|
end
|
31
39
|
|
32
|
-
def
|
33
|
-
assert_equal
|
40
|
+
def test_sleep_time_accelerate_real_world
|
41
|
+
assert_equal 240, GovDelivery::Proctor.sleep_time('accelerate', 8.minutes, 30, 0)
|
42
|
+
assert_equal 120, GovDelivery::Proctor.sleep_time('accelerate', 8.minutes, 30, 1)
|
43
|
+
assert_equal 40, GovDelivery::Proctor.sleep_time('accelerate', 8.minutes, 30, 5)
|
34
44
|
end
|
35
45
|
|
36
46
|
def test_backoff_check_condition_true
|
@@ -66,7 +76,7 @@ class TestProctor < Test::Unit::TestCase
|
|
66
76
|
false
|
67
77
|
end
|
68
78
|
end
|
69
|
-
assert_equal "
|
79
|
+
assert_equal "Accelerating check has taken too long. Have waited 1 seconds\nlog: ", ex.message
|
70
80
|
end
|
71
81
|
|
72
82
|
def test_steady_check_condition_false
|
metadata
CHANGED
@@ -1,57 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govdelivery-proctor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bill Bushey
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: bundler
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
requirement: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - "~>"
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '1.7'
|
25
|
+
prerelease: false
|
26
|
+
type: :development
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
15
34
|
requirement: !ruby/object:Gem::Requirement
|
16
35
|
requirements:
|
17
36
|
- - ">="
|
18
37
|
- !ruby/object:Gem::Version
|
19
38
|
version: '0'
|
20
|
-
type: :development
|
21
39
|
prerelease: false
|
40
|
+
type: :development
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
22
43
|
version_requirements: !ruby/object:Gem::Requirement
|
23
44
|
requirements:
|
24
45
|
- - ">="
|
25
46
|
- !ruby/object:Gem::Version
|
26
47
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler
|
29
48
|
requirement: !ruby/object:Gem::Requirement
|
30
49
|
requirements:
|
31
|
-
- - "
|
50
|
+
- - ">="
|
32
51
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
34
|
-
type: :development
|
52
|
+
version: '0'
|
35
53
|
prerelease: false
|
54
|
+
type: :development
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: test-unit
|
36
57
|
version_requirements: !ruby/object:Gem::Requirement
|
37
58
|
requirements:
|
38
|
-
- - "
|
59
|
+
- - ">="
|
39
60
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: pry-byebug
|
61
|
+
version: '0'
|
43
62
|
requirement: !ruby/object:Gem::Requirement
|
44
63
|
requirements:
|
45
|
-
- - "
|
64
|
+
- - ">="
|
46
65
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
48
|
-
type: :development
|
66
|
+
version: '0'
|
49
67
|
prerelease: false
|
68
|
+
type: :development
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activesupport
|
50
71
|
version_requirements: !ruby/object:Gem::Requirement
|
51
72
|
requirements:
|
52
73
|
- - "~>"
|
53
74
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
75
|
+
version: '4.0'
|
76
|
+
requirement: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '4.0'
|
81
|
+
prerelease: false
|
82
|
+
type: :development
|
55
83
|
description: Classes and functions to support feature testing.
|
56
84
|
email:
|
57
85
|
- bill.bushey@govdelivery.com
|
@@ -60,6 +88,8 @@ extensions: []
|
|
60
88
|
extra_rdoc_files: []
|
61
89
|
files:
|
62
90
|
- ".gitignore"
|
91
|
+
- ".gitlab-ci.yml"
|
92
|
+
- ".ruby-version"
|
63
93
|
- CHANGELOG.md
|
64
94
|
- Gemfile
|
65
95
|
- Gemfile.lock
|
@@ -75,7 +105,7 @@ homepage: ''
|
|
75
105
|
licenses:
|
76
106
|
- MIT
|
77
107
|
metadata: {}
|
78
|
-
post_install_message:
|
108
|
+
post_install_message:
|
79
109
|
rdoc_options: []
|
80
110
|
require_paths:
|
81
111
|
- lib
|
@@ -90,9 +120,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
120
|
- !ruby/object:Gem::Version
|
91
121
|
version: '0'
|
92
122
|
requirements: []
|
93
|
-
rubyforge_project:
|
94
|
-
rubygems_version: 2.
|
95
|
-
signing_key:
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.4.8
|
125
|
+
signing_key:
|
96
126
|
specification_version: 4
|
97
127
|
summary: Classes and functions to support feature testing.
|
98
128
|
test_files:
|