コード例 #1
0
func TestRestartIfRestartAlways(t *testing.T) {
	hl, sb := FakeHoistLaunchableForDir("successful_scripts_test_hoist_launchable")
	defer CleanupFakeLaunchable(hl, sb)

	// If the launchable is intended to be restarted, the launchable
	// should launch using 'sv restart'
	hl.RestartPolicy_ = runit.RestartPolicyAlways

	sv := runit.NewRecordingSV()
	err := hl.Launch(sb, sv)
	Assert(t).IsNil(err, "Unexpected error when launching")
	Assert(t).AreEqual(sv.(*runit.RecordingSV).LastCommand(), "restart", "Expected 'restart' command to be used for a launchable with RestartPolicyAlways")
}
コード例 #2
0
func TestRestartServiceAndLogAgent(t *testing.T) {
	hl, sb := FakeHoistLaunchableForDir("successful_scripts_test_hoist_launchable")
	defer CleanupFakeLaunchable(hl, sb)
	sv := runit.NewRecordingSV()

	hl.RestartPolicy_ = runit.RestartPolicyAlways
	hl.start(sb, sv)

	commands := sv.(*runit.RecordingSV).Commands
	Assert(t).AreEqual(len(commands), 2, "Expected 2 restart commands to be issued")
	Assert(t).AreEqual(commands[0], "restart", "Expected 2 restart commands to be issued")
	Assert(t).AreEqual(commands[1], "restart", "Expected 2 restart commands to be issued")
}
コード例 #3
0
ファイル: hoist_launchable_test.go プロジェクト: tomzhang/p2
func TestOnceIfRestartNever(t *testing.T) {
	hl, sb := FakeHoistLaunchableForDir("successful_scripts_test_hoist_launchable")
	defer CleanupFakeLaunchable(hl, sb)

	// If the launchable isn't intended to be restarted, the launchable
	// should launch using 'sv once' instead of 'sv restart'
	hl.RestartPolicy = runit.RestartPolicyNever

	sv := runit.NewRecordingSV()
	err := hl.Launch(sb, sv)
	Assert(t).IsNil(err, "Unexpected error when launching")
	Assert(t).AreEqual(sv.(*runit.RecordingSV).LastCommand, "once", "Expected 'once' command to be used for a launchable with RestartPolicyNever")
}