Skip to content

Commit

Permalink
PROM-6026 | e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinFalkowski committed Feb 25, 2025
1 parent 12e5ee0 commit c3e9a22
Showing 1 changed file with 64 additions and 0 deletions.
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()
}
}

0 comments on commit c3e9a22

Please sign in to comment.