[ 
https://issues.apache.org/jira/browse/SOLR-17478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17887045#comment-17887045
 ] 

Chris M. Hostetter commented on SOLR-17478:
-------------------------------------------

(FWIW: I found this while using the solr test-framework in my own (Solr plugin) 
project, where I try to avoid the bloat of SolrTestCaseJ4 whenever possible – 
but this is not merely an academic/esoteric problem. 
{{SolrZkClientCompressedDataTest}} is an example of a test Solr has today that 
uses ZkTestServer but does not extend SolrTestCaseJ4.)

Strawman suggestion:
 * Remove everything related to {{SolrZkServer.ZK_WHITELIST_PROPERTY}} from 
{{SolrTestCaseJ4}}
 * Wrap every {{ClientBase.waitFor...}} call in {{ZkTestServer}} with an 
{{assertTrue}}
 * Add some *NON STATIC* code to {{ZkTestServer}} (either constructor, or 
run(), etc...) that looks something like...

{code:java}
if ( ! FourLetterCommands.isEnabled("stat") ) {
  log.error("ZkTestServer requires the 'stat' command, temporarily manipulating 
your whitelist");
  String tmp = System.getProperty(ZK_WHITELIST_PROPERTY);
  System.setProperty(ZK_WHITELIST_PROPERTY, "*");
  FourLetterCommands.resetWhiteList();
  assertTrue(FourLetterCommands.isEnabled("stat"));
  System.setProperty(ZK_WHITELIST_PROPERTY, tmp);
}
{code}

> ZkTestServer bugs can cause 30sec test pauses
> ---------------------------------------------
>
>                 Key: SOLR-17478
>                 URL: https://issues.apache.org/jira/browse/SOLR-17478
>             Project: Solr
>          Issue Type: Test
>      Security Level: Public(Default Security Level. Issues are Public) 
>            Reporter: Chris M. Hostetter
>            Priority: Major
>
> Pop Quiz: which of these two (psuedo-code) ZK based test classes will be 
> faster...
> {code:java}
> public class Test_X extends SolrTestCase {
>   public void test() throws Exception {
>     ZkTestServer zkServer = new ZkTestServer(createTempDir());
>     zkServer.run();
>     zkServer.shutdown();
>   }
> }
> public class Test_Y extends SolrTestCaseJ4 {
>   public void test() throws Exception {
>     ZkTestServer zkServer = new ZkTestServer(createTempDir());
>     zkServer.run();
>     zkServer.shutdown();
>   }
> }
> {code}
> ...if you guessed "Test_X, because SolrTestCase has less overhead then 
> SolrTestCaseJ4" then you are *wrong by ~30 seconds.*
> Actually, that's not _always_ true: if you run both tests in the same JVM 
> then they will both take the same amount of time:
>  * If Test_Y runs first, they will both take ~1 second each
>  * If Test_X runs first, they will both take 30+ seconds *_each_*
> The reason for the dependency comes down to:
>  * The {{"zookeeper.4lw.commands.whitelist"}} sysprop is set/cleared in 
> SolrTestCaseJ4 (BeforeClass/AfterClass), but _NOT_ in SolrTestCase
>  * ZkTestServer depends on the ZK helper methods 
> {{ClientBase.waitForServerUp()}} which depends on the 4LW {{"stat"}} being 
> whitelisted
>  ** If "stat" is not whitelisted, then {{waitForServerUp()}} timesout after 
> 30 sec and return a failure
>  ** Bonus problem: ZkTestServer never checks of the return value of 
> {{waitForServerUp()}} !
>  * Zookeeper only checks for the 4LW whitelist sysprop the first time it's 
> needed by the {{FourLetterCommands}} class _and then caches it staticly_
>  ** So if the first testclass to run a ZK server doesn't extend 
> SolrTestCaseJ4, then _every_ test that uses ZkTestServer in that JVM will 
> stall for 30 seconds



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to