}) JustBeforeEach(func() { runner.Start() }) AfterEach(func(done Done) { close(flushEvents) runner.KillWithFire() fakeGarden.Close() close(done) }) Context("when Garden is available", func() { BeforeEach(func() { fakeGarden.Start() }) Describe("when an interrupt signal is sent to the representative", func() { JustBeforeEach(func() { if runtime.GOOS == "windows" { Skip("Interrupt isn't supported on windows") } runner.Stop() }) It("should die", func() { Eventually(runner.Session.ExitCode).Should(Equal(0)) }) })
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"), ghttp.RespondWith(http.StatusOK, "true"), ), ) resp, err = client.Get("unix://" + socket + "/_ping") })
timeout = 100 * time.Millisecond serverDelay = 0 server.HTTPTestServer.Listener = listener serverAddr = listener.Addr().String() _, port, err = net.SplitHostPort(serverAddr) Expect(err).NotTo(HaveOccurred()) }) JustBeforeEach(func() { server.RouteToHandler("GET", "/api/_ping", func(http.ResponseWriter, *http.Request) { time.Sleep(serverDelay) }) server.Start() hc = healthcheck.NewHealthCheck("tcp", uri, port, timeout) }) AfterEach(func() { if server != nil { server.CloseClientConnections() server.Close() } }) Describe("check interfaces", func() { It("succeeds when there are healthy interfaces", func() { interfaces, err := net.Interfaces() Expect(err).NotTo(HaveOccurred())
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) }, } tlsServer.RouteToHandler("POST", "/test", ghttp.CombineHandlers(handlers...)) insecureServer.RouteToHandler("POST", "/test", ghttp.CombineHandlers(handlers...)) insecureServer.Start() tlsServer.HTTPTestServer.StartTLS() }) It("uses the tls configuration for task callbacks with https", func() { client, err = bbs.NewSecureClient(bbsURL.String(), caFile, certFile, keyFile, 0, 0) Expect(err).NotTo(HaveOccurred()) taskDef := model_helpers.NewValidTaskDefinition() taskDef.CompletionCallbackUrl = tlsServer.URL() + "/test" err := client.DesireTask(logger, "task-guid", "domain", taskDef) Expect(err).NotTo(HaveOccurred()) err = client.CancelTask(logger, "task-guid") Expect(err).NotTo(HaveOccurred())