optimize defaultTestContainer startup
This commit is contained in:
parent
ee5a5301f1
commit
e85be4cc20
1 changed files with 18 additions and 4 deletions
|
@ -12,14 +12,21 @@ val testDockerWithSudo = ("true" != System.getProperty("testdockerwithoutsudo")?
|
|||
|
||||
const val defaultTestContainerName = "provs_test"
|
||||
|
||||
private lateinit var prov: Prov
|
||||
|
||||
fun defaultTestContainer(startMode: ContainerStartMode = ContainerStartMode.USE_RUNNING_ELSE_CREATE): Prov {
|
||||
val image = UbuntuPlusUser()
|
||||
val prov = testLocal()
|
||||
if (!prov.dockerImageExists(image.imageName(), testDockerWithSudo)) {
|
||||
prov.dockerProvideImage(image, sudo = testDockerWithSudo)
|
||||
if (!::prov.isInitialized) { prov = initDefaultTestContainer(startMode) }
|
||||
return prov
|
||||
}
|
||||
|
||||
return Prov.newInstance(
|
||||
private fun initDefaultTestContainer(startMode: ContainerStartMode): Prov {
|
||||
val image = UbuntuPlusUser()
|
||||
val localProv = testLocal()
|
||||
if (!localProv.dockerImageExists(image.imageName(), testDockerWithSudo)) {
|
||||
localProv.dockerProvideImage(image, sudo = testDockerWithSudo)
|
||||
}
|
||||
|
||||
val containerProv = Prov.newInstance(
|
||||
ContainerUbuntuHostProcessor(
|
||||
defaultTestContainerName,
|
||||
startMode = startMode,
|
||||
|
@ -28,6 +35,13 @@ fun defaultTestContainer(startMode: ContainerStartMode = ContainerStartMode.USE_
|
|||
),
|
||||
progressType = ProgressType.NONE
|
||||
)
|
||||
|
||||
containerProv.sh("""
|
||||
sudo apt-get update
|
||||
sudo apt-get upgrade -qqq
|
||||
""".trimIndent())
|
||||
|
||||
return containerProv
|
||||
}
|
||||
|
||||
fun testLocal(): Prov {
|
||||
|
|
Loading…
Reference in a new issue