Skip to content

Commit

Permalink
fix: move user setting to mail server, add test
Browse files Browse the repository at this point in the history
  • Loading branch information
m-raab committed Nov 30, 2023
1 parent 684dbfd commit 981ba4f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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())
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<PrepareNetwork>) : AbstractTaskPreparer(project, networkTask) {
Expand All @@ -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() } )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down Expand Up @@ -875,7 +875,6 @@ class ICMDockerPluginIntegegrationSpec extends AbstractIntegrationGroovySpec {
then:
result1.task(":startSolr").outcome == SUCCESS

/**
when:
sleep(30000)

Expand All @@ -886,7 +885,7 @@ class ICMDockerPluginIntegegrationSpec extends AbstractIntegrationGroovySpec {

then:
resultTest.task(":cleanUpSolr").outcome == SUCCESS
**/

when:
def result2 = getPreparedGradleRunner()
.withArguments("stopZK", "-s", "-i")
Expand All @@ -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)

Expand Down

0 comments on commit 981ba4f

Please sign in to comment.