Issue with getting rspec test output to use Junit XML format


(Aman Uppal) #1

I'm trying to install a rspec_junit_formatter gem to write rspec output to file as JUnit XML so that Jenkins CI can read the generated XML
I'm using an Ubuntu 14.04 docker container and installing Logstash 1.5.2:

###Installing logstash:

wget -nv -P /tmp https://download.elastic.co/logstash/logstash/packages/debian/logstash_1.5.2-1_all.deb
dpkg -i /tmp/logstash_1.5.2-1_all.deb```


###Turn on development:
```root@tick:/opt/logstash# /opt/logstash/bin/plugin install --development
Installing logstash-devutils, ftw, logstash-output-elasticsearch, stud, logstash-codec-json, logstash-codec-multiline, flores, simplecov, coveralls, logstash-input-generator, longshoreman, rumbster, logstash-filter-kv, logstash-filter-ruby, logstash-input-stdin, logstash-codec-line
Installation successful```

###Export path to jruby:
```export PATH=$PATH:/opt/logstash/vendor/jruby/bin```

At this point, I install the filter plugin that I want to test using `bin/plugin install /tmp/logstash-filter-cluster/logstash-filter-cluster-0.1.0.gem` and it installs in vendor/local_gems/..
```Validating logstash-filter-cluster-0.1.0.gem
Installing logstash-filter-cluster
Installation successful```

###Install rspec_junit_formatter gem
```root@tick:/tmp/logstash-filter-cluster# jruby -S gem install rspec_junit_formatter
Fetching: builder-3.2.2.gem (100%)
Successfully installed builder-3.2.2
Fetching: rspec-support-3.4.1.gem (100%)
Successfully installed rspec-support-3.4.1
Fetching: rspec-core-3.4.1.gem (100%)
Successfully installed rspec-core-3.4.1
Fetching: rspec_junit_formatter-0.2.3.gem (100%)
Successfully installed rspec_junit_formatter-0.2.3
4 gems installed```

###Installed gems
```root@tick:/tmp/logstash-filter-cluster# jruby -S gem list
axiom-types (0.1.1)
builder (3.2.2)
coercible (1.0.0)
descendants_tracker (0.0.4)
equalizer (0.0.11)
ice_nine (0.11.1)
jar-dependencies (0.1.13)
jruby-openssl (0.9.7 java)
json (1.8.0 java)
maven-tools (1.0.8)
rake (10.1.0)
rdoc (4.1.2)
rspec-core (3.4.1)
rspec-support (3.4.1)
rspec_junit_formatter (0.2.3) <================
ruby-maven (3.1.1.0.8)
ruby-maven-libs (3.1.1)
thread_safe (0.3.5 java)
virtus (1.0.5)```

Now that the gem is install, try and run the rspec: (https://github.com/sj26/rspec_junit_formatter)
###Running the tests

LoadError: no such file to load -- rspec_junit_formatter
               require at org/jruby/RubyKernel.java:1072
             requires= at /opt/logstash/vendor/bundle/jruby/1.9/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1072
                  each at org/jruby/RubyArray.java:1613
             requires= at /opt/logstash/vendor/bundle/jruby/1.9/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1072
  process_options_into at /opt/logstash/vendor/bundle/jruby/1.9/gems/rspec-core-3.1.7/lib/rspec/core/configuration_options.rb:103
                  each at org/jruby/RubyArray.java:1613
  process_options_into at /opt/logstash/vendor/bundle/jruby/1.9/gems/rspec-core-3.1.7/lib/rspec/core/configuration_options.rb:102
             configure at /opt/logstash/vendor/bundle/jruby/1.9/gems/rspec-core-3.1.7/lib/rspec/core/configuration_options.rb:22
                 setup at /opt/logstash/vendor/bundle/jruby/1.9/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:95
                   run at /opt/logstash/vendor/bundle/jruby/1.9/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:84
                   run at /opt/logstash/vendor/bundle/jruby/1.9/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:69
                (root) at /opt/logstash/lib/bootstrap/rspec.rb:10```
Fails

Just making sure bin/plugin isn't supposed to plugin install junit_formatter:
```root@tick:/opt/logstash# bin/plugin install rspec_junit_formatter
Validating rspec_junit_formatter
rspec_junit_formatter is not a Logstash plugin
ERROR: Installation aborted, verification failed for rspec_junit_formatter
```..I guess not.

###Trying a stack overflow solution
From http://stackoverflow.com/questions/25984620/how-to-add-gems-into-logstash:
Found jruby.jar in /opt/logstash/vendor/jruby/lib

```root@tick:/opt/logstash# which ruby
/usr/bin/ruby
root@tick:/opt/logstash# which gem
/usr/bin/gem```

###Now, trying to install again:
```root@tick:/opt/logstash# env GEM_HOME=vendor/bundle/jruby/1.9/ GEM_PATH="" java -jar vendor/jruby/lib/jruby.jar -S gem list
LoadError: no such file to load -- rubygems
  require at org/jruby/RubyKernel.java:1072
   (root) at /usr/bin/gem:8```


From my understanding, the Logstash's rspec is having issues communicating with Jruby gems & I cannot use Jruby's rspec to run the tests because it doesn't have Logstash libraries.

I'm not sure if I'm doing someting wrong or if this use case just isn't supported.

Thanks!

(system) #2