chaotic_job 0.1.1 → 0.2.0

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: b82a52379f9efe41b3243e19904fa96e0cc8703bf813a42401b74128242ea6a2
4
- data.tar.gz: b4979b0ba3ddec6e2c8ab680458853a7ffeda84e25af95e6858d16846f5d77b2
3
+ metadata.gz: 8241f1235f37ed46c1da18d53e18c6fce43fb5758273bb51dba8db332dddb5b6
4
+ data.tar.gz: fc86ee73cf18b16d6142f7111e5d1cfa446b46bfea2e1959eb7aa222a5bf42dd
5
5
  SHA512:
6
- metadata.gz: 0f38bed8995ac63a1755dcb316c3886dcf32cb5fb953aec4d3be8ce4b3b7690c76febacc458fc05ca2e30ef8b67947a4b639f7035e8cea7aac84d59bd1da37a3
7
- data.tar.gz: 616f9d8543fa39d00e30f82bd20edb22ddae4578f4c0e9a7557135b599002f9dbdc29a64bba6c25471a76f489004556745e3708310789d6f716fe9c879ccd2ff
6
+ metadata.gz: 7d32f1ab9748ea544d13c15692934634a6c3bcc01d602903e5e554abd229b7623a6a9aff111357031f474ec701fcd96131994604a121f9e55672eaed2616107b
7
+ data.tar.gz: c8ef73d8d07a091f59ebd1347ecc3f11fbd6ba6abc3eee218e251600ff156f748ec2a911d8108834cad96f9ce7ef59d1b3989606a27a827f1bb7bd93bfd9b062
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.0] - 2024-11-06
4
+
5
+ - Update the `perform_all` helper method to `perform_all_jobs`
6
+ - Update the `perform_all_before` helper method to `perform_all_jobs_before`
7
+ - Update the `perform_all_after` helper method to `perform_all_jobs_after`
8
+ - Update the `perform_all_within` helper method to `perform_all_jobs_within`
9
+
3
10
  ## [0.1.1] - 2024-11-06
4
11
 
5
12
  - Update `Journal` interface
data/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
  > [!TIP]
11
11
  > This gem helps you test that your Active Jobs are reliable and resilient to failures. If you want to more easily *build* reliable and resilient Active Jobs, check out the companion [Acidic Job](https://github.com/fractaledmind/acidic_job/tree/alpha-1.0) gem.
12
12
 
13
- `ChaoticJob` provides a set of tools to help you test the reliability and resilience of your Active Jobs. It does this by allowing you to simulate various types of failures and glitches that can occur in a production environment.
13
+ `ChaoticJob` provides a set of tools to help you test the reliability and resilience of your Active Jobs. It does this by allowing you to simulate various types of failures and glitches that can occur in a production environment, inspired by the principles of [chaos testing](https://principlesofchaos.org) and [deterministic simulation testing](https://blog.resonatehq.io/deterministic-simulation-testing)
14
14
 
15
15
  ## Installation
16
16
 
@@ -59,29 +59,29 @@ end
59
59
 
60
60
  But, this method does not behave as you would expect. Functionally, it overwrites the `enqueue` method to immediately perform the job, which means that instead of your job being performed in waves, the retry is performed _within_ the execution of the original job. This both confuses the logs and means the behavior in your tests are not representative of the behavior in production.
61
61
 
62
- In order to properly test job retries, you should use the `perform_all` method provided by `ChaoticJob::Helpers`:
62
+ In order to properly test job retries, you should use the `perform_all_jobs` method provided by `ChaoticJob::Helpers`:
63
63
 
64
64
  ```ruby
65
65
  Job.perform_later
66
- perform_all
66
+ perform_all_jobs
67
67
  ```
68
68
 
69
69
  This helper will perform the job and all of its retries in the proper way, in waves, just like it would in production.
70
70
 
71
- If you need more control over which batches of jobs are performed, you can use the `perform_all_before` and `perform_all_after` methods. These are particularly useful if you need to test the behavior of a job that schedules another job. You can use these methods to perform only the original job and its retries, assert the state of the system, and then perform the scheduled job and its retries.
71
+ If you need more control over which batches of jobs are performed, you can use the `perform_all_jobs_before` and `perform_all_jobs_after` methods. These are particularly useful if you need to test the behavior of a job that schedules another job. You can use these methods to perform only the original job and its retries, assert the state of the system, and then perform the scheduled job and its retries.
72
72
 
73
73
  ```ruby
74
74
  JobThatSchedules.perform_later
75
- perform_all_before(4.seconds)
75
+ perform_all_jobs_before(4.seconds)
76
76
  assert_equal 1, enqueued_jobs.size
77
77
  assert_equal 2, performed_jobs.size
78
78
 
79
- perform_all_after(1.day)
79
+ perform_all_jobs_after(1.day)
80
80
  assert_equal 0, enqueued_jobs.size
81
81
  assert_equal 3, performed_jobs.size
82
82
  ```
83
83
 
84
- You can pass either a `Time` object or an `ActiveSupport::Duration` object to these methods. And, to make the code as readable as possible, the `perform_all_before` is also aliased as the `perform_all_within` method. This allows you to write the example above as `perform_all_within(4.seconds)`.
84
+ You can pass either a `Time` object or an `ActiveSupport::Duration` object to these methods. And, to make the code as readable as possible, the `perform_all_jobs_before` is also aliased as the `perform_all_jobs_within` method. This allows you to write the example above as `perform_all_jobs_within(4.seconds)`.
85
85
 
86
86
  ### Simulating Failures
87
87
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ChaoticJob
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/chaotic_job.rb CHANGED
@@ -40,19 +40,16 @@ module ChaoticJob
40
40
  end
41
41
 
42
42
  module Helpers
43
- def perform_all
43
+ def perform_all_jobs
44
44
  Performer.perform_all
45
45
  end
46
46
 
47
- def perform_all_within(time)
48
- Performer.perform_all_within(time)
49
- end
50
-
51
- def perform_all_before(time)
47
+ def perform_all_jobs_before(time)
52
48
  Performer.perform_all_before(time)
53
49
  end
50
+ alias_method :perform_all_jobs_within, :perform_all_jobs_before
54
51
 
55
- def perform_all_after(time)
52
+ def perform_all_jobs_after(time)
56
53
  Performer.perform_all_after(time)
57
54
  end
58
55
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chaotic_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Margheim