added a test for wwctl node add

Signed-off-by: Christian Goll <cgoll@suse.de>
This commit is contained in:
Christian Goll
2023-03-07 08:58:29 +01:00
parent a422a1617c
commit 3367b67b9f
8 changed files with 177 additions and 5 deletions

View File

@@ -23,6 +23,23 @@ const (
var loginit bool
// allow to run without daemon for tests
var nodaemon bool
func init() {
nodaemon = false
}
// run without daemon
func SetNoDaemon() {
nodaemon = true
}
// run with daemon
func SetDaemon() {
nodaemon = false
}
func DaemonFormatter(logLevel int, rec *wwlog.LogRecord) string {
return "[" + rec.Time.Format(time.UnixDate) + "] " + wwlog.DefaultFormatter(logLevel, rec)
}
@@ -66,6 +83,10 @@ func DaemonInitLogging() error {
}
func DaemonStart() error {
if nodaemon {
return nil
}
if os.Getenv("WAREWULFD_BACKGROUND") == "1" {
err := RunServer()
if err != nil {
@@ -116,6 +137,10 @@ func DaemonStart() error {
}
func DaemonStatus() error {
if nodaemon {
return nil
}
if !util.IsFile(WAREWULFD_PIDFILE) {
return errors.New("Warewulf server is not running")
}
@@ -142,6 +167,9 @@ func DaemonStatus() error {
}
func DaemonReload() error {
if nodaemon {
return nil
}
if !util.IsFile(WAREWULFD_PIDFILE) {
return errors.New("Warewulf server is not running")
}