You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "Chris M. Hostetter (Jira)" <ji...@apache.org> on 2019/10/15 18:34:00 UTC

[jira] [Commented] (SOLR-13846) PreemptiveBasicAuthClientBuilderFactory use of static code blocks makes it unreliable in tests

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

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

the really weird thing here, is that both of the tests that currently use PreemptiveBasicAuthClientBuilderFactory use the exact same user:pass combination, so even if the static initialization is bleeding over from one test to the other, it seems like they should still pass....

Which means something else wonky is happening here.

> PreemptiveBasicAuthClientBuilderFactory use of static code blocks makes it unreliable in tests
> ----------------------------------------------------------------------------------------------
>
>                 Key: SOLR-13846
>                 URL: https://issues.apache.org/jira/browse/SOLR-13846
>             Project: Solr
>          Issue Type: Bug
>      Security Level: Public(Default Security Level. Issues are Public) 
>            Reporter: Chris M. Hostetter
>            Priority: Major
>
> PreemptiveBasicAuthClientBuilderFactory uses static code blocks to initialize global static variables in a way that makes it largely unusable in tests.
> Notably: it uses {{System.getProperty(...)}} during classloading to read system properties that then affect the behavior of all future instances -- even if an individual test explicitly sets the system property in question before instaniating instances of this class.
> This means that if two tests that both use instances of PreemptiveBasicAuthClientBuilderFactory run in the same JVM, only the system properties set in the first test will be used by PreemptiveBasicAuthClientBuilderFactory in the *second* test (even those the system properties get reset by the test framework between runs)
> There are currently two tests using PreemptiveBasicAuthClientBuilderFactory, and depending on the order they run, one will fail...
> {noformat}
> $ ant test -Dtests.jvms=1 '-Dtests.class=*.TestQueryingOnDownCollection|*.BasicAuthOnSingleNodeTest' -Dtests.seed=EC8FB67A91689F48 -Dtests.slow=true -Dtests.badapples=true -Dtests.locale=sl -Dtests.timezone=Asia/Baghdad -Dtests.asserts=true -Dtests.file.encoding=US-ASCII
> ...
>    [junit4]   2> NOTE: reproduce with: ant test  -Dtestcase=BasicAuthOnSingleNodeTest -Dtests.method=basicTest -Dtests.seed=EC8FB67A91689F48 -Dtests.slow=true -Dtests.badapples=true -Dtests.locale=sl -Dtests.timezone=Asia/Baghdad -Dtests.asserts=true -Dtests.file.encoding=US-ASCII
>    [junit4] ERROR   4.05s | BasicAuthOnSingleNodeTest.basicTest <<<
>    [junit4]    > Throwable #1: org.apache.solr.client.solrj.impl.BaseHttpSolrClient$RemoteSolrException: Error from server at http://127.0.0.1:37047/solr: Expected mime type application/octet-stream but got text/html. <html>
>    [junit4]    > <head>
>    [junit4]    > <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
>    [junit4]    > <title>Error 401 Bad credentials</title>
>    [junit4]    > </head>
>    [junit4]    > <body><h2>HTTP ERROR 401</h2>
>    [junit4]    > <p>Problem accessing /solr/authCollection/select. Reason:
>    [junit4]    > <pre>    Bad credentials</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.19.v20190610</a><hr/>
>    [junit4]    > </body>
>    [junit4]    > </html>
>    [junit4]    > 	at __randomizedtesting.SeedInfo.seed([EC8FB67A91689F48:1E7BA118D5CD927B]:0)
>    [junit4]    > 	at org.apache.solr.client.solrj.impl.Http2SolrClient.processErrorsAndResponse(Http2SolrClient.java:696)
>    [junit4]    > 	at org.apache.solr.client.solrj.impl.Http2SolrClient.request(Http2SolrClient.java:402)
>    [junit4]    > 	at org.apache.solr.client.solrj.impl.Http2SolrClient.request(Http2SolrClient.java:754)
>    [junit4]    > 	at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:207)
>    [junit4]    > 	at org.apache.solr.client.solrj.SolrClient.query(SolrClient.java:1003)
>    [junit4]    > 	at org.apache.solr.security.BasicAuthOnSingleNodeTest.basicTest(BasicAuthOnSingleNodeTest.java:72)
>    [junit4]    > 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>    [junit4]    > 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>    [junit4]    > 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>    [junit4]    > 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
>    [junit4]    > 	at java.base/java.lang.Thread.run(Thread.java:834)
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org