resqued 0.7.6 → 0.7.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e4fb0bcb7e96b0df5bfa4dfa32340b99a5eea002
4
- data.tar.gz: 76710f5182ec2f97a5136619a0ac573c40c6d96a
3
+ metadata.gz: 303c225999215b8daf81924a374a7a1f2fe2b47a
4
+ data.tar.gz: 8d841be51e42d4c1a21ce6d35082d7273e3274c7
5
5
  SHA512:
6
- metadata.gz: 9fddc96d14a8c6905d4b8220debe910d88a2a7bc8c6566b9b933117bb7b0f9752a0a339d0c59e6fb06f15894b6779894b776393679ef835f9e2f5afddfdf4649
7
- data.tar.gz: dbea0b63b9e6c85593540cb76a2f74e427def5a34e492dcd8a4f9ab7f4d5d32b84078c92ad7c3b85b87e9e451cf5f721b2c6cb39cfe702a7194ccd709329eff2
6
+ metadata.gz: cccb7db2c2b54dfd86512fb9089062c5a39bfd9fce0d8c742af3ddbed7d520cde62c6b359eba03fd0a233d8cbbe49ba911fc6a4ac586421f5a183b8fdb5ccaea
7
+ data.tar.gz: 6a0666ac544803c3e2b13047525c01de41967501b156f67a0c60fdabd823d37e8fb1ef53c6551c3fb1db9a5fea1fbfe1241a84617c67fc4cfd48ba3836d0eb05
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Resqued is a multi-process daemon that controls and monitors a pool of resque workers. It works well with slow jobs and continuous delivery.
4
4
 
5
+ [![travis status](https://travis-ci.org/spraints/resqued.png)](https://travis-ci.org/spraints/resqued)
6
+
5
7
  ## Installation
6
8
 
7
9
  Install by adding resqued to your Gemfile
@@ -128,6 +130,19 @@ If your app has several work machines, each with the same application code but d
128
130
  $ resqued config/shared.rb config/pool-a.rb
129
131
  $ resqued config/shared.rb config/pool-b.rb
130
132
 
133
+ ## Testing
134
+
135
+ To test your resqued configuration, add a test case like this:
136
+
137
+ ```
138
+ class MyResquedTest < Test::Unit::TestCase
139
+ include Resqued::TestCase
140
+ def test_resqued_config
141
+ assert_resqued 'config/resqued.rb'
142
+ end
143
+ end
144
+ ```
145
+
131
146
  ## See also
132
147
 
133
148
  For information about how resqued works, see the [documentation](docs/).
@@ -1,84 +1,27 @@
1
- # This file includes example assertions for your resqued configuration.
2
- #
3
- # assert_resqued 'config/resqued/environment.rb', 'config/resqued/pool-a.rb'
1
+ require 'resqued/config'
2
+
4
3
  module Resqued
5
4
  module TestCase
6
- module ForkToStart
7
- # Public: Fork a process that spins up a Resqued::Master process directly.
8
- def assert_resqued(*configs)
9
- options = configs.last.is_a?(Hash) ? configs.pop : {}
10
- check_workers = options.fetch(:expect_workers, false)
11
- worker_timeout = options.fetch(:worker_timeout, 5)
12
- resqued_bin = options.fetch(:resqued_bin) { `which resqued || bundle exec which resqued`.chomp }
13
- status = IO.pipe
14
- if pid = fork
15
- message = read_status_from_resqued(:pipe => status[0], :pid => pid)
16
- if message !~ /^listener,\d+,start$/
17
- fail "Expected listener to start, but received #{message.inspect}"
18
- end
19
- message = read_status_from_resqued(:pipe => status[0], :pid => pid)
20
- if message !~ /^listener,\d+,ready$/
21
- fail "Expected listener to be ready, but received #{message.inspect}"
22
- end
23
- if check_workers
24
- start = Time.now
25
- workers_started = 0
26
- loop do
27
- elapsed = Time.now - start
28
- time_remaining = worker_timeout - elapsed
29
- break unless time_remaining > 0
30
- if message = read_status_from_resqued(:pipe => status[0], :pid => pid, :timeout => time_remaining)
31
- if message =~ /worker,\d+,start/
32
- workers_started = workers_started + 1
33
- else
34
- fail "Expected to see workers starting, instead saw #{message.inspect}"
35
- end
36
- end
37
- end
38
- if workers_started == 0
39
- fail "Expected at least one worker to start, but none did"
40
- end
41
- end
42
- else
43
- $0 = "resqued master for #{$0}"
44
- unless ENV['NOISY_RESQUED_TESTS']
45
- devnull = File.open('/dev/null', 'w')
46
- $stdout.reopen(devnull)
47
- $stderr.reopen(devnull)
48
- end
49
- begin
50
- # This should match how `exe/resqued` starts the master process.
51
- require 'resqued'
52
- Resqued::START_CTX['$0'] = resqued_bin
53
- Resqued::Master.new(:config_paths => configs, :status_pipe => status[1]).run
54
- rescue Object => e
55
- # oops
56
- end
57
- exit! # Do not make this look like a failing test.
58
- end
59
- ensure
60
- begin
61
- Process.kill :QUIT, pid
62
- Process.waitpid2(pid) if pid
63
- rescue Errno::ESRCH, Errno::ECHILD
64
- # already dead.
65
- end
66
- end
67
-
68
- def read_status_from_resqued(options)
69
- status = options.fetch(:pipe)
70
- pid = options.fetch(:pid)
71
- timeout = options[:timeout]
72
- loop do
73
- if IO.select([status], nil, nil, timeout || 2)
74
- return status.readline.chomp
75
- elsif dead = Process.waitpid2(pid, Process::WNOHANG)
76
- fail "Resqued stopped too soon."
77
- elsif timeout
78
- return nil
79
- end
80
- end
5
+ module LoadConfig
6
+ # Test your resqued config.
7
+ #
8
+ # If you do this to start resqued:
9
+ #
10
+ # $ resqued config/resqued-environment.rb config/resqued-workers.rb
11
+ #
12
+ # Then you'll want to do this in a test:
13
+ #
14
+ # assert_resqued 'config/resqued-environment.rb', 'config/resqued-workers.rb'
15
+ def assert_resqued(*paths)
16
+ config = Resqued::Config.new(paths)
17
+ config.before_fork
18
+ config.build_workers
19
+ config.after_fork(Resque::Worker.new('*'))
81
20
  end
82
21
  end
22
+
23
+ Default = LoadConfig
24
+
25
+ include Default
83
26
  end
84
27
  end
@@ -1,3 +1,3 @@
1
1
  module Resqued
2
- VERSION = '0.7.6'
2
+ VERSION = '0.7.7'
3
3
  end
@@ -3,37 +3,12 @@ require 'resqued/test_case'
3
3
 
4
4
  describe Resqued::TestCase do
5
5
  let(:test_case) { Object.new.extend(the_module) }
6
- before { mock_redis.start ; ENV['RESQUED_TEST_REDIS_PORT'] = mock_redis.port.to_s }
7
- after { mock_redis.stop }
8
- let(:mock_redis) { MockRedisServer.new }
9
6
 
10
- context 'ForkToStart' do
11
- let(:the_module) { described_class::ForkToStart }
7
+ context 'LoadConfig' do
8
+ let(:the_module) { described_class::LoadConfig }
12
9
  it { expect { test_case.assert_resqued 'spec/fixtures/test_case_environment.rb', 'spec/fixtures/test_case_clean.rb' }.not_to raise_error }
13
10
  it { expect { test_case.assert_resqued 'spec/fixtures/test_case_environment.rb', 'spec/fixtures/test_case_before_fork_raises.rb' }.to raise_error }
14
- it { expect { test_case.assert_resqued 'spec/fixtures/test_case_environment.rb', 'spec/fixtures/test_case_after_fork_raises.rb' }.not_to raise_error }
11
+ it { expect { test_case.assert_resqued 'spec/fixtures/test_case_environment.rb', 'spec/fixtures/test_case_after_fork_raises.rb' }.to raise_error }
15
12
  it { expect { test_case.assert_resqued 'spec/fixtures/test_case_environment.rb', 'spec/fixtures/test_case_no_workers.rb' }.not_to raise_error }
16
- it { expect { test_case.assert_resqued 'spec/fixtures/test_case_environment.rb', 'spec/fixtures/test_case_clean.rb', :expect_workers => true }.not_to raise_error }
17
- it { expect { test_case.assert_resqued 'spec/fixtures/test_case_environment.rb', 'spec/fixtures/test_case_after_fork_raises.rb', :expect_workers => true }.to raise_error }
18
- it { expect { test_case.assert_resqued 'spec/fixtures/test_case_environment.rb', 'spec/fixtures/test_case_no_workers.rb', :expect_workers => true }.to raise_error }
19
- end
20
- end
21
-
22
- class MockRedisServer
23
- def start
24
- return if @server
25
- require 'socket'
26
- @server = TCPServer.new(0)
27
- end
28
-
29
- def stop
30
- return unless @server
31
- @server.close
32
- ensure
33
- @server = nil
34
- end
35
-
36
- def port
37
- @server && @server.addr[1]
38
13
  end
39
14
  end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+ require 'resqued/test_case'
3
+
4
+ describe Resqued::TestCase do
5
+ let(:test_case) { Object.new.extend(the_module) }
6
+
7
+ context 'LoadConfig' do
8
+ let(:the_module) { described_class::LoadConfig }
9
+ it { expect { test_case.assert_resqued 'spec/fixtures/test_case_environment.rb', 'spec/fixtures/test_case_clean.rb' }.not_to raise_error }
10
+ it { expect { test_case.assert_resqued 'spec/fixtures/test_case_environment.rb', 'spec/fixtures/test_case_before_fork_raises.rb' }.to raise_error }
11
+ it { expect { test_case.assert_resqued 'spec/fixtures/test_case_environment.rb', 'spec/fixtures/test_case_after_fork_raises.rb' }.to raise_error }
12
+ it { expect { test_case.assert_resqued 'spec/fixtures/test_case_environment.rb', 'spec/fixtures/test_case_no_workers.rb' }.not_to raise_error }
13
+ <<<<<<< HEAD
14
+ =======
15
+ it { expect { test_case.assert_resqued 'spec/fixtures/test_case_environment.rb', 'spec/fixtures/test_case_clean.rb', :expect_workers => true }.not_to raise_error }
16
+ it { expect { test_case.assert_resqued 'spec/fixtures/test_case_environment.rb', 'spec/fixtures/test_case_after_fork_raises.rb', :expect_workers => true }.to raise_error }
17
+ it { expect { test_case.assert_resqued 'spec/fixtures/test_case_environment.rb', 'spec/fixtures/test_case_no_workers.rb', :expect_workers => true }.to raise_error }
18
+ end
19
+ end if false
20
+
21
+ class MockRedisServer
22
+ def start
23
+ return if @server
24
+ require 'socket'
25
+ @server = TCPServer.new(0)
26
+ end
27
+
28
+ def stop
29
+ return unless @server
30
+ @server.close
31
+ ensure
32
+ @server = nil
33
+ end
34
+
35
+ def port
36
+ @server && @server.addr[1]
37
+ >>>>>>> origin/master
38
+ end
39
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resqued
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.6
4
+ version: 0.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Burke
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2013-11-20 00:00:00.000000000 Z
11
+ date: 2013-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kgio
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - '>='
32
32
  - !ruby/object:Gem::Version
33
- version: 1.9.0
33
+ version: 1.9.1
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
- version: 1.9.0
40
+ version: 1.9.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mono_logger
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.0'
55
- - !ruby/object:Gem::Dependency
56
- name: debugger
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - '>='
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: rspec
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -94,48 +80,6 @@ dependencies:
94
80
  - - ~>
95
81
  - !ruby/object:Gem::Version
96
82
  version: 0.9.0
97
- - !ruby/object:Gem::Dependency
98
- name: guard-rspec
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ~>
102
- - !ruby/object:Gem::Version
103
- version: 2.4.1
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ~>
109
- - !ruby/object:Gem::Version
110
- version: 2.4.1
111
- - !ruby/object:Gem::Dependency
112
- name: guard-bundler
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ~>
116
- - !ruby/object:Gem::Version
117
- version: 1.0.0
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ~>
123
- - !ruby/object:Gem::Version
124
- version: 1.0.0
125
- - !ruby/object:Gem::Dependency
126
- name: rb-fsevent
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - '>='
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - '>='
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
83
  description: Daemon of resque workers
140
84
  email: spraints@gmail.com
141
85
  executables:
@@ -177,11 +121,12 @@ files:
177
121
  - spec/resqued/config/worker_spec.rb
178
122
  - spec/resqued/sleepy_spec.rb
179
123
  - spec/resqued/test_case_spec.rb
124
+ - spec/resqued/test_case_spec.rb.orig
180
125
  - spec/spec_helper.rb
181
126
  - spec/support/custom_matchers.rb
182
127
  - exe/resqued
183
128
  - exe/resqued-listener
184
- homepage: https://github.com
129
+ homepage: https://github.com/spraints/resqued
185
130
  licenses: []
186
131
  metadata: {}
187
132
  post_install_message:
@@ -215,5 +160,6 @@ test_files:
215
160
  - spec/resqued/config/worker_spec.rb
216
161
  - spec/resqued/sleepy_spec.rb
217
162
  - spec/resqued/test_case_spec.rb
163
+ - spec/resqued/test_case_spec.rb.orig
218
164
  - spec/spec_helper.rb
219
165
  - spec/support/custom_matchers.rb