Skip to content

Commit

Permalink
Get rid of Thread.Sleep everywhere and see if Travis can handle it
Browse files Browse the repository at this point in the history
  • Loading branch information
Maor Rosenfeld committed Feb 23, 2017
1 parent 78f466c commit 289d3cc
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/IntegrationTests/Log4net/Log4netPerfTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public void MeasurePerfForLog4net()
Console.WriteLine("Total time: " + stopwatch.Elapsed);
stopwatch.Elapsed.Should().BeLessOrEqualTo(TimeSpan.FromMilliseconds(100));

Thread.Sleep(logsAmount); //Make sure the logs are added to the queue before we flush everything
new Bootstraper().Resolve<IShipper>().WaitForSendLogsTask();

logzioAppender.Close();
Expand Down
2 changes: 1 addition & 1 deletion src/IntegrationTests/Log4net/Log4netSanityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void Sanity()
var logger = LogManager.GetLogger(typeof (Log4netSanityTests));

logger.Info("Just a random log line");
Thread.Sleep(200);

new Bootstraper().Resolve<IShipper>().WaitForSendLogsTask();
logzioAppender.Close();
LogManager.Shutdown();
Expand Down
2 changes: 0 additions & 2 deletions src/IntegrationTests/NLog/NLogPerfTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ public void Perf()

stopwatch.Elapsed.Should().BeLessOrEqualTo(TimeSpan.FromMilliseconds(100));

Thread.Sleep(logsAmount * 2); //Make sure the logs are added to the queue before we flush everything

new Bootstraper().Resolve<IShipper>().WaitForSendLogsTask();
LogManager.Shutdown();

Expand Down
1 change: 0 additions & 1 deletion src/IntegrationTests/NLog/NLogSanityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public void Sanity()

var logger = LogManager.GetCurrentClassLogger();
logger.Info("Hello");
Thread.Sleep(100);

new Bootstraper().Resolve<IShipper>().WaitForSendLogsTask();
LogManager.Shutdown();
Expand Down
2 changes: 1 addition & 1 deletion src/IntegrationTests/Shipper/ShipperThreadHandlingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void Ship_SendLogsInDelay_CreatesNewThreadCorrectly()

_shipper.Ship(GetLogging(), options);
_shipper.Flush(options);
Thread.Sleep(TimeSpan.FromSeconds(2));

_shipper.Ship(GetLogging(), options);
_shipper.Flush(options);

Expand Down
10 changes: 1 addition & 9 deletions src/UnitTests/Log4net/LogzioAppenderTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Threading;
using log4net.Core;
using log4net.Core;
using Logzio.DotNet.Core.InternalLogger;
using Logzio.DotNet.Core.Shipping;
using Logzio.DotNet.Log4net;
Expand All @@ -26,7 +25,6 @@ public void Append_Appending_CallsShipperWithCorrectValues()
{
_target.DoAppend(GetLoggingEventWithSomeData());
_target.Close();
SleepJustABit();
_shipper.Received().Ship(Arg.Is<LogzioLoggingEvent>(x => (string) x.LogData["domain"] == "Such domain"),
Arg.Any<ShipperOptions>());
}
Expand All @@ -37,7 +35,6 @@ public void Append_AppendingWithCustomFields_CallsShipperWithCorrectValues()
_target.AddCustomField(new LogzioAppenderCustomField { Key = "DatKey", Value = "DatVal"});
_target.DoAppend(GetLoggingEventWithSomeData());
_target.Close();
SleepJustABit();
_shipper.Received().Ship(Arg.Is<LogzioLoggingEvent>(x => (string) x.LogData["DatKey"] == "DatVal"), Arg.Any<ShipperOptions>());
}

Expand All @@ -50,10 +47,5 @@ private LoggingEvent GetLoggingEventWithSomeData()
Message = "That's a message alright"
});
}

private void SleepJustABit()
{
Thread.Sleep(50);
}
}
}
2 changes: 1 addition & 1 deletion src/UnitTests/Shipping/ShipperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void Ship_BufferTimeoutReached_LogWasSent()

_bulkSender.DidNotReceiveWithAnyArgs().Send(Arg.Any<ICollection<LogzioLoggingEvent>>(), Arg.Any<BulkSenderOptions>());

Thread.Sleep(TimeSpan.FromMilliseconds(30));
Thread.Sleep(TimeSpan.FromMilliseconds(30)); //wait for the actual timeout
_bulkSender.Received().Send(Arg.Is<ICollection<LogzioLoggingEvent>>(x => x.Count == 2), Arg.Any<BulkSenderOptions>());
}

Expand Down

0 comments on commit 289d3cc

Please sign in to comment.