Esempio n. 1
0
				Expect(cfg.TCPBatchSizeBytes).To(BeEquivalentTo(1024))
				Expect(cfg.TCPBatchIntervalMilliseconds).To(BeEquivalentTo(10))

				Expect(cfg.Protocols).To(Equal([]config.Protocol{"tls", "udp"}))

				Expect(cfg.TLSConfig).To(Equal(config.TLSConfig{
					CertFile: "./fixtures/client.crt",
					KeyFile:  "./fixtures/client.key",
					CAFile:   "./fixtures/ca.crt",
				}))
			})
		})

		Describe("Parse", func() {
			It("sets defaults", func() {
				cfg, err := config.Parse(strings.NewReader("{}"))
				Expect(err).ToNot(HaveOccurred())

				Expect(cfg).To(Equal(&config.Config{
					TCPBatchIntervalMilliseconds:     100,
					TCPBatchSizeBytes:                10240,
					MetricBatchIntervalMilliseconds:  5000,
					RuntimeStatsIntervalMilliseconds: 15000,
					Protocols:                        []config.Protocol{"udp"},
				}))
			})

			Context("with valid protocols", func() {
				DescribeTable("doesn't return error", func(proto string) {
					_, err := config.Parse(bytes.NewBufferString(fmt.Sprintf(`
						{
Esempio n. 2
0
			Expect(cfg.MetricBatchIntervalMilliseconds).To(BeEquivalentTo(20))
			Expect(cfg.RuntimeStatsIntervalMilliseconds).To(BeEquivalentTo(15))
			Expect(cfg.Syslog).To(Equal("syslog.namespace"))

			Expect(cfg.PreferredProtocol).To(Equal("udp"))
			Expect(cfg.BufferSize).To(Equal(100))

			Expect(cfg.TLSConfig).To(Equal(config.TLSConfig{
				CertFile: "./fixtures/client.crt",
				KeyFile:  "./fixtures/client.key",
				CAFile:   "./fixtures/ca.crt",
			}))

			Expect(cfg.EnableBuffer).To(BeTrue())
		})

		It("sets defaults", func() {
			cfg, err := config.Parse(strings.NewReader("{}"))
			Expect(err).ToNot(HaveOccurred())

			Expect(cfg).To(Equal(&config.Config{
				MetricBatchIntervalMilliseconds:  5000,
				RuntimeStatsIntervalMilliseconds: 15000,
				PreferredProtocol:                "udp",
				BufferSize:                       100,
			}))
		})
	})
})
Esempio n. 3
0
import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"metron/config"
	"os"
	"strings"

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

var _ = Describe("Parse", func() {
	It("sets defaults", func() {
		cfg, err := config.Parse(strings.NewReader(`{}`))
		Expect(err).ToNot(HaveOccurred())

		Expect(cfg).To(Equal(&config.Config{
			TCPBatchIntervalMilliseconds:     100,
			TCPBatchSizeBytes:                10240,
			MetricBatchIntervalMilliseconds:  5000,
			RuntimeStatsIntervalMilliseconds: 15000,
			Protocols:                        config.Protocols{"udp": struct{}{}},
		}))
	})

	Context("with valid protocols", func() {
		DescribeTable("doesn't return error", func(proto string) {
			json := fmt.Sprintf(`{"Protocols": ["%s"]}`, proto)
			_, err := config.Parse(strings.NewReader(json))