void TC00033_doWorkRemote2(bool recordrequest, bool recordresponse) { Thread.Sleep(10000); try { CommonUtils.RemoveService(url2mod); CommonUtils.SetPolicy(url2mod, recordrequest, recordresponse); HelloWorldESMWCF2.Service1Client c = new HelloWorldESMWCF2.Service1Client(); string s = c.GetData(5); c.Close(); Thread.Sleep(15000); DateTime timeout = DateTime.Now.AddMinutes(1); Console.Out.WriteLine("message sent queue size" + MessageProcessor.GetQueueSize()); } catch (Exception ex) { string _err = ""; while (ex != null) { _err += ex.Message + " " + ex.StackTrace; ex = ex.InnerException; } CommonUtils.RemoveService(url_mod); Assert.Fail(_err); } string err = CommonUtils.VerifyLastMessagePayloads(url2mod, recordrequest, recordresponse, 1); CommonUtils.RemoveService(url2mod); if (!String.IsNullOrEmpty(err)) { Assert.Fail(err); } }
/* [Test] * public void TC00134_1_ChainingThinClientToWCFServiceToWCFService() * { * TC00035_doWork("http://localhost/HelloWorldESMTester/callWithMonitor.aspx", true, true, 2); * //there should be exactly two transactions recorded, since this service is monitored via web.config settings * }*/ //Failed TC00035_3_ThinClientNoPayloadsWithClientMonitorAndServiceMonitor FGSMS.NETTestSuite /* Assert.Fail failed. the transaction 05604057-bff9-4907-8527-f9c6b68fc4dc did not have a related transaction id, * this means that an http header was not propagated agent org.miloss.fgsms.agent.wcf.AgentWCFClientMessageInspector.client * Agent Outbound queue: 0 Outbound Threads 1 Thread FGSMS DataPusher from thread 13 mem stat 324771840/4294434816 */ void TC00035_doWork(string url, bool recordrequest, bool recordresponse, int expectedcount) { Thread.Sleep(10000); string st = ""; try { CommonUtils.RemoveService(url3mod); CommonUtils.SetPolicy(url3mod, recordrequest, recordresponse); WebClient cw = new WebClient(); st = cw.DownloadString(url); Thread.Sleep(15000); DateTime timeout = DateTime.Now.AddMinutes(1); Console.Out.WriteLine("message sent queue size" + MessageProcessor.GetQueueSize()); } catch (Exception ex) { CommonUtils.RemoveService(url3mod); string s = ""; while (ex != null) { s += ex.Message + ex.StackTrace; ex = ex.InnerException; } Assert.Fail(s); } string err = CommonUtils.VerifyLastMessagePayloads(url3mod, recordrequest, recordresponse, expectedcount); if (expectedcount == 2) { err += err = CommonUtils.VerifyLastMessagePayloadsTwoAgentsOneTransaction(url3mod); } if (st.Contains("ERROR")) { err += st; } CommonUtils.RemoveService(url3mod); if (!String.IsNullOrEmpty(err)) { Assert.Fail(err); } }
void TC00137_dowork(bool request, bool response) { string urlmod = MessageProcessor.ModifyURL(ConfigurationManager.AppSettings["HelloWorldASPNET2"], true); try { CommonUtils.RemoveService(urlmod); CommonUtils.SetPolicy(urlmod, request, response); HelloWorldASPNET2.Service2 svc = new HelloWorldASPNET2.Service2(); MessageProcessor mp = MessageProcessor.Instance; MessageProcessor.PurgeOutboundQueue(); MessageProcessor.PurgePolicyCache(); svc.Url = ConfigurationManager.AppSettings["HelloWorldASPNET2"]; string s = svc.HelloWorld("test"); //just confirm that we are NOT monitored for this context Assert.IsTrue(MessageProcessor.GetPolicyCacheSize() == 0); Assert.IsTrue(MessageProcessor.GetQueueSize() == 0); Thread.Sleep(10000); //give the remote agent a few seconds to record and send back the data svc.Dispose(); } catch (Exception ex) { string _err = ""; while (ex != null) { _err += ex.Message + " " + ex.StackTrace; ex = ex.InnerException; } CommonUtils.RemoveService(urlmod); Assert.Fail(_err); } Thread.Sleep(15000); //give the remote agent a few seconds to record and send back the data string s2 = CommonUtils.VerifyLastMessagePayloads(urlmod, request, response, 1); CommonUtils.RemoveService(urlmod); if (!String.IsNullOrEmpty(s2)) { Assert.Fail(s2); } }
public void dowork_156(bool recordrequest, bool recordresponse) { Thread.Sleep(10000); CommonUtils.RemoveService(url_mod); CommonUtils.SetPolicy(url_mod, recordrequest, recordresponse); try { MessageProcessor mp = MessageProcessor.Instance; MessageProcessor.PurgePolicyCache(); MessageProcessor.PurgeOutboundQueue(); Assert.IsTrue(MessageProcessor.GetPolicyCacheSize() == 0); Assert.IsTrue(MessageProcessor.GetQueueSize() == 0); WebServiceHost host = new WebServiceHost(typeof(Service), new Uri(url_mod)); host.Description.Behaviors.Remove(typeof(org.miloss.fgsms.agent.wcf.AgentWCFServiceBehavior)); host.Description.Behaviors.Add(new org.miloss.fgsms.agent.wcf.AgentWCFServiceBehavior()); ServiceEndpoint ep = host.AddServiceEndpoint(typeof(IService), new WebHttpBinding(), ""); host.Open(); //do work WebClient c = new WebClient(); c.DownloadString(url_mod + "EchoWithGet?s=hello"); host.Close(); Thread.Sleep(5000); DateTime timeout = DateTime.Now.AddMinutes(2); Console.Out.WriteLine("message sent queue size" + MessageProcessor.GetQueueSize()); while (MessageProcessor.GetQueueSize() > 0 && DateTime.Now < timeout) { Thread.Sleep(1000); } } catch (Exception ex) { string _err = ""; while (ex != null) { _err += ex.Message + " " + ex.StackTrace; ex = ex.InnerException; } CommonUtils.RemoveService(url_mod); Assert.Fail(_err); } Thread.Sleep(10000); string err = ""; if (MessageProcessor.GetPolicyCacheSize() == 0) { err += "policy cache is empty, it should have at least one item in it"; } if (!String.IsNullOrEmpty(MessageProcessor.LastErrorMessage)) { err += "agent error " + MessageProcessor.LastErrorMessage; } TransactionalWebServicePolicy tp = MessageProcessor.GetPolicyIfAvailable(url_mod, true); if (tp == null) { err += "the policy for the service was not cached, which means something went wrong"; } err += CommonUtils.VerifyLastMessagePayloads(url_mod, recordrequest, recordresponse, 1); //err += CommonUtils.VerifyLastMessagePayloadsTwoAgentsOneTransaction(url_mod); CommonUtils.RemoveService(url_mod); if (!String.IsNullOrEmpty(err)) { Assert.Fail(err); } }
/// <summary> /// monitored self hosted service and client handler added programmatically /// </summary> /// <param name="recordrequest"></param> /// <param name="recordresponse"></param> void TC00139_doWork(bool recordrequest, bool recordresponse) { Thread.Sleep(10000); CommonUtils.RemoveService(url_mod); CommonUtils.SetPolicy(url_mod, recordrequest, recordresponse); try { MessageProcessor mp = MessageProcessor.Instance; MessageProcessor.PurgePolicyCache(); MessageProcessor.PurgeOutboundQueue(); Assert.IsTrue(MessageProcessor.GetPolicyCacheSize() == 0); Assert.IsTrue(MessageProcessor.GetQueueSize() == 0); ServiceHost host = new ServiceHost(typeof(FGSMSNetServiceImpl)); host.Description.Behaviors.Remove(typeof(org.miloss.fgsms.agent.wcf.AgentWCFServiceBehavior)); host.Description.Behaviors.Add(new org.miloss.fgsms.agent.wcf.AgentWCFServiceBehavior()); host.Open(); IFGSMSNetService svc = getproxyWithMonitor(url_mod); SomeComplexRequestObject req = new SomeComplexRequestObject(); req.stdout = "hi"; svc.getData(req); Thread.Sleep(5000); DateTime timeout = DateTime.Now.AddMinutes(2); Console.Out.WriteLine("message sent queue size" + MessageProcessor.GetQueueSize()); while (MessageProcessor.GetQueueSize() > 0 && DateTime.Now < timeout) { Thread.Sleep(1000); } ((IClientChannel)svc).Close(); ((IClientChannel)svc).Dispose(); host.Close(); } catch (Exception ex) { string _err = ""; while (ex != null) { _err += ex.Message + " " + ex.StackTrace; ex = ex.InnerException; } CommonUtils.RemoveService(url_mod); Assert.Fail(_err); } Thread.Sleep(10000); string err = ""; if (MessageProcessor.GetPolicyCacheSize() == 0) { err += "policy cache is empty, it should have at least one item in it"; } if (!String.IsNullOrEmpty(MessageProcessor.LastErrorMessage)) { err += "agent error " + MessageProcessor.LastErrorMessage; } TransactionalWebServicePolicy tp = MessageProcessor.GetPolicyIfAvailable(url_mod, true); if (tp == null) { err += "the policy for the service was not cached, which means something went wrong"; } err += CommonUtils.VerifyLastMessagePayloads(url_mod, recordrequest, recordresponse, 2); err += CommonUtils.VerifyLastMessagePayloadsTwoAgentsOneTransaction(url_mod); CommonUtils.RemoveService(url_mod); if (!String.IsNullOrEmpty(err)) { Assert.Fail(err); } }