Documentation
¶
Index ¶
Constants ¶
View Source
const ( ServiceExistCron = "cron" ServiceExistIptables = "iptables" ServiceNonExistUfwx = "ufwx" ServiceNonExistUfwx2 = "ufwx2" )
Variables ¶
View Source
var ServicesErrorValidationTestCases = []ServicesTestCaseWrapper{ { Header: "[Simple error] Restarting services [ufwx, cron, iptables, ufwx2] services and should fail on ufwx and ufwx2 continue on error!", ErrorValidation: []string{ "[Error (UnknownService - #627): Service is unknown in the operating system! Additional : UnknownService. Ref(s) {[Service Name (string): \"ufwx\"], [Applying Action (string): \"restart\"]}]", "[Error (UnknownService - #627): Service is unknown in the operating system! Additional : UnknownService. Ref(s) {[Service Name (string): \"ufwx2\"], [Applying Action (string): \"restart\"]}]", "[Error (ServiceStatusCodeMismatch - #632): service status code or exit code mismatch! ufwx is not in the expected status! - Expect [\"ActiveRunning[1]\"] != [\"UnknownService[5]\"] Actual.]", "[Error (ServiceStatusCodeMismatch - #632): service status code or exit code mismatch! ufwx2 is not in the expected status! - Expect [\"ActiveRunning[1]\"] != [\"UnknownService[5]\"] Actual.]", }, ServicesInstruction: linuxservicecmd.ServicesInstruction{ IsDetailedError: false, IsContinueOnError: true, RestartServicesNames: []string{ ServiceNonExistUfwx, ServiceExistCron, ServiceExistIptables, ServiceNonExistUfwx2, }, Validations: &linuxservicecmd.StateValidateInstructions{ Validations: []linuxservicecmd.StateValidateInstruction{ { ServiceName: ServiceNonExistUfwx, ExpectedExitCode: linuxservicestate.ActiveRunning, }, { ServiceName: ServiceNonExistUfwx2, ExpectedExitCode: linuxservicestate.ActiveRunning, }, }, }, }, }, { Header: "[Simple error] Restarting services [ufwx, cron, iptables, ufwx2] services and should fail on ufw and NOT continue on error!", ErrorValidation: []string{ "[Error (UnknownService - #627): Service is unknown in the operating system! Additional : UnknownService. Ref(s) {[Service Name (string): \"ufwx\"], [Applying Action (string): \"restart\"]}]", }, ServicesInstruction: linuxservicecmd.ServicesInstruction{ IsDetailedError: false, IsContinueOnError: false, RestartServicesNames: []string{ ServiceNonExistUfwx, ServiceExistCron, ServiceExistIptables, ServiceNonExistUfwx2, }, Validations: &linuxservicecmd.StateValidateInstructions{ Validations: []linuxservicecmd.StateValidateInstruction{ { ServiceName: ServiceNonExistUfwx, ExpectedExitCode: linuxservicestate.ActiveRunning, }, { ServiceName: ServiceNonExistUfwx2, ExpectedExitCode: linuxservicestate.ActiveRunning, }, }, }, }, }, }
View Source
var ServicesTestCases = []ServicesTestCaseWrapper{ { Header: "Stop [cron, iptables] service and remains not running and ufwx service is unknown", ServicesInstruction: linuxservicecmd.ServicesInstruction{ StopServicesNames: []string{ServiceExistCron, ServiceExistIptables}, Services: linuxservicecmd.ManyServicesInstructions{}, Validations: &linuxservicecmd.StateValidateInstructions{ Validations: []linuxservicecmd.StateValidateInstruction{ { ServiceName: ServiceExistCron, ExpectedExitCode: linuxservicestate.NotRunning, }, { ServiceName: ServiceExistIptables, ExpectedExitCode: linuxservicestate.NotRunning, }, { ServiceName: ServiceNonExistUfwx, ExpectedExitCode: linuxservicestate.UnknownService, }, }, }, }, }, { Header: "Start [cron, iptables] started and active running!", ServicesInstruction: linuxservicecmd.ServicesInstruction{ StartServicesNames: []string{ServiceExistCron, ServiceExistIptables}, Services: linuxservicecmd.ManyServicesInstructions{}, Validations: &linuxservicecmd.StateValidateInstructions{ Validations: []linuxservicecmd.StateValidateInstruction{ { ServiceName: ServiceExistCron, ExpectedExitCode: linuxservicestate.ActiveRunning, }, { ServiceName: ServiceExistIptables, ExpectedExitCode: linuxservicestate.ActiveRunning, }, }, }, }, }, { Header: "Stop [cron, iptables] service and remains not running", ServicesInstruction: linuxservicecmd.ServicesInstruction{ StopServicesNames: []string{ServiceExistCron, ServiceExistIptables}, Services: linuxservicecmd.ManyServicesInstructions{}, Validations: &linuxservicecmd.StateValidateInstructions{ Validations: []linuxservicecmd.StateValidateInstruction{ { ServiceName: ServiceExistCron, ExpectedExitCode: linuxservicestate.NotRunning, }, { ServiceName: ServiceExistIptables, ExpectedExitCode: linuxservicestate.NotRunning, }, }, }, }, }, { Header: "Restarting [cron, iptables] stopped and started and active running!", ServicesInstruction: linuxservicecmd.ServicesInstruction{ RestartServicesNames: []string{ServiceExistCron, ServiceExistIptables}, Services: linuxservicecmd.ManyServicesInstructions{}, Validations: &linuxservicecmd.StateValidateInstructions{ Validations: []linuxservicecmd.StateValidateInstruction{ { ServiceName: ServiceExistCron, ExpectedExitCode: linuxservicestate.ActiveRunning, }, { ServiceName: ServiceExistIptables, ExpectedExitCode: linuxservicestate.ActiveRunning, }, }, }, }, }, { Header: "Stop and disable [cron, iptables] services!", ServicesInstruction: linuxservicecmd.ServicesInstruction{ IsDetailedError: true, StopServicesNames: []string{ServiceExistCron, ServiceExistIptables}, DisableServicesNames: []string{ServiceExistCron, ServiceExistIptables}, Services: linuxservicecmd.ManyServicesInstructions{}, Validations: &linuxservicecmd.StateValidateInstructions{ Validations: []linuxservicecmd.StateValidateInstruction{ { ServiceName: ServiceExistCron, ExpectedExitCode: linuxservicestate.NotRunning, }, { ServiceName: ServiceExistIptables, ExpectedExitCode: linuxservicestate.NotRunning, }, }, }, }, }, { Header: "enable and start [cron, iptables] services and active running!", ServicesInstruction: linuxservicecmd.ServicesInstruction{ IsDetailedError: true, StopServicesNames: []string{ServiceExistCron, ServiceExistIptables}, EnableServicesNames: []string{ServiceExistCron, ServiceExistIptables}, Services: linuxservicecmd.ManyServicesInstructions{ IsDetailedError: false, IsContinueOnError: false, Instructions: []linuxservicecmd.CoreServicesInstruction{ { IsIgnoreUnknownService: true, Action: servicestate.Start, ServicesNames: []string{ ServiceExistCron, ServiceExistIptables, ServiceNonExistUfwx, }, }, }, }, Validations: &linuxservicecmd.StateValidateInstructions{ Validations: []linuxservicecmd.StateValidateInstruction{ { ServiceName: ServiceExistCron, ExpectedExitCode: linuxservicestate.ActiveRunning, }, { ServiceName: ServiceExistIptables, ExpectedExitCode: linuxservicestate.ActiveRunning, }, }, }, }, }, { Header: "Restarting [cron, iptables] services and active running!", ServicesInstruction: linuxservicecmd.ServicesInstruction{ IsDetailedError: true, IsContinueOnError: true, RestartServicesNames: []string{ ServiceExistCron, ServiceExistIptables, }, Validations: &linuxservicecmd.StateValidateInstructions{ Validations: []linuxservicecmd.StateValidateInstruction{ { ServiceName: ServiceExistCron, ExpectedExitCode: linuxservicestate.ActiveRunning, }, { ServiceName: ServiceExistIptables, ExpectedExitCode: linuxservicestate.ActiveRunning, }, }, }, }, }, }
Functions ¶
This section is empty.
Types ¶
type ServicesTestCaseWrapper ¶
type ServicesTestCaseWrapper struct { Header string linuxservicecmd.ServicesInstruction ErrorValidation []string }
Click to show internal directories.
Click to hide internal directories.