public void TcsContinuationErrorsDontGetLoggedAsGeneralErrors()
        {
            var testLogger       = new TestApplicationErrorLogger();
            var testKestrelTrace = new TestKestrelTrace(testLogger);
            var threadPool       = new LoggingThreadPool(testKestrelTrace);

            var completeTcs = new TaskCompletionSource <object>();

            ThrowSynchronously(completeTcs.Task);
            threadPool.Complete(completeTcs);

            var errorTcs = new TaskCompletionSource <object>();

            ThrowSynchronously(errorTcs.Task);
            threadPool.Error(errorTcs, new Exception());

            var cancelTcs = new TaskCompletionSource <object>();

            ThrowSynchronously(cancelTcs.Task);
            threadPool.Cancel(cancelTcs);

            Assert.Throws <AggregateException>(() =>
                                               Task.WhenAll(completeTcs.Task, errorTcs.Task, cancelTcs.Task).Wait());

            Assert.Equal(0, testLogger.TotalErrorsLogged);
        }
Exemple #2
0
        public void DoesNotEndConnectionOnZeroRead()
        {
            var mockLibuv = new MockLibuv();

            using (var memory = new MemoryPool())
                using (var engine = new KestrelEngine(mockLibuv, new TestServiceContext()))
                {
                    engine.Start(count: 1);

                    var trace   = new TestKestrelTrace();
                    var context = new ListenerContext(new TestServiceContext())
                    {
                        FrameFactory = connectionContext => new Frame <HttpContext>(
                            new DummyApplication(httpContext => TaskUtilities.CompletedTask), connectionContext),
                        Memory        = memory,
                        ServerAddress = ServerAddress.FromUrl($"http://localhost:{TestServer.GetNextPort()}"),
                        Thread        = engine.Threads[0]
                    };
                    var socket     = new MockSocket(mockLibuv, Thread.CurrentThread.ManagedThreadId, trace);
                    var connection = new Connection(context, socket);
                    connection.Start();

                    Libuv.uv_buf_t ignored;
                    mockLibuv.AllocCallback(socket.InternalGetHandle(), 2048, out ignored);
                    mockLibuv.ReadCallback(socket.InternalGetHandle(), 0, ref ignored);
                    Assert.False(connection.SocketInput.RemoteIntakeFin);

                    connection.ConnectionControl.End(ProduceEndType.SocketDisconnect);
                }
        }
 public TestServiceContext()
 {
     AppLifetime            = new LifetimeNotImplemented();
     Log                    = new TestKestrelTrace();
     ThreadPool             = new LoggingThreadPool(Log);
     DateHeaderValueManager = new DateHeaderValueManager(systemClock: new MockSystemClock());
     DateHeaderValue        = DateHeaderValueManager.GetDateHeaderValues().String;
     ServerOptions          = new KestrelServerOptions {
         AddServerHeader = false
     };
     ServerOptions.ShutdownTimeout = TimeSpan.FromSeconds(5);
 }
Exemple #4
0
        public TestServiceContext()
        {
            AppLifetime            = new LifetimeNotImplemented();
            Log                    = new TestKestrelTrace();
            ThreadPool             = new LoggingThreadPool(Log);
            DateHeaderValueManager = new TestDateHeaderValueManager();

            ServerOptions = new KestrelServerOptions();
            ServerOptions.ShutdownTimeout = TimeSpan.FromSeconds(5);

            HttpComponentFactory = new HttpComponentFactory(ServerOptions);
        }