From 6e389828d05c83e5c93127817ba19dc775bc00a8 Mon Sep 17 00:00:00 2001 From: Kevin Oliver Date: Thu, 17 Sep 2015 18:53:51 +0000 Subject: [PATCH] twitter-server: Fix flaky LoggingHandler test Motivation Due to the recent logging addition via TimerStats, depending on timing this test sometimes sees different output. Solution Make the test more resilient to this sort of behavior. RB_ID=743918 --- .../server/handler/LoggingHandlerTest.scala | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/test/scala/com/twitter/server/handler/LoggingHandlerTest.scala b/src/test/scala/com/twitter/server/handler/LoggingHandlerTest.scala index 5249d0f6..03102d7c 100644 --- a/src/test/scala/com/twitter/server/handler/LoggingHandlerTest.scala +++ b/src/test/scala/com/twitter/server/handler/LoggingHandlerTest.scala @@ -1,16 +1,16 @@ package com.twitter.server.handler -import com.twitter.finagle.httpx.{Request, Response, Status} -import com.twitter.io.Charsets +import com.twitter.finagle.httpx.{Request, Status} import com.twitter.logging.{Level, Logger} -import com.twitter.server.util.HttpUtils._ import com.twitter.util.Await import org.junit.runner.RunWith -import org.scalatest.FunSuite +import org.scalatest.{Matchers, FunSuite} import org.scalatest.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) -class LoggingHandlerTest extends FunSuite { +class LoggingHandlerTest extends FunSuite + with Matchers +{ test("query all loggers") { val handler = new LoggingHandler val loggers = Logger.iterator @@ -61,7 +61,9 @@ class LoggingHandlerTest extends FunSuite { val res = Await.result(handler(req)) assert(res.status === Status.Ok) val text = res.contentString - assert(text === "root OFF\nl0 ALL\nl1 DEBUG") + text should include ("root OFF") + text should include ("l0 ALL") + text should include ("l1 DEBUG") } } }