Exemple #1
0
package clientpool_test

import (
	"metron/clientpool"
	"net"

	"github.com/cloudfoundry/gosteno"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("UDP Client", func() {
	var (
		client      clientpool.Client
		udpListener *net.UDPConn
	)

	BeforeEach(func() {
		udpAddr, err := net.ResolveUDPAddr("udp", "127.0.0.1:0")
		Expect(err).NotTo(HaveOccurred())
		udpListener, err = net.ListenUDP("udp", udpAddr)
		Expect(err).NotTo(HaveOccurred())

		client, err = clientpool.NewUDPClient(gosteno.NewLogger("TestLogger"), udpListener.LocalAddr().String(), 0)
		Expect(err).NotTo(HaveOccurred())
	})

	AfterEach(func() {
		client.Close()
		udpListener.Close()
	var (
		udpClientCreator *clientpool.UDPClientCreator
		logger           *gosteno.Logger
		address          string
	)

	BeforeEach(func() {
		logger = gosteno.NewLogger("TestLogger")
		address = "127.0.0.1:1234"
		udpClientCreator = clientpool.NewUDPClientCreator(logger)
	})

	Describe("CreateClient", func() {
		var (
			client    clientpool.Client
			createErr error
		)

		JustBeforeEach(func() {
			client, createErr = udpClientCreator.CreateClient(address)
		})
		It("makes clients", func() {
			Expect(createErr).ToNot(HaveOccurred())
			Expect(client.Address()).To(Equal(address))
			Expect(client.Scheme()).To(Equal("udp"))
		})

		Context("with an invalid address", func() {
			BeforeEach(func() {
				address = "I am definitely not an address"
			})
Exemple #3
0
	"doppler/listeners"
	"metron/clientpool"
	"net"
	"time"

	"github.com/cloudfoundry/gosteno"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("TLS Client", func() {
	var (
		logger      *gosteno.Logger
		tlsListener net.Listener
		connChan    chan net.Conn

		client clientpool.Client
	)

	BeforeEach(func() {
		logger = gosteno.NewLogger("test")

		var err error
		tlsServerConfig, err := listeners.NewTLSConfig("fixtures/server.crt", "fixtures/server.key", "fixtures/loggregator-ca.crt")
		Expect(err).NotTo(HaveOccurred())
		tlsListener, err = tls.Listen("tcp", "127.0.0.1:0", tlsServerConfig)
		Expect(err).NotTo(HaveOccurred())

		connChan = make(chan net.Conn, 1)