gush 2.0.0 → 2.0.1

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
  SHA256:
3
- metadata.gz: a9e61295e87f5c707a6f93a3cce7238c0650876be7ff76c4cba0c60133832217
4
- data.tar.gz: 7df67c0134bc1e7bd036da850287191463557a764279790072f3f0a3887bf44b
3
+ metadata.gz: ffcdce12d2f530e27afdd048328d8942e60efcddfbe20a18426b8d245589c759
4
+ data.tar.gz: 3c95194d44f446a694af83b06b06eac55a3e5ed1f8555fe86958fa110b357647
5
5
  SHA512:
6
- metadata.gz: 133913d52aaef1d470ca8be41c865c26949577df06935b034e83bb0ee616f5cd812d0c49730bbfc504342a46a6f0c6b813df19705f0a6c4448ba18969172e418
7
- data.tar.gz: b08039f50aba1ab24fbe957669f16d51258913353ffba98b168a9df74782b46459c79f083c7e54b1dfa717a5878e85bb72ba07397993f833e83f9733ec5089dd
6
+ metadata.gz: e75e7f0ae5c5c83302d0507bb502a30a860f276e0706edd5a4119bb9c50bf88c73c9839ac1f141f4569017301ebb61fe943317d214c0c9a10f49309e674bd183
7
+ data.tar.gz: 38f3baaa43a4d512d5d5ec6c476d21965d27116e7dc8bc1ae3cc3fa4a4fac13e6d18272ed236fd413aba0c304f0e79aee59f3c06cdad19db7fa02e41305fe491
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## 2.0.1
9
+
10
+ ### Fixed
11
+
12
+ - Fix bug when retried jobs didn't correctly reset their failed flag when ran again (Thanks to @theo-delaune-argus and @mickael-palma-argus! [See issue](https://github.com/chaps-io/gush/issues/61))
13
+
8
14
  ## 2.0.0
9
15
 
10
16
  ## Changed
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "gush"
7
- spec.version = "2.0.0"
7
+ spec.version = "2.0.1"
8
8
  spec.authors = ["Piotrek Okoński"]
9
9
  spec.email = ["piotrek@okonski.org"]
10
10
  spec.summary = "Fast and distributed workflow runner based on ActiveJob and Redis"
@@ -47,6 +47,7 @@ module Gush
47
47
 
48
48
  def start!
49
49
  @started_at = current_timestamp
50
+ @failed_at = nil
50
51
  end
51
52
 
52
53
  def enqueue!
@@ -15,6 +15,53 @@ describe "Workflows" do
15
15
  end
16
16
  end
17
17
 
18
+ context 'when one of the jobs fails initally' do
19
+ it 'succeeds when the job retries' do
20
+ FAIL_THEN_SUCCEED_SPY = double()
21
+ allow(FAIL_THEN_SUCCEED_SPY).to receive(:foo).and_return('failure', 'success')
22
+
23
+ class FailsThenSucceeds < Gush::Job
24
+ def perform
25
+ if FAIL_THEN_SUCCEED_SPY.foo == 'failure'
26
+ raise NameError
27
+ end
28
+ end
29
+ end
30
+
31
+ class SecondChanceWorkflow < Gush::Workflow
32
+ def configure
33
+ run Prepare
34
+ run FailsThenSucceeds, after: Prepare
35
+ run NormalizeJob, after: FailsThenSucceeds
36
+ end
37
+ end
38
+
39
+ flow = SecondChanceWorkflow.create
40
+ flow.start!
41
+
42
+ expect(Gush::Worker).to have_jobs(flow.id, jobs_with_id(['Prepare']))
43
+ perform_one
44
+
45
+ expect(Gush::Worker).to have_jobs(flow.id, jobs_with_id(['FailsThenSucceeds']))
46
+ expect do
47
+ perform_one
48
+ end.to raise_error(NameError)
49
+
50
+ expect(flow.reload).to be_failed
51
+ expect(Gush::Worker).to have_jobs(flow.id, jobs_with_id(['FailsThenSucceeds']))
52
+
53
+ # Retry the same job again, but this time succeeds
54
+ perform_one
55
+
56
+ expect(Gush::Worker).to have_jobs(flow.id, jobs_with_id(['NormalizeJob']))
57
+ perform_one
58
+
59
+ flow = flow.reload
60
+ expect(flow).to be_finished
61
+ expect(flow).to_not be_failed
62
+ end
63
+ end
64
+
18
65
  it "runs the whole workflow in proper order" do
19
66
  flow = TestWorkflow.create
20
67
  flow.start!
@@ -77,8 +124,6 @@ describe "Workflows" do
77
124
 
78
125
  perform_one
79
126
  expect(flow.reload.find_job("PrependJob").output_payload).to eq("A prefix: SOME TEXT")
80
-
81
-
82
127
  end
83
128
 
84
129
  it "passes payloads from workflow that runs multiple same class jobs with nameized payloads" do
@@ -52,10 +52,18 @@ describe Gush::Job do
52
52
  describe "#start!" do
53
53
  it "resets flags and marks as running" do
54
54
  job = described_class.new(name: "a-job")
55
+
56
+ job.enqueue!
57
+ job.fail!
58
+
59
+ now = Time.now.to_i
60
+ expect(job.started_at).to eq(nil)
61
+ expect(job.failed_at).to eq(now)
62
+
55
63
  job.start!
64
+
56
65
  expect(job.started_at).to eq(Time.now.to_i)
57
- expect(job.enqueued?).to eq(false)
58
- expect(job.running?).to eq(true)
66
+ expect(job.failed_at).to eq(nil)
59
67
  end
60
68
  end
61
69
 
@@ -14,7 +14,7 @@ class PersistSecondJob < Gush::Job; end
14
14
  class NormalizeJob < Gush::Job; end
15
15
  class BobJob < Gush::Job; end
16
16
 
17
- GUSHFILE = Pathname.new(__FILE__).parent.join("Gushfile")
17
+ GUSHFILE = Pathname.new(__FILE__).parent.join("Gushfile")
18
18
 
19
19
  class TestWorkflow < Gush::Workflow
20
20
  def configure
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gush
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotrek Okoński
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-22 00:00:00.000000000 Z
11
+ date: 2019-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob