|
1 | 1 | package com.twitter.finagle.integration
|
2 | 2 |
|
| 3 | +import com.twitter.finagle.service.Retries |
3 | 4 | import com.twitter.finagle.service.StatsFilter
|
4 |
| -import com.twitter.finagle.{Http, Memcached, Mysql, Redis, Thrift, ThriftMux} |
| 5 | +import com.twitter.finagle.Http |
| 6 | +import com.twitter.finagle.Memcached |
| 7 | +import com.twitter.finagle.Mysql |
| 8 | +import com.twitter.finagle.PostgreSql |
| 9 | +import com.twitter.finagle.Redis |
| 10 | +import com.twitter.finagle.Thrift |
| 11 | +import com.twitter.finagle.ThriftMux |
| 12 | +import com.twitter.finagle.client.StackBasedClient |
5 | 13 | import org.scalatest.funsuite.AnyFunSuite
|
6 | 14 |
|
7 | 15 | class StackClientTest extends AnyFunSuite {
|
@@ -44,4 +52,23 @@ class StackClientTest extends AnyFunSuite {
|
44 | 52 | assert(!c.stack.contains(role))
|
45 | 53 | }
|
46 | 54 |
|
| 55 | + def testThatRetryBudgetIsShared(newClient: () => StackBasedClient[_, _], protocol: String): Unit = |
| 56 | + test(s"$protocol clients shipped with retry-budget included") { |
| 57 | + // every new clients gets new retry budget |
| 58 | + assert( |
| 59 | + newClient().params[Retries.Budget].retryBudget ne newClient() |
| 60 | + .params[Retries.Budget].retryBudget) |
| 61 | + |
| 62 | + // single client shares the retry budget between it's modules |
| 63 | + val client = newClient() |
| 64 | + assert(client.params[Retries.Budget].retryBudget eq client.params[Retries.Budget].retryBudget) |
| 65 | + } |
| 66 | + |
| 67 | + testThatRetryBudgetIsShared(Thrift.client _, "Thrift") |
| 68 | + testThatRetryBudgetIsShared(ThriftMux.client _, "ThriftMux") |
| 69 | + testThatRetryBudgetIsShared(Http.client _, "Http") |
| 70 | + testThatRetryBudgetIsShared(Memcached.client _, "Memcached") |
| 71 | + testThatRetryBudgetIsShared(Redis.client _, "Redis") |
| 72 | + testThatRetryBudgetIsShared(Mysql.client _, "Mysql") |
| 73 | + testThatRetryBudgetIsShared(PostgreSql.client _, "PostgreSql") |
47 | 74 | }
|
0 commit comments