Skip to content

Commit

Permalink
Adding keep-running flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Hinderberger committed Jul 3, 2024
1 parent e110c58 commit a8f24fe
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ This starts the command with the following default settings:

- `stop-on-fail`: Stop execution of later test suites if a test suite fails

### Keep running

- `keep-running`: Wait for a keyboard interrupt after each test suite invocation.
This can be useful for keeping the HTTP / SMTP server for manual inspection.

### Configure logging

Per default request and response of a request will be logged on test failure. If you want to see more information you
Expand Down
17 changes: 17 additions & 0 deletions api_testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"
"net/url"
"os"
"os/signal"
"path/filepath"
"strconv"
"sync"
Expand Down Expand Up @@ -230,6 +231,22 @@ func (ats *Suite) Run() bool {
}
}

if keepRunning { // flag defined in main.go
logrus.Info("Waiting until a keyboard interrupt (usually CTRL+C) is received...")

if ats.HttpServer != nil {
logrus.Info("HTTP Server URL:", ats.HttpServer.Addr)
}
if ats.SmtpServer != nil {
logrus.Info("SMTP Server URL:", ats.SmtpServer.Addr)
}

sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt)

<-sigChan
}

return success
}

Expand Down
12 changes: 8 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import (
)

var (
reportFormat, reportFile, serverURL, httpServerReplaceHost string
logNetwork, logDatastore, logVerbose, logTimeStamp, logShort, logCurl, stopOnFail bool
rootDirectorys, singleTests []string
limitRequest, limitResponse, reportStatsGroups uint
reportFormat, reportFile, serverURL, httpServerReplaceHost string
keepRunning, logNetwork, logDatastore, logVerbose, logTimeStamp, logShort, logCurl, stopOnFail bool
rootDirectorys, singleTests []string
limitRequest, limitResponse, reportStatsGroups uint
// set via -ldflags during build
buildCommit, buildTime, buildVersion string
)
Expand Down Expand Up @@ -85,6 +85,10 @@ func init() {
&logCurl, "curl-bash", false,
"Log network output as bash curl command")

testCMD.PersistentFlags().BoolVar(
&keepRunning, "keep-running", false,
"Before returning from each test suite, prompt for a keyboard interrupt")

testCMD.PersistentFlags().BoolVar(
&stopOnFail, "stop-on-fail", false,
"Stop execution of later test suites if a test suite fails")
Expand Down

0 comments on commit a8f24fe

Please sign in to comment.