Permalink
Browse files

[System.ServiceModel] Speed up Bug652331_2Test test execution.

For reasons I currently can't explain, the Service1Client test type
appears to support having only one async operation "in flight" at a
time. As a result of this, calling multiple Async methods on the
Service1Client instance, as was done previously, would result in not
all of the event handlers being invoked, and the test timing out
after 60s instead of exiting quickly because all event handlers had
been raised.

I don't understand enough of WCF & this code to say why Service1Client
can have only one async operation in progress at once, but making this
change so that each async operation operates on a separate instance
speeds up the Bug652331_2Test execution from 60s to 5s.
  • Loading branch information...
1 parent b42fb3a commit 5a6f9b7e521fcba3e9ed9f2b4032805503be84bb @jonpryor jonpryor committed Jan 20, 2012
Showing with 20 additions and 11 deletions.
  1. +20 −11 mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/Bug652331_2Test.cs
@@ -68,37 +68,46 @@ void RunClient ()
{
var binding = new BasicHttpBinding ();
var remoteAddress = new EndpointAddress ("http://localhost:37564/Service1");
- var client = new Service1Client (binding, remoteAddress);
+
+ var normalClient = new Service1Client (binding, remoteAddress);
+ var collectionClient = new Service1Client (binding, remoteAddress);
+ var nestedClient = new Service1Client (binding, remoteAddress);
var waits = new ManualResetEvent [3];
for (int i = 0; i < waits.Length; i++)
waits [i] = new ManualResetEvent (false);
- client.GetDataCompleted += delegate (object o, GetDataCompletedEventArgs e) {
- if (e.Error != null)
+ 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");
waits [0].Set ();
};
- client.GetDataAsync ();
+ normalClient.GetDataAsync ();
- client.GetCollectionDataCompleted += delegate (object sender, GetCollectionDataCompletedEventArgs e) {
- if (e.Error != null)
+ 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");
waits [1].Set ();
};
- client.GetCollectionDataAsync ();
+ collectionClient.GetCollectionDataAsync ();
- client.GetNestedDataCompleted += delegate (object sender, GetNestedDataCompletedEventArgs e) {
- if (e.Error != null)
+ 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");
waits [2].Set ();
};
- client.GetNestedDataAsync ();
+ nestedClient.GetNestedDataAsync ();
- WaitHandle.WaitAll (waits.Cast<WaitHandle> ().ToArray (), TimeSpan.FromMinutes (1));
+ WaitHandle.WaitAll (waits, TimeSpan.FromMinutes (1));
}
string ItemsToString (IEnumerable<DataType1> items)

0 comments on commit 5a6f9b7

Please sign in to comment.