Ejemplo n.º 1
0
func (c *concurrentWriteRequestSimulator) concurrentWriteRequests(count int, writer syslogwriter.Writer) {
	wg := &sync.WaitGroup{}
	wg.Add(count)

	for i := 0; i < count; i++ {
		go func() {
			writer.Write(standardErrorPriority, []byte("Message"), "just a test", "TEST", time.Now().UnixNano())
			wg.Done()
		}()
	}

	wg.Wait()
}
Ejemplo n.º 2
0
	"os/exec"
	"strconv"
	"time"

	. "github.com/onsi/ginkgo"
	"github.com/onsi/ginkgo/config"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
	"github.com/onsi/gomega/gexec"
)

const standardOutPriority = 14

var _ = Describe("SyslogWriter", func() {

	var sysLogWriter syslogwriter.Writer
	var dialer *net.Dialer
	var syslogServerSession *gexec.Session

	BeforeEach(func() {
		dialer = &net.Dialer{
			Timeout: 500 * time.Millisecond,
		}

		port := 9800 + config.GinkgoConfig.ParallelNode
		address := net.JoinHostPort("127.0.0.1", strconv.Itoa(port))

		outputURL := &url.URL{Scheme: "syslog", Host: address}
		syslogServerSession = startSyslogServer(address)
		sysLogWriter, _ = syslogwriter.NewSyslogWriter(outputURL, "appId", dialer, 0)
Ejemplo n.º 3
0
			_, err := syslogwriter.NewTlsWriter(outputURL, "appId", false, dialer, ioTimeout)
			Expect(err).To(HaveOccurred())
		})

		It("returns an error if the provided dialer is nil", func() {
			outputURL, _ := url.Parse("syslog-tls://localhost")
			_, err := syslogwriter.NewTlsWriter(outputURL, "appId", false, nil, ioTimeout)
			Expect(err).To(HaveOccurred())
			Expect(err.Error()).To(ContainSubstring("cannot construct a writer with a nil dialer"))
		})
	})

	Describe("Write", func() {
		const standardOutPriority = 14
		var syslogServerSession *gexec.Session
		var syslogWriter syslogwriter.Writer
		var skipCertVerify bool

		BeforeEach(func() {
			skipCertVerify = true
		})

		JustBeforeEach(func() {
			dialer = &net.Dialer{
				Timeout: time.Second,
			}

			var err error
			port := 9900 + config.GinkgoConfig.ParallelNode
			address := net.JoinHostPort("127.0.0.1", strconv.Itoa(port))
			syslogServerSession = startEncryptedTCPServer(address)