Skip to content

Commit bec8ad7

Browse files
sebastianrakelbastelfreak
authored andcommitted
CI: Adjust error message matching for newer json gem
A bit of backstory. I did a lot of JRuby debugging in #122. Yesterday @sebastianrakel and I did a bit of deep diving. Some numbers: * puppetserver 8.7.0, the last open source release from Perforce, ships JRuby 9.4.8.0 * openvox-server 8.9.0 ships JRuby 9.4.8.0 * puppet enterprise 2025.4.0 (latest version at 2025-07-27) ships pe-puppetserver JRuby 9.4.8.0 * latest JRuby 9.4 is 9.4.13.0 * JRuby 9.4 series is compatible with MRI Ruby 3.1 * puppetserver 7 uses JRuby 9.3 which is compatible with Ruby 2.6 * Perforce never tested JRuby 9.4.8.0 in CI, JRuby was pinned to 9.4.3.0 Since openvox runs tests, the Rspec JRuby pipeline fails. We cannot access the old perforce pipeline logs. Their last successful CI run I could fine was https://github.com/puppetlabs/puppet/actions/runs/11693993097. This was triggered by commit puppetlabs/puppet@4ea6ee2 on 2024-11-06. In https://github.com/puppetlabs/puppet/actions/runs/12021455668 we see the first failed pipelline for puppetserver 8, triggered by puppetlabs/puppet@e967115 on 2024-11-24. The used JRuby verison in both jobs was 9.4.3.0 Something changed between 2024-11-06 and 2024-11-24 and I doubt it was related to puppetlabs/puppet@e967115 (puppetlabs/puppet#9523). Whatever changed in that timeframe modified the error reporting. Basic example: ``` class a {} class a {} ``` raises: ``` Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Class 'a' is already defined (file: /etc/puppetlabs/code/environments/server/manifests/site.pp, line: 1); cannot redefine (file: /etc/puppetlabs/code/environments/server/manifests/site.pp, line: 2) (file: /etc/puppetlabs/code/environments/server/manifests/site.pp, line: 2) on node puppettestinfra.voxpupu.li ``` After "cannot redefine", the file is listed twice. This issue is reproducible puppetserver 8.7.0, Puppet Enterprise 2025.4.0 & openvox-server 8.9.0. After some testing in #122 I noticed that JRuby 9.4.3.0 indeed raises errors now, but others. I assume the JRuby issues are, at least in part, triggered by a webmock update. I don't know yet what causes the duplicate file lines in the output. The old rspec tests demand a single file line in the output. In #164 I'm testing different Jruby Versions with a webmock pinned to 3.25.0. 3.25.0 was released on 2025-02-06. The version before that, 3.24.0, on 2024-09-30. That's what Perforce was using back then. And after diffing CI output from JRuby 9.4.3, 9.4.4, 9.4.5 & 9.4.6 we can see that the duplicate line messages start with JRuby 9.4.6: https://gist.github.com/bastelfreak/025c23417f9dd7215b5c5af205fc8b76
1 parent 2715065 commit bec8ad7

File tree

9 files changed

+15
-16
lines changed

9 files changed

+15
-16
lines changed

.github/workflows/tests.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ jobs:
4646
- {os: ubuntu-24.04, ruby: '3.3'} # openssl 3
4747
- {os: ubuntu-24.04, ruby: '3.4'} # openssl 3
4848
- {os: ubuntu-24.04, ruby: 'jruby-9.4'}
49+
- {os: ubuntu-24.04, ruby: 'jruby-9.4.8.0'}
50+
- {os: ubuntu-24.04, ruby: 'jruby-9.4.13.0'}
4951
- {os: windows-2025, ruby: '3.1'}
5052
- {os: windows-2025, ruby: '3.2'} # openssl 3
5153
- {os: windows-2025, ruby: '3.3'} # openssl 3

spec/unit/file_system/path_pattern_spec.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,6 @@
134134
end
135135

136136
it 'globs wildcard patterns properly' do
137-
# See PUP-11788 and https://github.com/jruby/jruby/issues/7836.
138-
pending 'JRuby does not properly handle Dir.glob' if Puppet::Util::Platform.jruby?
139-
140137
dir = tmpdir('globtest')
141138
create_file_in(dir, 'foo.pp')
142139
create_file_in(dir, 'foo.pp.pp')

spec/unit/functions/break_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class does_break {
149149
}
150150
include(does_break)
151151
CODE
152-
end.to raise_error(/break\(\) from context where this is illegal \(file: unknown, line: 3\) on node.*/)
152+
end.to raise_error(/break\(\) from context where this is illegal .*/)
153153
end
154154

155155
it 'does not provide early exit from a define' do
@@ -166,7 +166,7 @@ class does_break {
166166
}
167167
does_break { 'no_you_cannot': }
168168
CODE
169-
end.to raise_error(/break\(\) from context where this is illegal \(file: unknown, line: 3\) on node.*/)
169+
end.to raise_error(/break\(\) from context where this is illegal .*/)
170170
end
171171

172172
it 'can be called when nested in a function to make that function behave as a break' do
@@ -191,7 +191,7 @@ class does_break {
191191
$result = with(1) |$x| { with($x) |$x| {break() }}
192192
notice $result
193193
CODE
194-
end.to raise_error(/break\(\) from context where this is illegal \(file: unknown, line: 3\) on node.*/)
194+
end.to raise_error(/break\(\) from context where this is illegal .*/)
195195
end
196196

197197
it 'can not be called from top scope' do
@@ -201,7 +201,7 @@ class does_break {
201201
# line 2
202202
break()
203203
CODE
204-
end.to raise_error(/break\(\) from context where this is illegal \(file: unknown, line: 3\) on node.*/)
204+
end.to raise_error(/break\(\) from context where this is illegal .*/)
205205
end
206206
end
207207
end

spec/unit/functions/next_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,6 @@ class does_next {
8888
# line 2
8989
next()
9090
CODE
91-
end.to raise_error(/next\(\) from context where this is illegal \(file: unknown, line: 3\) on node.*/)
91+
end.to raise_error(/next\(\) from context where this is illegal .*/)
9292
end
9393
end

spec/unit/functions/return_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class does_next {
9494
$result = with(1) |$x| { with($x) |$x| {return(100) }}
9595
notice $result
9696
CODE
97-
end.to raise_error(/return\(\) from context where this is illegal \(file: unknown, line: 3\) on node.*/)
97+
end.to raise_error(/return\(\) from context where this is illegal .*/)
9898
end
9999

100100
it 'can not be called from top scope' do
@@ -104,6 +104,6 @@ class does_next {
104104
# line 2
105105
return()
106106
CODE
107-
end.to raise_error(/return\(\) from context where this is illegal \(file: unknown, line: 3\) on node.*/)
107+
end.to raise_error(/return\(\) from context where this is illegal .*/)
108108
end
109109
end

spec/unit/http/service/compiler_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@
594594
invalid_facts = Puppet::Node::Facts.new(certname, {'invalid_utf8_sequence' => "\xE2\x82".force_encoding('binary')})
595595
expect {
596596
subject.put_facts(certname, environment: 'production', facts: invalid_facts)
597-
}.to raise_error(Puppet::HTTP::SerializationError, /Failed to serialize Puppet::Node::Facts to json: ("\\xE2" from ASCII-8BIT to UTF-8|partial character in source, but hit end)/)
597+
}.to raise_error(Puppet::HTTP::SerializationError, /Failed to serialize Puppet::Node::Facts to json: /)
598598
end
599599
end
600600

spec/unit/parser/compiler_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ class #{name} {}
874874
include #{name}
875875
}
876876
MANIFEST
877-
}.to raise_error(Puppet::Error, /Class '#{name}' is already defined \(line: 1\); cannot be redefined as a node \(line: 2\) on node #{name}/)
877+
}.to raise_error(Puppet::Error, /Class '#{name}' is already defined \(line: 1\); cannot be redefined as a node /)
878878
end
879879

880880
it "evaluates the class if the node definition uses a regexp" do

spec/unit/task_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@
233233

234234
expect {
235235
tasks[0].metadata
236-
}.to raise_error(Puppet::Module::Task::InvalidMetadata, /expected ':' after object key/)
236+
}.to raise_error(Puppet::Module::Task::InvalidMetadata)
237237
end
238238

239239
it 'returns empty hash for metadata when json metadata file is empty' do

spec/unit/util/json_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
it 'raises an error if JSON is invalid' do
2424
expect {
2525
Puppet::Util::Json.load('{ invalid')
26-
}.to raise_error(Puppet::Util::Json::ParseError, /expected object key, got 'invalid' at line 1 column 3/)
26+
}.to raise_error(Puppet::Util::Json::ParseError)
2727
end
2828

2929
it 'raises an error if the content is empty' do
@@ -74,7 +74,7 @@
7474
it 'returns nil when the file is invalid JSON and debug logs about it' do
7575
file_path = file_containing('input', '{ invalid')
7676
expect(Puppet).to receive(:debug)
77-
.with(/Could not retrieve JSON content .+: expected object key, got 'invalid' at line 1 column 3/).and_call_original
77+
.with(/Could not retrieve JSON content/).and_call_original
7878

7979
expect(Puppet::Util::Json.load_file_if_valid(file_path)).to eql(nil)
8080
end
@@ -102,7 +102,7 @@
102102

103103
expect {
104104
Puppet::Util::Json.load_file(file_path)
105-
}.to raise_error(Puppet::Util::Json::ParseError, /expected object key, got 'invalid' at line 1 column 3/)
105+
}.to raise_error(Puppet::Util::Json::ParseError)
106106
end
107107

108108
it 'raises an error when the filename is illegal' do

0 commit comments

Comments
 (0)