Solr
  1. Solr
  2. SOLR-4853

SolrJettyTestBase can no longer be reused by end users

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.2.1, 4.3
    • Fix Version/s: 4.3.1, 4.4, 6.0
    • Component/s: Tests
    • Labels:
    • Environment:

      Java 1.7.0_21, Maven 3.0.3, OS X 10.7.5

      Description

      While trying to use SolrJettyTestBase to build some unit tests for my project I ran into an NPE:

      java.lang.NullPointerException
              at org.apache.solr.util.ExternalPaths.determineSourceHome(ExternalPaths.java:50)
              at org.apache.solr.util.ExternalPaths.<clinit>(ExternalPaths.java:28)
              at org.apache.solr.SolrJettyTestBase.<clinit>(SolrJettyTestBase.java:53)
              at java.lang.Class.forName0(Native Method)
              at java.lang.Class.forName(Class.java:266)
              at com.carrotsearch.randomizedtesting.RandomizedRunner$1.run(RandomizedRunner.java:486)
      

      Apparently some changes to SolrJettyTestBase's https support caused it to require the keystore that's distributed with the Solr examples. Specifically the TEST_KEYSTORE static variable triggers a search for SOURCE_HOME in ExternalPaths which throws an NPE if the folder isn't found.

      According to Steve Molloy this used to work in Solr 4.1 and Chris Hostetter confirmed that this is a bug. Ludovic Boutros also reported this in SOLR-4394.

        Issue Links

          Activity

          Hide
          Hoss Man added a comment -

          Thanks for opening this John,

          I don't remember seeing Ludovic's comment in SOLR-4394 after that issue was resolved, but even looking at it now i couldn't understand how my change caused a problem in that code since: a) i didn't modify anything in ExternalPaths; b) SolrJettyTestBase already had a compile time dependency on ExternalPaths. It's only because of your stack trace that i was able to understand his comment about overriding getSolrHome() and how my change introducing TEST_KEYSTORE introduced a problem for people subclassing SolrjettyTestBase in their external tests.

          I'm attaching a patch that i think resolves this issue. SolrJettyTestBase now skips the SSL randomization logic (instead of a hard fail) if the example configs can't be found, and i also tried to improve ExternalPaths.SOURCE_HOME (and determineSourceHome()) have cleaner behavior in the event that they get used inadvertently by a client test.

          I experimenting with this changes in a little one off external test i created and it seemed to work, but i'd appreciate feedback from an end user who got burned by this bug to e sure it really resolves things for you.

          Show
          Hoss Man added a comment - Thanks for opening this John, I don't remember seeing Ludovic's comment in SOLR-4394 after that issue was resolved, but even looking at it now i couldn't understand how my change caused a problem in that code since: a) i didn't modify anything in ExternalPaths; b) SolrJettyTestBase already had a compile time dependency on ExternalPaths. It's only because of your stack trace that i was able to understand his comment about overriding getSolrHome() and how my change introducing TEST_KEYSTORE introduced a problem for people subclassing SolrjettyTestBase in their external tests. I'm attaching a patch that i think resolves this issue. SolrJettyTestBase now skips the SSL randomization logic (instead of a hard fail) if the example configs can't be found, and i also tried to improve ExternalPaths.SOURCE_HOME (and determineSourceHome()) have cleaner behavior in the event that they get used inadvertently by a client test. I experimenting with this changes in a little one off external test i created and it seemed to work, but i'd appreciate feedback from an end user who got burned by this bug to e sure it really resolves things for you.
          Hide
          John Gibson added a comment -

          Thanks for the patch Hoss Man. I tried it out against 4.3.1, 4.4, and 5.0 and it worked with all of them. It produced the following message at the beginning of the test and then continued execution:

          2013-06-01 17:55:48,860 INFO - Solr's example keystore not defined (not a solr test?) skipping SSL randomization

          Show
          John Gibson added a comment - Thanks for the patch Hoss Man. I tried it out against 4.3.1, 4.4, and 5.0 and it worked with all of them. It produced the following message at the beginning of the test and then continued execution: 2013-06-01 17:55:48,860 INFO - Solr's example keystore not defined (not a solr test?) skipping SSL randomization
          Hide
          Hoss Man added a comment -

          Thanks for testing John,

          prepping to commit & backport now

          Show
          Hoss Man added a comment - Thanks for testing John, prepping to commit & backport now
          Hide
          Hoss Man added a comment -

          Committed revision 1489081.
          Committed revision 1489098.
          Committed revision 1489105.

          Show
          Hoss Man added a comment - Committed revision 1489081. Committed revision 1489098. Committed revision 1489105.
          Hide
          Shalin Shekhar Mangar added a comment -

          Bulk close after 4.3.1 release

          Show
          Shalin Shekhar Mangar added a comment - Bulk close after 4.3.1 release

            People

            • Assignee:
              Hoss Man
              Reporter:
              John Gibson
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development