コード例 #1
0
        public static void CustomCounterCollection(HttpListenerObservable listener)
        {
            var counterItems = listener.ReceiveItemsOfType<TelemetryItem<MetricData>>(10, TestListenerWaitTimeInMs);

            AssertCustomCounterReported(counterItems, "Custom counter one");
            AssertCustomCounterReported(counterItems, "Custom counter two");
        }
コード例 #2
0
        public static void DefaultCounterCollection(HttpListenerObservable listener)
        {
            var counterItems = listener.ReceiveItemsOfType <TelemetryItem <MetricData> >(10, TestListenerWaitTimeInMs);

            AssertCustomCounterReported(counterItems, "\\Memory\\Available Bytes");
            AssertCustomCounterReported(counterItems, @"\Process(??APP_WIN32_PROC??)\% Processor Time Normalized");
        }
コード例 #3
0
        public static void CustomCounterCollection(HttpListenerObservable listener)
        {
            var counterItems = listener.ReceiveItemsOfType <TelemetryItem <MetricData> >(10, TestListenerWaitTimeInMs);

            AssertCustomCounterReported(counterItems, "Custom counter one");
            AssertCustomCounterReported(counterItems, "Custom counter two");
        }
コード例 #4
0
        public static Envelope[] ReceiveAllItemsDuringTime(
            this HttpListenerObservable listener,
            int timeOut)
        {
            if (null == listener)
            {
                throw new ArgumentNullException("listener");
            }

            return(listener
                   .Where(item => !(item is TelemetryItem <RemoteDependencyData>))
                   .TakeUntil(DateTimeOffset.UtcNow.AddMilliseconds(timeOut))
                   .ToEnumerable()
                   .ToArray());
        }
コード例 #5
0
        public static T[] ReceiveAllItemsDuringTimeOfType <T>(
            this HttpListenerObservable listener,
            int timeOut)
        {
            if (null == listener)
            {
                throw new ArgumentNullException("listener");
            }

            return(listener
                   .TakeUntil(DateTimeOffset.UtcNow.AddMilliseconds(timeOut))
                   .Where(item => (item is T))
                   .Cast <T>()
                   .ToEnumerable()
                   .ToArray());
        }
コード例 #6
0
        public static Envelope[] ReceiveItemsOfTypes <T1, T2>(
            this HttpListenerObservable listener,
            int count,
            int timeOut)
        {
            var result = listener
                         .Where(item => ((item is T1) || (item is T2)))
                         .TakeUntil(DateTimeOffset.UtcNow.AddMilliseconds(timeOut))
                         .Take(count)
                         .ToEnumerable()
                         .ToArray();

            if (result.Length != count)
            {
                throw new InvalidDataException("Incorrect number of items. Expected: " + count + " Received: " + result.Length);
            }

            return(result);
        }
コード例 #7
0
        public static void MyClassInitialize(TestContext testContext)
        {
            // this makes all traces have a timestamp so it's easier to troubleshoot timing issues
            // looking for the better approach...
            foreach (TraceListener listener in Trace.Listeners)
            {
                listener.TraceOutputOptions |= TraceOptions.DateTime;
            }
            sdkEventListener = new HttpListenerObservable(Aspx451FakeDataPlatformEndpoint);

            aspx451TestWebApplication.Deploy();
            aspx451TestWebApplicationWin32.Deploy(true);

            AzureStorageHelper.Initialize();

            LocalDb.CreateLocalDb("RDDTestDatabase", aspx451TestWebApplication.AppFolder + "\\TestDatabase.sql");

            if (DotNetVersionCheck.IsNet46Installed)
            {
                // .NET 4.6 onwards, there is no need of installing agent
                sourceExpected = DependencySourceType.Aic;
            }
            else
            {
                sourceExpected = DependencySourceType.Apmc;
                Installer.SetInternalUI(InstallUIOptions.Silent);
                string installerPath = ExecutionEnvironment.InstallerPath;
                try
                {
                    Installer.InstallProduct(installerPath, "ACTION=INSTALL ALLUSERS=1 MSIINSTALLPERUSER=1");
                }
                catch (Exception ex)
                {
                    Trace.TraceError("Agent installer not found. Agent is required for running tests for framework version below 4.6" + ex);
                    throw;
                }
            }

            Iis.Reset();
        }
コード例 #8
0
        public static Envelope[] ReceiveItems(
            this HttpListenerObservable listener,
            int count,
            int timeOut)
        {
            if (null == listener)
            {
                throw new ArgumentNullException("listener");
            }

            var result = listener
                         .Where(item => !(item is TelemetryItem <RemoteDependencyData>))
                         .TakeUntil(DateTimeOffset.UtcNow.AddMilliseconds(timeOut))
                         .Take(count)
                         .ToEnumerable()
                         .ToArray();

            if (result.Length != count)
            {
                throw new InvalidDataException("Incorrect number of items. Expected: " + count + " Received: " + result.Length);
            }

            return(result);
        }
コード例 #9
0
        public static void DefaultCounterCollection(HttpListenerObservable listener)
        {
            var counterItems = listener.ReceiveItemsOfType <TelemetryItem <PerformanceCounterData> >(10, TestListenerWaitTimeInMs);

            AssertDefaultCounterReported(counterItems, "Memory", "Available Bytes");
        }
コード例 #10
0
        public static void NonExistentCounterWhichUsesPlaceHolder(HttpListenerObservable listener)
        {
            var counterItems = listener.ReceiveItemsOfType<TelemetryItem<MetricData>>(10, TestListenerWaitTimeInMs);

            AssertCustomCounterReported(counterItems, @"Custom counter with placeholder - does not exist", false);
        }
コード例 #11
0
        public static void NonExistentCounterWhichUsesPlaceHolder(HttpListenerObservable listener)
        {
            var counterItems = listener.ReceiveItemsOfType <TelemetryItem <MetricData> >(10, TestListenerWaitTimeInMs);

            AssertCustomCounterReported(counterItems, @"Custom counter with placeholder - does not exist", false);
        }
コード例 #12
0
        public static void DefaultCounterCollection(HttpListenerObservable listener)
        {
            var counterItems = listener.ReceiveItemsOfType<TelemetryItem<PerformanceCounterData>>(10, TestListenerWaitTimeInMs);

            AssertDefaultCounterReported(counterItems, "Memory", "Available Bytes");  
        }
        /// <summary>
        /// Deploy all test applications and prepera infra.
        /// </summary>
        public static void Initialize()
        {
            if (!isInitialized)
            {
                lock (lockObj)
                {
                    if (!isInitialized)
                    {
                        Aspx451TestWebApplication = new TestWebApplication
                        {
                            AppName = "Aspx451",
                            Port = Aspx451Port,
                            IsRedFieldApp = false
                        };

                        Aspx451TestWebApplicationWin32 = new TestWebApplication
                        {
                            AppName = "Aspx451Win32",
                            Port = Aspx451PortWin32,
                            IsRedFieldApp = false
                        };

                        // this makes all traces have a timestamp so it's easier to troubleshoot timing issues
                        // looking for the better approach...
                        foreach (TraceListener listener in Trace.Listeners)
                        {
                            listener.TraceOutputOptions |= TraceOptions.DateTime;
                        }

                        SdkEventListener = new HttpListenerObservable(Aspx451FakeDataPlatformEndpoint);

                        EtwSession = new EtwEventSessionRdd();
                        EtwSession.Start();

                        Aspx451TestWebApplication.Deploy();
                        Aspx451TestWebApplicationWin32.Deploy(true);

                        if (RegistryCheck.IsNet46Installed)
                        {
                            Trace.TraceInformation("Detected DotNet46 as installed. Will check StatusMonitor status to determine expected prefix");

                            if(RegistryCheck.IsStatusMonitorInstalled)
                            {
                                Trace.TraceInformation("Detected Status Monitor as installed, ExpectedPrefix: rddp");
                                ExpectedSDKPrefix = "rddp";
                            }
                            else
                            {
                                Trace.TraceInformation("Detected Status Monitor as not installed, ExpectedPrefix: rddf");
                                ExpectedSDKPrefix = "rddf";
                            }
                        }
                        else
                        {
                            Trace.TraceInformation("Detected DotNet46 as not installed. Will install StatusMonitor if not already installed.");
                            Trace.TraceInformation("Tests against StatusMonitor instrumentation.");
                            ExpectedSDKPrefix = "rddp";

                            if (!RegistryCheck.IsStatusMonitorInstalled)
                            {
                                Trace.TraceInformation("StatusMonitor not already installed.Installing from:" + ExecutionEnvironment.InstallerPath);
                                Installer.SetInternalUI(InstallUIOptions.Silent);
                                string installerPath = ExecutionEnvironment.InstallerPath;
                                try
                                {
                                    Installer.InstallProduct(installerPath, "ACTION=INSTALL ALLUSERS=1 MSIINSTALLPERUSER=1");
                                    Trace.TraceInformation("StatusMonitor installed without errors.");
                                }
                                catch (Exception ex)
                                {
                                    Trace.TraceError(
                                        "Agent installer not found. Agent is required for running tests for framework version below 4.6" +
                                        ex);
                                    throw;
                                }
                            }
                            else
                            {
                                Trace.TraceInformation("StatusMonitor already installed.");
                            }
                        }

                        Trace.TraceInformation("IIS Restart begin.");
                        Iis.Reset();
                        Trace.TraceInformation("IIS Restart end.");

                        isInitialized = true;
                    }
                }
            }
        }
コード例 #14
0
        public static void DefaultCounterCollection(HttpListenerObservable listener)
        {
            var counterItems = listener.ReceiveItemsOfType <TelemetryItem <MetricData> >(10, TestListenerWaitTimeInMs);

            AssertCustomCounterReported(counterItems, "\\Memory\\Available Bytes");
        }
        public void TestInitialize()
        {
            this.applicationDirectory = Path.Combine(
                Directory.GetCurrentDirectory(),
                TestWebApplicaionDestPath);

            Trace.WriteLine("Application directory:" + this.applicationDirectory);

            this.Listener = new HttpListenerObservable("http://localhost:4002/v2/track/");
            this.Listener.Start();

            this.EtwSession = new EtwEventSession();
            this.EtwSession.Start();

            Thread.Sleep(5000);
        }
コード例 #16
0
        public static void NonParsableCounter(HttpListenerObservable listener)
        {
            var counterItems = listener.ReceiveItemsOfType<TelemetryItem<MetricData>>(10, TestListenerWaitTimeInMs);

            AssertCustomCounterReported(counterItems, @"Custom counter - will not parse", false);
        }
コード例 #17
0
        public static void MyClassInitialize(TestContext testContext)
        {
            // this makes all traces have a timestamp so it's easier to troubleshoot timing issues
            // looking for the better approach...
            foreach (TraceListener listener in Trace.Listeners)
            {
                listener.TraceOutputOptions |= TraceOptions.DateTime;
            }
            sdkEventListener = new HttpListenerObservable(Aspx451FakeDataPlatformEndpoint);

            aspx451TestWebApplication.Deploy();
            aspx451TestWebApplicationWin32.Deploy(true);

            AzureStorageHelper.Initialize();

            LocalDb.CreateLocalDb("RDDTestDatabase", aspx451TestWebApplication.AppFolder + "\\TestDatabase.sql");

            if (DotNetVersionCheck.IsNet46Installed)
            {
                // .NET 4.6 onwards, there is no need of installing agent
                sourceExpected = DependencySourceType.Aic;
            }
            else
            {
                sourceExpected = DependencySourceType.Apmc;
                Installer.SetInternalUI(InstallUIOptions.Silent);
                string installerPath = ExecutionEnvironment.InstallerPath;
                try
                {
                    Installer.InstallProduct(installerPath, "ACTION=INSTALL ALLUSERS=1 MSIINSTALLPERUSER=1");
                }
                catch (Exception ex)
                {
                    Trace.TraceError("Agent installer not found. Agent is required for running tests for framework version below 4.6" + ex);
                    throw;
                }
            }

            Iis.Reset();
        }
コード例 #18
0
        public static void NonParsableCounter(HttpListenerObservable listener)
        {
            var counterItems = listener.ReceiveItemsOfType <TelemetryItem <MetricData> >(10, TestListenerWaitTimeInMs);

            AssertCustomCounterReported(counterItems, @"Custom counter - will not parse", false);
        }
コード例 #19
0
        public static void DefaultCounterCollection(HttpListenerObservable listener)
        {
            var counterItems = listener.ReceiveItemsOfType<TelemetryItem<MetricData>>(10, TestListenerWaitTimeInMs);

            AssertCustomCounterReported(counterItems, "\\Memory\\Available Bytes");
        }