mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-23 02:14:56 +08:00
expose caddytest timeouts (#3329)
This commit is contained in:
parent
a77bd1d887
commit
d0770dbbb3
|
@ -34,12 +34,18 @@ type Defaults struct {
|
||||||
AdminPort int
|
AdminPort int
|
||||||
// Certificates we expect to be loaded before attempting to run the tests
|
// Certificates we expect to be loaded before attempting to run the tests
|
||||||
Certifcates []string
|
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
|
// Default testing values
|
||||||
var Default = Defaults{
|
var Default = Defaults{
|
||||||
AdminPort: 2019,
|
AdminPort: 2019,
|
||||||
Certifcates: []string{"/caddy.localhost.crt", "/caddy.localhost.key"},
|
Certifcates: []string{"/caddy.localhost.crt", "/caddy.localhost.key"},
|
||||||
|
TestRequestTimeout: 5 * time.Second,
|
||||||
|
LoadRequestTimeout: 5 * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -65,7 +71,7 @@ func NewTester(t *testing.T) *Tester {
|
||||||
Client: &http.Client{
|
Client: &http.Client{
|
||||||
Transport: CreateTestingTransport(),
|
Transport: CreateTestingTransport(),
|
||||||
Jar: jar,
|
Jar: jar,
|
||||||
Timeout: 5 * time.Second,
|
Timeout: Default.TestRequestTimeout,
|
||||||
},
|
},
|
||||||
t: t,
|
t: t,
|
||||||
}
|
}
|
||||||
|
@ -125,7 +131,7 @@ func (tc *Tester) initServer(rawConfig string, configType string) error {
|
||||||
|
|
||||||
rawConfig = prependCaddyFilePath(rawConfig)
|
rawConfig = prependCaddyFilePath(rawConfig)
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Timeout: time.Second * 2,
|
Timeout: Default.LoadRequestTimeout,
|
||||||
}
|
}
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
req, err := http.NewRequest("POST", fmt.Sprintf("http://localhost:%d/load", Default.AdminPort), strings.NewReader(rawConfig))
|
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 {
|
func isCaddyAdminRunning() error {
|
||||||
// assert that caddy is running
|
// assert that caddy is running
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Timeout: time.Second * 2,
|
Timeout: Default.LoadRequestTimeout,
|
||||||
}
|
}
|
||||||
_, err := client.Get(fmt.Sprintf("http://localhost:%d/config/", Default.AdminPort))
|
_, err := client.Get(fmt.Sprintf("http://localhost:%d/config/", Default.AdminPort))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user