pl.allegro.tech.servicemesh.envoycontrol.StatusRouteTest.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of envoy-control-tests Show documentation
Show all versions of envoy-control-tests Show documentation
Production-ready Control Plane for Service Mesh based on Envoy Proxy.
The newest version!
package pl.allegro.tech.servicemesh.envoycontrol
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.RegisterExtension
import pl.allegro.tech.servicemesh.envoycontrol.assertions.untilAsserted
import pl.allegro.tech.servicemesh.envoycontrol.config.consul.ConsulExtension
import pl.allegro.tech.servicemesh.envoycontrol.config.envoy.EnvoyExtension
import pl.allegro.tech.servicemesh.envoycontrol.config.envoycontrol.EnvoyControlExtension
import pl.allegro.tech.servicemesh.envoycontrol.config.service.EchoServiceExtension
import pl.allegro.tech.servicemesh.envoycontrol.snapshot.EndpointMatch
class StatusRouteTest {
companion object {
@JvmField
@RegisterExtension
val consul = ConsulExtension()
@JvmField
@RegisterExtension
val envoyControl = EnvoyControlExtension(consul, mapOf(
"envoy-control.envoy.snapshot.routes.status.enabled" to true,
"envoy-control.envoy.snapshot.routes.status.endpoints" to mutableListOf(EndpointMatch().also { it.path = "/my-status/" }),
"envoy-control.envoy.snapshot.routes.status.createVirtualCluster" to true
))
@JvmField
@RegisterExtension
val service = EchoServiceExtension()
@JvmField
@RegisterExtension
val envoy = EnvoyExtension(envoyControl, service)
}
@Test
fun `should allow defining custom status prefix`() {
untilAsserted {
// when
val ingressRoot = envoy.ingressOperations.callLocalService(endpoint = "/my-status/abc")
// then
val statusUpstreamOk = envoy.container.admin().statValue(
"vhost.secured_local_service.vcluster.status.upstream_rq_200"
)?.toInt()
assertThat(statusUpstreamOk).isGreaterThan(0)
assertThat(ingressRoot.code).isEqualTo(200)
}
}
}