Exemple #1
0
        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...");
        }
Exemple #2
0
        private static ExpectedTrace RemovePlaceholderTrace(ExpectedTrace expectedTrace)
        {
            ExpectedTrace modifiedTrace = new ExpectedTrace(expectedTrace);
            int           count         = modifiedTrace.Trace.Steps.Count;

            for (int i = 0; i < count; i++)
            {
                WorkflowTraceStep workflowTraceStep = expectedTrace.Trace.Steps[i];
                if (workflowTraceStep is IPlaceholderTraceProvider)
                {
                    modifiedTrace.Trace.Steps[i] = ((IPlaceholderTraceProvider)workflowTraceStep).GetPlaceholderTrace();
                    continue;
                }
                else if (workflowTraceStep is TraceGroup)
                {
                    ExpectedTrace tempExpectedTrace = new ExpectedTrace
                    {
                        Trace = TraceGroup.GetNewTraceGroup((TraceGroup)workflowTraceStep)
                    };

                    modifiedTrace.Trace.Steps.RemoveAt(i);

                    ExpectedTrace cleanedUpExpectedTrace = TrackingFilter.RemovePlaceholderTrace(tempExpectedTrace);

                    //add only if it is non-empty
                    modifiedTrace.Trace.Steps.Insert(i, cleanedUpExpectedTrace.Trace);
                }
            }
            return(modifiedTrace);
        }
Exemple #3
0
        private static bool ShouldTrackStep(this TrackingProfile profile, WorkflowTraceStep workflowTraceStep)
        {
            if (workflowTraceStep is TraceGroup)
            {
                // Don't filter out a nested TraceGroup.
                return(true);
            }

            ActivityTrace activityTrace = workflowTraceStep as ActivityTrace;

            if (activityTrace != null)
            {
                //check the activity track queries
                foreach (ActivityStateQuery activityQuery in profile.Queries.OfType <ActivityStateQuery>())
                {
                    //either all activities are tracked or only this specific one.
                    if (TrackingFilter.IsActivityLocationTracked(activityQuery, activityTrace.ActivityName, activityTrace.ActivityStatus))
                    {
                        return(true);
                    }
                }

                //check the ActivityScheduledQuery
                foreach (ActivityScheduledQuery activityScheduledQuery in profile.Queries.OfType <ActivityScheduledQuery>())
                {
                    //either all activities are tracked or only this specific one.
                    if (TrackingFilter.IsActivityScheduledTracked(activityScheduledQuery, activityTrace.ActivityName))
                    {
                        return(true);
                    }
                }
            }

            WorkflowInstanceTrace workflowInstanceTrace = workflowTraceStep as WorkflowInstanceTrace;

            if (workflowInstanceTrace != null)
            {
                foreach (WorkflowInstanceQuery workflowInstanceTrackingQuery in profile.Queries.OfType <WorkflowInstanceQuery>())
                {
                    if (workflowInstanceTrackingQuery.States.Contains(workflowInstanceTrace.InstanceStatus.ToString()))
                    {
                        return(true);
                    }
                }
            }

            UserTrace userTrace = workflowTraceStep as UserTrace;

            if (userTrace != null)
            {
                //presently we (trackign team) do not track any userTrace values through profile om.
                return(true);
            }
            return(false);
        }
Exemple #4
0
        private static ExpectedTrace RemoveUserTrace(ExpectedTrace expectedTrace)
        {
            ExpectedTrace modifiedTrace = new ExpectedTrace(expectedTrace);
            int           count         = modifiedTrace.Trace.Steps.Count;
            int           removedCount  = 0;

            for (int i = 0; i < count; i++)
            {
                WorkflowTraceStep workflowTraceStep = expectedTrace.Trace.Steps[i];
                if (workflowTraceStep is UserTrace)
                {
                    modifiedTrace.Trace.Steps.Remove(workflowTraceStep);
                    removedCount++;
                    continue;
                }
                else if (workflowTraceStep is TraceGroup)
                {
                    ExpectedTrace tempExpectedTrace = new ExpectedTrace
                    {
                        Trace = TraceGroup.GetNewTraceGroup((TraceGroup)workflowTraceStep)
                    };
                    //take into account for activities already removed.
                    modifiedTrace.Trace.Steps.RemoveAt(i - removedCount);

                    ExpectedTrace cleanedUpExpectedTrace = TrackingFilter.RemoveUserTrace(tempExpectedTrace);

                    //add only if it is non-empty
                    if ((cleanedUpExpectedTrace != null) &&
                        (cleanedUpExpectedTrace.Trace != null) &&
                        (cleanedUpExpectedTrace.Trace.Steps != null) &&
                        (cleanedUpExpectedTrace.Trace.Steps.Count != 0)
                        )
                    {
                        modifiedTrace.Trace.Steps.Insert(i - removedCount, cleanedUpExpectedTrace.Trace);
                    }
                    else
                    {
                        removedCount++;
                    }
                }
            }
            return(modifiedTrace);
        }
Exemple #5
0
        public static ExpectedTrace ApplyTrackingProfile(ExpectedTrace expectedTrace, TrackingProfile profile)
        {
            ExpectedTrace modifiedTrace = TrackingFilter.RemovePlaceholderTrace(expectedTrace);

            modifiedTrace = TrackingFilter.RemoveUserTrace(modifiedTrace);
            TestTraceManager.OptionalLogTrace("[TrackingFilter]After Remove UserTrace, modifiedTrace = {0}", modifiedTrace);
            modifiedTrace = TrackingFilter.NormalizeTrace(modifiedTrace);
            TestTraceManager.OptionalLogTrace("[TrackingFilter]After NormalizeTrace, modifiedTrace = {0}", modifiedTrace);
            //vc temp only till we figure out the user record story for M2.
            if (profile == null)//all events to be returned
            {
                return(modifiedTrace);
            }

            int count = modifiedTrace.Trace.Steps.Count;

            for (int i = 0; i < count; i++)
            {
                WorkflowTraceStep workflowTraceStep = modifiedTrace.Trace.Steps[i];

                // Check if this is a faulted state.
                // When we have a faulted state the preceding executing state should be deleted.

                TrackingConfiguration currentTrackingConfiguration = GetCurrentTP(profile.Name);
                bool isExecutingRecExpectedOnFaultedState          = true;
                if (!isExecutingRecExpectedOnFaultedState)
                {
                    ActivityTrace activityTrace = (ActivityTrace)workflowTraceStep;
                    if ((i > 0) && (activityTrace.ActivityStatus == ActivityInstanceState.Faulted))
                    {
                        ActivityTrace precedingActivityTrace = (ActivityTrace)modifiedTrace.Trace.Steps[i - 1];
                        if (precedingActivityTrace.ActivityStatus == ActivityInstanceState.Executing)
                        {
                            bool trackScheduledQuery = false;

                            foreach (ActivityScheduledQuery activityScheduledQuery in profile.Queries.OfType <ActivityScheduledQuery>())
                            {
                                if (IsActivityScheduledTracked(activityScheduledQuery, precedingActivityTrace.ActivityName))
                                {
                                    trackScheduledQuery = true;
                                }
                            }

                            // If we don't track the scheduled records delete the preceding executing state record.
                            // The preceding executing state is from scheduled record.
                            if (!trackScheduledQuery)
                            {
                                modifiedTrace.Trace.Steps.RemoveAt(i - 1);
                                i--;
                                count = modifiedTrace.Trace.Steps.Count;
                                //Log.TraceInternal("[TrackingFilter]Preceding executing activity trace deleted because the current expected trace state is Faulted.");
                            }
                        }
                    }
                }

                if (!profile.ShouldTrackStep(workflowTraceStep))
                {
                    modifiedTrace.Trace.Steps.RemoveAt(i);
                    count = modifiedTrace.Trace.Steps.Count;
                    //continue at the same step
                    i--;
                    //Log.TraceInternal("[TrackingFilter]Removed event = {0}=", workflowTraceStep);
                }
            }

            return(modifiedTrace);
        }