-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-enable specs to run via JRuby-provided bundler #261
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
d9fa998
to
15edd63
Compare
This comment was marked as outdated.
This comment was marked as outdated.
I'll have a look at the Input failures soon. |
I suppose that's what I get for not getting tests running before making changes. Here's the patch for JRuby::Rack::Input: diff --git a/src/main/java/org/jruby/rack/ext/Input.java b/src/main/java/org/jruby/rack/ext/Input.java
index e680e79..2cdd8e3 100644
--- a/src/main/java/org/jruby/rack/ext/Input.java
+++ b/src/main/java/org/jruby/rack/ext/Input.java
@@ -172,7 +172,7 @@ public class Input extends RubyObject {
if ( buffer != null ) {
buffer.clear();
try {
- int unused = (int) CONCAT_WITH_CODERANGE.invokeExact(new ByteList(bytes, false), StringSupport.CR_UNKNOWN);
+ int unused = (int) CONCAT_WITH_CODERANGE.invokeExact(buffer, new ByteList(bytes, false), StringSupport.CR_UNKNOWN);
} catch (Throwable t) {
Helpers.throwException(t);
} |
@jlahtinen The patch above should work properly... I botched it before 🤦. |
@chadlwilson I merged that fix to master so if you rebase you'll pick it up. |
ba22ea9
to
f2ac0fb
Compare
This comment was marked as resolved.
This comment was marked as resolved.
Hmm, there's a few suspicious bits around the place like the below, so perhaps these specs requiring a new rack version to be dynamically installed or use of JRuby home in tmpdir weren't working for a long time - not sure how long since TravisCI was passing :D Lines 38 to 39 in 5c060ae
jruby-rack/src/main/ruby/jruby/rack/booter.rb Lines 176 to 192 in d3ee8f0
|
@chadlwilson that first loaderror is pretty odd. If I try and load it I can see it:
If I had to guess perhaps something is changing
|
Unrelated to |
This comment was marked as resolved.
This comment was marked as resolved.
@chadlwilson I am also guessing the booter does not remove the include directory so require jruby.rb probably would normall work but this spec is doing something special. Random thoughts:
it is ``["3.1/site_ruby", "stdlib"]`. This may need rbconfig to get version so this is more future proof.
Anyways some thoughts to try and help. This work is incredible and we need to get jruby-rack back into shape. |
Thanks, yeah. I tried changing the paths after your message but it still seemed to be failing in the same way. Actually after reading your message it reminded me that I am trying to do this on My thinking was to try and get the tests passing to give more confidence in merging that PR, but given 1.1 is probably more stable than 1.2/master (right now) and may indeed have test fixes, I might have that around the wrong way and should at least look at that branch. It's a separate topic to this specific case (where deleting the old code seems most advisable) but perhaps worth keeping in mind for some of the remaining failures. |
This is the last version which is known to have working implementations in production, and compatibility tests currently fail with Rack 3.0 so let's move this forward separately as an independent chunk of work. Signed-off-by: Chad Wilson <chadw@thoughtworks.com>
af3d4de
to
cb35667
Compare
The last remaining test failing is jruby-rack/src/spec/ruby/rack/application_spec.rb Lines 313 to 328 in cb35667
I am not a Ruby expert, but I wonder if the underlying functionality is no longer required now. This functionality appears to allow jruby-rack to dynamically install/load/require a specific Rack version from There is also a bundled version of rack which I don't fully understand interactions of. Not quite sure how to proceed on this one, but suffice it to say that after this logic is executed in test setup without error, rack can still not be found jruby-rack/src/spec/ruby/spec_helper.rb Lines 96 to 100 in 34f390c
...leading to...
when running
|
@chadlwilson sorry I missed your last comments. I am not sure if this is still valid or not and I do not see any obvious rack documentation on this (although to be honest I only looked a for a few minutes). It is definitely possible to run JRuby without bundler but has rack just decided people need bundler? Does the magic comments still work? Maybe @kares knows. A possible way to test this would be to make a simple config.ru and trying it with C Ruby and see if it works with the magic comment. The fact this is just embedded code in Java does not change that this could just be invoked from Ruby. If it works then we probably need to change how we require the gem (like something is missing or gem api changed over time and we are not calling something). If it doesn't then it can be nuked from orbit. |
No worries @enebo I think the magic comment is a jruby-rack invention, perhaps specific to a Jruby context due jruby-rack bundling an opinionated rack version: https://github.com/jruby/jruby-rack/blob/master/History.md#1112-281112 In the README, and
I'm a little bit lost here as I don't know rackup (the app I use uses So as long as rackup is still useful, and jruby-rack still bundles a rack version, it seems conceptually possible that the functionality is needed, but I can't for the life of me figure out how to empirically test the various cases and work backwards to how the test should behave 😅 (definitely a skill issue, rack is not something I've put much time into understanding) |
cb35667
to
43c0d38
Compare
@chadlwilson I decided to look a little bit. In trying to just run rake instead of full maven run I had to tweak: diff --git a/Rakefile b/Rakefile
index 599ce7b..19f50a2 100644
--- a/Rakefile
+++ b/Rakefile
@@ -110,7 +110,8 @@ task :speconly => [ :resources, :test_resources ] do
spec = ENV['SPEC'] || File.join(Dir.getwd, "src/spec/ruby/**/*_spec.rb")
opts = opts.split(' ').push *FileList[spec].to_a
- args = ENV['RUBY'].split(' ') + %w{-Isrc/spec/ruby -rbundler/setup -S rspec}
+ ruby = ENV['RUBY'] || 'jruby'
+ args = ruby.split(' ') + %w{-Isrc/spec/ruby -rbundler/setup -S rspec}
sh *args, *opts
end
end Then rake test runs but I get 3 errors all of which is failing to find servlet class so servlet_30? fails to work right. I guess this may be a stretch goal but it would be nice to just run rake for local dev. Maven does repro locally for me so something with maven it properly loading the servlet API before running rake. |
Ah I see ... this will generate a full Java CMD and not use jruby itself. This also explains why servlets classes are not found since it builds up a classpath while in maven. Ignore my previous comment. It would be nice just to type |
Yeah, I agree. The feedback loop is pretty painful right now. I was just going the path of least resistance since things were not in a working state, and I had no access to prior builds to even know when the tests last passed, against which versions of things and on which branches :-) This branch also does not have a whole lot of fixes from https://github.com/jruby/jruby-rack/tree/1.1-stable just yet, so it's possible that will change things again. It's also possible that a change somewhere on that branch not merged to master did something to address the tests here, or even allow them to work with |
Signed-off-by: Chad Wilson <chadw@thoughtworks.com>
Signed-off-by: Chad Wilson <chadw@thoughtworks.com>
Signed-off-by: Chad Wilson <chadw@thoughtworks.com>
The code and tests related to hacking load paths for old J2EE webservers which cannot detect jruby.home correctly hasn't worked for a long time due to incorrect load path assumptions, and the tests currently fail. Let's move forward and remove these old hacks. Signed-off-by: Chad Wilson <chadw@thoughtworks.com>
- removes exception unwrapping workarounds - removes JRuby 1.6 specific specs - tests RUBYOPT with a supported flag on modern Ruby Signed-off-by: Chad Wilson <chadw@thoughtworks.com>
Thx, I've merged this - that's better.
Interesting, this provides a hint I guess to why the other test is failing, as it must be to do with the wrapping environment |
43c0d38
to
39cdba5
Compare
The
So it knows how to acculmulate all those jar files into a java command. My patch makes things work until you need one of these jars (since just calling jruby by itself is not adding them). It is fascinating that only three things fail though. If whatever jar which includes def servlet_30?
return @@servlet_30 unless @@servlet_30.nil?
@@servlet_30 = !! ( Java::JavaClass.for_name('javax.servlet.AsyncContext') rescue nil )
end So the specs could load the jar(s) via require...but then we would have this odd data replication since we specify deps in pom.xml and we would also have requires elsewhere. I might have opened a can of worms :) |
Yeah, on current deps it will be
Since rake already calls some |
The problem with the last failing test when run via When running via Maven, the test installs the "override" rack version to a place like Before requiring jruby-rack/src/spec/ruby/rack/application_spec.rb Lines 320 to 324 in 39cdba5
These first two lines dont seem to have the intended effect of changing where the runtime will load Gems from to match what By contrast, when running tests directly via @enebo or @headius - once against excusing my JRuby ignorance, does this ring a bell to you, as to why the below would be ineffective in actually changing @runtime.evalScriptlet "ENV['GEM_HOME'] = #{ENV['GEM_HOME'].inspect}" |
@chadlwilson I realize after reading this that rubygems is run as part of initialization and this used to not be the case (we changed to this whenever C Ruby made the change). This spec starts a new Ruby instances which loads rubygems then it sets GEM_HOME after gems have already loaded. as part of the instance coming up. This explains why it is not seeing the gems. We can probably make this work by setting java system property |
@chadlwilson to be more explicit I mean this line will load rubygems:
|
Right, that's what I thought might be happening. The test is really trying to check you can load a custom rack version using the magic comments and needs to change the GEM_HOME to do so between tests. Alternatively it could change it for all tests prior to starting and have the same effect rather than trying to swap it in between tests. If there is no way to change the Gem.dir after rubygems is loaded what would be the right way to have the GEM_HOME or additional GEM_PATHs set prior to the runtime creation when doing so programmatically like in these tests so it's picked up by the initialization? |
@chadlwilson oh yeah I forgot! You can try something like this before the newRuntime call (but you should remove it after the test as well): java.lang.System.properties.put("jruby.cli.rubygems.enable", "false") This should prevent it from loading rubygems by default...which is unclear how gems ends up being loaded by the test but it must do it somewhere. |
Sadly I cannot find a place to set this (or any related things!) that seems to work. The runtimes are reused between tests, but since it is all happening within one JVM instance launched by I also tried appending to Due to my own inexperience, I am leaning towards just deleting this test and leaving it untested, relying solely on the bundler test and assuming that any sane individual trying to do this magic comment stuff is doing so via Bundler/Gemfile rather than relying on a naked Gem install. |
@chadlwilson I think excluding and working towards the longer goal of getting jruby-rack back up to date and in shape. We can always figure this out later (pend the spec). |
This test does not work anymore due to rubygems being loaded by CRuby/JRuby by default and not being able to easily switch around `GEM_HOME` and such to point to a location outside JRuby's own internal location inside the jruby-core jar when tests are run via Maven directly. Can't find a way to workaround this to get JRuby/rack runtimes under test to look for the gem in the correct external `target/rubygems` dir that Maven otherwise uses. To move forward, am removing this test for now. Signed-off-by: Chad Wilson <chadw@thoughtworks.com>
This removes support for the long end-of-life and completely insecure Log4j 1.x Signed-off-by: Chad Wilson <chadw@thoughtworks.com>
…tions Uses latest versions that can be compiled and tested against right now. Signed-off-by: Chad Wilson <chadw@thoughtworks.com>
These don't all work with modern versions, but getting incrementally closer. Signed-off-by: Chad Wilson <chadw@thoughtworks.com>
Signed-off-by: Chad Wilson <chadw@thoughtworks.com>
OK, I have removed this one test, which gets things passing now. Ready for review whenever you folks are able. Next I'll try and tackle getting all the |
Everything looked so straightforward I just merged this without other reviews (which I am not normally a jruby-rack person but these were all sensible changes). @chadlwilson Thanks. You are well on your way to untangling this thing. We look forward to the next step. |
This is work-in-progress to get the tests running/passing again against latest JRuby.
Getting tests/specs passing again
ruby
task ended up trying to execute an incorrect Ruby binary viaENV['RUBY]
when running inside JRuby, and also was trying to run system ruby when run withFULL_BIN_PATH
, and thus dependent on the environment around it (rather than how Maven was configured with jruby jars).2.2.9
as the last known validated-in-real-world version (?) which passes the tests.Changes in non-test functionality
provided
scope, to allow for users why may be usingjruby-complete
. BYO JRuby, basically.booter.rb
which causes problems with getting tests to pass and seems extremely legacy now.