Skip to content

Commit

Permalink
Added testcontainers dependency and configured simple coturn server (F…
Browse files Browse the repository at this point in the history
  • Loading branch information
antonkosse authored Dec 4, 2023
1 parent ee1d292 commit ab191e8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 2 additions & 0 deletions kia-lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ dependencies {
testImplementation("io.kotest:kotest-runner-junit5:5.6.2")
testImplementation("io.kotest:kotest-assertions-core:5.6.2")
testImplementation("org.awaitility:awaitility:4.2.0")
testImplementation("org.testcontainers:testcontainers:1.18.3")
testImplementation("org.testcontainers:junit-jupiter:1.18.3")

testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation("io.mockk:mockk:1.13.7")
Expand Down
27 changes: 26 additions & 1 deletion kia-lib/src/test/kotlin/com/faforever/ice/IceAdapterIT.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,28 @@ import com.faforever.ice.gpgnet.GpgnetMessage
import com.faforever.ice.ice4j.CandidatesMessage
import com.faforever.ice.peering.CoturnServer
import org.junit.jupiter.api.Assertions.assertArrayEquals
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.testcontainers.containers.GenericContainer
import org.testcontainers.junit.jupiter.Container
import org.testcontainers.junit.jupiter.Testcontainers
import org.testcontainers.utility.DockerImageName

@Testcontainers
class IceAdapterIT {
companion object {
private const val DOCKER_IMAGE_NAME: String = "coturn/coturn";
private const val COTURN_SERVER_HOSTNAME: String = "test";

@Container
val coturnServerContainer: GenericContainer<Nothing> =
GenericContainer<Nothing>(DockerImageName.parse(DOCKER_IMAGE_NAME)).apply {
withCreateContainerCmdModifier { it.withHostName(COTURN_SERVER_HOSTNAME) }
withAccessToHost(true)
}
}

class CandidatesTestForwarder {
lateinit var adapter1: IceAdapter
lateinit var adapter2: IceAdapter
Expand All @@ -20,12 +39,18 @@ class IceAdapterIT {
adapter1.receiveIceCandidates(2, candidatesMessage)
}

@BeforeEach
fun testEnv() {
assertTrue(coturnServerContainer.isRunning)
}

@Test
fun `2 ice adapters should exchange a message`() {
val data = "hello world".encodeToByteArray()

val candidatesTestForwarder = CandidatesTestForwarder()
val coturnServers: List<CoturnServer> = listOf(CoturnServer("stun.l.google.com", 19302))
// all ports are open
val coturnServers: List<CoturnServer> = listOf(CoturnServer(coturnServerContainer.host, 19302))

val adapter1 = IceAdapter(
iceOptions = IceOptions(
Expand Down

0 comments on commit ab191e8

Please sign in to comment.