[ 
https://issues.apache.org/jira/browse/SOLR-13664?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Hoss Man updated SOLR-13664:
----------------------------
    Description: 
Prior to Solr 8.3, the javadocs for {{SolrTestCaseJ4.deleteCore()}} said that 
that method would delete the dataDir used by {{initCore()}} in spite of that 
method not actaully doing anything to clean up the dataDir for a very long time 
(exactly when the bug was introduced is not known)

For that reason, in most solr versions up to and including 8.2, tests that 
called combinations of {{initCore()}} / {{deleteCore()}} within a single test 
class would see the data from a previous core polluting the data of a newly 
introduced core.

As part of this jira, this bug was fixed, by udpating {{deleteCore()}} to 
"reset" the value of the {{initCoreDataDir}} variable to null, so that it 
can/will be re-initialized on the next call to either {{initCore()}} or the 
lower level {{createCore()}}. 

Existing tests that refer to the {{initCoreDataDir}} directly (either before, 
or during the lifecycle of an active core managed via {{initCore()}} / 
{{deleteCore()}} ) may encounter {{NullPointerExceptions}} on upgrading to Solr 
8.3 as a result of this bug fix.  These tests are encouraged to use the new 
helper method {{initAndGetDataDir()}} in place of directly refering to the (now 
deprecated) {{initCoreDataDir}} variable directly.

Any existing tests that refer to the {{initCoreDataDir}} directly *after* 
calling {{deleteCore()}} with the intention of inspecting the index contents 
after shutdown, will need to be modified to preserved the rsults of calling 
{{initAndGetDataDir()}} into a new variable for such introspection – the actual 
contents of the directory will not be removed until the full ifecycle of the 
test class is complete (see {{LuceneTestCase.createTempDir()}})

 

  was:

In spite of what it's javadocs say, {{SolrTestCaseJ4.deleteCore()}} does 
nothing to delete the dataDir used by the TestHarness

The git history is a bit murky, so i'm not entirely certain when this stoped 
working, but I suspect it happened as part of the overall cleanup regarding 
test temp dirs and the use of {{LuceneTestCase.createTempDir(...) -> 
TestRuleTemporaryFilesCleanup}}

While this is not problematic in many test classes, where a single 
{{initCore(...) is called in a {{@BeforeClass}} and the test then re-uses that 
SolrCore for all test methods and relies on {{@AfterClass 
SolrTestCaseJ4.teardownTestCases()}} to call {{deleteCore()}}, it's problematic 
in test classes where {{deleteCore()}} is explicitly called in an {{@After}} 
method to ensure a unique core (w/unique dataDir) is used for each test method.

(there are currently about 61 tests that call {{deleteCore()}} directly)



updated jira summary to be more helpful to users who may find this jira via 
CHANGES.txt pointer and need more information on how it affects them if they 
have their own custom tests using SolrTestCaseJ4.

>  SolrTestCaseJ4.deleteCore() does not delete/clean dataDir
> ----------------------------------------------------------
>
>                 Key: SOLR-13664
>                 URL: https://issues.apache.org/jira/browse/SOLR-13664
>             Project: Solr
>          Issue Type: Bug
>      Security Level: Public(Default Security Level. Issues are Public) 
>            Reporter: Hoss Man
>            Assignee: Hoss Man
>            Priority: Major
>         Attachments: SOLR-13664.patch, SOLR-13664.patch, SOLR-13664.patch, 
> SOLR-13664.patch
>
>
> Prior to Solr 8.3, the javadocs for {{SolrTestCaseJ4.deleteCore()}} said that 
> that method would delete the dataDir used by {{initCore()}} in spite of that 
> method not actaully doing anything to clean up the dataDir for a very long 
> time (exactly when the bug was introduced is not known)
> For that reason, in most solr versions up to and including 8.2, tests that 
> called combinations of {{initCore()}} / {{deleteCore()}} within a single test 
> class would see the data from a previous core polluting the data of a newly 
> introduced core.
> As part of this jira, this bug was fixed, by udpating {{deleteCore()}} to 
> "reset" the value of the {{initCoreDataDir}} variable to null, so that it 
> can/will be re-initialized on the next call to either {{initCore()}} or the 
> lower level {{createCore()}}. 
> Existing tests that refer to the {{initCoreDataDir}} directly (either before, 
> or during the lifecycle of an active core managed via {{initCore()}} / 
> {{deleteCore()}} ) may encounter {{NullPointerExceptions}} on upgrading to 
> Solr 8.3 as a result of this bug fix.  These tests are encouraged to use the 
> new helper method {{initAndGetDataDir()}} in place of directly refering to 
> the (now deprecated) {{initCoreDataDir}} variable directly.
> Any existing tests that refer to the {{initCoreDataDir}} directly *after* 
> calling {{deleteCore()}} with the intention of inspecting the index contents 
> after shutdown, will need to be modified to preserved the rsults of calling 
> {{initAndGetDataDir()}} into a new variable for such introspection – the 
> actual contents of the directory will not be removed until the full ifecycle 
> of the test class is complete (see {{LuceneTestCase.createTempDir()}})
>  



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to