Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
expose caddytest timeouts (#3329)
Mark Sargent committed
May 2, 2020 at 10:24 UTC
d0770dbbb3222413bde1013a13e0020c49ba2e30
1 file changed
+11
-5
caddytest/caddytest.go
+11
-5
@@ -34,12 +34,18 @@ type Defaults struct {
34
AdminPort int
35
// Certificates we expect to be loaded before attempting to run the tests
36
Certifcates []string
37
+ // TestRequestTimeout is the time to wait for a http request to
38
+ TestRequestTimeout time.Duration
39
+ // LoadRequestTimeout is the time to wait for the config to be loaded against the caddy server
40
+ LoadRequestTimeout time.Duration
41
}
42
43
// Default testing values
44
var Default = Defaults{
41
- AdminPort: 2019,
42
- Certifcates: []string{"/caddy.localhost.crt", "/caddy.localhost.key"},
45
+ AdminPort: 2019,
46
+ Certifcates: []string{"/caddy.localhost.crt", "/caddy.localhost.key"},
47
+ TestRequestTimeout: 5 * time.Second,
48
+ LoadRequestTimeout: 5 * time.Second,
49
}
50
51
var (
@@ -65,7 +71,7 @@ func NewTester(t *testing.T) *Tester {
71
Client: &http.Client{
72
Transport: CreateTestingTransport(),
73
Jar: jar,
68
- Timeout: 5 * time.Second,
74
+ Timeout: Default.TestRequestTimeout,
75
},
76
t: t,
77
}
@@ -125,7 +131,7 @@ func (tc *Tester) initServer(rawConfig string, configType string) error {
131
132
rawConfig = prependCaddyFilePath(rawConfig)
133
client := &http.Client{
128
- Timeout: time.Second * 2,
134
+ Timeout: Default.LoadRequestTimeout,
135
}
136
start := time.Now()
137
req, err := http.NewRequest("POST", fmt.Sprintf("http://localhost:%d/load", Default.AdminPort), strings.NewReader(rawConfig))
@@ -209,7 +215,7 @@ func validateTestPrerequisites() error {
215
func isCaddyAdminRunning() error {
216
// assert that caddy is running
217
client := &http.Client{
212
- Timeout: time.Second * 2,
218
+ Timeout: Default.LoadRequestTimeout,
219
}
220
_, err := client.Get(fmt.Sprintf("http://localhost:%d/config/", Default.AdminPort))
221
if err != nil {