[skip ci] add possibility for monthly reboot as "only" without provisioning server
This commit is contained in:
parent
e6db481ac9
commit
b4c907ec5e
3 changed files with 63 additions and 1 deletions
|
@ -26,6 +26,7 @@ fun Prov.provisionK3sCommand(cli: K3sCliCommand) = task {
|
||||||
} else {
|
} else {
|
||||||
provisionGrafana(cli.onlyModules, grafanaConfigResolved)
|
provisionGrafana(cli.onlyModules, grafanaConfigResolved)
|
||||||
provisionHetznerCSI(cli.onlyModules, hcloudConfigResolved)
|
provisionHetznerCSI(cli.onlyModules, hcloudConfigResolved)
|
||||||
|
scheduleMonthlyReboot(cli.onlyModules)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,3 +107,11 @@ private fun Prov.provisionHetznerCSI(
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Prov.scheduleMonthlyReboot(
|
||||||
|
onlyModules: List<String>?,
|
||||||
|
) = task {
|
||||||
|
if (onlyModules != null && onlyModules.contains(ServerOnlyModule.MONTHLY_REBOOT.name.lowercase())) {
|
||||||
|
scheduleMonthlyReboot()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -2,5 +2,6 @@ package org.domaindrivenarchitecture.provs.server.domain.k3s
|
||||||
|
|
||||||
enum class ServerOnlyModule {
|
enum class ServerOnlyModule {
|
||||||
GRAFANA,
|
GRAFANA,
|
||||||
HETZNER_CSI
|
HETZNER_CSI,
|
||||||
|
MONTHLY_REBOOT,
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
package org.domaindrivenarchitecture.provs.server.application
|
||||||
|
|
||||||
|
import io.mockk.*
|
||||||
|
import org.domaindrivenarchitecture.provs.framework.core.Prov
|
||||||
|
import org.domaindrivenarchitecture.provs.framework.core.ProvResult
|
||||||
|
import org.domaindrivenarchitecture.provs.framework.core.local
|
||||||
|
import org.domaindrivenarchitecture.provs.framework.core.processors.DummyProcessor
|
||||||
|
import org.domaindrivenarchitecture.provs.framework.core.remote
|
||||||
|
import org.domaindrivenarchitecture.provs.framework.ubuntu.cron.infrastructure.scheduleMonthlyReboot
|
||||||
|
import org.domaindrivenarchitecture.provs.server.domain.k3s.provisionK3s
|
||||||
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
|
|
||||||
|
class ApplicationKtTest {
|
||||||
|
@Test
|
||||||
|
fun test_main_with_only_monthly_reboot() {
|
||||||
|
// given
|
||||||
|
val dummyProv = Prov.newInstance(DummyProcessor())
|
||||||
|
|
||||||
|
mockkObject(Prov)
|
||||||
|
every { Prov.newInstance(any(), any(), any(), any()) } returns dummyProv
|
||||||
|
|
||||||
|
mockkStatic(::local)
|
||||||
|
every { local() } returns dummyProv
|
||||||
|
|
||||||
|
mockkStatic(::remote)
|
||||||
|
every { remote(any(), any(), any(), any()) } returns dummyProv
|
||||||
|
|
||||||
|
mockkStatic(Prov::scheduleMonthlyReboot)
|
||||||
|
every { any<Prov>().scheduleMonthlyReboot() } returns ProvResult(
|
||||||
|
true,
|
||||||
|
cmd = "mocked command"
|
||||||
|
)
|
||||||
|
|
||||||
|
mockkStatic(Prov::provisionK3s)
|
||||||
|
every { any<Prov>().provisionK3s(any(), any(), any(), any()) } returns ProvResult(
|
||||||
|
true,
|
||||||
|
cmd = "mocked command"
|
||||||
|
)
|
||||||
|
|
||||||
|
// when
|
||||||
|
main(arrayOf("k3s", "user123:pw@host123.meissa", "-o", "monthly_reboot"))
|
||||||
|
|
||||||
|
//then
|
||||||
|
verify(exactly = 1) { any<Prov>().scheduleMonthlyReboot() }
|
||||||
|
verify(exactly = 0) { any<Prov>().provisionK3s(any(), any(), any(), any()) }
|
||||||
|
|
||||||
|
// cleanup
|
||||||
|
unmockkAll()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue