Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scheduler+lock tests #1

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2

[*.{diff}]
trim_trailing_whitespace = false
67 changes: 67 additions & 0 deletions .github/workflows/test-scheduler-lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
on:
push:
branches: [$default-branch]
pull_request:
jobs:
test-scheduler-lock:
runs-on: ubuntu-latest
services:
# Label used to access the service container
redis:
# Docker Hub image
image: redis
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps port 6379 on service container to the host
- "6379:6379"
strategy:
fail-fast: false
matrix:
ruby-version:
- "3.0"
- "3.1"
- "3.2"
- "3.3"
resque-version:
- "~> 1.23"
redis-version:
- "~> 3.3"
- "~> 4.8"
resque-scheduler-version:
- "4.3.0"
- "< 4.9.0"
- "~> 4.9"
- "https://github.com/Ibotta/resque-scheduler.git@enqueue-multi-rollback"
resque-lock-timeout-version:
- "latest"
- "https://github.com/Ibotta/resque-lock-timeout.git@v0.5.0-ibotta"
- "https://github.com/Ibotta/resque-lock-timeout.git@tests-with-scheduler"
exclude:
# resque-scheduler (= 4.3.0) depends on redis (~> 3.3)
- redis-version: "~> 4.8"
resque-scheduler-version: "4.3.0"
env:
REDIS_VERSION: "${{ matrix.redis-version }}"
RESQUE: "${{ matrix.resque-version }}"
RESQUE_SCHEDULER_VERSION: "${{ matrix.resque-scheduler-version }}"
RESQUE_LOCK_TIMEOUT_VERSION: "${{ matrix.resque-lock-timeout-version }}"
# The hostname used to communicate with the Redis service container
REDIS_TEST_HOST: localhost
# The default Redis port
REDIS_TEST_PORT: 6379
steps:
- uses: actions/checkout@v4
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
working-directory: scheduler-lock
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- name: Run tests
working-directory: scheduler-lock
run: bundle exec rake
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,7 @@ build-iPhoneSimulator/

# Used by RuboCop. Remote config files pulled in from inherit_from directive.
# .rubocop-https?--*
stdout
dump.rdb
coverage
Gemfile.lock
74 changes: 74 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
education, socio-economic status, nationality, personal appearance, race,
religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at osscompliance@ibotta.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

51 changes: 51 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
## 0.5.0 (Ibotta) (2023-01-23)

- Fix: normalize args when creating identifier
- Fix: adjust test with concurrency issues
- Maintenance: Update gem dependencies to support rubies >= 2.7
- Maintenance: test against redis gem 3, 4
- Maintenance: run in github actions

## 0.4.5 (2015-08-04)

- Fix: ensure exceptions are kept if raised **after** lock timeout expires.

## 0.4.4 (2014-02-21)

- Add: `enqueued?` and `loner_locked?` helper methods.
- Bump minimum version of resque to v1.22

## 0.4.1 (2012-11-19)

- Fix: allow `@loner` job to be enqueued if timeout expires.

## 0.4.0 (2012-11-09)

- Add: `@loner` boolean option to prevent job being enqueued if already
running/enqueued. (Thanks to @ssaunier)

## 0.3.3 (2012-03-09)

- Tested against v1.20.0 of resque.

## 0.3.1 (2011-07-16)

- Pass job arguments to `lock_timeout`. (Bob Potter)
- Added `refresh_lock!` method for long running jobs. (Bob Potter)

## 0.3.0 (2011-07-16)

- Ability to customize redis connection used for storing locks.
(thanks Richie Vos =))
- Added Bundler `Gemfile`.
- Added abstract stub methods for callback methods:
`lock_failed`, `lock_expired_before_release`

## 0.2.1 (2010-06-16)

- Relax gemspec dependancies.

## 0.2.0 (2010-05-05)

- Initial release as `resque-lock-timeout`, forked from Chris Wanstrath'
`resque-lock`.
60 changes: 60 additions & 0 deletions scheduler-lock/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
source "https://rubygems.org"

case resque_version = ENV.fetch("RESQUE", "latest")
when "master"
gem "resque", git: "https://github.com/resque/resque"
when /^git:/, /^https:/
gem "resque", git: resque_version
when "latest"
gem "resque"
else
versions = resque_version.split(",")
gem "resque", *versions
end

case redis_version = ENV.fetch("REDIS_VERSION", "latest")
when "master"
gem "redis", git: "https://github.com/redis/redis-rb"
when /^git:/, /^https:/
gem "redis", git: redis_version
when "latest"
gem "redis"
else
versions = redis_version.split(",")
gem "redis", *versions
end

case resque_scheduler_version = ENV.fetch("RESQUE_SCHEDULER_VERSION", "latest")
when "master"
gem "resque-scheduler", git: "https://github.com/resque/resque-scheduler"
when /^git:/, /^https:/
repo, ref = resque_scheduler_version.split("@", 2)
gem "resque-scheduler", git: repo, ref: ref
when "latest"
gem "resque-scheduler"
else
versions = resque_scheduler_version.split(",")
gem "resque-scheduler", *versions
end

case resque_lock_timeout_version = ENV.fetch("RESQUE_LOCK_TIMEOUT_VERSION", "latest")
when "master"
gem "resque-lock-timeout", git: "https://github.com/Ibotta/resque-lock-timeout.git"
when /^git:/, /^https:/
repo, ref = resque_lock_timeout_version.split("@", 2)
gem "resque-lock-timeout", git: repo, ref: ref
when "latest"
gem "resque-lock-timeout"
else
versions = resque_lock_timeout_version.split(",")
gem "resque-lock-timeout", *versions
end

gem "rake"
gem "minitest"
gem "simplecov"
gem "debug"

gem "standard", "~> 1.41"

gem "logger", "~> 1.6"
9 changes: 9 additions & 0 deletions scheduler-lock/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require "rake/testtask"

task default: :test

desc "Run unit tests."
Rake::TestTask.new(:test) do |task|
task.test_files = FileList["test/*_test.rb"]
task.verbose = true
end
Loading