-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ : add simple integration test for DockerRunner
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
} | ||
} |