Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: move user setting to mail server, add test #88

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using an internal class will make upgrade much trickier.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe alternatively use System.getProperty("os.name")?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are correct - it is internal and a method with System.getProperty is possible. I asked StackOverflow for an approach that is working on different OSs. This internal API is not the only one and I think they will create also an external API.

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(gradleVersion)
.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
Loading