示例#1
0
        public void InstantiateTrackingParticipants(IEnumerable <TrackingConfiguration> config)
        {
            _trackingParticipants = new Dictionary <string, TrackingParticipant>();
            bool isTrackingParticipantSelected = false;
            int  numberOfTrackingParticipants  = config.Count();

            foreach (TrackingConfiguration trackingConfig in config)
            {
                TestTraceManager.OptionalLogTrace("[TestTrackingDataManager]Adding tracking participant TrackingParticipantType = {0}, ProfileManagerType = {1}, TestProfileType = {2}",
                                                  trackingConfig.TrackingParticipantType,
                                                  trackingConfig.ProfileManagerType,
                                                  trackingConfig.TestProfileType);
                switch (trackingConfig.TrackingParticipantType)
                {
                //case TrackingParticipantType.SqlTrackingParticipant:
                //    //Sql works against the product & only for the default config profile provider
                //    SqlTrackingParticipant sqlTrackingParticipant = (SqlTrackingParticipant)TestTrackingParticipantBase.GetInstance(trackingConfig.TrackingParticipantType, ParticipantAssociation.WorkflowExtention);
                //    SqlTrackingConfiguration sqlTrackingConfig = trackingConfig as SqlTrackingConfiguration;
                //    //sqlTrackingParticipant.TrackingProfile = TestProfileProvider.GetTrackingProfile(sqlTrackingConfig.ProfileName);
                //    //Log.TraceInternal("[TestTrackingDataManager]sqlTrackingParticipant.TrackingProfile =" + sqlTrackingParticipant.TrackingProfile);

                //    sqlTrackingParticipant.ParticipateInProcessTransaction = sqlTrackingConfig.IsTransactional;
                //    sqlTrackingParticipant.ConnectionString = sqlTrackingConfig.ConnectionString;
                //    this.trackingParticipants.Add(trackingConfig.TrackingParticipantName, sqlTrackingParticipant);
                //    if (!isTrackingParticipantSelected)
                //    {
                //        //Log.TraceInternal("[TestTrackingDataManager]Test profile type = {0}, TestProfileProvider.IsAllOrNullProfile(trackingConfig.TestProfileType) = {1}", trackingConfig.TestProfileType, TestProfileProvider.IsAllOrNullProfile(trackingConfig.TestProfileType));
                //        //if (TestProfileProvider.IsAllOrNullProfile(trackingConfig.TestProfileType) || (numberOfTrackingParticipants == 1))
                //        //{
                //        //    isTrackingParticipantSelected = true;
                //        //    sqlTrackingConfig.PushToTrackingDataManager = true;
                //        //}
                //    }
                //    //Log.TraceInternal("[TestTrackingDataManager]Added PRODUCT SqlTrackingParticipant with: ProfileName={0}, isTransactional={1}, ConnectionString={2}",
                //    //    sqlTrackingParticipant.TrackingProfile.Name,
                //    //    sqlTrackingParticipant.ParticipateInProcessTransaction.ToString(),
                //    //    sqlTrackingParticipant.ConnectionString);
                //    break;
                case TrackingParticipantType.InMemoryTrackingParticipant:
                    InMemoryTrackingParticipant memoryTrackingParticipant = (InMemoryTrackingParticipant)TestTrackingParticipantBase.GetInstance(trackingConfig.TrackingParticipantType, ParticipantAssociation.WorkflowExtention);
                    memoryTrackingParticipant.PushToTrackingDataManager = true;
                    _trackingParticipants.Add(trackingConfig.TrackingParticipantName, memoryTrackingParticipant);
                    break;

                default:
                    TestTrackingParticipantBase trackingParticipant = (TestTrackingParticipantBase)TestTrackingParticipantBase.GetInstance(trackingConfig.TrackingParticipantType, ParticipantAssociation.TestVerification);
                    //trackingParticipant.ProfileProvider = TestProfileProvider.GetInstance(trackingConfig);
                    trackingParticipant.ProfileProvider.ActiveTrackingProfile = trackingConfig.TestProfileType;
                    trackingParticipant.Name = trackingConfig.TrackingParticipantName;
                    _trackingParticipants.Add(trackingConfig.TrackingParticipantName, trackingParticipant);
                    if (!isTrackingParticipantSelected)
                    {
                        //if (TestProfileProvider.IsAllOrNullProfile(trackingConfig.TestProfileType) || (numberOfTrackingParticipants == 1))
                        //{
                        //    isTrackingParticipantSelected = true;
                        //    trackingParticipant.PushToTrackingDataManager = true;
                        //}
                    }
                    break;
                }
                TestTraceManager.OptionalLogTrace("[TestTrackingDataManager]Successfully added tracking participant");
            }
            TestTraceManager.OptionalLogTrace("[TestTrackingDataManager]Successfully added all tracking participants...");
        }
 /// <summary>
 /// To make the default Sql tracking participant work for all test cases going forward, we implement it as follows:
 /// When the tracking participant needs to be added to the workflow, the OOB SqlTrackingParticipant get invoked.
 /// For verification purposes, the custom sql tracking participant is instantiated & the corresponding methods invoked.
 /// </summary>
 public static TestTrackingParticipantBase GetInstanceForVerification(TrackingParticipantType type)
 {
     return((TestTrackingParticipantBase)TestTrackingParticipantBase.GetInstance(type, ParticipantAssociation.TestVerification));
 }
        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);
            }
        }