internal override bool NotifyTraces(ActualTrace instanceTraces) { bool foundTrace = false; foreach (IActualTraceStep step in instanceTraces.Steps) { if (step.Equals(this.traceStep)) { foundTrace = true; _successfulTraceStep = this.traceStep; } else if (step.Equals(_otherTraceStep)) { foundTrace = true; _successfulTraceStep = _otherTraceStep; } if (foundTrace) { this.manualResetEvent.Set(); break; } } return(foundTrace); }
private bool TrackActivityStateRecord(ActivityStateRecord activityRecord, ActualTrace _trace) { TestTraceManager.OptionalLogTrace("[InMemoryTrackingParticipant]activityRecord.Name = {0}", activityRecord.Activity.Name); ActivityTrace activityTrace = new ActivityTrace( activityRecord.Activity.Name, (ActivityInstanceState)Enum.Parse(typeof(ActivityInstanceState), activityRecord.State), activityRecord); //to avoid the confusion b\w Executing & scheduling events, we always use scheduled if (activityTrace.ActivityStatus != ActivityInstanceState.Executing) { _trace.Add(activityTrace); return(true); } //for tracking test cases, it may be the scenario that the profile does not have a scheduled record. //in that scenario, we need to add that explicitly to the trace. if (TestTraceManager.IsDefaultTrackingConfiguration == false)//is a tracking test case { if ( (_trace.Steps.Count == 0) || ( (_trace.Steps.Count != 0) && (_trace.Steps[_trace.Steps.Count - 1].Equals(activityTrace) == false) ) ) { _trace.Add(activityTrace); return(true); } } return(false); }
private void CheckSubscriptions(Guid instanceId, ActualTrace instanceTraces) { lock (_thisLock) { List <Subscription> workflowInstanceSubscriptions = null; if (_allSubscriptions.TryGetValue(instanceId, out workflowInstanceSubscriptions)) { List <Subscription> subscriptionsPendingRemoval = new List <Subscription>(); foreach (Subscription subscription in workflowInstanceSubscriptions) { if (subscription.NotifyTraces(instanceTraces)) { subscriptionsPendingRemoval.Add(subscription); } } foreach (Subscription subscription in subscriptionsPendingRemoval) { workflowInstanceSubscriptions.Remove(subscription); } if (workflowInstanceSubscriptions.Count == 0) { _allSubscriptions.Remove(instanceId); } } } }
public static void ValidateWorkflow(Guid workflowInstanceId, TestActivity testWorkflowDefinition) { ActualTrace actualTrace = TestTraceManager.Instance.GetInstanceActualTrace(workflowInstanceId); ExpectedTrace expectedTrace = testWorkflowDefinition.GetExpectedTrace(); actualTrace.Validate(testWorkflowDefinition.GetExpectedTrace()); }
public static void ValidateTracking(ExpectedTrace expectedTrace, ActualTrace actualTrace, TrackingProfile profile, TestProfileType profileType, TrackingParticipantType participantType) { //1. Filter the expected trace against the workFlow profile ExpectedTrace filteredExpectedTrace = TrackingFilter.ApplyTrackingProfile(expectedTrace, profile); ////2. Delete not supported trace steps by testObjects. ActualTrace modifiedActualTrace = TrackingFilter.DeleteNotSupportedTraceSteps(actualTrace); TestTraceManager.OptionalLogTrace("[TestTrackingDataManager]*****ValidateTracking()"); ////3. Validate the expected & the actual trace TestTraceManager.OptionalLogTrace("[TestTrackingDataManager]Profile = {0}", profile); TestTraceManager.OptionalLogTrace("[TestTrackingDataManager]Actual Trace = {0}", actualTrace); TestTraceManager.OptionalLogTrace("[TestTrackingDataManager]Expected Trace = {0}", expectedTrace); TestTraceManager.OptionalLogTrace("[TestTrackingDataManager]Filtered Expected Trace (after applying tracking profile) = {0}", filteredExpectedTrace); TestTraceManager.OptionalLogTrace("[TestTrackingDataManager]Modified ActualTrace Trace = {0}", modifiedActualTrace); TestTraceManager.OptionalLogTrace("[TestTrackingDataManager]Invoking internally the trace validation..."); ////if (!(TestProfileProvider.IsAllOrNullProfile(profileType) && if (((participantType != TrackingParticipantType.SqlTrackingParticipant) && (participantType != TrackingParticipantType.ETWTrackingParticipant))) { modifiedActualTrace.Validate(filteredExpectedTrace, TestTraceManager.IsDefaultTrackingConfiguration); } //Log.TraceInternal("[TestTrackingDataManager]*****Validate method Succeeded..."); }
internal override bool NotifyTraces(ActualTrace instanceTraces) { // Dont want to modify the original numOccurances int countCopy = _numOccurences; foreach (IActualTraceStep step in instanceTraces.Steps) { if (step is WorkflowAbortedTrace) { countCopy--; // if this aborted is the last trace, we wont have a deleted if (_waitingForDeleted && countCopy == 1) { countCopy--; } if (_expectedFinalState != WorkflowInstanceState.Aborted) { _error = string.Format("While waiting for a {0} trace, received an aborted trace - {1}", _expectedFinalState, ActualTracesAsString()); } } else if (step is WorkflowInstanceTrace) { WorkflowInstanceTrace wit = (WorkflowInstanceTrace)step; if (wit.InstanceStatus == WorkflowInstanceState.Deleted) { countCopy--; // Deleted trace will always be last, if its not then this will hang, so instead complete it and throw exception if (countCopy > 0) { _error = string.Format("Received deleted trace, before the expected number of {0} - {1}.", _expectedFinalState, ActualTracesAsString()); countCopy = 0; } } else if (wit.InstanceStatus == WorkflowInstanceState.Completed || wit.InstanceStatus == WorkflowInstanceState.Canceled || wit.InstanceStatus == WorkflowInstanceState.Terminated) { // reset error countCopy--; _error = (wit.InstanceStatus == _expectedFinalState) ? null : string.Format("While waiting for a {0} trace, received another terminal trace, {1} - {2}.", _expectedFinalState.ToString(), wit.InstanceStatus.ToString(), ActualTracesAsString()); } } } bool success = countCopy <= 0; if (success) { this.manualResetEvent.Set(); } return(success); }
private string ActualTracesAsString() { string concatenatedSteps = string.Format("InstanceID {0} traces: ", _instanceId.ToString()); ActualTrace actualTrace = TestTraceManager.Instance.GetInstanceActualTrace(_instanceId); foreach (IActualTraceStep step in actualTrace.Steps) { concatenatedSteps = concatenatedSteps + "; " + step.ToString(); } return(concatenatedSteps); }
private void TrackCancelRequestedRecord(CancelRequestedRecord cancelRecord, ActualTrace _trace) { TestTraceManager.OptionalLogTrace("[InMemoryTrackingParticipant]cancelRequestedRecord.TargetName = {0}", cancelRecord.Child.Name); //this gets propogated twice by the product: ActivityStates.Fault information. { // WFCore - AT LEAST the DoWhile test cases that Cancel were failing because of these "extra" // Activity Canceled records in the trace. It's not clear if this is the right thing to do. //_trace.Add(new ActivityTrace( // cancelRecord.Child.Name, // (ActivityInstanceState)Enum.Parse(typeof(ActivityInstanceState), ActivityStates.Canceled))); } }
public ActualTrace GetInstanceActualTrace(Guid instanceId) { lock (_thisLock) { if (!_allTraces.TryGetValue(instanceId, out ActualTrace instanceTraces)) { instanceTraces = new ActualTrace(); _allTraces.Add(instanceId, instanceTraces); } return(instanceTraces); } }
private void TrackFaultPropagationRecord(FaultPropagationRecord faultRecord, ActualTrace _trace) { string faultName = (faultRecord.FaultHandler == null) ? "<Unknown>" : faultRecord.FaultHandler.Name; TestTraceManager.OptionalLogTrace("[InMemoryTrackingParticipant]faultPropatationRecord.TargetName = {0}", faultName); //string status = "Faulted"; // There is no Property called State in FaultPropagationRecord. Need to understand Fault propagation here //this gets propogated twice by the product: ActivityStates.Fault information. //if (faultRecord.State == ActivityStates.Schedule) //{ // _trace.Add(new ActivityTrace( // faultName, // (ActivityInstanceState)Enum.Parse(typeof(ActivityInstanceState), status))); //} }
public void AddTrace(Guid instanceId, IActualTraceStep trace) { if (trace == null) { throw new ArgumentNullException("trace"); } //Log.TraceInternal("[TestTraceManager] " + instanceId + " - " + trace.ToString()); lock (_thisLock) { ActualTrace instanceTraces = GetInstanceActualTrace(instanceId); instanceTraces.Add(trace); CheckSubscriptions(instanceId, instanceTraces); } }
protected override void Track(TrackingRecord record, TimeSpan timeout) { try { TestTraceManager.OptionalLogTrace("[InMemoryTrackingParticipant]Track()::InMemory tracking participant = {0} ; Tracking record type = {1} ; Record Details = {2}", this.Name, record.GetType(), record.ToString()); TestTraceManager.OptionalLogTrace("[InMemoryTrackingParticipant]TestTraceManager.IsDefaultTrackingConfiguration = {0}", TestTraceManager.IsDefaultTrackingConfiguration.ToString()); bool IsPushDataToTraceManager = true; ActualTrace _trace = this.GetActualTrackingData(record.InstanceId); if (record is WorkflowInstanceRecord) { TrackWorkflowInstanceRecord(record as WorkflowInstanceRecord, _trace); } else if (record is ActivityStateRecord) { IsPushDataToTraceManager = TrackActivityStateRecord(record as ActivityStateRecord, _trace); } else if (record is ActivityScheduledRecord) { TrackActivityScheduledRecord(record as ActivityScheduledRecord, _trace); } else if (record is BookmarkResumptionRecord) { TrackBookmarkResumptionRecord(record as BookmarkResumptionRecord, _trace); } else if (record is CancelRequestedRecord) { TrackCancelRequestedRecord(record as CancelRequestedRecord, _trace); } else if (record is FaultPropagationRecord) { TrackFaultPropagationRecord(record as FaultPropagationRecord, _trace); } if (IsPushDataToTraceManager) { PushDataToTraceManager(record); } } //This exception will be eaten by the product tracking code and not available for review //So the only chance we have to see it is if we log it. catch (Exception e) { //Log.WarnInternal("Exception thrown in Track() method\n" + e.ToString()); throw; } }
internal void ValidateTraces(ExpectedTrace expectedTrace, ActualTrace actualTrace) { //If no tracking participant tracks all events tracign validation will fail since it doesn't accoutn for the tracking profiles. //This is true ONLY for some trakcing test cases & not for runtime test cases which run with all tracking turned Off. //Hence we will not to tracing validation in this case & only do the tracking validation. //if (!TestTrackingDataManager.DoesAnyProfileTrackAllEvents(TestConfiguration.Current.TrackingServiceConfigurations)) //{ // Log.TraceInternal("[TestTracingWatcher]No tracking participant tracks all events. Hece skipp tracing verification"); // return; //} foreach (TraceFilter filter in expectedTrace.Filters) { expectedTrace = filter.FilterExpectedTrace(expectedTrace); actualTrace = filter.FilterActualTrace(actualTrace); } actualTrace.Validate(expectedTrace); }
public Exception GetUnhandledException() { ActualTrace actualTrace = GetActualTrace(); // Can shortcut in the workflowruntime case if (!IsHosted && _remoteworkflowRuntime.LastException != null) { return(_remoteworkflowRuntime.LastException); } foreach (IActualTraceStep traceStep in actualTrace.Steps) { if (traceStep is WorkflowExceptionTrace) { return(((WorkflowExceptionTrace)traceStep).InstanceException); } } return(null); }
//for workflow tracking records not yet supported by testObjects. public static ActualTrace DeleteNotSupportedTraceSteps(ActualTrace actualTrace) { ActualTrace modifiedTrace = new ActualTrace(actualTrace); List <IActualTraceStep> stepsToBeRemoved = new List <IActualTraceStep>(); foreach (IActualTraceStep actualTraceStep in modifiedTrace.Steps) { if (actualTraceStep is WorkflowInstanceTrace || actualTraceStep is BookmarkResumptionTrace) { stepsToBeRemoved.Add(actualTraceStep); } } foreach (IActualTraceStep traceStepToBeRemoved in stepsToBeRemoved) { modifiedTrace.Steps.Remove(traceStepToBeRemoved); } return(modifiedTrace); }
internal virtual bool NotifyTraces(ActualTrace instanceTraces) { bool removeSubscription = false; int currentCount = this.count; foreach (IActualTraceStep step in instanceTraces.Steps) { if (step.Equals(this.traceStep)) { currentCount--; } if (currentCount == 0) { removeSubscription = true; this.manualResetEvent.Set(); break; } } return(removeSubscription); }
public Exception GetAbortedReason() { ActualTrace actualTrace = GetActualTrace(); // Can shortcut in the workflowruntime case if (!IsHosted && _remoteworkflowRuntime.LastException != null) { return(_remoteworkflowRuntime.LastException); } //With unhandled exceptions, the workflow running in standalone is aborted with AbortedTrace and it having the right exception message //But when hosted as a service, it gets the aborted trace with a generic system.exception message. //To make HostWFAsService compatible with WFRuntime, we should check for the WorkflowExceptionTrace instead of WorkflowAbortedTrace. foreach (IActualTraceStep traceStep in actualTrace.Steps) { if (traceStep is WorkflowAbortedTrace) { return(((WorkflowAbortedTrace)traceStep).AbortedReason); } } return(null); }
private void TrackWorkflowInstanceRecord(WorkflowInstanceRecord workflowInstanceRecord, ActualTrace _trace) { WorkflowInstanceState workflowInstanceState = (WorkflowInstanceState)Enum.Parse(typeof(WorkflowInstanceState), workflowInstanceRecord.State); WorkflowInstanceTrace workflowInstanceTrace = new WorkflowInstanceTrace(workflowInstanceRecord.InstanceId, workflowInstanceRecord.WorkflowDefinitionIdentity, workflowInstanceState); _trace.Add(workflowInstanceTrace); }
private void TrackBookmarkResumptionRecord(BookmarkResumptionRecord bookmarkResumptionRecord, ActualTrace _trace) { TestTraceManager.OptionalLogTrace("[InMemoryTrackingParticipant]BookmarkName = {0}, bookmarkResumptionRecord = {1} ", bookmarkResumptionRecord.BookmarkName, bookmarkResumptionRecord.ToString()); _trace.Add(new BookmarkResumptionTrace( bookmarkResumptionRecord.BookmarkName, bookmarkResumptionRecord.BookmarkScope, bookmarkResumptionRecord.Owner.Name)); //_trace.Add(new ActivityTrace(bookmarkResumptionRecord.ToString(), // ActivityInstanceState.Executing)); }
private void TrackActivityScheduledRecord(ActivityScheduledRecord activityScheduledRecord, ActualTrace _trace) { //the scheduling record simply states that i am scheduled blah. Currently we do not have any support in TO for this. //Hence, turning it off for now. we will have the tracking tests cover the validation. TestTraceManager.OptionalLogTrace("[InMemoryTrackingParticipant]activityScheduledRecord.TargetName = {0}", activityScheduledRecord.Child.Name); _trace.Add(new ActivityTrace(activityScheduledRecord.Child.Name, ActivityInstanceState.Executing, activityScheduledRecord)); }