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"
|
const val defaultTestContainerName = "provs_test"
|
||||||
|
|
||||||
|
private lateinit var prov: Prov
|
||||||
|
|
||||||
fun defaultTestContainer(startMode: ContainerStartMode = ContainerStartMode.USE_RUNNING_ELSE_CREATE): Prov {
|
fun defaultTestContainer(startMode: ContainerStartMode = ContainerStartMode.USE_RUNNING_ELSE_CREATE): Prov {
|
||||||
|
if (!::prov.isInitialized) { prov = initDefaultTestContainer(startMode) }
|
||||||
|
return prov
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initDefaultTestContainer(startMode: ContainerStartMode): Prov {
|
||||||
val image = UbuntuPlusUser()
|
val image = UbuntuPlusUser()
|
||||||
val prov = testLocal()
|
val localProv = testLocal()
|
||||||
if (!prov.dockerImageExists(image.imageName(), testDockerWithSudo)) {
|
if (!localProv.dockerImageExists(image.imageName(), testDockerWithSudo)) {
|
||||||
prov.dockerProvideImage(image, sudo = testDockerWithSudo)
|
localProv.dockerProvideImage(image, sudo = testDockerWithSudo)
|
||||||
}
|
}
|
||||||
|
|
||||||
return Prov.newInstance(
|
val containerProv = Prov.newInstance(
|
||||||
ContainerUbuntuHostProcessor(
|
ContainerUbuntuHostProcessor(
|
||||||
defaultTestContainerName,
|
defaultTestContainerName,
|
||||||
startMode = startMode,
|
startMode = startMode,
|
||||||
|
@ -28,6 +35,13 @@ fun defaultTestContainer(startMode: ContainerStartMode = ContainerStartMode.USE_
|
||||||
),
|
),
|
||||||
progressType = ProgressType.NONE
|
progressType = ProgressType.NONE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
containerProv.sh("""
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get upgrade -qqq
|
||||||
|
""".trimIndent())
|
||||||
|
|
||||||
|
return containerProv
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testLocal(): Prov {
|
fun testLocal(): Prov {
|
||||||
|
|
Loading…
Reference in a new issue