Beispiel #1
0
        public void DiscoverTests(IEnumerable <string> sources, IDiscoveryContext discoveryContext, IMessageLogger log, ITestCaseDiscoverySink discoverySink)
        {
            log.Version();

            RemotingUtility.CleanUpRegisteredChannels();

            foreach (var assemblyPath in sources)
            {
                try
                {
                    if (AssemblyDirectoryContainsFixie(assemblyPath))
                    {
                        log.Info("Processing " + assemblyPath);

                        using (var environment = new ExecutionEnvironment(assemblyPath))
                        {
                            var methodGroups = environment.DiscoverTestMethodGroups(new Options());

                            foreach (var methodGroup in methodGroups)
                            {
                                discoverySink.SendTestCase(new TestCase(methodGroup.FullName, VsTestExecutor.Uri, assemblyPath));
                            }
                        }
                    }
                    else
                    {
                        log.Info("Skipping " + assemblyPath + " because it is not a test assembly.");
                    }
                }
                catch (Exception exception)
                {
                    log.Error(exception);
                }
            }
        }
Beispiel #2
0
        public void DiscoverTests(IEnumerable<string> sources, IDiscoveryContext discoveryContext, IMessageLogger log, ITestCaseDiscoverySink discoverySink)
        {
            log.Version();

            RemotingUtility.CleanUpRegisteredChannels();

            foreach (var assemblyPath in sources)
            {
                try
                {
                    if (AssemblyDirectoryContainsFixie(assemblyPath))
                    {
                        log.Info("Processing " + assemblyPath);

                        using (var environment = new ExecutionEnvironment(assemblyPath))
                        {
                            var methodGroups = environment.DiscoverTestMethodGroups(new Options());

                            foreach (var methodGroup in methodGroups)
                                discoverySink.SendTestCase(new TestCase(methodGroup.FullName, VsTestExecutor.Uri, assemblyPath));
                        }
                    }
                    else
                    {
                        log.Info("Skipping " + assemblyPath + " because it is not a test assembly.");
                    }
                }
                catch (Exception exception)
                {
                    log.Error(exception);
                }
            }
        }
Beispiel #3
0
        public void RunTests(IEnumerable <string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            IMessageLogger log = frameworkHandle;

            log.Version();

            HandlePoorVisualStudioImplementationDetails(runContext, frameworkHandle);

            foreach (var assemblyPath in sources)
            {
                try
                {
                    if (AssemblyDirectoryContainsFixie(assemblyPath))
                    {
                        log.Info("Processing " + assemblyPath);

                        var listener = new VisualStudioListener(frameworkHandle, assemblyPath);

                        using (var environment = new ExecutionEnvironment(assemblyPath))
                        {
                            environment.RunAssembly(new Options(), listener);
                        }
                    }
                    else
                    {
                        log.Info("Skipping " + assemblyPath + " because it is not a test assembly.");
                    }
                }
                catch (Exception exception)
                {
                    log.Error(exception);
                }
            }
        }
Beispiel #4
0
        static void DiscoverTests(IMessageLogger log, ITestCaseDiscoverySink discoverySink, string assemblyPath)
        {
            if (!IsTestAssembly(assemblyPath))
            {
                log.Info("Skipping " + assemblyPath + " because it is not a test assembly.");
                return;
            }

            log.Info("Processing " + assemblyPath);

            var pipeName = Guid.NewGuid().ToString();

            Environment.SetEnvironmentVariable("FIXIE_NAMED_PIPE", pipeName);

            using (var pipe = new NamedPipeServerStream(pipeName, PipeDirection.InOut, 1, PipeTransmissionMode.Message))
                using (var process = Start(assemblyPath))
                {
                    pipe.WaitForConnection();

                    pipe.Send <PipeMessage.DiscoverTests>();

                    var recorder = new DiscoveryRecorder(log, discoverySink, assemblyPath);

                    while (true)
                    {
                        var messageType = pipe.ReceiveMessage();

                        if (messageType == typeof(PipeMessage.TestDiscovered).FullName)
                        {
                            var testDiscovered = pipe.Receive <PipeMessage.TestDiscovered>();
                            recorder.Record(testDiscovered);
                        }
                        else if (messageType == typeof(PipeMessage.Exception).FullName)
                        {
                            var exception = pipe.Receive <PipeMessage.Exception>();
                            throw new RunnerException(exception);
                        }
                        else if (messageType == typeof(PipeMessage.Completed).FullName)
                        {
                            var completed = pipe.Receive <PipeMessage.Completed>();
                            break;
                        }
                        else if (!string.IsNullOrEmpty(messageType))
                        {
                            var body = pipe.ReceiveMessage();
                            log.Error($"The test runner received an unexpected message of type {messageType}: {body}");
                        }
                        else
                        {
                            throw new TestProcessExitException(process.TryGetExitCode());
                        }
                    }
                }
        }
 public void Dispose()
 {
     Channel?.Close();
     connection?.Close();
     Channel?.Dispose();
     connection?.Dispose();
     messageLogger.Info($"Disconnected from RabbitMQ {connectionConfiguration.HostName}");
 }
Beispiel #6
0
        public static void Version(this IMessageLogger logger)
        {
            var assemblyName = typeof(ExecutionEnvironment).Assembly.GetName();
            var name         = assemblyName.Name;
            var version      = assemblyName.Version;

            logger.Info(name + " " + version);
        }
Beispiel #7
0
        public void DiscoverTests(IEnumerable <string> sources, IDiscoveryContext discoveryContext, IMessageLogger log, ITestCaseDiscoverySink discoverySink)
        {
            log.Version();

            RemotingUtility.CleanUpRegisteredChannels();

            foreach (var assemblyPath in sources)
            {
                try
                {
                    if (AssemblyDirectoryContainsFixie(assemblyPath))
                    {
                        log.Info("Processing " + assemblyPath);
                        ISourceLocationProvider sourceLocationProvider = new SourceLocationProvider();

                        using (var environment = new ExecutionEnvironment(assemblyPath))
                        {
                            var methodGroups = environment.DiscoverTestMethodGroups(new Options());
                            //Debugger.Launch();
                            foreach (var methodGroup in methodGroups)
                            {
                                var testCase       = new TestCase(methodGroup.FullName, VsTestExecutor.Uri, assemblyPath);
                                var sourceLocation = sourceLocationProvider.GetSourceLocation(assemblyPath, methodGroup.Class, methodGroup.Method);
                                testCase.CodeFilePath = sourceLocation.Path;
                                testCase.LineNumber   = sourceLocation.LineNumber;
                                discoverySink.SendTestCase(testCase);
                            }
                        }
                    }
                    else
                    {
                        log.Info("Skipping " + assemblyPath + " because it is not a test assembly.");
                    }
                }
                catch (Exception exception)
                {
                    log.Error(exception);
                }
            }
        }
Beispiel #8
0
        public void RunTests(IEnumerable <TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            IMessageLogger log = frameworkHandle;

            log.Version();

            HandlePoorVisualStudioImplementationDetails(runContext, frameworkHandle);

            var assemblyGroups = tests.GroupBy(tc => tc.Source);

            foreach (var assemblyGroup in assemblyGroups)
            {
                var assemblyPath = assemblyGroup.Key;

                try
                {
                    if (AssemblyDirectoryContainsFixie(assemblyPath))
                    {
                        log.Info("Processing " + assemblyPath);

                        var methodGroups = assemblyGroup.Select(x => new MethodGroup(x.FullyQualifiedName)).ToArray();

                        var listener = new VisualStudioListener(frameworkHandle, assemblyPath);

                        using (var environment = new ExecutionEnvironment(assemblyPath))
                        {
                            environment.RunMethods(new Options(), listener, methodGroups);
                        }
                    }
                    else
                    {
                        log.Info("Skipping " + assemblyPath + " because it is not a test assembly.");
                    }
                }
                catch (Exception exception)
                {
                    log.Error(exception);
                }
            }
        }
Beispiel #9
0
        public IActionResult Login(LoginRequest request)
        {
            var messageClientId = new MessageClientId(request.ClientId);
            var messageChainId  = new MessageChainId(Guid.NewGuid().ToString());

            _logger.Info(messageClientId, messageChainId, String.Format("Запрос Login. {0}", JsonSerializer.Serialize(request)));
            var inputMessage = new LoginInputMessage(messageClientId, messageChainId)
            {
                Login    = request.Login,
                Password = request.Password
            };

            _logger.InputMessageCreated(inputMessage);
            _queueManager.SendMessage(AuthSettings.AuthInputQueue, inputMessage);

            return(Ok());
        }
        public void Run(MessageConfiguration config)
        {
            Bind(config.Handler.FullName, config.RoutingKey, connectionConfiguration.Exchange);

            Channel.BasicQos(prefetchSize: 0, prefetchCount: 1, global: false);

            var consumer = new EventingBasicConsumer(Channel);

            consumer.Received += (sender, e) =>
            {
                try
                {
                    var message = Encoding.UTF8.GetString(e.Body);
                    messageLogger.Info($" [x] Received '{e.RoutingKey}':'{message}'");

                    var handler = handlerFactory.Resolve(config.Handler.FullName);
                    handler.Handle(message);
                    handlerFactory.Release(handler);

                    Channel.BasicAck(deliveryTag: e.DeliveryTag, multiple: false);
                }
                catch (Exception exception)
                {
                    Channel.BasicReject(deliveryTag: e.DeliveryTag, requeue: false);

                    if (e.BasicProperties.Headers == null)
                    {
                        e.BasicProperties.Headers = new Dictionary <string, object>();
                    }
                    e.BasicProperties.Headers.Add("Queue", config.Handler.FullName);

                    Channel.BasicPublish(exchange: connectionConfiguration.PoisionExchange,
                                         routingKey: config.RoutingKey,
                                         basicProperties: e.BasicProperties,
                                         body: e.Body);

                    messageLogger.Error(exception);
                    throw;
                }
            };

            Channel.BasicConsume(queue: config.Handler.FullName,
                                 autoAck: false,
                                 consumer: consumer);
        }
Beispiel #11
0
        public void Send(string routingKey,
                         string message)
        {
            var body = Encoding.UTF8.GetBytes(message);

            var properties = Channel.CreateBasicProperties();

            properties.Persistent = true;

            Channel.ConfirmSelect();
            Channel.BasicPublish(exchange: connectionConfiguration.Exchange,
                                 routingKey: routingKey,
                                 basicProperties: properties,
                                 mandatory: true,
                                 body: body);
            Channel.WaitForConfirms();

            messageLogger.Info($" [x] Sent {message}");
        }
Beispiel #12
0
        static void RunTests(IMessageLogger log, IFrameworkHandle frameworkHandle, string assemblyPath, Action <NamedPipeServerStream> sendCommand)
        {
            if (!IsTestAssembly(assemblyPath))
            {
                log.Info("Skipping " + assemblyPath + " because it is not a test assembly.");
                return;
            }

            log.Info("Processing " + assemblyPath);

            var pipeName = Guid.NewGuid().ToString();

            Environment.SetEnvironmentVariable("FIXIE_NAMED_PIPE", pipeName);

            using (var pipe = new NamedPipeServerStream(pipeName, PipeDirection.InOut, 1, PipeTransmissionMode.Message))
            {
                Start(assemblyPath, frameworkHandle);

                pipe.WaitForConnection();

                sendCommand(pipe);

                var recorder = new ExecutionRecorder(frameworkHandle, assemblyPath);

                while (true)
                {
                    var messageType = pipe.ReceiveMessage();

                    if (messageType == typeof(PipeMessage.CaseSkipped).FullName)
                    {
                        var testResult = pipe.Receive <PipeMessage.CaseSkipped>();
                        recorder.Record(testResult);
                    }
                    else if (messageType == typeof(PipeMessage.CasePassed).FullName)
                    {
                        var testResult = pipe.Receive <PipeMessage.CasePassed>();
                        recorder.Record(testResult);
                    }
                    else if (messageType == typeof(PipeMessage.CaseFailed).FullName)
                    {
                        var testResult = pipe.Receive <PipeMessage.CaseFailed>();
                        recorder.Record(testResult);
                    }
                    else if (messageType == typeof(PipeMessage.Exception).FullName)
                    {
                        var exception = pipe.Receive <PipeMessage.Exception>();
                        throw new RunnerException(exception);
                    }
                    else if (messageType == typeof(PipeMessage.Completed).FullName)
                    {
                        var completed = pipe.Receive <PipeMessage.Completed>();
                        break;
                    }
                    else
                    {
                        var body = pipe.ReceiveMessage();
                        throw new Exception($"Test runner received unexpected message of type {messageType}: {body}");
                    }
                }
            }
        }
Beispiel #13
0
 public static void Version(this IMessageLogger logger)
 => logger.Info(Framework.Version);