Exemple #1
0
func TestRunSecureServer(t *testing.T) {
	serverIP := fmt.Sprintf("https://localhost:%d", testSecurePort)

	go func() {
		opt := getServerOptions()
		opt.InsecurePort = 0
		opt.SecurePort = testSecurePort
		opt.CertDirectory = "/tmp"

		server, err := app.NewHeapsterApiServer(opt, emptyMetricSink, emptyNodeLister, emptyPodLister)
		if err != nil {
			t.Fatalf("Could not create the API server: %v", err)
		}
		if err := server.RunServer(); err != nil {
			t.Fatalf("Error in bringing up the server: %v", err)
		}
	}()
	if err := waitForApiserverUp(serverIP); err != nil {
		t.Fatalf("%v", err)
	}
	testSwaggerSpec(t, serverIP)
	testAPIGroupList(t, serverIP)
	testAPIGroup(t, serverIP)
	testAPIResourceList(t, serverIP)
}
Exemple #2
0
func createAndRunAPIServer(opt *options.HeapsterRunOptions, metricSink *metricsink.MetricSink,
	nodeLister *cache.StoreToNodeLister, podLister *cache.StoreToPodLister) {

	server, err := app.NewHeapsterApiServer(opt, metricSink, nodeLister, podLister)
	if err != nil {
		glog.Errorf("Could not create the API server: %v", err)
		return
	}
	healthz.InstallHandler(server.Mux, healthzChecker(metricSink))
	runApiServer := func(s *app.HeapsterAPIServer) {
		if err := s.RunServer(); err != nil {
			fmt.Fprintf(os.Stderr, "%v\n", err)
			os.Exit(1)
		}
	}
	glog.Infof("Starting Heapster API server on port %d", opt.InsecurePort)
	go runApiServer(server)
}