-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
12e5ee0
commit c3e9a22
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
...n/kotlin/pl/allegro/tech/servicemesh/envoycontrol/routing/CrossEnvTrafficDetectionTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package pl.allegro.tech.servicemesh.envoycontrol.routing | ||
|
||
import org.assertj.core.api.Assertions | ||
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.isFrom | ||
import pl.allegro.tech.servicemesh.envoycontrol.assertions.isOk | ||
import pl.allegro.tech.servicemesh.envoycontrol.config.RandomConfigFile | ||
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 | ||
|
||
class CrossEnvTrafficDetectionTest { | ||
|
||
companion object { | ||
|
||
private val properties = mapOf( | ||
"envoy-control.envoy.snapshot.routing.service-tags.enabled" to true, | ||
) | ||
|
||
@JvmField | ||
@RegisterExtension | ||
val consul = ConsulExtension() | ||
|
||
@JvmField | ||
@RegisterExtension | ||
val envoyControl = EnvoyControlExtension(consul, properties) | ||
|
||
@JvmField | ||
@RegisterExtension | ||
val echoTheSameEnv = EchoServiceExtension() | ||
|
||
@JvmField | ||
@RegisterExtension | ||
val echoDifferentEnv = EchoServiceExtension() | ||
|
||
@JvmField | ||
@RegisterExtension | ||
val envoy = EnvoyExtension(envoyControl) | ||
.also { it.container.withEnv("DEFAULT_SERVICE_TAG_PREFERENCE", "lorem|ipsum|dolom") } | ||
} | ||
|
||
@Test | ||
fun `should log cross env traffic`() { | ||
// given | ||
consul.server.operations.registerService( | ||
name = "echo", | ||
extension = echoDifferentEnv, | ||
tags = listOf("diff-1", "diff-2") | ||
) | ||
envoy.waitForClusterEndpointHealthy("echo", echoDifferentEnv.container().ipAddress()) | ||
envoy.container.logRecorder.recordLogs { it.contains("CROSS ENV") } | ||
|
||
// when | ||
val response = envoy.egressOperations.callService(service = "echo") | ||
val crossEnvLogs = envoy.container.logRecorder.getRecordedLogs() | ||
|
||
// then | ||
assertThat(response).isOk().isFrom(echoDifferentEnv) | ||
assertThat(crossEnvLogs).isNotEmpty() | ||
} | ||
} |