puppet_forge 5.0.1 → 5.0.2

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: 03c98f5fd125a4ff36b815a734d7ac6bf7d51578550a1b873fcea09c33d028be
4
- data.tar.gz: 34f9e9b0f8e55939349ea47f4fb9c2ad8324a179c73fbb728709f453d9f5bfdf
3
+ metadata.gz: 173cc16e95da2ae090f719e7d6b1ff2e86f444c27f8c88ada965047e7c24afcc
4
+ data.tar.gz: 97b40c77169ce1c3f67fcf1ea70e48d8738e9623c3a9a76aa451e493b316b1ca
5
5
  SHA512:
6
- metadata.gz: 026cf550bb188d6e04eda4dc97a053439f49745fef1413b71c7c1ae9f9e8ed950fe3f89ca2e7d93924e86929e91f7d40ebcd526696992f2c9ddb15adcb20def5
7
- data.tar.gz: eee31c229447d406879270db396987ccc75c9cf3fd554efa8805dbbd22d931df648240c08bed8cdd6789f322d40f6e937eade56edd9ea6ce2a27e336c31325fa
6
+ metadata.gz: 9cea98cd9ec0b7a20f385c61b3f1776067eea4c4345dfc1d20ed274813d24a0d46af80109e709d57014e2cad09cd765ada4e82902cc1c3d3a698f0906453c7bb
7
+ data.tar.gz: a6bf1839d69b0bd3404c104e6621fe77e29c6e89cedc5ca19b0cdf78c9750ce60bb1cbc5879b23fd807f477b6731c281b6c830da3a48a11ad4fb6845dd1c899d
data/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  Starting with v2.0.0, all notable changes to this project will be documented in this file.
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## v5.0.2 - 2023-09-29
7
+ * Correct a Digest call making this thread-safe and allowing for concurrent r10k deploys.
8
+ Thanks to @cmd-ntrf for fixing it and to @baurmatt for tracking it down in the first place.
9
+
6
10
  ## v5.0.1 - 2023-07-10
7
11
  * Update README to reflect accurate Ruby requirement and `faraday` gem dependency
8
12
  ## v5.0.0 - 2023-05-07
@@ -9,7 +9,7 @@ module PuppetForge
9
9
  # a convenience method for generating cache keys. Cache keys do not
10
10
  # have to be SHA256 hashes, but they must be unique.
11
11
  def self.new_key(*string_args)
12
- Digest::SHA256.hexdigest(string_args.map(&:to_s).join(':'))
12
+ Digest(:SHA256).hexdigest(string_args.map(&:to_s).join(':'))
13
13
  end
14
14
 
15
15
  # @return [Integer] the maximum number of items to cache.
@@ -1,3 +1,3 @@
1
1
  module PuppetForge
2
- VERSION = '5.0.1' # Library version
2
+ VERSION = '5.0.2' # Library version
3
3
  end
@@ -67,18 +67,26 @@ describe PuppetForge::LruCache do
67
67
  expect(cache.send(:lru)).to eq(['foo', 'baz'])
68
68
  end
69
69
 
70
- # The below test is non-deterministic but I'm not sure how to unit
71
- # test thread-safety.
72
- # it 'is thread-safe' do
73
- # cache = PuppetForge::LruCache.new
74
- # cache.put('foo', 'bar')
75
- # cache.put('baz', 'qux')
76
- # threads = []
77
- # threads << Thread.new { 100.times { cache.get('foo') } }
78
- # threads << Thread.new { 100.times { cache.get('baz') } }
79
- # threads.each(&:join)
80
- # expect(cache.send(:lru)).to eq(['baz', 'foo'])
81
- # end
70
+ it 'is thread-safe for get calls' do
71
+ cache = PuppetForge::LruCache.new
72
+
73
+ # Populate the cache with initial values
74
+ cache.put('foo', 'bar')
75
+ cache.put('baz', 'qux')
76
+
77
+ # Create two threads for concurrent cache get operations
78
+ thread_one = Thread.new do
79
+ 100.times { expect(cache.get('foo')).to eq('bar') }
80
+ end
81
+
82
+ thread_two = Thread.new do
83
+ 100.times { expect(cache.get('baz')).to eq('qux') }
84
+ end
85
+
86
+ # Wait for both threads to complete
87
+ thread_one.join
88
+ thread_two.join
89
+ end
82
90
  end
83
91
 
84
92
  context '#put' do
@@ -102,16 +110,30 @@ describe PuppetForge::LruCache do
102
110
  expect(cache.send(:lru)).to eq(['quux', 'baz'])
103
111
  end
104
112
 
105
- # The below test is non-deterministic but I'm not sure how to unit
106
- # test thread-safety.
107
- # it 'is thread-safe' do
108
- # cache = PuppetForge::LruCache.new
109
- # threads = []
110
- # threads << Thread.new { 100.times { cache.put('foo', 'bar') } }
111
- # threads << Thread.new { 100.times { cache.put('baz', 'qux') } }
112
- # threads.each(&:join)
113
- # expect(cache.send(:lru)).to eq(['baz', 'foo'])
114
- # end
113
+ it 'is thread-safe' do
114
+ cache = PuppetForge::LruCache.new
115
+
116
+ # Create two threads for concurrent cache operations
117
+ thread_one = Thread.new do
118
+ 100.times { cache.put('foo', 'bar') }
119
+ end
120
+
121
+ thread_two = Thread.new do
122
+ 100.times { cache.put('baz', 'qux') }
123
+ end
124
+
125
+ # Wait for both threads to complete
126
+ thread_one.join
127
+ thread_two.join
128
+
129
+ # At this point, we don't need to compare the LRU list,
130
+ # because the order may change due to concurrent puts.
131
+
132
+ # Instead, we simply expect the code to run without errors.
133
+ expect { thread_one.value }.not_to raise_error
134
+ expect { thread_two.value }.not_to raise_error
135
+ end
136
+
115
137
  end
116
138
 
117
139
  context '#clear' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet_forge
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.1
4
+ version: 5.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Labs
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-10 00:00:00.000000000 Z
11
+ date: 2023-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -253,7 +253,7 @@ homepage: https://github.com/puppetlabs/forge-ruby
253
253
  licenses:
254
254
  - Apache-2.0
255
255
  metadata: {}
256
- post_install_message:
256
+ post_install_message:
257
257
  rdoc_options: []
258
258
  require_paths:
259
259
  - lib
@@ -268,8 +268,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
268
268
  - !ruby/object:Gem::Version
269
269
  version: '0'
270
270
  requirements: []
271
- rubygems_version: 3.1.6
272
- signing_key:
271
+ rubygems_version: 3.3.7
272
+ signing_key:
273
273
  specification_version: 4
274
274
  summary: Access the Puppet Forge API from Ruby for resource information and to download
275
275
  releases.