From 981ba4fee551626d05c5133c9ad7d05ceed3f2b1 Mon Sep 17 00:00:00 2001 From: Matthias Raab Date: Wed, 29 Nov 2023 14:27:08 +0100 Subject: [PATCH] fix: move user setting to mail server, add test --- .../icm/docker/utils/AbstractTaskPreparer.kt | 8 ----- .../icm/docker/utils/mail/TaskPreparer.kt | 9 +++++ .../ICMDockerPluginIntegegrationSpec.groovy | 35 +++++++++++++++++-- 3 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/com/intershop/gradle/icm/docker/utils/AbstractTaskPreparer.kt b/src/main/kotlin/com/intershop/gradle/icm/docker/utils/AbstractTaskPreparer.kt index c5b1615..b6c2f8d 100644 --- a/src/main/kotlin/com/intershop/gradle/icm/docker/utils/AbstractTaskPreparer.kt +++ b/src/main/kotlin/com/intershop/gradle/icm/docker/utils/AbstractTaskPreparer.kt @@ -31,8 +31,6 @@ import org.gradle.api.provider.Property import org.gradle.api.provider.Provider import org.gradle.api.tasks.TaskProvider import org.gradle.kotlin.dsl.getByType -import org.gradle.nativeplatform.platform.OperatingSystem -import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform abstract class AbstractTaskPreparer( protected val project: Project, @@ -93,11 +91,5 @@ abstract class AbstractTaskPreparer( task.hostConfig.autoRemove.set(true) task.containerName.set(getContainerName()) - - val os: OperatingSystem = DefaultNativePlatform.getCurrentOperatingSystem() - if(! os.isWindows) { - val uid = com.sun.security.auth.module.UnixSystem().uid - task.user.set(uid.toString()) - } } } diff --git a/src/main/kotlin/com/intershop/gradle/icm/docker/utils/mail/TaskPreparer.kt b/src/main/kotlin/com/intershop/gradle/icm/docker/utils/mail/TaskPreparer.kt index c77b759..2aedd83 100644 --- a/src/main/kotlin/com/intershop/gradle/icm/docker/utils/mail/TaskPreparer.kt +++ b/src/main/kotlin/com/intershop/gradle/icm/docker/utils/mail/TaskPreparer.kt @@ -24,6 +24,8 @@ import com.intershop.gradle.icm.docker.utils.Configuration import org.gradle.api.Project import org.gradle.api.provider.Provider import org.gradle.kotlin.dsl.getByType +import org.gradle.nativeplatform.platform.OperatingSystem +import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform class TaskPreparer(project: Project, networkTask: Provider) : AbstractTaskPreparer(project, networkTask) { @@ -42,6 +44,13 @@ class TaskPreparer(project: Project, project.tasks.register ("start${getExtensionName()}", StartExtraContainer::class.java) { task -> configureContainerTask(task) + + val os: OperatingSystem = DefaultNativePlatform.getCurrentOperatingSystem() + if(! os.isWindows) { + val uid = com.sun.security.auth.module.UnixSystem().uid + task.user.set(uid.toString()) + } + task.description = "Starts an local mail server for testing" task.targetImageId( project.provider { pullTask.get().image.get() } ) diff --git a/src/test/groovy/com/intershop/gradle/icm/docker/ICMDockerPluginIntegegrationSpec.groovy b/src/test/groovy/com/intershop/gradle/icm/docker/ICMDockerPluginIntegegrationSpec.groovy index 566440b..4aa2d0d 100644 --- a/src/test/groovy/com/intershop/gradle/icm/docker/ICMDockerPluginIntegegrationSpec.groovy +++ b/src/test/groovy/com/intershop/gradle/icm/docker/ICMDockerPluginIntegegrationSpec.groovy @@ -279,7 +279,7 @@ class ICMDockerPluginIntegegrationSpec extends AbstractIntegrationGroovySpec { intershop_docker { images { mssqldb = 'mcr.microsoft.com/mssql/server:2019-CU4-ubuntu-16.04' - + mailsrv = 'mailhog/mailhog:latest' solr = 'solr:8.5.2-slim' zookeeper = 'zookeeper:3.6.2' } @@ -875,7 +875,6 @@ class ICMDockerPluginIntegegrationSpec extends AbstractIntegrationGroovySpec { then: result1.task(":startSolr").outcome == SUCCESS - /** when: sleep(30000) @@ -886,7 +885,7 @@ class ICMDockerPluginIntegegrationSpec extends AbstractIntegrationGroovySpec { then: resultTest.task(":cleanUpSolr").outcome == SUCCESS - **/ + when: def result2 = getPreparedGradleRunner() .withArguments("stopZK", "-s", "-i") @@ -909,6 +908,36 @@ class ICMDockerPluginIntegegrationSpec extends AbstractIntegrationGroovySpec { gradleVersion << supportedGradleVersions } + def 'start mail server'() { + prepareDefaultBuildConfig(testProjectDir, settingsFile, buildFile) + + when: + def result1 = getPreparedGradleRunner() + .withArguments("startMailSrv", "-s", "-i") + //.withGradleVersion(gradleVersion) + .withGradleVersion("7.5") + .build() + + then: + result1.task(":startMailSrv").outcome == SUCCESS + file("build/mailoutput").exists() + + + when: + sleep(30000) + + def result2 = getPreparedGradleRunner() + .withArguments("removeMailSrv", "-s", "-i") + .withGradleVersion(gradleVersion) + .build() + + then: + result2.task(":removeMailSrv").outcome == SUCCESS + + where: + gradleVersion << supportedGradleVersions + } + def 'buildImages'() { prepareBuildConfig(testProjectDir, settingsFile, buildFile)