Exemplo n.º 1
0
        public ActualTrace GetActualTrackingData(string trackingParticipantName)
        {
            if (_trackingParticipants == null || _trackingParticipants.Count() == 0)
            {
                return(new ActualTrace());
            }

            TrackingParticipant         trackingParticipant     = _trackingParticipants[trackingParticipantName];
            TestTrackingParticipantBase testTrackingParticipant = trackingParticipant as TestTrackingParticipantBase;

            if (testTrackingParticipant != null)
            {
                return(testTrackingParticipant.GetActualTrackingData(_workflowId));
            }
            else
            {
                //for sql tracking participant.
                return(null);
            }
        }
        internal void ValidateTracking(ExpectedTrace expectedTrace)
        {
            // Sort before
            if (expectedTrace.SortBeforeVerification)
            {
                //Log.TraceInternal("[TestTracingWatcher] Sort before verification is enabled, tracking will go into an infinite loop, so skipping.");
                return;
            }

            ActualTrace actualTrace;

            //TestTrackingDataManager.ValidateTracking(expectedTrace, actualTrace, profile, trackingConfig.TestProfileType, trackingConfig.TrackingParticipantType);

            //expected trace needs to be validated with each of the trackign services that are currently enabled.
            //Initial Design: Moved the common validation to the base method to avoid redundant code. Validation still
            //in the tracking service so as to take into account the scneario for profile versioning when
            //the validation is tricky due to multipel profiles & the particular service may need finer control
            //for that particular workflow id.
            //Final Design: Moved it from the TrackingParticipant since we need validation to work fine even if say
            //for Partial trust.
            foreach (TrackingConfiguration trackingConfig in _remoteworkflowRuntime.TrackingConfigurations)
            {
                TestTraceManager.OptionalLogTrace("[TestTracingWatcher]******Tracking validation for {0}", trackingConfig.TrackingParticipantName);

                //1. get the profile for the workFlow
                //note profiles are not seralizable. Hence you need ot get it from a local instance. (in account for the web-hosted scenario)
                TestTrackingParticipantBase trackingParticipant = TestTrackingParticipantBase.GetInstanceForVerification(trackingConfig.TrackingParticipantType);
                TrackingProfile             profile             = TestProfileProvider.GetTrackingProfile(trackingParticipant, trackingConfig);

                // Assign tracking participant name to new profile name because this will be used to find out
                // the current tracking configuration in TrackingFilter.
                if (profile != null)
                {
                    profile.Name = trackingConfig.TrackingParticipantName;
                }

                switch (trackingConfig.TrackingParticipantType)
                {
                case TrackingParticipantType.SqlTrackingParticipant:
                    SqlTrackingConfiguration sqlTrackingConfiguration = trackingConfig as SqlTrackingConfiguration;
                    if (sqlTrackingConfiguration != null)
                    {
                        trackingParticipant.PushToTrackingDataManager = sqlTrackingConfiguration.PushToTrackingDataManager;
                    }
                    actualTrace = trackingParticipant.GetActualTrackingData(_workflowInstanceId);

                    for (int i = profile.Queries.Count - 1; i >= 0; i--)
                    {
                        Type queryType = profile.Queries[i].GetType();
                        if (queryType == typeof(ActivityScheduledQuery))
                        {
                            profile.Queries.RemoveAt(i);
                        }
                    }
                    break;

                default:
                    actualTrace = _remoteworkflowRuntime.ActualTrackingData(trackingConfig.TrackingParticipantName);
                    break;
                }

                //3. validate
                TestTrackingDataManager.ValidateTracking(expectedTrace, actualTrace, profile, trackingConfig.TestProfileType, trackingConfig.TrackingParticipantType);
            }
        }