Example #1
0
        public static async Task <bool> TEST_RuntimeIsResilientToServerClosing()
        {
            bool   fSuccess   = true;
            string serverName = ReverseServer.MakeServerAddress();

            Logger.logger.Log($"Server name is '{serverName}'");
            Task <bool> subprocessTask = Utils.RunSubprocess(
                currentAssembly: Assembly.GetExecutingAssembly(),
                environment: new Dictionary <string, string>
            {
                { Utils.DiagnosticPortsEnvKey, $"{serverName}" }
            },
                duringExecution: async(_) =>
            {
                var ad1 = await ReverseServer.CreateServerAndReceiveAdvertisement(serverName);
                Logger.logger.Log(ad1.ToString());
                var ad2 = await ReverseServer.CreateServerAndReceiveAdvertisement(serverName);
                Logger.logger.Log(ad2.ToString());
                var ad3 = await ReverseServer.CreateServerAndReceiveAdvertisement(serverName);
                Logger.logger.Log(ad3.ToString());
                var ad4 = await ReverseServer.CreateServerAndReceiveAdvertisement(serverName);
                Logger.logger.Log(ad4.ToString());
            }
                );

            fSuccess &= await subprocessTask;

            return(fSuccess);
        }
Example #2
0
        public static async Task <bool> TEST_ReverseConnectionCanRecycleWhileTracing()
        {
            bool   fSuccess   = true;
            string serverName = ReverseServer.MakeServerAddress();

            Logger.logger.Log($"Server name is '{serverName}'");
            Task <bool> subprocessTask = Utils.RunSubprocess(
                currentAssembly: Assembly.GetExecutingAssembly(),
                environment: new Dictionary <string, string>
            {
                { Utils.DiagnosticsMonitorAddressEnvKey, serverName },
                { Utils.DiagnosticsMonitorPauseOnStartEnvKey, "0" }
            },
                duringExecution: async(int pid) =>
            {
                ManualResetEvent mre = new ManualResetEvent(false);
                Task regularTask     = Task.Run(async() =>
                {
                    try
                    {
                        var config = new SessionConfiguration(
                            circularBufferSizeMB: 1000,
                            format: EventPipeSerializationFormat.NetTrace,
                            providers: new List <Provider> {
                            new Provider("Microsoft-DotNETCore-SampleProfiler")
                        });
                        Logger.logger.Log("Starting EventPipeSession over standard connection");
                        using Stream stream = EventPipeClient.CollectTracing(pid, config, out var sessionId);
                        Logger.logger.Log($"Started EventPipeSession over standard connection with session id: 0x{sessionId:x}");
                        using var source = new EventPipeEventSource(stream);
                        Task readerTask  = Task.Run(() => source.Process());
                        await Task.Delay(500);
                        Logger.logger.Log("Stopping EventPipeSession over standard connection");
                        EventPipeClient.StopTracing(pid, sessionId);
                        await readerTask;
                        Logger.logger.Log("Stopped EventPipeSession over standard connection");
                    }
                    finally
                    {
                        mre.Set();
                    }
                });

                Task reverseTask = Task.Run(async() =>
                {
                    while (!mre.WaitOne(0))
                    {
                        var ad1 = await ReverseServer.CreateServerAndReceiveAdvertisement(serverName);
                        Logger.logger.Log(ad1.ToString());
                    }
                });

                await Task.WhenAll(reverseTask, regularTask);
            }
                );

            fSuccess &= await subprocessTask;

            return(fSuccess);
        }
Example #3
0
        public static async Task <bool> TEST_RuntimeConnectsToExistingServer()
        {
            bool   fSuccess   = true;
            string serverName = ReverseServer.MakeServerAddress();
            Task <IpcAdvertise> advertiseTask = ReverseServer.CreateServerAndReceiveAdvertisement(serverName);

            Logger.logger.Log($"Server name is `{serverName}`");
            Task <bool> subprocessTask = Utils.RunSubprocess(
                currentAssembly: Assembly.GetExecutingAssembly(),
                environment: new Dictionary <string, string>
            {
                { Utils.DiagnosticsMonitorAddressEnvKey, serverName },
                { Utils.DiagnosticsMonitorPauseOnStartEnvKey, "0" }
            },
                duringExecution: async(_) =>
            {
                IpcAdvertise advertise = await advertiseTask;
                Logger.logger.Log(advertise.ToString());
            }
                );

            fSuccess &= await subprocessTask;

            return(fSuccess);
        }
Example #4
0
        public static async Task <bool> TEST_RuntimeIsResilientToServerClosing()
        {
            bool   fSuccess   = true;
            string serverName = ReverseServer.MakeServerAddress();

            Logger.logger.Log($"Server name is '{serverName}'");
            Task <bool> subprocessTask = Utils.RunSubprocess(
                currentAssembly: Assembly.GetExecutingAssembly(),
                environment: new Dictionary <string, string>
            {
                { Utils.DiagnosticsMonitorAddressEnvKey, serverName },
                { Utils.DiagnosticsMonitorPauseOnStartEnvKey, "0" }
            },
                duringExecution: async(_) =>
            {
                var ad1 = await Utils.WaitTillTimeout(ReverseServer.CreateServerAndReceiveAdvertisement(serverName), TimeSpan.FromMilliseconds(_maxPollTimeMS));
                Logger.logger.Log(ad1.ToString());
                var ad2 = await Utils.WaitTillTimeout(ReverseServer.CreateServerAndReceiveAdvertisement(serverName), TimeSpan.FromMilliseconds(_maxPollTimeMS));
                Logger.logger.Log(ad2.ToString());
                var ad3 = await Utils.WaitTillTimeout(ReverseServer.CreateServerAndReceiveAdvertisement(serverName), TimeSpan.FromMilliseconds(_maxPollTimeMS));
                Logger.logger.Log(ad3.ToString());
                var ad4 = await Utils.WaitTillTimeout(ReverseServer.CreateServerAndReceiveAdvertisement(serverName), TimeSpan.FromMilliseconds(_maxPollTimeMS));
                Logger.logger.Log(ad4.ToString());
            }
                );

            fSuccess &= await Utils.WaitTillTimeout(subprocessTask, TimeSpan.FromMinutes(1));

            return(fSuccess);
        }
Example #5
0
        public static async Task <bool> TEST_ReverseConnectionCanRecycleWhileTracing()
        {
            string serverName = ReverseServer.MakeServerAddress();

            Logger.logger.Log($"Server name is '{serverName}'");
            await RunSubprocess(
                serverName : serverName,
                duringExecution : async(int pid) =>
            {
                Task regularTask = Task.Run(async() =>
                {
                    var config = new SessionConfiguration(
                        circularBufferSizeMB: 1000,
                        format: EventPipeSerializationFormat.NetTrace,
                        providers: new List <Provider> {
                        new Provider("Microsoft-DotNETCore-SampleProfiler")
                    });
                    Logger.logger.Log("Starting EventPipeSession over standard connection");
                    using Stream stream = EventPipeClient.CollectTracing(pid, config, out var sessionId);
                    Logger.logger.Log($"Started EventPipeSession over standard connection with session id: 0x{sessionId:x}");
                    using var source = new EventPipeEventSource(stream);
                    Task readerTask  = Task.Run(() => source.Process());
                    await Task.Delay(500);
                    Logger.logger.Log("Stopping EventPipeSession over standard connection");
                    EventPipeClient.StopTracing(pid, sessionId);
                    await readerTask;
                    Logger.logger.Log("Stopped EventPipeSession over standard connection");
                });

                Task reverseTask = Task.Run(async() =>
                {
                    var ad1 = await WaitTillTimeout(ReverseServer.CreateServerAndReceiveAdvertisement(serverName), TimeSpan.FromMilliseconds(_maxPollTimeMS));
                    Logger.logger.Log(ad1.ToString());
                    var ad2 = await WaitTillTimeout(ReverseServer.CreateServerAndReceiveAdvertisement(serverName), TimeSpan.FromMilliseconds(_maxPollTimeMS));
                    Logger.logger.Log(ad2.ToString());
                    var ad3 = await WaitTillTimeout(ReverseServer.CreateServerAndReceiveAdvertisement(serverName), TimeSpan.FromMilliseconds(_maxPollTimeMS));
                    Logger.logger.Log(ad3.ToString());
                    var ad4 = await WaitTillTimeout(ReverseServer.CreateServerAndReceiveAdvertisement(serverName), TimeSpan.FromMilliseconds(_maxPollTimeMS));
                    Logger.logger.Log(ad4.ToString());
                });

                await Task.WhenAll(reverseTask, regularTask);
            }
                );

            return(true);
        }
Example #6
0
        public static async Task <bool> TEST_RuntimeConnectsToExistingServer()
        {
            string serverName = ReverseServer.MakeServerAddress();
            Task <IpcAdvertise> advertiseTask = ReverseServer.CreateServerAndReceiveAdvertisement(serverName);

            Logger.logger.Log($"Server name is `{serverName}`");
            await RunSubprocess(
                serverName : serverName,
                duringExecution : async(_) =>
            {
                IpcAdvertise advertise = await WaitTillTimeout(advertiseTask, TimeSpan.FromMilliseconds(_maxPollTimeMS));
                Logger.logger.Log(advertise.ToString());
            }
                );

            return(true);
        }
Example #7
0
        public static async Task <bool> TEST_RuntimeIsResilientToServerClosing()
        {
            string serverName = ReverseServer.MakeServerAddress();

            Logger.logger.Log($"Server name is '{serverName}'");
            await RunSubprocess(
                serverName : serverName,
                duringExecution : async(_) =>
            {
                var ad1 = await WaitTillTimeout(ReverseServer.CreateServerAndReceiveAdvertisement(serverName), TimeSpan.FromMilliseconds(_maxPollTimeMS));
                Logger.logger.Log(ad1.ToString());
                var ad2 = await WaitTillTimeout(ReverseServer.CreateServerAndReceiveAdvertisement(serverName), TimeSpan.FromMilliseconds(_maxPollTimeMS));
                Logger.logger.Log(ad2.ToString());
                var ad3 = await WaitTillTimeout(ReverseServer.CreateServerAndReceiveAdvertisement(serverName), TimeSpan.FromMilliseconds(_maxPollTimeMS));
                Logger.logger.Log(ad3.ToString());
                var ad4 = await WaitTillTimeout(ReverseServer.CreateServerAndReceiveAdvertisement(serverName), TimeSpan.FromMilliseconds(_maxPollTimeMS));
                Logger.logger.Log(ad4.ToString());
            }
                );

            return(true);
        }