Skip to content
Browse files

All unit tests pass

  • Loading branch information...
1 parent 5b18181 commit e6ed58786a4db7efaaede2b6f63cacde46aab797 Nick Kallen committed Jan 11, 2011
View
4 finagle-core/src/main/scala/com/twitter/finagle/builder/ClientBuilder.scala
@@ -181,7 +181,9 @@ case class ClientBuilder(
}
private def timeout(timeout: Duration)(broker: Broker) =
- new TimeoutBroker(broker, timeout)
+ if (timeout == Duration.MaxValue)
+ broker
+ else new TimeoutBroker(broker, timeout)
private def retrying(broker: Broker) =
(_retries, _initialBackoff, _backoffMultiplier) match {
View
3 finagle-core/src/main/scala/com/twitter/finagle/stats/TimeWindowedStatsRepository.scala
@@ -16,10 +16,9 @@ class TimeWindowedStatsRepository(numIntervals: Int, interval: Duration, timer:
extends StatsRepository
{
@volatile private[this] var position = 0
- private[this] def repositories = new Array[StatsRepository](numIntervals)
+ private[this] def repositories = Array.fill(numIntervals)(new SimpleStatsRepository)
private[this] def currentRepository = repositories(position % numIntervals)
- repositories(0) = new SimpleStatsRepository
timer.schedule(interval.fromNow, interval) {
repositories((position + 1) % numIntervals) = new SimpleStatsRepository
position += 1
View
38 finagle-core/src/test/scala/com/twitter/finagle/channel/LoadedBrokerSpec.scala
@@ -73,14 +73,14 @@ object LoadedBrokerSpec extends Specification with Mockito {
val underlying = new FakeLoadedBroker
- val statsRepository = mock[StatsRepository]
- val broker = new FailureAccruingLoadedBroker(underlying, statsRepository)
+ val statsRepository = smartMock[StatsRepository]
- val successSample = mock[ReadableCounter]
- val failureSample = mock[ReadableCounter]
+ val successStat = mock[ReadableCounter]
+ val failureStat = mock[ReadableCounter]
- statsRepository.counter("success" -> "broker") returns successSample
- statsRepository.counter("failure" -> "broker") returns failureSample
+ statsRepository.counter("success" -> "broker") returns successStat
+ statsRepository.counter("failure" -> "broker") returns failureStat
+ val broker = new FailureAccruingLoadedBroker(underlying, statsRepository)
"account for success" in {
val e = mock[Object]
@@ -90,11 +90,11 @@ object LoadedBrokerSpec extends Specification with Mockito {
broker(e) must be_==(f)
- there was no(successSample).incr()
- there was no(failureSample).incr()
+ there was no(successStat).incr()
+ there was no(failureStat).incr()
f() = Return("yipee!")
- there was one(successSample).incr()
+ there was one(successStat).incr()
}
"account for failure" in {
@@ -106,8 +106,8 @@ object LoadedBrokerSpec extends Specification with Mockito {
f() = Throw(new Exception("doh."))
- there was no(successSample).incr()
- there was one(failureSample).incr()
+ there was no(successStat).incr()
+ there was one(failureStat).incr()
}
"take into account failures" in {
@@ -118,27 +118,27 @@ object LoadedBrokerSpec extends Specification with Mockito {
broker(e) must be_==(f)
f() = Return("yipee!")
- there was no(failureSample).incr()
- there was one(successSample).incr()
+ there was no(failureStat).incr()
+ there was one(successStat).incr()
}
"not modify weights for a healhty client" in {
- successSample.sum returns 1
- failureSample.sum returns 0
+ successStat.sum returns 1
+ failureStat.sum returns 0
underlying.theWeight = 1.0f
broker.weight must be_==(1.0f)
}
"adjust weights for an unhealthy broker" in {
- successSample.sum returns 1
- failureSample.sum returns 1
+ successStat.sum returns 1
+ failureStat.sum returns 1
underlying.theWeight = 1.0f
broker.weight must be_==(0.5f)
}
"become unavailable when the success rate is 0" in {
- successSample.sum returns 0
- failureSample.sum returns 1
+ successStat.sum returns 0
+ failureStat.sum returns 1
broker.isAvailable must beFalse
}
}

0 comments on commit e6ed587

Please sign in to comment.
Something went wrong with that request. Please try again.