feat: support setting global testcase timeout and step timeout

This commit is contained in:
debugtalk
2022-06-26 11:30:56 +08:00
parent b8d7fd375c
commit 0a9332abf3
5 changed files with 101 additions and 10 deletions
+13
View File
@@ -143,6 +143,13 @@ func (r *HRPRunner) SetProxyUrl(proxyUrl string) *HRPRunner {
return r
}
// SetTimeout configures global timeout in seconds.
func (r *HRPRunner) SetTimeout(timeout time.Duration) *HRPRunner {
log.Info().Float64("timeout(seconds)", timeout.Seconds()).Msg("[init] SetTimeout")
r.httpClient.Timeout = timeout
return r
}
// SetSaveTests configures whether to save summary of tests.
func (r *HRPRunner) SetSaveTests(saveTests bool) *HRPRunner {
log.Info().Bool("saveTests", saveTests).Msg("[init] SetSaveTests")
@@ -260,6 +267,12 @@ func (r *HRPRunner) newCaseRunner(testcase *TestCase) (*testCaseRunner, error) {
return nil, errors.Wrap(err, "parse testcase config failed")
}
// set testcase timeout in seconds
if runner.testCase.Config.Timeout != 0 {
timeout := time.Duration(runner.testCase.Config.Timeout*1000) * time.Millisecond
runner.hrpRunner.SetTimeout(timeout)
}
return runner, nil
}