rootFSPath string logger *lagertest.TestLogger flushEvents chan struct{} ) var getActualLRPGroups = func() []*models.ActualLRPGroup { actualLRPGroups, err := bbsClient.ActualLRPGroups(models.ActualLRPFilter{}) Expect(err).NotTo(HaveOccurred()) return actualLRPGroups } BeforeEach(func() { Eventually(getActualLRPGroups, 5*pollingInterval).Should(BeEmpty()) flushEvents = make(chan struct{}) fakeGarden = ghttp.NewUnstartedServer() // these tests only look for the start of a sequence of requests fakeGarden.AllowUnhandledRequests = false fakeGarden.RouteToHandler("GET", "/ping", ghttp.RespondWithJSONEncoded(http.StatusOK, struct{}{})) fakeGarden.RouteToHandler("GET", "/containers", ghttp.RespondWithJSONEncoded(http.StatusOK, struct{}{})) fakeGarden.RouteToHandler("GET", "/capacity", ghttp.RespondWithJSONEncoded(http.StatusOK, garden.Capacity{MemoryInBytes: 1024 * 1024 * 1024, DiskInBytes: 2048 * 1024 * 1024, MaxContainers: 4})) fakeGarden.RouteToHandler("GET", "/containers/bulk_info", ghttp.RespondWithJSONEncoded(http.StatusOK, struct{}{})) logger = lagertest.NewTestLogger("test") serviceClient = bbs.NewServiceClient(consulSession, clock.NewClock()) pollingInterval = 50 * time.Millisecond evacuationTimeout = 200 * time.Millisecond rootFSName = "the-rootfs"
var ( unixSocketListener net.Listener unixSocketServer *ghttp.Server resp *http.Response err error ) BeforeEach(func() { uuid, err := uuid.NewV4() Expect(err).NotTo(HaveOccurred()) socket = fmt.Sprintf("/tmp/%s.sock", uuid) unixSocketListener, err = net.Listen("unix", socket) Expect(err).NotTo(HaveOccurred()) unixSocketServer = ghttp.NewUnstartedServer() unixSocketServer.HTTPTestServer = &httptest.Server{ Listener: unixSocketListener, Config: &http.Server{Handler: unixSocketServer}, } unixSocketServer.Start() client = http.Client{Transport: New(socket)} }) Context("when a simple GET request is sent", func() { BeforeEach(func() { unixSocketServer.AppendHandlers( ghttp.CombineHandlers( ghttp.VerifyRequest("GET", "/_ping"),
os.Setenv("HOME", homeDir) } }) AfterEach(func() { os.RemoveAll(homeDir) }) Describe("login", func() { var ( flyCmd *exec.Cmd stdin io.WriteCloser ) BeforeEach(func() { l := log.New(GinkgoWriter, "TLSServer", 0) atcServer = ghttp.NewUnstartedServer() atcServer.HTTPTestServer.Config.ErrorLog = l atcServer.HTTPTestServer.StartTLS() }) AfterEach(func() { atcServer.Close() }) Context("to new target with invalid SSL with -k", func() { BeforeEach(func() { atcServer.AppendHandlers( infoHandler(), ghttp.CombineHandlers( ghttp.VerifyRequest("GET", "/api/v1/auth/methods"), ghttp.RespondWithJSONEncoded(200, []atc.AuthMethod{
}) Context("task callbacks", func() { var ( caFile, certFile, keyFile string tlsServer, insecureServer *ghttp.Server doneChan chan struct{} ) BeforeEach(func() { doneChan = make(chan struct{}) caFile = path.Join(basePath, "green-certs", "server-ca.crt") certFile = path.Join(basePath, "green-certs", "client.crt") keyFile = path.Join(basePath, "green-certs", "client.key") tlsServer = ghttp.NewUnstartedServer() insecureServer = ghttp.NewUnstartedServer() tlsConfig, err := cfhttp.NewTLSConfig(certFile, keyFile, caFile) Expect(err).NotTo(HaveOccurred()) tlsServer.HTTPTestServer.TLS = tlsConfig handlers := []http.HandlerFunc{ ghttp.VerifyRequest("POST", "/test"), ghttp.RespondWith(200, nil), func(w http.ResponseWriter, request *http.Request) { close(doneChan) }, }