示例#1
0
        /// <summary>
        /// Initializes parameters for the new instance of the class <see cref="BlameDataCollector"/>
        /// </summary>
        /// <param name="configurationElement">The Xml Element to save to</param>
        /// <param name="events">Data collection events to which methods subscribe</param>
        /// <param name="dataSink">A data collection sink for data transfer</param>
        /// <param name="logger">Data Collection Logger to send messages to the client </param>
        /// <param name="environmentContext">Context of data collector environment</param>
        public override void Initialize(
            XmlElement configurationElement,
            DataCollectionEvents events,
            DataCollectionSink dataSink,
            DataCollectionLogger logger,
            DataCollectionEnvironmentContext environmentContext)
        {
            ValidateArg.NotNull(logger, nameof(logger));

            this.events               = events;
            this.dataCollectionSink   = dataSink;
            this.context              = environmentContext;
            this.configurationElement = configurationElement;
            this.testSequence         = new List <Guid>();
            this.testObjectDictionary = new Dictionary <Guid, BlameTestObject>();
            this.logger               = logger;

            // Subscribing to events
            this.events.TestHostLaunched += this.TestHostLaunchedHandler;
            this.events.SessionEnd       += this.SessionEndedHandler;
            this.events.TestCaseStart    += this.EventsTestCaseStart;
            this.events.TestCaseEnd      += this.EventsTestCaseEnd;

            if (this.configurationElement != null)
            {
                var collectDumpNode = this.configurationElement[Constants.DumpModeKey];
                this.collectProcessDumpOnTrigger = collectDumpNode != null;

                if (this.collectProcessDumpOnTrigger)
                {
                    this.ValidateAndAddTriggerBasedProcessDumpParameters(collectDumpNode);
                }

                var collectHangBasedDumpNode = this.configurationElement[Constants.CollectDumpOnTestSessionHang];
                this.collectProcessDumpOnTestHostHang = collectHangBasedDumpNode != null;
                if (this.collectProcessDumpOnTestHostHang)
                {
                    this.ValidateAndAddHangBasedProcessDumpParameters(collectHangBasedDumpNode);
                }

                var tfm = this.configurationElement[Constants.TargetFramework]?.InnerText;
                if (!string.IsNullOrWhiteSpace(tfm))
                {
                    this.targetFramework = tfm;
                }
            }

            this.attachmentGuid = Guid.NewGuid().ToString().Replace("-", string.Empty);

            if (this.collectProcessDumpOnTestHostHang)
            {
                this.inactivityTimer = this.inactivityTimer ?? new InactivityTimer(this.CollectDumpAndAbortTesthost);
                this.ResetInactivityTimer();
            }
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BlameCollector"/> class.
 /// </summary>
 /// <param name="blameReaderWriter">
 /// BlameReaderWriter instance.
 /// </param>
 /// <param name="processDumpUtility">
 /// IProcessDumpUtility instance.
 /// </param>
 /// <param name="inactivityTimer">
 /// InactivityTimer instance.
 /// </param>
 /// <param name="fileHelper">
 /// Filehelper instance.
 /// </param>
 internal BlameCollector(
     IBlameReaderWriter blameReaderWriter,
     IProcessDumpUtility processDumpUtility,
     IInactivityTimer inactivityTimer,
     IFileHelper fileHelper)
 {
     this.blameReaderWriter  = blameReaderWriter;
     this.processDumpUtility = processDumpUtility;
     this.inactivityTimer    = inactivityTimer;
     this.fileHelper         = fileHelper;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TestableBlameCollector"/> class.
 /// </summary>
 /// <param name="blameReaderWriter">
 /// The blame reader writer.
 /// </param>
 /// <param name="processDumpUtility">
 /// ProcessDumpUtility instance.
 /// </param>
 /// <param name="inactivityTimer">
 /// InactivityTimer instance.
 /// </param>
 /// <param name="mockFileHelper">
 /// MockFileHelper instance.
 /// </param>
 internal TestableBlameCollector(IBlameReaderWriter blameReaderWriter, IProcessDumpUtility processDumpUtility, IInactivityTimer inactivityTimer, IFileHelper mockFileHelper)
     : base(blameReaderWriter, processDumpUtility, inactivityTimer, mockFileHelper)
 {
 }
示例#4
0
        /// <summary>
        /// Initializes parameters for the new instance of the class <see cref="BlameDataCollector"/>
        /// </summary>
        /// <param name="configurationElement">The Xml Element to save to</param>
        /// <param name="events">Data collection events to which methods subscribe</param>
        /// <param name="dataSink">A data collection sink for data transfer</param>
        /// <param name="logger">Data Collection Logger to send messages to the client </param>
        /// <param name="environmentContext">Context of data collector environment</param>
        public override void Initialize(
            XmlElement configurationElement,
            DataCollectionEvents events,
            DataCollectionSink dataSink,
            DataCollectionLogger logger,
            DataCollectionEnvironmentContext environmentContext)
        {
            ValidateArg.NotNull(logger, nameof(logger));

            this.events               = events;
            this.dataCollectionSink   = dataSink;
            this.context              = environmentContext;
            this.configurationElement = configurationElement;
            this.testSequence         = new List <Guid>();
            this.testObjectDictionary = new Dictionary <Guid, BlameTestObject>();
            this.logger               = logger;

            // Subscribing to events
            this.events.TestHostLaunched += this.TestHostLaunchedHandler;
            this.events.SessionEnd       += this.SessionEndedHandler;
            this.events.TestCaseStart    += this.EventsTestCaseStart;
            this.events.TestCaseEnd      += this.EventsTestCaseEnd;

            if (this.configurationElement != null)
            {
                var collectDumpNode = this.configurationElement[Constants.DumpModeKey];
                this.collectProcessDumpOnTrigger = collectDumpNode != null;

                if (this.collectProcessDumpOnTrigger)
                {
                    this.ValidateAndAddTriggerBasedProcessDumpParameters(collectDumpNode);

                    // enabling dumps on MacOS needs to be done explicitly https://github.com/dotnet/runtime/pull/40105
                    this.environmentVariables.Add(new KeyValuePair <string, string>("COMPlus_DbgEnableElfDumpOnMacOS", "1"));
                    this.environmentVariables.Add(new KeyValuePair <string, string>("COMPlus_DbgEnableMiniDump", "1"));

                    // https://github.com/dotnet/coreclr/blob/master/Documentation/botr/xplat-minidump-generation.md
                    // 2   MiniDumpWithPrivateReadWriteMemory
                    // 4   MiniDumpWithFullMemory
                    this.environmentVariables.Add(new KeyValuePair <string, string>("COMPlus_DbgMiniDumpType", this.processFullDumpEnabled ? "4" : "2"));
                    var dumpDirectory = this.GetDumpDirectory();
                    var dumpPath      = Path.Combine(dumpDirectory, $"%e_%p_%t_crashdump.dmp");
                    this.environmentVariables.Add(new KeyValuePair <string, string>("COMPlus_DbgMiniDumpName", dumpPath));
                }

                var collectHangBasedDumpNode = this.configurationElement[Constants.CollectDumpOnTestSessionHang];
                this.collectProcessDumpOnTestHostHang = collectHangBasedDumpNode != null;
                if (this.collectProcessDumpOnTestHostHang)
                {
                    // enabling dumps on MacOS needs to be done explicitly https://github.com/dotnet/runtime/pull/40105
                    this.environmentVariables.Add(new KeyValuePair <string, string>("COMPlus_DbgEnableElfDumpOnMacOS", "1"));

                    this.ValidateAndAddHangBasedProcessDumpParameters(collectHangBasedDumpNode);
                }

                var tfm = this.configurationElement[Constants.TargetFramework]?.InnerText;
                if (!string.IsNullOrWhiteSpace(tfm))
                {
                    this.targetFramework = tfm;
                }
            }

            this.attachmentGuid = Guid.NewGuid().ToString().Replace("-", string.Empty);

            if (this.collectProcessDumpOnTestHostHang)
            {
                this.inactivityTimer = this.inactivityTimer ?? new InactivityTimer(this.CollectDumpAndAbortTesthost);
                this.ResetInactivityTimer();
            }
        }