Example #1
0
				autowire.Initialize(nil)
				Expect(reflect.TypeOf(http.DefaultTransport).Elem().Name()).To(Equal("Transport"))
			})
		})
	})

	Describe("CreateDefaultEmitter", func() {
		Context("with DROPSONDE_ORIGIN set", func() {
			BeforeEach(func() {
				os.Setenv("DROPSONDE_ORIGIN", "anything")
			})

			Context("with DROPSONDE_DESTINATION missing", func() {
				It("defaults to localhost", func() {
					os.Setenv("DROPSONDE_DESTINATION", "")
					_, destination := autowire.CreateDefaultEmitter()

					Expect(destination).To(Equal("localhost:3457"))
				})
			})

			Context("with DROPSONDE_DESTINATION set", func() {
				It("uses the configured destination", func() {
					os.Setenv("DROPSONDE_DESTINATION", "test")
					_, destination := autowire.CreateDefaultEmitter()

					Expect(destination).To(Equal("test"))
				})
			})
		})
	"net"
	"net/http"
	"os"
	"sync"
)

// these tests need to be invoked individually from an external script,
// since environment variables need to be set/unset before starting the tests
var _ = Describe("Autowire End-to-End", func() {
	Context("with DROPSONDE_ORIGIN set", func() {
		var oldEnv string

		BeforeEach(func() {
			oldEnv = os.Getenv("DROPSONDE_ORIGIN")
			os.Setenv("DROPSONDE_ORIGIN", "test-origin")
			emitter, _ := autowire.CreateDefaultEmitter()
			autowire.Initialize(emitter)
			metrics.Initialize(metric_sender.NewMetricSender(autowire.AutowiredEmitter()))
		})

		AfterEach(func() {
			os.Setenv("DROPSONDE_ORIGIN", oldEnv)
		})

		It("emits HTTP client/server events and heartbeats", func() {
			udpListener, err := net.ListenPacket("udp4", ":3457")
			Expect(err).ToNot(HaveOccurred())
			defer udpListener.Close()
			udpDataChan := make(chan []byte, 16)

			receivedEvents := make(map[string]bool)