[ https://issues.apache.org/jira/browse/SOLR-13846?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16952291#comment-16952291 ]
Chris M. Hostetter commented on SOLR-13846: ------------------------------------------- i can't really wrap my head around how/why it fails the way it does – but more importantly: nothing in either of these 2 affected tests actual cares about using PreemptiveBasicAuthClientBuilderFactory: * BasicAuthOnSingleNodeTest explicitly sets the credentials on most requests, and seems to use PreemptiveBasicAuthClientBuilderFactory purely as a way to ensure credentials are set when querying with the {{SolrQuery}} API (which doesn't have credential realted methods ** using the more full featured {{QueryRequest}} API in it's place and setting credentials on those objects works just as well * TestQueryingOnDownCollection already explicitly sets the credentials on every request ** removing the initialization of PreemptiveBasicAuthClientBuilderFactory from this test has zero impact on it's behavior. ...so i'm going to go ahead and remove PreemptiveBasicAuthClientBuilderFactory from these tests, and leave this issue open for the future to fix PreemptiveBasicAuthClientBuilderFactory so more then one instance could potentially be used in a single JVM. > 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-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org