mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +00:00
testservers: return Run method errors correctly
This commit is contained in:
parent
a13599be7e
commit
4860f8732a
@ -113,9 +113,10 @@ func StartTestServer(t Logger, customFlags []string) (result TestServer, err err
|
|||||||
return result, fmt.Errorf("failed to create config from options: %v", err)
|
return result, fmt.Errorf("failed to create config from options: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errCh := make(chan error)
|
||||||
go func(stopCh <-chan struct{}) {
|
go func(stopCh <-chan struct{}) {
|
||||||
if err := app.Run(config.Complete(), stopCh); err != nil {
|
if err := app.Run(config.Complete(), stopCh); err != nil {
|
||||||
t.Errorf("cloud-apiserver failed run: %v", err)
|
errCh <- err
|
||||||
}
|
}
|
||||||
}(stopCh)
|
}(stopCh)
|
||||||
|
|
||||||
@ -125,6 +126,12 @@ func StartTestServer(t Logger, customFlags []string) (result TestServer, err err
|
|||||||
return result, fmt.Errorf("failed to create a client: %v", err)
|
return result, fmt.Errorf("failed to create a client: %v", err)
|
||||||
}
|
}
|
||||||
err = wait.Poll(100*time.Millisecond, 30*time.Second, func() (bool, error) {
|
err = wait.Poll(100*time.Millisecond, 30*time.Second, func() (bool, error) {
|
||||||
|
select {
|
||||||
|
case err := <-errCh:
|
||||||
|
return false, err
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
result := client.CoreV1().RESTClient().Get().AbsPath("/healthz").Do()
|
result := client.CoreV1().RESTClient().Get().AbsPath("/healthz").Do()
|
||||||
status := 0
|
status := 0
|
||||||
result.StatusCode(&status)
|
result.StatusCode(&status)
|
||||||
|
@ -145,9 +145,10 @@ func StartTestServer(t Logger, instanceOptions *TestServerInstanceOptions, custo
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return result, fmt.Errorf("failed to create server chain: %v", err)
|
return result, fmt.Errorf("failed to create server chain: %v", err)
|
||||||
}
|
}
|
||||||
|
errCh := make(chan error)
|
||||||
go func(stopCh <-chan struct{}) {
|
go func(stopCh <-chan struct{}) {
|
||||||
if err := server.PrepareRun().Run(stopCh); err != nil {
|
if err := server.PrepareRun().Run(stopCh); err != nil {
|
||||||
t.Errorf("kube-apiserver failed run: %v", err)
|
errCh <- err
|
||||||
}
|
}
|
||||||
}(stopCh)
|
}(stopCh)
|
||||||
|
|
||||||
@ -158,6 +159,12 @@ func StartTestServer(t Logger, instanceOptions *TestServerInstanceOptions, custo
|
|||||||
return result, fmt.Errorf("failed to create a client: %v", err)
|
return result, fmt.Errorf("failed to create a client: %v", err)
|
||||||
}
|
}
|
||||||
err = wait.Poll(100*time.Millisecond, 30*time.Second, func() (bool, error) {
|
err = wait.Poll(100*time.Millisecond, 30*time.Second, func() (bool, error) {
|
||||||
|
select {
|
||||||
|
case err := <-errCh:
|
||||||
|
return false, err
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
result := client.CoreV1().RESTClient().Get().AbsPath("/healthz").Do()
|
result := client.CoreV1().RESTClient().Get().AbsPath("/healthz").Do()
|
||||||
status := 0
|
status := 0
|
||||||
result.StatusCode(&status)
|
result.StatusCode(&status)
|
||||||
|
@ -114,9 +114,10 @@ func StartTestServer(t Logger, customFlags []string) (result TestServer, err err
|
|||||||
return result, fmt.Errorf("failed to create config from options: %v", err)
|
return result, fmt.Errorf("failed to create config from options: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errCh := make(chan error)
|
||||||
go func(stopCh <-chan struct{}) {
|
go func(stopCh <-chan struct{}) {
|
||||||
if err := app.Run(config.Complete(), stopCh); err != nil {
|
if err := app.Run(config.Complete(), stopCh); err != nil {
|
||||||
t.Errorf("kube-apiserver failed run: %v", err)
|
errCh <- err
|
||||||
}
|
}
|
||||||
}(stopCh)
|
}(stopCh)
|
||||||
|
|
||||||
@ -126,6 +127,12 @@ func StartTestServer(t Logger, customFlags []string) (result TestServer, err err
|
|||||||
return result, fmt.Errorf("failed to create a client: %v", err)
|
return result, fmt.Errorf("failed to create a client: %v", err)
|
||||||
}
|
}
|
||||||
err = wait.Poll(100*time.Millisecond, 30*time.Second, func() (bool, error) {
|
err = wait.Poll(100*time.Millisecond, 30*time.Second, func() (bool, error) {
|
||||||
|
select {
|
||||||
|
case err := <-errCh:
|
||||||
|
return false, err
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
result := client.CoreV1().RESTClient().Get().AbsPath("/healthz").Do()
|
result := client.CoreV1().RESTClient().Get().AbsPath("/healthz").Do()
|
||||||
status := 0
|
status := 0
|
||||||
result.StatusCode(&status)
|
result.StatusCode(&status)
|
||||||
|
@ -150,9 +150,10 @@ func StartTestServer(t Logger, instanceOptions *TestServerInstanceOptions, custo
|
|||||||
return result, fmt.Errorf("failed to create server: %v", err)
|
return result, fmt.Errorf("failed to create server: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errCh := make(chan error)
|
||||||
go func(stopCh <-chan struct{}) {
|
go func(stopCh <-chan struct{}) {
|
||||||
if err := server.GenericAPIServer.PrepareRun().Run(stopCh); err != nil {
|
if err := server.GenericAPIServer.PrepareRun().Run(stopCh); err != nil {
|
||||||
t.Errorf("apiextensions-apiserver failed run: %v", err)
|
errCh <- err
|
||||||
}
|
}
|
||||||
}(stopCh)
|
}(stopCh)
|
||||||
|
|
||||||
@ -163,6 +164,12 @@ func StartTestServer(t Logger, instanceOptions *TestServerInstanceOptions, custo
|
|||||||
return result, fmt.Errorf("failed to create a client: %v", err)
|
return result, fmt.Errorf("failed to create a client: %v", err)
|
||||||
}
|
}
|
||||||
err = wait.Poll(100*time.Millisecond, 30*time.Second, func() (bool, error) {
|
err = wait.Poll(100*time.Millisecond, 30*time.Second, func() (bool, error) {
|
||||||
|
select {
|
||||||
|
case err := <-errCh:
|
||||||
|
return false, err
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
result := client.CoreV1().RESTClient().Get().AbsPath("/healthz").Do()
|
result := client.CoreV1().RESTClient().Get().AbsPath("/healthz").Do()
|
||||||
status := 0
|
status := 0
|
||||||
result.StatusCode(&status)
|
result.StatusCode(&status)
|
||||||
|
Loading…
Reference in New Issue
Block a user