Skip to content
Snippets Groups Projects
Verified Commit e6b4118d authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Cleanup ci containers

parent 4f7d34f7
Branches
No related tags found
No related merge requests found
Pipeline #585 failed
Showing
with 101 additions and 20 deletions
plugins {
kotlin("jvm")
}
dependencies {
implementation(kotlin("stdlib"))
val testContainersVersion: String by project.extra
api("org.testcontainers", "testcontainers", testContainersVersion)
api("org.testcontainers", "junit-jupiter", testContainersVersion)
}
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2021 Janne Mareike Koschinski
* Copyright (c) 2021 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.ci_containers
import org.junit.jupiter.api.extension.ExtendWith
@MustBeDocumented
@Target(AnnotationTarget.CLASS, AnnotationTarget.ANNOTATION_CLASS)
@Retention(AnnotationRetention.RUNTIME)
@ExtendWith(CiContainersExtension::class)
annotation class CiContainers
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2021 Janne Mareike Koschinski
* Copyright (c) 2021 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.ci_containers
import org.junit.jupiter.api.extension.AfterEachCallback
import org.junit.jupiter.api.extension.BeforeEachCallback
import org.junit.jupiter.api.extension.ExtensionContext
class CiContainersExtension : BeforeEachCallback, AfterEachCallback {
private fun getContainers(context: ExtensionContext?): List<ProvidedContainer> {
val containers = mutableListOf<ProvidedContainer>()
context?.requiredTestInstances?.allInstances?.forEach { instance ->
instance.javaClass.declaredFields.map { field ->
if (field.type == ProvidedContainer::class.java) {
field.trySetAccessible()
containers.add(field.get(instance) as ProvidedContainer)
}
}
}
return containers
}
override fun beforeEach(context: ExtensionContext?) {
getContainers(context).forEach(ProvidedContainer::start)
}
override fun afterEach(context: ExtensionContext?) {
getContainers(context).forEach(ProvidedContainer::stop)
}
}
......@@ -17,7 +17,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.libquassel.testutil
package de.kuschku.ci_containers
import java.net.InetSocketAddress
......
......@@ -17,7 +17,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.libquassel.testutil
package de.kuschku.ci_containers
import java.net.InetSocketAddress
......
......@@ -17,7 +17,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.libquassel.testutil
package de.kuschku.ci_containers
import org.testcontainers.containers.GenericContainer
import java.net.InetSocketAddress
......
......@@ -17,7 +17,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.libquassel.testutil
package de.kuschku.ci_containers
import java.net.InetSocketAddress
......
......@@ -31,8 +31,7 @@ dependencies {
testRuntimeOnly("org.junit.jupiter", "junit-jupiter-engine", junit5Version)
val hamcrestVersion: String by project.extra
testImplementation("org.hamcrest", "hamcrest-library", hamcrestVersion)
val testContainersVersion: String by project.extra
testImplementation("org.testcontainers", "testcontainers", testContainersVersion)
testImplementation("org.testcontainers", "junit-jupiter", testContainersVersion)
testImplementation(project(":ci-containers"))
testImplementation("org.slf4j", "slf4j-simple", "1.7.30")
}
......@@ -20,6 +20,8 @@
package de.kuschku.libquassel
import de.kuschku.bitflags.of
import de.kuschku.ci_containers.CiContainers
import de.kuschku.ci_containers.CiContainersExtension
import de.kuschku.libquassel.protocol.connection.*
import de.kuschku.libquassel.protocol.features.FeatureSet
import de.kuschku.libquassel.protocol.io.ChainedByteBuffer
......@@ -34,13 +36,13 @@ import de.kuschku.libquassel.testutil.quasselContainer
import de.kuschku.quasseldroid.protocol.io.CoroutineChannel
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.runBlocking
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import java.nio.ByteBuffer
import javax.net.ssl.SSLContext
@ExperimentalCoroutinesApi
@CiContainers
class EndToEndTest {
private val quassel = quasselContainer()
......@@ -53,16 +55,6 @@ class EndToEndTest {
private val sendBuffer = ChainedByteBuffer(direct = true)
private val channel = CoroutineChannel()
@BeforeEach
fun start() {
quassel.start()
}
@AfterEach
fun stop() {
quassel.stop()
}
@Test
fun testConnect() = runBlocking {
channel.connect(quassel.address)
......
......@@ -19,6 +19,9 @@
package de.kuschku.libquassel.testutil
import de.kuschku.ci_containers.TestContainersProvidedContainer
import de.kuschku.ci_containers.providedContainer
fun quasselContainer() = providedContainer("QUASSEL_CONTAINER") {
TestContainersProvidedContainer(
QuasselCoreContainer(),
......
......@@ -25,5 +25,6 @@ include(
":bitflags",
":protocol",
":coverage-annotations",
":libquassel"
":libquassel",
":ci-containers"
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment