cem_acpt 0.3.2-universal-java-17 → 0.3.4-universal-java-17

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,215 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../logging'
4
+ require_relative 'workflow/manager'
5
+ require_relative 'workflow/step'
6
+
7
+ module CemAcpt
8
+ module TestRunner
9
+ # Namespace for workflow classes
10
+ module Workflow; end
11
+ end
12
+ end
13
+
14
+ # module CemAcpt
15
+ # module TestRunner
16
+
17
+
18
+ # # Workflow is a class that manages how steps are executed.
19
+ # class Workflow
20
+ # include CemAcpt::LoggingAsync
21
+
22
+ # attr_reader :steps, :groups, :group_retry_max, :completed_steps
23
+
24
+ # def initialize(init_steps: [], **opts)
25
+ # raise ArgumentError, 'init_steps must be an Array' unless init_steps.is_a?(Array)
26
+ # raise ArgumentError, 'init_steps must be an Array of Step objects' unless init_steps.all? { |step| step.is_a?(Step) }
27
+
28
+ # @steps = init_steps
29
+ # @groups = @steps.map(&:group).compact.uniq
30
+ # @group_retry_max = opts[:group_retry_max] || 3
31
+ # @group_tries = {}
32
+ # @last_error = nil
33
+ # @completed_steps = []
34
+ # end
35
+
36
+ # def add_step(step, order = nil)
37
+ # raise ArgumentError, 'step must be a Step object' unless step.is_a?(Step)
38
+
39
+ # unless order.nil?
40
+ # @steps.insert(order, step)
41
+ # else
42
+ # @steps << step
43
+ # end
44
+ # end
45
+
46
+ # def add_step_with(name, order = nil, **kwargs, &block)
47
+ # raise ArgumentError, 'order must be an Integer' unless order.is_a?(Integer) || order.nil?
48
+ # raise ArgumentError, 'name must be a Symbol' unless name.is_a?(Symbol)
49
+
50
+ # unless order.nil?
51
+ # @steps.insert(order, Step.new(name, **kwargs, &block))
52
+ # else
53
+ # @steps << Step.new(name, **kwargs, &block)
54
+ # end
55
+ # end
56
+
57
+ # def run
58
+ # current_run_groups = []
59
+ # @steps.each do |step|
60
+ # next if step.name == :clean_up
61
+
62
+ # group_run_increment(step, current_run_groups)
63
+ # step.run
64
+ # @completed_steps << step
65
+ # end
66
+ # @completed_steps
67
+ # rescue StandardError => e
68
+ # async_error("Workflow failed with error: #{e}")
69
+ # @last_error = e
70
+ # raise e
71
+ # ensure
72
+ # clean_up
73
+ # end
74
+
75
+ # def success?
76
+ # (@completed_steps.length == @steps.length) && @completed_steps.none? { |step| step.result.is_a?(StepError) }
77
+ # end
78
+
79
+ # private
80
+
81
+ # def group_run_increment(step, current_run_groups = [])
82
+ # if step.grouped? && !current_run_groups.include?(step.group)
83
+ # current_run_groups << step.group
84
+ # if @group_tries[step.group].nil? || @group_tries[step.group].zero?
85
+ # @group_tries[step.group] = 1
86
+ # elsif @group_tries[step.group] >= @group_retry_max
87
+ # raise StepError.new(step, @last_error)
88
+ # else
89
+ # @group_tries[step.group] += 1
90
+ # end
91
+ # end
92
+ # end
93
+
94
+ # def run_step(step)
95
+ # result = step.run
96
+ # #handle_result(step, result)
97
+ # @completed_steps << step
98
+ # result
99
+ # end
100
+
101
+ # def handle_result(step, result)
102
+ # if result.is_a?(StepError)
103
+ # handle_error(step, result)
104
+ # else
105
+ # async_info("Step '#{step.name}' completed successfully")
106
+ # end
107
+ # end
108
+
109
+ # def handle_error(step, err)
110
+ # if step.retryable? && step.runs < @retry_max
111
+ # async_info("Retrying step '#{step.name}' (attempt #{step.runs + 1} of #{@retry_max})")
112
+ # sleep step.retry_delay if step.retry_delay > 0
113
+ # run_step(step)
114
+ # else
115
+ # async_debug("Step '#{step.name}' is not retryable or has exceeded the maximum number of retries")
116
+ # raise err if step.raise_on_fail?
117
+ # end
118
+ # end
119
+
120
+ # def default_clean_up
121
+ # Step.new(:clean_up, retryable: false, raise_on_fail: true) do
122
+ # async_info('No clean_up step defined, skipping')
123
+ # end
124
+ # end
125
+
126
+ # def clean_up
127
+ # cleanup_step = @steps.find { |step| step.name == :clean_up } || default_clean_up
128
+ # unless cleanup_step.nil?
129
+ # cleanup_step.retryable = false # clean_up steps should not be retried
130
+ # cleanup_step.raise_on_fail = true # clean_up steps should always raise on failure
131
+ # run_step(cleanup_step)
132
+ # end
133
+ # end
134
+ # end
135
+
136
+ # # Step is a class that defines a single step in a Workflow.
137
+ # class Step
138
+ # include CemAcpt::LoggingAsync
139
+
140
+ # attr_reader :group, :name, :opts, :result, :retry_delay, :retry_max, :runs
141
+
142
+ # def initialize(name, **opts, &logic)
143
+ # @name = name
144
+ # @logic = logic
145
+ # @group = opts[:group] || nil
146
+ # @retryable = opts[:retryable] || false
147
+ # @retry_delay = opts[:retry_delay] || 0
148
+ # @retry_max = opts[:retry_max] || 3
149
+ # @retry_group_on_fail = opts[:retry_group_on_fail] || false
150
+ # @raise_on_fail = opts[:raise_on_fail] || true
151
+ # @runs = 0
152
+ # @opts = opts
153
+ # @result = :not_run
154
+ # end
155
+
156
+ # def grouped?
157
+ # !@group.nil?
158
+ # end
159
+
160
+ # def retryable?
161
+ # @retryable
162
+ # end
163
+
164
+ # def retry_group_on_fail?
165
+ # @retry_group_on_fail
166
+ # end
167
+
168
+ # def raise_on_fail?
169
+ # @raise_on_fail
170
+ # end
171
+
172
+ # def retryable=(val)
173
+ # raise ArgumentError, 'retryable must be a Boolean' unless val.is_a?(TrueClass) || val.is_a?(FalseClass)
174
+
175
+ # @retryable = val
176
+ # end
177
+
178
+ # def retry_delay=(val)
179
+ # raise ArgumentError, 'retry_delay must be an Integer' unless val.is_a?(Integer)
180
+
181
+ # @retry_delay = val
182
+ # end
183
+
184
+ # def retry_group_on_fail=(val)
185
+ # raise ArgumentError, 'retry_group_on_fail must be a Boolean' unless val.is_a?(TrueClass) || val.is_a?(FalseClass)
186
+
187
+ # @retry_group_on_fail = val
188
+ # end
189
+
190
+ # def raise_on_fail=(val)
191
+ # raise ArgumentError, 'raise_on_fail must be a Boolean' unless val.is_a?(TrueClass) || val.is_a?(FalseClass)
192
+
193
+ # @raise_on_fail = val
194
+ # end
195
+
196
+ # def run
197
+ # begin
198
+ # @runs += 1
199
+ # async_info("Running step #{@name}...") if @runs == 1
200
+ # @result = @logic.call(@opts)
201
+ # rescue StandardError => e
202
+ # if retryable? && @runs < @retry_max
203
+ # sleep @retry_delay if @retry_delay > 0
204
+ # async_info("Retrying step #{@name} (attempt #{@runs + 1} of #{@retry_max})")
205
+ # run
206
+ # else
207
+ # @result = CemAcpt::TestRunner::StepError.new(@name, e)
208
+ # raise @result if raise_on_fail?
209
+ # end
210
+ # end
211
+ # @result
212
+ # end
213
+ # end
214
+ # end
215
+ # end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CemAcpt
4
- VERSION = '0.3.2'
4
+ VERSION = '0.3.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cem_acpt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.4
5
5
  platform: universal-java-17
6
6
  authors:
7
7
  - puppetlabs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-13 00:00:00.000000000 Z
11
+ date: 2023-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -132,6 +132,20 @@ dependencies:
132
132
  - - ">="
133
133
  - !ruby/object:Gem::Version
134
134
  version: '0'
135
+ - !ruby/object:Gem::Dependency
136
+ requirement: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ name: pry
142
+ prerelease: false
143
+ type: :development
144
+ version_requirements: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
135
149
  description: Litmus-like library focusing on CEM Acceptance Tests
136
150
  email:
137
151
  - abide-team@puppet.com
@@ -140,6 +154,7 @@ executables:
140
154
  extensions: []
141
155
  extra_rdoc_files: []
142
156
  files:
157
+ - ".github/workflows/spec.yml"
143
158
  - ".gitignore"
144
159
  - ".rspec"
145
160
  - CODEOWNERS
@@ -167,6 +182,7 @@ files:
167
182
  - lib/cem_acpt/platform/gcp.rb
168
183
  - lib/cem_acpt/platform/gcp/cmd.rb
169
184
  - lib/cem_acpt/platform/gcp/compute.rb
185
+ - lib/cem_acpt/platform/utils/linux.rb
170
186
  - lib/cem_acpt/platform/vmpooler.rb
171
187
  - lib/cem_acpt/puppet_helpers.rb
172
188
  - lib/cem_acpt/rspec_utils.rb
@@ -177,6 +193,10 @@ files:
177
193
  - lib/cem_acpt/test_runner/run_handler.rb
178
194
  - lib/cem_acpt/test_runner/runner.rb
179
195
  - lib/cem_acpt/test_runner/runner_result.rb
196
+ - lib/cem_acpt/test_runner/runner_workflow_builder.rb
197
+ - lib/cem_acpt/test_runner/workflow.rb
198
+ - lib/cem_acpt/test_runner/workflow/manager.rb
199
+ - lib/cem_acpt/test_runner/workflow/step.rb
180
200
  - lib/cem_acpt/utils.rb
181
201
  - lib/cem_acpt/version.rb
182
202
  - sample_config.yaml