add aggregation integration test

Kubernetes-commit: 5cfe26dece13c77bd17fd10e47d2c00bf5da9b6d
This commit is contained in:
deads2k 2017-02-23 16:34:09 -05:00 committed by Kubernetes Publisher
parent 51e6651c84
commit 9c5ae42f4d
2 changed files with 114 additions and 106 deletions

View File

@ -189,16 +189,16 @@ func (s *GenericAPIServer) PrepareRun() preparedGenericAPIServer {
// Run spawns the http servers (secure and insecure). It only returns if stopCh is closed // Run spawns the http servers (secure and insecure). It only returns if stopCh is closed
// or one of the ports cannot be listened on initially. // or one of the ports cannot be listened on initially.
func (s preparedGenericAPIServer) Run(stopCh <-chan struct{}) { func (s preparedGenericAPIServer) Run(stopCh <-chan struct{}) error {
if s.SecureServingInfo != nil && s.Handler != nil { if s.SecureServingInfo != nil && s.Handler != nil {
if err := s.serveSecurely(stopCh); err != nil { if err := s.serveSecurely(stopCh); err != nil {
glog.Fatal(err) return err
} }
} }
if s.InsecureServingInfo != nil && s.InsecureHandler != nil { if s.InsecureServingInfo != nil && s.InsecureHandler != nil {
if err := s.serveInsecurely(stopCh); err != nil { if err := s.serveInsecurely(stopCh); err != nil {
glog.Fatal(err) return err
} }
} }
@ -210,6 +210,7 @@ func (s preparedGenericAPIServer) Run(stopCh <-chan struct{}) {
} }
<-stopCh <-stopCh
return nil
} }
// EffectiveSecurePort returns the secure port we bound to. // EffectiveSecurePort returns the secure port we bound to.

View File

@ -448,6 +448,8 @@ NextTest:
} }
stopCh := make(chan struct{}) stopCh := make(chan struct{})
func() {
defer close(stopCh)
// launch server // launch server
config := setUp(t) config := setUp(t)
@ -472,14 +474,14 @@ NextTest:
config.LoopbackClientConfig = &restclient.Config{} config.LoopbackClientConfig = &restclient.Config{}
if err := secureOptions.ApplyTo(&config); err != nil { if err := secureOptions.ApplyTo(&config); err != nil {
t.Errorf("%q - failed applying the SecureServingOptions: %v", title, err) t.Errorf("%q - failed applying the SecureServingOptions: %v", title, err)
continue NextTest return
} }
config.InsecureServingInfo = nil config.InsecureServingInfo = nil
s, err := config.Complete().New() s, err := config.Complete().New()
if err != nil { if err != nil {
t.Errorf("%q - failed creating the server: %v", title, err) t.Errorf("%q - failed creating the server: %v", title, err)
continue NextTest return
} }
// patch in a 0-port to enable auto port allocation // patch in a 0-port to enable auto port allocation
@ -492,7 +494,11 @@ NextTest:
return nil return nil
}) })
preparedServer := s.PrepareRun() preparedServer := s.PrepareRun()
go preparedServer.Run(stopCh) go func() {
if err := preparedServer.Run(stopCh); err != nil {
t.Fatal(err)
}
}()
// load ca certificates into a pool // load ca certificates into a pool
roots := x509.NewCertPool() roots := x509.NewCertPool()
@ -512,7 +518,7 @@ NextTest:
}) })
if err != nil { if err != nil {
t.Errorf("%q - failed to connect: %v", title, err) t.Errorf("%q - failed to connect: %v", title, err)
continue NextTest return
} }
// check returned server certificate // check returned server certificate
@ -537,25 +543,26 @@ NextTest:
if err == nil { if err == nil {
t.Errorf("%q - expected error creating loopback client config", title) t.Errorf("%q - expected error creating loopback client config", title)
} }
continue NextTest return
} }
if err != nil { if err != nil {
t.Errorf("%q - failed creating loopback client config: %v", title, err) t.Errorf("%q - failed creating loopback client config: %v", title, err)
continue NextTest return
} }
client, err := discovery.NewDiscoveryClientForConfig(s.LoopbackClientConfig) client, err := discovery.NewDiscoveryClientForConfig(s.LoopbackClientConfig)
if err != nil { if err != nil {
t.Errorf("%q - failed to create loopback client: %v", title, err) t.Errorf("%q - failed to create loopback client: %v", title, err)
continue NextTest return
} }
got, err := client.ServerVersion() got, err := client.ServerVersion()
if err != nil { if err != nil {
t.Errorf("%q - failed to connect with loopback client: %v", title, err) t.Errorf("%q - failed to connect with loopback client: %v", title, err)
continue NextTest return
} }
if expected := &v; !reflect.DeepEqual(got, expected) { if expected := &v; !reflect.DeepEqual(got, expected) {
t.Errorf("%q - loopback client didn't get correct version info: expected=%v got=%v", title, expected, got) t.Errorf("%q - loopback client didn't get correct version info: expected=%v got=%v", title, expected, got)
} }
}()
} }
} }