NightOwl888 commented on issue #768:
URL: https://github.com/apache/lucenenet/issues/768#issuecomment-1355228404

   Hi @Jeevananthan-23. Thanks for volunteering.
   
   I don't believe that .NET has a built-in "crash" function that can be 
executed from the outside of a process like Java does, so we will need to 
change the approach. My thought is to do something along the lines of:
   
   1. Have the test generate the C# code to create a basic console app that 
runs 2 threads.
      a. Thread 1 will execute the code in the 
`TestNRTThreads.TestNRTThreads_Mem()` method up to 10 times. This test should 
be modified to check for the directory to create the index in from an 
environment variable, and if the environment variable isn't passed to proceed 
with a random index directory as it currently does.
      b. Thread 2 will sleep for a random number of milliseconds (between 3000 
and 4000) and then throw an uncaught exception. This will crash the application 
on .NET Core. Inherit`ThreadJob` to make the thread, similar to how they are 
done in Java. `ThreadJob` automatically re-throws the exception when you call 
`Join`, which if we leave uncaught will also crash on .NET Framework.
   2. The test would use `System.Diagnostics.Process` to call `dotnet run` to 
compile and run the console app. It should attach an in-memory listener to 
STDERR so it can confirm that an error occurred.
   3. The test should create a random temp directory name and pass the name to 
the console app using the `EnvironmentVariables `property of 
`System.Diagnostics.Process.StartInfo`.
   4. The test will wait for the process to exit before proceeding.
   5. Once it has exited, the test should check to ensure the output of STDERR 
has a length greater than 0.
   6. Next, proceed with the original `checkIndexes(tempDir)` test with the 
directory that was created in step 3.
   
   Of course, if during your research you think you have found another approach 
that works, you can modify it accordingly. But please use the original 
`TestNRTThreads.TestNRTThreads_Mem()` and `checkIndexes(tempDir)` to generate 
the index and check to see that it is not corrupted.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to