private void VerifyCommandFailed(TestEvents ev, TimeSpan timeout, params string[] commands) { List <string> expected = new List <string>(); expected.Add("Request[Type:Create, Path:/$metadata/scheduler/commands]"); expected.Add("Request[Type:Create, Path:/$metadata/scheduler/failures]"); expected.Add("Request[Type:Create, Path:/$metadata/scheduler/inflight]"); expected.Add("Request[Type:GetChildren, Path:/$metadata/scheduler/commands]"); foreach (string command in commands) { expected.Add("<contains>Request[Type:Create, Path:/$metadata/scheduler/commands/" + command + "]"); } expected.Add("WatchedEvent[Class:WatchedEvent,Path=/$metadata/scheduler/commands,EventType=NodeChildrenChanged,KeeperState=SyncConnected]"); expected.Add("Request[Type:GetChildren, Path:/$metadata/scheduler/commands]"); foreach (string command in commands) { expected.Add("Request[Type:GetData, Path:/$metadata/scheduler/commands/" + command + "]"); expected.Add("Request[Type:Multi, Requests:Request[Type:Create, Path:/$metadata/scheduler/failures/" + command + "];Request[Type:Move, Path:/$metadata/scheduler/commands/" + command + ", PathDst:/$metadata/scheduler/failures/" + command + "];Request[Type:Create, Path:/$metadata/scheduler/failures/" + command + "/ResultData]]"); } string[] expectedArray = expected.ToArray(); ev.AssertOccursInOrder( "Timeout (10s) waiting for scheduler to close command as failed", false, TimeSpan.FromSeconds(10), expectedArray); }
private void OutputDataReceived(object sender, DataReceivedEventArgs e) { if (OnTestProgress != null && e != null && String.IsNullOrEmpty(e.Data) == false) { TestEvents.ProcessProgress(e.Data, OnTestProgress); } }
private void OnProgress(string cmdId, string args) { if (String.IsNullOrEmpty(args)) { return; } String[] vals = Regex.Split(args, ";"); if (vals == null || vals.Length != 3) { return; } try { CollectPageInformation collectType = (CollectPageInformation)Enum.ToObject(typeof(CollectPageInformation), int.Parse(vals[0])); int prg = int.Parse(vals[1]); int tot = int.Parse(vals[2]); if ((collectType & CollectPageInformation.Screenshots_Small) == CollectPageInformation.Screenshots_Small || (collectType & CollectPageInformation.Screenshots_Full) == CollectPageInformation.Screenshots_Full) { TestEvents.FireProgressEvent(TestEventType.CapturingSegment, prg, tot, null); } else { TestEvents.FireProgressEvent(TestEventType.RenderingSegment, prg, tot, null); } } catch { } }
private void VerifyCreated(TestEvents ev, TimeSpan timeout, string path) { ev.AssertOccursInOrder( "Timeout (10s) waiting for path to be created", false, TimeSpan.FromSeconds(10), "<contains>Request[Type:Create, Path:" + path + "]"); }
private void VerifySetup(TestEvents ev, TimeSpan timeout) { ev.AssertOccursInOrder( "Timeout (10s) waiting for scheduler to learn about baseline commands", false, TimeSpan.FromSeconds(10), "Request[Type:Create, Path:/$metadata/scheduler/commands]", "Request[Type:Create, Path:/$metadata/scheduler/failures]", "Request[Type:GetChildren, Path:/$metadata/scheduler/commands]"); }
public ActionResult About() { TestEvents events = new TestEvents() { Message = "this is my first events" }; EventBus.Publish(events); return(Content("")); }
private void VerifyCommandTaken(TestEvents ev, TimeSpan timeout, string command) { ev.AssertOccursInOrder( "Timeout (10s) waiting for scheduler to collect data for the new command", false, timeout, "Request[Type:Create, Path:/$metadata/scheduler/commands]", "Request[Type:Create, Path:/$metadata/scheduler/failures]", "Request[Type:Create, Path:/$metadata/scheduler/inflight]", "Request[Type:GetChildren, Path:/$metadata/scheduler/commands]", "<contains>Request[Type:Create, Path:/$metadata/scheduler/commands/" + command + "]", "WatchedEvent[Class:WatchedEvent,Path=/$metadata/scheduler/commands,EventType=NodeChildrenChanged,KeeperState=SyncConnected]", "Request[Type:GetChildren, Path:/$metadata/scheduler/commands]", "Request[Type:GetData, Path:/$metadata/scheduler/commands/" + command + "]", "<contains>Request[Type:Move, Path:/$metadata/scheduler/commands/" + command + ", PathDst:/$metadata/scheduler/"); }
public override void SendData(byte[] buffer, int offset, int length) { if (isRequest && this.PipesChain.ChainState.ContainsKey(STATE_KEY) == false && this.PipesChain.ChainState.ContainsKey("REQUEST_URI")) { HttpTransaction httpTranc = new HttpTransaction(); httpTranc.URL = (String)this.PipesChain.ChainState["REQUEST_URI"]; httpTranc.Mode = HttpMode.SendingRequest; httpTranc.ConnectionStartTime = DateTime.Now; httpTranc.SendingRequestStartTime = DateTime.Now; httpTranc.TotalSent = length; TestEvents.FireProgressEvent(TestEventType.RequestingFile, httpTranc.URL); TestEvents.FireProgressEvent(TestEventType.SendingData, length, 0, httpTranc.URL); this.PipesChain.ChainState.Add(STATE_KEY, httpTranc); AddRequestToTracker(httpTranc); } else if (isRequest) { HttpTransaction httpTranc = (HttpTransaction)this.PipesChain.ChainState[STATE_KEY]; httpTranc.TotalSent += length; TestEvents.FireProgressEvent(TestEventType.SendingData, length, 0, httpTranc.URL); } else if (isRequest == false && this.PipesChain.ChainState.ContainsKey(STATE_KEY)) { HttpTransaction httpTranc = (HttpTransaction)this.PipesChain.ChainState[STATE_KEY]; if (httpTranc.Mode == HttpMode.WaitingForResponse) { httpTranc.Mode = HttpMode.ReceivingResponse; httpTranc.ReceivingResponseStartTime = DateTime.Now; } httpTranc.TotalReceived += length; TestEvents.FireProgressEvent(TestEventType.ReceivingData, length, 0, httpTranc.URL); } base.SendData(buffer, offset, length); }
public override void Flush() { if (this.PipesChain.ChainState.ContainsKey(STATE_KEY)) { HttpTransaction httpTranc = (HttpTransaction)this.PipesChain.ChainState[STATE_KEY]; if (isRequest) { httpTranc.Mode = HttpMode.WaitingForResponse; httpTranc.SendingRequestEndTime = DateTime.Now; } else { TestEvents.FireProgressEvent(TestEventType.ResponseEnded, httpTranc.URL); httpTranc.Mode = HttpMode.Completed; httpTranc.ReceivingResponseEndTime = DateTime.Now; httpTranc.ConnectionEndTime = DateTime.Now; } } base.Flush(); }
static void Main(string[] args) { commandArgs = args; AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); PageDataCollectorStartInfo pdcsi = new PageDataCollectorStartInfo(args); if (pdcsi.IsValid() == false) { PageDataCollectorStartInfo.PrintUsage(System.Console.Error); System.Environment.ExitCode = (int)(PageDataCollectorErrors.InvalidOrMissingArguments); } else { TestEvents.IsVerbose = pdcsi.IsVerbose; TestEvents.FireProgressEvent(TestEventType.TestStarted); pdcsi.IsDebug = true; _Collector c = new _Collector(pdcsi); try { System.Environment.ExitCode = c.Run(); } catch { System.Environment.ExitCode = (int)PageDataCollectorErrors.Unknown; } finally { c.Release(); } TestEvents.FireProgressEvent(TestEventType.TestEnded); } }
public TestMarshaller(TestEvents ev) { this.ev = ev; }
public TestRingMaster(TestEvents ev, TestMarshaller marshaller) : base(string.Empty, 10, null) { this.ev = ev; this.marshaller = marshaller; }
// [TestMethod] public void ValidateScheduler() { bool ok = false; TestEvents ev = new TestEvents(); TestMarshaller marshaller = new TestMarshaller(ev); TestRingMaster testRM = new TestRingMaster(ev, marshaller); ScheduledCommand scheduler = null; try { foreach (string path in ScheduledCommand.GetPaths()) { testRM.Create(path, null, null, CreateMode.PersistentAllowPathCreation); } scheduler = new ScheduledCommand(() => { return(testRM.IsPrimary); }, testRM, marshaller); scheduler.InternalOnAbandon = new Action <Exception>(ex => { Assert.Fail("Scheduler Abandoned: " + ex); }); scheduler.Start(); this.VerifySetup(ev, TimeSpan.FromSeconds(15)); string res = testRM.Create("/$metadata/scheduler/commands/c1", null, null, CreateMode.Persistent); this.VerifyCommandTaken(ev, TimeSpan.FromSeconds(10), "c1"); this.VerifyCommandFailed(ev, TimeSpan.FromSeconds(10), "c1"); List <Op> ops = new List <Op>(); ops.Add(Op.Create("/$metadata/scheduler/commands/c2", null, null, CreateMode.Persistent)); ops.Add(Op.Create("/$metadata/scheduler/commands/c4", null, null, CreateMode.Persistent)); ops.Add(Op.Create("/$metadata/scheduler/commands/c3", null, null, CreateMode.Persistent)); IReadOnlyList <OpResult> resL = testRM.Multi(ops.AsReadOnly(), completeSynchronously: true, scheduledName: null); this.VerifyCommandTaken(ev, TimeSpan.FromSeconds(10), "c2"); this.VerifyCommandTaken(ev, TimeSpan.FromSeconds(10), "c3"); this.VerifyCommandTaken(ev, TimeSpan.FromSeconds(10), "c4"); this.VerifyCommandFailed(ev, TimeSpan.FromSeconds(10), "c2", "c3", "c4"); ops.Clear(); ops.Add(Op.Create("/test1", null, null, CreateMode.Persistent)); resL = testRM.Multi(ops.AsReadOnly(), completeSynchronously: true, scheduledName: "c5"); this.VerifyCommandTaken(ev, TimeSpan.FromSeconds(10), "c5"); this.VerifyCommandSucceeded(ev, TimeSpan.FromSeconds(10), "c5"); this.VerifyCreated(ev, TimeSpan.FromSeconds(10), "/test1"); Assert.IsTrue(testRM.Exists("/test1", false, false) != null); Assert.IsTrue(testRM.Exists("/$metadata/scheduler/commands/c5", false, false) == null); ok = true; } finally { if (!ok) { testRM.DumpNodes(); } ThreadPool.QueueUserWorkItem(_ => { if (scheduler != null) { scheduler.Close(); } testRM.Close(); }); } }
public Task HandleEventAsync(TestEvent e) { TestEvents.Add(e); return(Task.CompletedTask); }