diff options
author | Mark Sargent <99003+sarge@users.noreply.github.com> | 2020-05-02 10:24:35 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-02 10:24:35 +1200 |
commit | d0770dbbb3222413bde1013a13e0020c49ba2e30 (patch) | |
tree | 863117a587aeff52cc9e8b24ca570ae222a397c4 | |
parent | a77bd1d8877fbbc8828e464a8c600e5a8aeb9aee (diff) |
expose caddytest timeouts (#3329)
-rw-r--r-- | caddytest/caddytest.go | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/caddytest/caddytest.go b/caddytest/caddytest.go index b0f23d0..48dd3fa 100644 --- a/caddytest/caddytest.go +++ b/caddytest/caddytest.go @@ -34,12 +34,18 @@ type Defaults struct { AdminPort int // Certificates we expect to be loaded before attempting to run the tests Certifcates []string + // TestRequestTimeout is the time to wait for a http request to + TestRequestTimeout time.Duration + // LoadRequestTimeout is the time to wait for the config to be loaded against the caddy server + LoadRequestTimeout time.Duration } // Default testing values var Default = Defaults{ - AdminPort: 2019, - Certifcates: []string{"/caddy.localhost.crt", "/caddy.localhost.key"}, + AdminPort: 2019, + Certifcates: []string{"/caddy.localhost.crt", "/caddy.localhost.key"}, + TestRequestTimeout: 5 * time.Second, + LoadRequestTimeout: 5 * time.Second, } var ( @@ -65,7 +71,7 @@ func NewTester(t *testing.T) *Tester { Client: &http.Client{ Transport: CreateTestingTransport(), Jar: jar, - Timeout: 5 * time.Second, + Timeout: Default.TestRequestTimeout, }, t: t, } @@ -125,7 +131,7 @@ func (tc *Tester) initServer(rawConfig string, configType string) error { rawConfig = prependCaddyFilePath(rawConfig) client := &http.Client{ - Timeout: time.Second * 2, + Timeout: Default.LoadRequestTimeout, } start := time.Now() req, err := http.NewRequest("POST", fmt.Sprintf("http://localhost:%d/load", Default.AdminPort), strings.NewReader(rawConfig)) @@ -209,7 +215,7 @@ func validateTestPrerequisites() error { func isCaddyAdminRunning() error { // assert that caddy is running client := &http.Client{ - Timeout: time.Second * 2, + Timeout: Default.LoadRequestTimeout, } _, err := client.Get(fmt.Sprintf("http://localhost:%d/config/", Default.AdminPort)) if err != nil { |