Skip to content

Commit

Permalink
✅ : add simple integration test for DockerRunner
Browse files Browse the repository at this point in the history
  • Loading branch information
juwit committed Dec 19, 2019
1 parent 62ef9b1 commit b728f95
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/test/java/io/codeka/gaia/runner/DockerRunnerIT.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package io.codeka.gaia.runner

import io.codeka.gaia.runner.config.DockerConfig
import io.codeka.gaia.settings.bo.Settings
import io.codeka.gaia.stacks.bo.Job
import io.codeka.gaia.stacks.workflow.JobWorkflow
import org.junit.Assert
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.TestPropertySource

@SpringBootTest(classes = [DockerRunner::class, DockerConfig::class, Settings::class, HttpHijackWorkaround::class])
@EnableConfigurationProperties
@TestPropertySource(properties = ["gaia.dockerDaemonUrl=unix:///var/run/docker.sock"])
class DockerRunnerIT {

@Autowired
private lateinit var dockerRunner: DockerRunner

@Test
fun `runContainerForJob() should work with a simple script`() {
val script = "echo 'Hello World'"

val job = Job()
job.cliVersion = "0.12.18"
val jobWorkflow = JobWorkflow(job)

Assert.assertEquals(0, dockerRunner.runContainerForJob(jobWorkflow, script).toLong())
}

@Test
fun `runContainerForJob() should return the script exit code`() {
val script = "exit 5"

val job = Job()
job.cliVersion = "0.12.18"
val jobWorkflow = JobWorkflow(job)

Assert.assertEquals(5, dockerRunner.runContainerForJob(jobWorkflow, script).toLong())
}
}

0 comments on commit b728f95

Please sign in to comment.