chef-utils 18.0.161 → 18.0.169

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +201 -201
  3. data/Rakefile +15 -15
  4. data/chef-utils.gemspec +50 -50
  5. data/lib/chef-utils/dist.rb +154 -154
  6. data/lib/chef-utils/dsl/architecture.rb +150 -150
  7. data/lib/chef-utils/dsl/cloud.rb +155 -155
  8. data/lib/chef-utils/dsl/default_paths.rb +60 -60
  9. data/lib/chef-utils/dsl/introspection.rb +134 -134
  10. data/lib/chef-utils/dsl/os.rb +58 -58
  11. data/lib/chef-utils/dsl/path_sanity.rb +39 -39
  12. data/lib/chef-utils/dsl/platform.rb +387 -387
  13. data/lib/chef-utils/dsl/platform_family.rb +360 -360
  14. data/lib/chef-utils/dsl/platform_version.rb +41 -41
  15. data/lib/chef-utils/dsl/service.rb +112 -112
  16. data/lib/chef-utils/dsl/train_helpers.rb +87 -87
  17. data/lib/chef-utils/dsl/virtualization.rb +272 -272
  18. data/lib/chef-utils/dsl/which.rb +123 -123
  19. data/lib/chef-utils/dsl/windows.rb +86 -86
  20. data/lib/chef-utils/internal.rb +114 -114
  21. data/lib/chef-utils/mash.rb +263 -263
  22. data/lib/chef-utils/parallel_map.rb +131 -131
  23. data/lib/chef-utils/version.rb +20 -20
  24. data/lib/chef-utils/version_string.rb +160 -160
  25. data/lib/chef-utils.rb +53 -53
  26. data/spec/spec_helper.rb +100 -100
  27. data/spec/unit/dsl/architecture_spec.rb +151 -151
  28. data/spec/unit/dsl/cloud_spec.rb +93 -93
  29. data/spec/unit/dsl/dsl_spec.rb +34 -34
  30. data/spec/unit/dsl/introspection_spec.rb +201 -201
  31. data/spec/unit/dsl/os_spec.rb +175 -175
  32. data/spec/unit/dsl/path_sanity_spec.rb +86 -86
  33. data/spec/unit/dsl/platform_family_spec.rb +235 -235
  34. data/spec/unit/dsl/platform_spec.rb +252 -252
  35. data/spec/unit/dsl/service_spec.rb +117 -117
  36. data/spec/unit/dsl/virtualization_spec.rb +75 -75
  37. data/spec/unit/dsl/which_spec.rb +171 -171
  38. data/spec/unit/dsl/windows_spec.rb +84 -84
  39. data/spec/unit/mash_spec.rb +51 -51
  40. data/spec/unit/parallel_map_spec.rb +156 -156
  41. metadata +3 -3
@@ -1,156 +1,156 @@
1
- # frozen_string_literal: true
2
- #
3
- # Copyright:: Copyright (c) Chef Software Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require "chef-utils/parallel_map"
20
-
21
- using ChefUtils::ParallelMap
22
-
23
- RSpec.describe ChefUtils::ParallelMap do
24
-
25
- shared_examples_for "common parallel API tests" do
26
-
27
- before(:each) do
28
- ChefUtils::DefaultThreadPool.instance.instance_variable_set(:@pool, nil)
29
- ChefUtils::DefaultThreadPool.instance.threads = threads
30
- end
31
-
32
- after(:each) do
33
- ChefUtils::DefaultThreadPool.instance.instance_variable_set(:@pool, nil)
34
- end
35
-
36
- it "parallel_map runs in parallel" do
37
- # this is implicitly also testing that we run in the caller when we exhaust threads by running threads+1
38
- val = threads + 1
39
- ret = []
40
- start = Time.now
41
- (1..val).parallel_map do |i|
42
- loop do
43
- if val == i
44
- ret << i
45
- val -= 1
46
- break
47
- end
48
- # we spin for quite awhile to wait for very slow testers if we have to
49
- if Time.now - start > 30
50
- raise "timed out; deadlocked due to lack of parallelization?"
51
- end
52
-
53
- # need to sleep a tiny bit to let other threads schedule
54
- sleep 0.000001
55
- end
56
- end
57
- expected = (1..threads + 1).to_a.reverse
58
- expect(ret).to eql(expected)
59
- end
60
-
61
- it "parallel_each runs in parallel" do
62
- # this is implicitly also testing that we run in the caller when we exhaust threads by running threads+1
63
- val = threads + 1
64
- ret = []
65
- start = Time.now
66
- (1..val).parallel_each do |i|
67
- loop do
68
- if val == i
69
- ret << i
70
- val -= 1
71
- break
72
- end
73
- # we spin for quite awhile to wait for very slow testers if we have to
74
- if Time.now - start > 30
75
- raise "timed out; deadlocked due to lack of parallelization?"
76
- end
77
-
78
- # need to sleep a tiny bit to let other threads schedule
79
- sleep 0.000001
80
- end
81
- end
82
- expected = (1..threads + 1).to_a.reverse
83
- expect(ret).to eql(expected)
84
- end
85
-
86
- it "parallel_map throws exceptions" do
87
- expect { (0..10).parallel_map { |i| raise "boom" } }.to raise_error(RuntimeError)
88
- end
89
-
90
- it "parallel_each throws exceptions" do
91
- expect { (0..10).parallel_each { |i| raise "boom" } }.to raise_error(RuntimeError)
92
- end
93
-
94
- it "parallel_map runs" do
95
- ans = Timeout.timeout(30) do
96
- (1..10).parallel_map { |i| i }
97
- end
98
- expect(ans).to eql((1..10).to_a)
99
- end
100
-
101
- it "parallel_each runs" do
102
- Timeout.timeout(30) do
103
- (1..10).parallel_each { |i| i }
104
- end
105
- end
106
-
107
- it "recursive parallel_map will not deadlock" do
108
- ans = Timeout.timeout(30) do
109
- (1..2).parallel_map { |i| (1..2).parallel_map { |i| i } }
110
- end
111
- expect(ans).to eql([[1, 2], [1, 2]])
112
- end
113
-
114
- it "recursive parallel_each will not deadlock" do
115
- Timeout.timeout(30) do
116
- (1..2).parallel_each { |i| (1..2).parallel_each { |i| i } }
117
- end
118
- end
119
-
120
- it "parallel_map is lazy" do
121
- ans = Timeout.timeout(30) do
122
- (1..).lazy.parallel_map { |i| i }.first(5)
123
- end
124
- expect(ans).to eql((1..5).to_a)
125
- end
126
-
127
- it "parallel_each is lazy" do
128
- Timeout.timeout(30) do
129
- (1..).lazy.parallel_each { |i| i }.first(5)
130
- end
131
- end
132
- end
133
-
134
- context "with 10 threads" do
135
- let(:threads) { 10 }
136
- it_behaves_like "common parallel API tests"
137
- end
138
-
139
- context "with 0 threads" do
140
- let(:threads) { 0 }
141
- it_behaves_like "common parallel API tests"
142
- end
143
-
144
- context "with 1 threads" do
145
- let(:threads) { 1 }
146
- it_behaves_like "common parallel API tests"
147
- end
148
-
149
- context "flat_each" do
150
- it "runs each over items which are nested one level" do
151
- sum = 0
152
- [ [ 1, 2 ], [3, 4]].flat_each { |i| sum += i }
153
- expect(sum).to eql(10)
154
- end
155
- end
156
- end
1
+ # frozen_string_literal: true
2
+ #
3
+ # Copyright:: Copyright (c) Chef Software Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require "chef-utils/parallel_map"
20
+
21
+ using ChefUtils::ParallelMap
22
+
23
+ RSpec.describe ChefUtils::ParallelMap do
24
+
25
+ shared_examples_for "common parallel API tests" do
26
+
27
+ before(:each) do
28
+ ChefUtils::DefaultThreadPool.instance.instance_variable_set(:@pool, nil)
29
+ ChefUtils::DefaultThreadPool.instance.threads = threads
30
+ end
31
+
32
+ after(:each) do
33
+ ChefUtils::DefaultThreadPool.instance.instance_variable_set(:@pool, nil)
34
+ end
35
+
36
+ it "parallel_map runs in parallel" do
37
+ # this is implicitly also testing that we run in the caller when we exhaust threads by running threads+1
38
+ val = threads + 1
39
+ ret = []
40
+ start = Time.now
41
+ (1..val).parallel_map do |i|
42
+ loop do
43
+ if val == i
44
+ ret << i
45
+ val -= 1
46
+ break
47
+ end
48
+ # we spin for quite awhile to wait for very slow testers if we have to
49
+ if Time.now - start > 30
50
+ raise "timed out; deadlocked due to lack of parallelization?"
51
+ end
52
+
53
+ # need to sleep a tiny bit to let other threads schedule
54
+ sleep 0.000001
55
+ end
56
+ end
57
+ expected = (1..threads + 1).to_a.reverse
58
+ expect(ret).to eql(expected)
59
+ end
60
+
61
+ it "parallel_each runs in parallel" do
62
+ # this is implicitly also testing that we run in the caller when we exhaust threads by running threads+1
63
+ val = threads + 1
64
+ ret = []
65
+ start = Time.now
66
+ (1..val).parallel_each do |i|
67
+ loop do
68
+ if val == i
69
+ ret << i
70
+ val -= 1
71
+ break
72
+ end
73
+ # we spin for quite awhile to wait for very slow testers if we have to
74
+ if Time.now - start > 30
75
+ raise "timed out; deadlocked due to lack of parallelization?"
76
+ end
77
+
78
+ # need to sleep a tiny bit to let other threads schedule
79
+ sleep 0.000001
80
+ end
81
+ end
82
+ expected = (1..threads + 1).to_a.reverse
83
+ expect(ret).to eql(expected)
84
+ end
85
+
86
+ it "parallel_map throws exceptions" do
87
+ expect { (0..10).parallel_map { |i| raise "boom" } }.to raise_error(RuntimeError)
88
+ end
89
+
90
+ it "parallel_each throws exceptions" do
91
+ expect { (0..10).parallel_each { |i| raise "boom" } }.to raise_error(RuntimeError)
92
+ end
93
+
94
+ it "parallel_map runs" do
95
+ ans = Timeout.timeout(30) do
96
+ (1..10).parallel_map { |i| i }
97
+ end
98
+ expect(ans).to eql((1..10).to_a)
99
+ end
100
+
101
+ it "parallel_each runs" do
102
+ Timeout.timeout(30) do
103
+ (1..10).parallel_each { |i| i }
104
+ end
105
+ end
106
+
107
+ it "recursive parallel_map will not deadlock" do
108
+ ans = Timeout.timeout(30) do
109
+ (1..2).parallel_map { |i| (1..2).parallel_map { |i| i } }
110
+ end
111
+ expect(ans).to eql([[1, 2], [1, 2]])
112
+ end
113
+
114
+ it "recursive parallel_each will not deadlock" do
115
+ Timeout.timeout(30) do
116
+ (1..2).parallel_each { |i| (1..2).parallel_each { |i| i } }
117
+ end
118
+ end
119
+
120
+ it "parallel_map is lazy" do
121
+ ans = Timeout.timeout(30) do
122
+ (1..).lazy.parallel_map { |i| i }.first(5)
123
+ end
124
+ expect(ans).to eql((1..5).to_a)
125
+ end
126
+
127
+ it "parallel_each is lazy" do
128
+ Timeout.timeout(30) do
129
+ (1..).lazy.parallel_each { |i| i }.first(5)
130
+ end
131
+ end
132
+ end
133
+
134
+ context "with 10 threads" do
135
+ let(:threads) { 10 }
136
+ it_behaves_like "common parallel API tests"
137
+ end
138
+
139
+ context "with 0 threads" do
140
+ let(:threads) { 0 }
141
+ it_behaves_like "common parallel API tests"
142
+ end
143
+
144
+ context "with 1 threads" do
145
+ let(:threads) { 1 }
146
+ it_behaves_like "common parallel API tests"
147
+ end
148
+
149
+ context "flat_each" do
150
+ it "runs each over items which are nested one level" do
151
+ sum = 0
152
+ [ [ 1, 2 ], [3, 4]].flat_each { |i| sum += i }
153
+ expect(sum).to eql(10)
154
+ end
155
+ end
156
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 18.0.161
4
+ version: 18.0.169
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef Software, Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-13 00:00:00.000000000 Z
11
+ date: 2022-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  - !ruby/object:Gem::Version
95
95
  version: '0'
96
96
  requirements: []
97
- rubygems_version: 3.3.7
97
+ rubygems_version: 3.2.32
98
98
  signing_key:
99
99
  specification_version: 4
100
100
  summary: Basic utility functions for Core Chef Infra development