diff options
author | Ludovic Henry <ludovic@xamarin.com> | 2015-12-14 20:08:55 +0300 |
---|---|---|
committer | Ludovic Henry <ludovic@xamarin.com> | 2015-12-15 02:59:42 +0300 |
commit | 6776742fdea37b4aa612f953e4b4f22c74ab4bb2 (patch) | |
tree | 5a374f36494cb7966b478e75f2dba38c66e86893 /mcs | |
parent | 9900f812e2fc72b1e9389c4e7a0602007f256718 (diff) |
[tests] Attempt at fixing System.ServiceModel.Dispatcher.Bug32886.Bug32886_Test flakiness
Diffstat (limited to 'mcs')
3 files changed, 87 insertions, 62 deletions
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/Bug32886Test.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/Bug32886Test.cs index 17712fec024..22110a5d519 100644 --- a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/Bug32886Test.cs +++ b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/Bug32886Test.cs @@ -63,16 +63,21 @@ namespace MonoTests.System.ServiceModel.Dispatcher var client = new TempConvertSoapClient (binding, remoteAddress); var wait = new ManualResetEvent (false); + + Exception error = null; + string result = null; + client.CelsiusToFahrenheitCompleted += delegate (object o, CelsiusToFahrenheitCompletedEventArgs e) { - if (e.Error != null) - throw e.Error; - Assert.AreEqual ("76.1", e.Result, "#1"); + error = e.Error; + result = e.Result; wait.Set (); }; client.CelsiusToFahrenheitAsync ("24.5"); - if (!wait.WaitOne (TimeSpan.FromSeconds (20))) - Assert.Fail ("timeout"); + + Assert.IsTrue (wait.WaitOne (TimeSpan.FromSeconds (20)), "timeout"); + Assert.IsNull (error, "#1, inner exception: {0}", error); + Assert.AreEqual ("76.1", result, "#2"); } finally { serviceHost.Close (); } diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/Bug652331Test.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/Bug652331Test.cs index cdc68486779..7ecaee844d6 100644 --- a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/Bug652331Test.cs +++ b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/Bug652331Test.cs @@ -66,16 +66,21 @@ namespace MonoTests.System.ServiceModel.Dispatcher var client = new Service1Client (binding, remoteAddress); var wait = new ManualResetEvent (false); + + Exception error = null; + object result = null; + client.GetDataCompleted += delegate (object o, GetDataCompletedEventArgs e) { - if (e.Error != null) - throw e.Error; - Assert.AreEqual ("A", ((DataType1) e.Result).Id, "#1"); + error = e.Error; + result = e.Result; wait.Set (); }; client.GetDataAsync (); - if (!wait.WaitOne (TimeSpan.FromSeconds (20))) - Assert.Fail ("timeout"); + + Assert.IsTrue (wait.WaitOne (TimeSpan.FromSeconds (20)), "timeout"); + Assert.IsNull (error, "#1, inner exception: {0}", error); + Assert.AreEqual ("A", ((DataType1) result).Id, "#2"); } finally { serviceHost.Close (); } diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/Bug652331_2Test.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/Bug652331_2Test.cs index 4d6fca943e6..bd3252b7cdc 100644 --- a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/Bug652331_2Test.cs +++ b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/Bug652331_2Test.cs @@ -76,58 +76,73 @@ namespace MonoTests.System.ServiceModel.Dispatcher var nestedClient = new Service1Client (binding, remoteAddress); var dbClient = new Service1Client (binding, remoteAddress); - var waits = new ManualResetEvent [4]; - for (int i = 0; i < waits.Length; i++) - waits [i] = new ManualResetEvent (false); - - int passed = 0; - - normalClient.GetDataCompleted += delegate (object o, GetDataCompletedEventArgs e) { - if (e.Error != null) { - Assert.Fail ("Normal failed; error: {0}", e.Error); - throw e.Error; - } - Assert.AreEqual ("A", ((DataType1) e.Result).Id, "Normal"); - Interlocked.Increment (ref passed); - waits [0].Set (); - }; - normalClient.GetDataAsync (); - - collectionClient.GetCollectionDataCompleted += delegate (object sender, GetCollectionDataCompletedEventArgs e) { - if (e.Error != null) { - Assert.Fail ("Collection failed; error: {0}", e.Error); - throw e.Error; - } - Assert.AreEqual ("B,C", ItemsToString (e.Result.Cast<DataType1> ()), "Collection"); - Interlocked.Increment (ref passed); - waits [1].Set (); - }; - collectionClient.GetCollectionDataAsync (); - - nestedClient.GetNestedDataCompleted += delegate (object sender, GetNestedDataCompletedEventArgs e) { - if (e.Error != null) { - Assert.Fail ("Nested failed; error: {0}", e.Error); - throw e.Error; - } - Assert.AreEqual ("D,E", ItemsToString (e.Result.Items.Cast<DataType1> ()), "Nested"); - Interlocked.Increment (ref passed); - waits [2].Set (); - }; - nestedClient.GetNestedDataAsync (); - - dbClient.JSMGetDatabasesCompleted += delegate (object sender, JSMGetDatabasesCompletedEventArgs e) { - waits [3].Set (); - if (e.Error != null) { - throw e.Error; - } - Assert.AreEqual ("databases", e.Result, "Databases"); - Interlocked.Increment (ref passed); - }; - dbClient.JSMGetDatabasesAsync(); - - WaitHandle.WaitAll (waits, TimeSpan.FromMinutes (1)); - if (passed != waits.Length) - Assert.Fail ("Not all tests passed!"); + { + ManualResetEvent wait = new ManualResetEvent (false); + Exception error = null; + object result = null; + + normalClient.GetDataCompleted += delegate (object o, GetDataCompletedEventArgs e) { + error = e.Error; + result = e.Result; + wait.Set (); + }; + normalClient.GetDataAsync (); + + Assert.IsTrue (wait.WaitOne (TimeSpan.FromSeconds (20)), "#1 timeout"); + Assert.IsNull (error, "#1.1, inner exception: {0}", error); + Assert.AreEqual ("A", ((DataType1) result).Id, "#1.2"); + } + + { + ManualResetEvent wait = new ManualResetEvent (false); + Exception error = null; + ObservableCollection<object> result = null; + + collectionClient.GetCollectionDataCompleted += delegate (object sender, GetCollectionDataCompletedEventArgs e) { + error = e.Error; + result = e.Result; + wait.Set (); + }; + collectionClient.GetCollectionDataAsync (); + + Assert.IsTrue (wait.WaitOne (TimeSpan.FromSeconds (20)), "#2 timeout"); + Assert.IsNull (error, "#2.1, inner exception: {0}", error); + Assert.AreEqual ("B,C", ItemsToString (result.Cast<DataType1> ()), "#2.2"); + } + + { + ManualResetEvent wait = new ManualResetEvent (false); + Exception error = null; + WebServiceMoonlightTest.ServiceReference2.DataType2 result = null; + + nestedClient.GetNestedDataCompleted += delegate (object sender, GetNestedDataCompletedEventArgs e) { + error = e.Error; + result = e.Result; + wait.Set (); + }; + nestedClient.GetNestedDataAsync (); + + Assert.IsTrue (wait.WaitOne (TimeSpan.FromSeconds (20)), "#3 timeout"); + Assert.IsNull (error, "#3.1, inner exception: {0}", error); + Assert.AreEqual ("D,E", ItemsToString (result.Items.Cast<DataType1> ()), "#3.2"); + } + + { + ManualResetEvent wait = new ManualResetEvent (false); + Exception error = null; + string result = null; + + dbClient.JSMGetDatabasesCompleted += delegate (object sender, JSMGetDatabasesCompletedEventArgs e) { + error = e.Error; + result = e.Result; + wait.Set (); + }; + dbClient.JSMGetDatabasesAsync(); + + Assert.IsTrue (wait.WaitOne (TimeSpan.FromSeconds (20)), "#4 timeout"); + Assert.IsNull (error, "#4.1, inner exception: {0}", error); + Assert.AreEqual ("databases", result, "#4.2"); + } } string ItemsToString (IEnumerable<DataType1> items) |