Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into api-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
meatballhat committed Feb 18, 2014
2 parents 1a5212b + 59e1679 commit b09d0a2
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ nbproject
*.swp

/coverage/
/.vagrant/
/dump.rdb
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@ language: ruby
rvm:
- 1.9.3
- 2.0.0
- 2.1.0
- jruby-19mode
- rbx
env:
global:
- RESQUE_SCHEDULER_DISABLE_TEST_REDIS_SERVER=1
matrix:
allow_failures:
- rvm: jruby-19mode
- rvm: rbx
services:
- redis-server
notifications:
Expand Down
15 changes: 15 additions & 0 deletions .vagrant-provision-as-vagrant.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -e
set -x

ln -svf /vagrant/.vagrant-skel/bashrc ~/.bashrc
ln -svf /vagrant/.vagrant-skel/bash_profile ~/.bash_profile

source ~/.bashrc

set +x
curl -L https://get.rvm.io | bash -s stable --ruby=2.0.0 --auto-dotfiles

source ~/.rvm/scripts/rvm
gem install --no-ri --no-rdoc bundler foreman
23 changes: 23 additions & 0 deletions .vagrant-provision.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

export DEBIAN_FRONTEND=noninteractive

umask 022

set -e
set -x

apt-get update -yq
apt-get install --no-install-suggests -yq python-software-properties
add-apt-repository -y ppa:chris-lea/redis-server
apt-get update -yq
apt-get install --no-install-suggests -yq \
build-essential \
byobu \
curl \
git \
make \
redis-server \
screen

su - vagrant -c /vagrant/.vagrant-provision-as-vagrant.sh
7 changes: 7 additions & 0 deletions .vagrant-skel/bash_profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!bash

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

if [[ "$PS1" ]] ; then
cd /vagrant
fi
7 changes: 7 additions & 0 deletions .vagrant-skel/bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!bash

export LANG='en_US.UTF-8'
export LANGUAGE='en_US.UTF-8'
export LC_ALL='en_US.UTF-8'

export PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,33 @@ of the code looking very similar to resque, particularly in resque-web
and the views. I wanted it to be similar enough that someone familiar
with resque could easily work on resque-scheduler.

### Development

Working on resque-scheduler requires the following:

* A relatively modern Ruby interpreter (MRI 1.9+ is what's tested)
* bundler

The development setup looks like this, which is roughly the same thing
that happens on Travis CI:

``` bash
# Install everything
bundle install
# Make sure tests are green before you change stuff
bundle exec rake
# Change stuff
# Repeat
```

If you have [vagrant](http://www.vagrantup.com) installed, there is a
development box available that requires no plugins or external
provisioners:

``` bash
vagrant up
```

### Contributing

Expand Down
14 changes: 14 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# vim:filetype=ruby

Vagrant.configure('2') do |config|
config.vm.hostname = 'resque-scheduler'
config.vm.box = 'precise64'
config.vm.box_url = 'http://cloud-images.ubuntu.com/vagrant/precise/' <<
'current/precise-server-cloudimg-amd64-vagrant-disk1.box'

config.vm.network :private_network, ip: '33.33.33.10', auto_correct: true
config.vm.network :forwarded_port, guest: 5678, host: 15678,
auto_correct: true

config.vm.provision :shell, path: '.vagrant-provision.sh'
end
4 changes: 4 additions & 0 deletions lib/resque/scheduler/lock/resilient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ def locked?
).to_i == 1
end

def timeout=(t)
@timeout = t if locked?
end

private

def locked_sha(refresh = false)
Expand Down
6 changes: 5 additions & 1 deletion lib/resque/scheduler/server/views/delayed.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@
<% end %>
</td>
<td><%= h(job['args'].inspect) if job && delayed_timestamp_size == 1 %></td>
<td><a href="<%=u URI("/delayed/jobs/#{job['class']}?args=" + URI.encode(job['args'].to_json)) %>">All schedules</a></td>
<td>
<% if job %>
<a href="<%=u URI("/delayed/jobs/#{job['class']}?args=" + URI.encode(job['args'].to_json)) %>">All schedules</a>
<% end %>
</td>
</tr>
<% end %>
</table>
Expand Down
20 changes: 20 additions & 0 deletions test/scheduler_locking_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,5 +257,25 @@ def lock_is_not_held(lock)
assert Resque.redis.ttl(@lock.key) <= 10,
'TTL should not have been updated'
end

test 'setting the lock timeout changes the key TTL if we hold it' do
@lock.acquire!

@lock.timeout = 120
ttl = Resque.redis.ttl(@lock.key)
assert_send [ttl, :>, 100]

@lock.timeout = 180
ttl = Resque.redis.ttl(@lock.key)
assert_send [ttl, :>, 120]
end

test 'setting the lock timeout is a noop if not held' do
@lock.acquire!
@lock.timeout = 100
@lock.stubs(:locked?).returns(false)
@lock.timeout = 120
assert_equal 100, @lock.timeout
end
end
end

0 comments on commit b09d0a2

Please sign in to comment.