Lucene.Net.Tests.Index.TestIndexWriter (TestThreadInterruptDeadlock + TestTwoThreadsInterruptDeadlock): Manually failing these tests under specific build configurations because they cause the test runner to crash - need to investigate
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/40c42ced Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/40c42ced Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/40c42ced Branch: refs/heads/master Commit: 40c42ced8127d61a9e066548ceb54d03868e54a0 Parents: 62333ec Author: Shad Storhaug <[email protected]> Authored: Sat Sep 9 00:21:55 2017 +0700 Committer: Shad Storhaug <[email protected]> Committed: Sat Sep 9 00:21:55 2017 +0700 ---------------------------------------------------------------------- src/Lucene.Net.Tests/Index/TestIndexWriter.cs | 60 ++++++++++++++++++++-- 1 file changed, 56 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/40c42ced/src/Lucene.Net.Tests/Index/TestIndexWriter.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests/Index/TestIndexWriter.cs b/src/Lucene.Net.Tests/Index/TestIndexWriter.cs index d8145e8..0238ade 100644 --- a/src/Lucene.Net.Tests/Index/TestIndexWriter.cs +++ b/src/Lucene.Net.Tests/Index/TestIndexWriter.cs @@ -319,6 +319,7 @@ namespace Lucene.Net.Index [Test] public virtual void TestSmallRAMBuffer() { + Directory dir = NewDirectory(); IndexWriter writer = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetRAMBufferSizeMB(0.000001).SetMergePolicy(NewLogMergePolicy(10))); int lastNumFile = dir.ListAll().Length; @@ -776,7 +777,7 @@ namespace Lucene.Net.Index dir.Dispose(); } -#if !NETSTANDARD //NOTE: Cannot set ThreadPriority in .NET Core. +#if !NETSTANDARD1_5 //NOTE: Cannot set ThreadPriority in .NET Core. // LUCENE-1036 [Test] public virtual void TestMaxThreadPriority() @@ -1141,6 +1142,7 @@ namespace Lucene.Net.Index internal volatile bool Failed; internal volatile bool Finish; + internal volatile Exception Exception; internal volatile bool AllowInterrupt = false; internal readonly Random Random; @@ -1354,9 +1356,25 @@ namespace Lucene.Net.Index { w.Rollback(); } +#if !NETSTANDARD1_5 + // LUCENENET TODO: Is this the right decision here, or is IndexWriter + // supposed to swallow ThreadInterruptedException? + + // LUCENENET specific - there is a chance that our thread will be + // interrupted here, so we need to catch and ignore that exception + // when our MockDirectoryWrapper throws it. + catch (ThreadInterruptedException) + { + // ignore + } +#endif catch (IOException ioe) { - throw new Exception(ioe.ToString(), ioe); + //throw new Exception(ioe.ToString(), ioe); + // LUCENENET specific - throwing the exception on + // a background thread will crash the runner, so we + // need to store and throw it from the test. + this.Exception = ioe; } } @@ -1389,7 +1407,11 @@ namespace Lucene.Net.Index } catch (IOException e) { - throw new Exception(e.ToString(), e); + //throw new Exception(e.ToString(), e); + // LUCENENET specific - throwing the exception on + // a background thread will crash the runner, so we + // need to store and throw it from the test. + this.Exception = e; } try { @@ -1397,7 +1419,11 @@ namespace Lucene.Net.Index } catch (IOException e) { - throw new Exception(e.ToString(), e); + //throw new Exception(e.ToString(), e); + // LUCENENET specific - throwing the exception on + // a background thread will crash the runner, so we + // need to store and throw it from the test. + this.Exception = e; } } } @@ -1405,6 +1431,16 @@ namespace Lucene.Net.Index [Test] public virtual void TestThreadInterruptDeadlock() { +#if DEBUG +#if NETSTANDARD1_5 + fail("LUCENENET TODO: Uncaught exceptions on background thread causing test runner crash"); +#endif +#endif + +#if NETCOREAPP2_0 + fail("LUCENENET TODO: Uncaught exceptions on background thread causing test runner crash"); +#endif + IndexerThreadInterrupt t = new IndexerThreadInterrupt(this); t.SetDaemon(true); t.Start(); @@ -1435,6 +1471,10 @@ namespace Lucene.Net.Index } t.Finish = true; t.Join(); + + // LUCENENET specific - if our background thread had an exception, + // we need to report it here on the main thread. + Assert.IsNull(t.Exception, t.Exception?.ToString()); Assert.IsFalse(t.Failed); } @@ -1443,6 +1483,10 @@ namespace Lucene.Net.Index [Test] public virtual void TestTwoThreadsInterruptDeadlock() { +#if NETCOREAPP2_0 + fail("LUCENENET TODO: Uncaught exceptions on background thread causing test runner crash"); +#endif + IndexerThreadInterrupt t1 = new IndexerThreadInterrupt(this); t1.SetDaemon(true); t1.Start(); @@ -1481,7 +1525,15 @@ namespace Lucene.Net.Index t2.Finish = true; t1.Join(); t2.Join(); + + // LUCENENET specific - if our background thread had an exception, + // we need to report it here on the main thread. + Assert.IsNull(t1.Exception, t1.Exception?.ToString()); Assert.IsFalse(t1.Failed); + + // LUCENENET specific - if our background thread had an exception, + // we need to report it here on the main thread. + Assert.IsNull(t2.Exception, t2.Exception?.ToString()); Assert.IsFalse(t2.Failed); }
