cem_acpt 0.7.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/cem_acpt.rb CHANGED
@@ -22,6 +22,7 @@ module CemAcpt
22
22
  end
23
23
 
24
24
  def run(command, original_command, options)
25
+ set_up_signal_handlers
25
26
  case command
26
27
  when :version
27
28
  puts "#{original_command} v#{CemAcpt::VERSION}"
@@ -30,9 +31,9 @@ module CemAcpt
30
31
  when :print_explain_config
31
32
  print_config(options, command: original_command.to_sym, format: :explain)
32
33
  when :cem_acpt
33
- run_cem_acpt(options)
34
+ trace_it(options[:trace], options[:trace_events]) { run_cem_acpt(options) }
34
35
  when :cem_acpt_image
35
- run_cem_acpt_image(options)
36
+ trace_it(options[:trace], options[:trace_events]) { run_cem_acpt_image(options) }
36
37
  else
37
38
  raise "Command #{command} does not exist"
38
39
  end
@@ -78,41 +79,70 @@ module CemAcpt
78
79
  new_log
79
80
  end
80
81
 
82
+ TRACE_EVENTS = %i[line call b_call thread_begin thread_end].freeze
83
+
84
+ def trace_it(should_trace = false, trace_events = nil)
85
+ if should_trace
86
+ trace_events ||= TRACE_EVENTS
87
+ tracer = TracePoint.new(*trace_events.map(&:to_sym)) do |tp|
88
+ if tp&.path&.include?('lib/cem_acpt') && !tp&.path&.include?('lib/cem_acpt/logging')
89
+ begin
90
+ logger << "## TRACE ## #{tp.path}:#{tp.lineno}: #{tp.event} #{tp.method_id}\n"
91
+ rescue StandardError
92
+ # Trace will often run into the trap context problem before the signal handler call back
93
+ logger.trap_context = true
94
+ logger << "## TRACE ## #{tp.path}:#{tp.lineno}: #{tp.event}\n"
95
+ end
96
+ end
97
+ end
98
+ tracer.enable do
99
+ yield
100
+ end
101
+ else
102
+ yield
103
+ end
104
+ end
105
+
106
+ def signal_handlers
107
+ {
108
+ 'INT' => proc do
109
+ @trap_context = true
110
+ logger.trap_context = @trap_context
111
+ logger.fatal('CemAcpt') { 'Received interrupt signal. Exiting.' }
112
+ exit 1
113
+ end,
114
+ }
115
+ end
116
+
117
+ def set_up_signal_handlers
118
+ signal_handlers.each do |signal, handler|
119
+ Signal.trap(signal, &handler)
120
+ logger.debug('CemAcpt') { "Signal handler set for #{signal}" }
121
+ end
122
+ end
123
+
81
124
  def run_cem_acpt(options)
82
125
  # Set up config, logger, and helper
83
126
  @config = new_config(options)
84
127
  initialize_logger!
128
+ logger.debug('CemAcpt') { 'Config set and logger initialized...' }
85
129
  runner = new_runner
86
-
87
- # Set up signal handlers
88
- Signal.trap('INT') do
89
- @trap_context = true
90
- logger.trap_context = @trap_context
91
- logger.fatal('Signal Handler') { 'Received interrupt signal. Cleaning up test suite...' }
92
- runner.clean_up(@trap_context)
93
- logger.fatal('Signal Handler') { 'Exiting due to interrupt signal' }
94
- exit 1
95
- end
130
+ logger.debug('CemAcpt') { 'Runner initialized...' }
96
131
 
97
132
  # Run the test suite
133
+ logger.debug('CemAcpt') { 'Running test suite...' }
98
134
  runner.run
99
-
135
+ logger.debug('CemAcpt') { "Test suite run complete, exiting with code #{runner.exit_code}" }
100
136
  exit runner.exit_code
101
137
  end
102
138
 
103
139
  def run_cem_acpt_image(options)
104
140
  @config = new_config(options, command: :cem_acpt_image)
105
141
  initialize_logger!
106
-
107
- # Set up signal handlers
108
- Signal.trap('INT') do
109
- @trap_context = true
110
- logger.trap_context = @trap_context
111
- logger.fatal('Signal Handler') { 'Received interrupt signal. Cleaning up test suite...' }
112
- exit 1
113
- end
142
+ logger.debug('CemAcptImage') { 'Config set and logger initialized...' }
114
143
 
115
144
  # Build the images
145
+ logger.debug('CemAcptImage') { 'Building images...' }
116
146
  CemAcpt::ImageBuilder.build_images(@config)
117
147
  end
118
148
  end
@@ -27,6 +27,27 @@ variable "subnetwork" {
27
27
  type = string
28
28
  }
29
29
 
30
+ # Just stub this out for now
31
+ variable "username" {
32
+ type = string
33
+ }
34
+
35
+ # Just stub this out for now
36
+ variable "private_key" {
37
+ type = string
38
+ sensitive = true
39
+ }
40
+
41
+ # Just stub this out for now
42
+ variable "public_key" {
43
+ type = string
44
+ }
45
+
46
+ # Just stub this out for now
47
+ variable "puppet_module_package" {
48
+ type = string
49
+ }
50
+
30
51
  variable "node_data" {
31
52
  type = map(object({
32
53
  machine_type = string
@@ -71,6 +92,11 @@ resource "google_compute_instance" "acpt-test-node" {
71
92
  }
72
93
  }
73
94
 
95
+ service_account {
96
+ email = "cem-windows-acpt-test@team-sse.iam.gserviceaccount.com"
97
+ scopes = ["cloud-platform"]
98
+ }
99
+
74
100
  metadata = {
75
101
  "enable-oslogin" = "TRUE"
76
102
  "cem-acpt-test" = each.value.test_name
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.7.3
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - puppetlabs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-18 00:00:00.000000000 Z
11
+ date: 2023-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-http
@@ -105,19 +105,25 @@ dependencies:
105
105
  - !ruby/object:Gem::Version
106
106
  version: 0.0.1
107
107
  - !ruby/object:Gem::Dependency
108
- name: ruby-terraform
108
+ name: winrm
109
109
  requirement: !ruby/object:Gem::Requirement
110
110
  requirements:
111
- - - "~>"
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '2.3'
114
+ - - "<"
112
115
  - !ruby/object:Gem::Version
113
- version: '1.7'
116
+ version: '3.0'
114
117
  type: :runtime
115
118
  prerelease: false
116
119
  version_requirements: !ruby/object:Gem::Requirement
117
120
  requirements:
118
- - - "~>"
121
+ - - ">="
119
122
  - !ruby/object:Gem::Version
120
- version: '1.7'
123
+ version: '2.3'
124
+ - - "<"
125
+ - !ruby/object:Gem::Version
126
+ version: '3.0'
121
127
  - !ruby/object:Gem::Dependency
122
128
  name: pry
123
129
  requirement: !ruby/object:Gem::Requirement
@@ -146,6 +152,34 @@ dependencies:
146
152
  - - ">="
147
153
  - !ruby/object:Gem::Version
148
154
  version: '0'
155
+ - !ruby/object:Gem::Dependency
156
+ name: rubocop-performance
157
+ requirement: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ type: :development
163
+ prerelease: false
164
+ version_requirements: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ - !ruby/object:Gem::Dependency
170
+ name: rubocop-rspec
171
+ requirement: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ type: :development
177
+ prerelease: false
178
+ version_requirements: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
149
183
  description: Litmus-like library focusing on CEM Acceptance Tests
150
184
  email:
151
185
  - abide-team@puppet.com
@@ -170,6 +204,7 @@ files:
170
204
  - exe/cem_acpt
171
205
  - exe/cem_acpt_image
172
206
  - lib/cem_acpt.rb
207
+ - lib/cem_acpt/action_result.rb
173
208
  - lib/cem_acpt/cli.rb
174
209
  - lib/cem_acpt/config.rb
175
210
  - lib/cem_acpt/config/base.rb
@@ -192,16 +227,19 @@ files:
192
227
  - lib/cem_acpt/provision/terraform.rb
193
228
  - lib/cem_acpt/provision/terraform/linux.rb
194
229
  - lib/cem_acpt/provision/terraform/os_data.rb
230
+ - lib/cem_acpt/provision/terraform/terraform_cmd.rb
195
231
  - lib/cem_acpt/provision/terraform/windows.rb
196
232
  - lib/cem_acpt/puppet_helpers.rb
197
233
  - lib/cem_acpt/test_data.rb
198
234
  - lib/cem_acpt/test_runner.rb
199
235
  - lib/cem_acpt/test_runner/log_formatter.rb
236
+ - lib/cem_acpt/test_runner/log_formatter/error_formatter.rb
200
237
  - lib/cem_acpt/test_runner/log_formatter/goss_action_response.rb
201
238
  - lib/cem_acpt/utils.rb
202
239
  - lib/cem_acpt/utils/puppet.rb
203
240
  - lib/cem_acpt/utils/ssh.rb
204
241
  - lib/cem_acpt/utils/terminal.rb
242
+ - lib/cem_acpt/utils/winrm_runner.rb
205
243
  - lib/cem_acpt/version.rb
206
244
  - lib/terraform/gcp/linux/goss/puppet_idempotent.yaml
207
245
  - lib/terraform/gcp/linux/goss/puppet_noop.yaml
@@ -238,7 +276,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
238
276
  - !ruby/object:Gem::Version
239
277
  version: '0'
240
278
  requirements: []
241
- rubygems_version: 3.4.6
279
+ rubygems_version: 3.4.18
242
280
  signing_key:
243
281
  specification_version: 4
244
282
  summary: CEM Acceptance Tests