Exemple #1
0
func main() {
	runtime.GOMAXPROCS(4)

	var interval = flag.String("interval", "1s", "Interval for reported results")
	var writeRate = flag.Int("writeRate", 15000, "Number of writes per second to send to metron")
	var stopAfter = flag.String("stopAfter", "5m", "How long to run the experiment for")
	flag.Parse()

	duration, err := time.ParseDuration(*interval)
	if err != nil {
		log.Fatalf("Invalid duration %s\n", *interval)
	}

	stopAfterDuration, err := time.ParseDuration(*stopAfter)
	if err != nil {
		log.Fatalf("Invalid duration %s\n", *stopAfter)
	}

	internalMetricsCounter := metricsreporter.NewCounter("internal metrics")
	reporter := metricsreporter.New(duration, os.Stdout, internalMetricsCounter)

	reader := messagereader.NewMessageReader(3457)
	legacyReader := legacyreader.NewLegacyReader(reporter.GetReceivedCounter(), internalMetricsCounter, reader)

	exp := experiment.NewExperiment(legacyReader)

	generator := messagegenerator.NewValueMetricGenerator()
	writer := messagewriter.NewMessageWriter("localhost", 51161, "", reporter.GetSentCounter())
	writeStrategy := writestrategies.NewConstantWriteStrategy(generator, writer, *writeRate)
	exp.AddWriteStrategy(writeStrategy)

	legacyGenerator := messagegenerator.NewLegacyLogGenerator()
	legacyWriter := messagewriter.NewMessageWriter("localhost", 51160, "", reporter.GetSentCounter())
	legacyWriteStrategy := writestrategies.NewConstantWriteStrategy(legacyGenerator, legacyWriter, *writeRate)
	exp.AddWriteStrategy(legacyWriteStrategy)

	announceToEtcd()

	go reporter.Start()
	go exp.Start()

	timer := time.NewTimer(stopAfterDuration)
	<-timer.C
	exp.Stop()
	reporter.Stop()
}
Exemple #2
0
func NewFakeApp(appID string, warmupRate int, logRate int) *FakeApp {
	generator := messagegenerator.NewLogMessageGenerator(appID)
	counter := metricsreporter.NewCounter("sentLogs")
	// 49625 is the DropsondeIncomingMessagesPort for the metron that will be spun up.
	writer := messagewriter.NewMessageWriter("localhost", 49625, "", counter)

	writeStrategy := writestrategies.NewConstantWriteStrategy(generator, writer, logRate)
	warmupStrategy := writestrategies.NewConstantWriteStrategy(generator, writer, warmupRate)

	return &FakeApp{
		appID:          appID,
		logRate:        logRate,
		writeStrategy:  writeStrategy,
		warmupStrategy: warmupStrategy,
		logCounter:     counter,
	}
}
Exemple #3
0
func chooseStrategy(generator writestrategies.MessageGenerator, writer writestrategies.MessageWriter, writeRate int, burstDelay time.Duration) experiment.WriteStrategy {
	if burstDelay > 0 {
		params := writestrategies.BurstParameters{
			Minimum:   writeRate,
			Maximum:   writeRate,
			Frequency: burstDelay,
		}
		return writestrategies.NewBurstWriteStrategy(generator, writer, params)
	}
	return writestrategies.NewConstantWriteStrategy(generator, writer, writeRate)
}
Exemple #4
0
func main() {
	runtime.GOMAXPROCS(4)

	var interval = flag.String("interval", "1s", "Interval for reported results")
	var writeRate = flag.Int("writeRate", 15000, "Number of writes per second to send to doppler")
	var stopAfter = flag.String("stopAfter", "5m", "How long to run the experiment for")
	var sharedSecret string
	flag.StringVar(&sharedSecret, "sharedSecret", "", "Shared secret used by Doppler to verify message validity")
	var dopplerOutgoingPort = flag.Int("dopplerOutgoingPort", 8080, "Outgoing port from doppler")
	var dopplerIncomingDropsondePort = flag.Int("dopplerIncomingDropsondePort", 3457, "Incoming dropsonde port to doppler")
	flag.Parse()

	duration, err := time.ParseDuration(*interval)
	if err != nil {
		log.Fatalf("Invalid duration %s\n", *interval)
	}

	stopAfterDuration, err := time.ParseDuration(*stopAfter)
	if err != nil {
		log.Fatalf("Invalid duration %s\n", *stopAfter)
	}

	reporter := metricsreporter.New(duration, os.Stdout)
	ip, err := localip.LocalIP()
	if err != nil {
		panic(err)
	}

	generator := messagegenerator.NewValueMetricGenerator()
	writer := messagewriter.NewMessageWriter(ip, *dopplerIncomingDropsondePort, sharedSecret, reporter.SentCounter())
	reader := websocketmessagereader.New(fmt.Sprintf("%s:%d", ip, *dopplerOutgoingPort), reporter.ReceivedCounter())
	defer reader.Close()

	writeStrategy := writestrategies.NewConstantWriteStrategy(generator, writer, *writeRate)
	exp := experiment.NewExperiment(reader)
	exp.AddWriteStrategy(writeStrategy)

	exp.Warmup()
	go reporter.Start()
	go exp.Start()

	timer := time.NewTimer(stopAfterDuration)
	<-timer.C
	exp.Stop()
	reporter.Stop()
}
Exemple #5
0
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	var interval = flag.String("interval", "1s", "Interval for reported results")
	var writeRate = flag.Int("writeRate", 15000, "Number of writes per second to send to metron")
	var stopAfter = flag.String("stopAfter", "5m", "How long to run the experiment for")
	var concurrentWriters = flag.Int("concurrentWriters", 1, "Number of concurrent writers")

	flag.Parse()

	duration, err := time.ParseDuration(*interval)
	if err != nil {
		log.Fatalf("Invalid duration %s\n", *interval)
	}

	stopAfterDuration, err := time.ParseDuration(*stopAfter)
	if err != nil {
		log.Fatalf("Invalid duration %s\n", *stopAfter)
	}

	reporter := metricsreporter.New(duration, os.Stdout)
	generator := messagegenerator.NewValueMetricGenerator()
	reader := messagereader.NewMessageReader(3457)
	valueMetricReader := valuemetricreader.NewValueMetricReader(reporter.GetReceivedCounter(), reader)
	exp := experiment.NewExperiment(valueMetricReader)

	for i := 0; i < *concurrentWriters; i++ {
		writer := messagewriter.NewMessageWriter("localhost", 51161, "", reporter.GetSentCounter())
		writeStrategy := writestrategies.NewConstantWriteStrategy(generator, writer, *writeRate)
		exp.AddWriteStrategy(writeStrategy)
	}

	announceToEtcd()

	exp.Warmup()
	go reporter.Start()
	go exp.Start()

	timer := time.NewTimer(stopAfterDuration)
	<-timer.C
	exp.Stop()
	reporter.Stop()
}
	. "github.com/onsi/gomega"
)

var _ = Describe("WriteStrategies", func() {
	Context("ConstantWriteStrategy", func() {
		Describe("StartWriter", func() {
			var (
				writer        mockWriter
				stopChan      chan struct{}
				writeStrategy *writestrategies.ConstantWriteStrategy
			)

			BeforeEach(func() {
				writer = mockWriter{}
				stopChan = make(chan struct{})
				writeStrategy = writestrategies.NewConstantWriteStrategy(&mockGenerator{}, &writer, 1000)
			})

			It("writes messages at a constant rate", func() {
				go writeStrategy.StartWriter(stopChan)

				time.Sleep(time.Millisecond * 50)
				writes := atomic.LoadUint32(&writer.count)
				Expect(writes).To(BeNumerically(">", 40))
				Expect(writes).To(BeNumerically("<", 60))

				time.Sleep(time.Millisecond * 50)
				writes = atomic.LoadUint32(&writer.count)
				Expect(writes).To(BeNumerically(">", 90))
				Expect(writes).To(BeNumerically("<", 110))
type Stopper interface {
	Stop()
}

var _ = Describe("End to end benchmarks", func() {
	benchmarkEndToEnd := func() {
		Measure("dropsonde metrics being passed from metron to the firehose nozzle", func(b Benchmarker) {
			const writeRatePerSecond = 1000
			metronStreamWriter := endtoend.NewMetronStreamWriter()

			firehoseReader := endtoend.NewFirehoseReader()

			generator := messagegenerator.NewValueMetricGenerator()

			writeStrategy := writestrategies.NewConstantWriteStrategy(generator, metronStreamWriter, writeRatePerSecond)
			ex := experiment.NewExperiment(firehoseReader)
			ex.AddWriteStrategy(writeStrategy)

			ex.Warmup()

			go stopExperimentAfterTimeout(ex)
			b.Time("runtime", func() {
				ex.Start()
			})

			reportResults(firehoseReader, metronStreamWriter.Writes, b)
			Expect(float64(firehoseReader.MetronSentMessageCount)).To(BeNumerically(">", writeRatePerSecond))
		}, 1)

		Measure("dropsonde metrics being passed from metron to the firehose nozzle in burst sequence", func(b Benchmarker) {
)

type Stopper interface {
	Stop()
}

var _ = Describe("End to end test", func() {
	Measure("dropsonde metrics being passed from metron to the firehose nozzle", func(b Benchmarker) {
		const numMessagesSent = 1000
		metronStreamWriter := endtoend.NewMetronStreamWriter()

		firehoseReader := endtoend.NewFirehoseReader()

		generator := messagegenerator.NewValueMetricGenerator()

		writeStrategy := writestrategies.NewConstantWriteStrategy(generator, metronStreamWriter, numMessagesSent)
		ex := experiment.NewExperiment(firehoseReader)
		ex.AddWriteStrategy(writeStrategy)

		go stopExperimentAfterTimeout(ex)

		b.Time("runtime", func() {
			ex.Start()
		})

		reportResults(firehoseReader, b)
		Expect(float64(firehoseReader.MetronMessageCount)).To(BeNumerically(">", numMessagesSent))
	}, 3)

	Measure("dropsonde metrics being passed from metron to the firehose nozzle in burst sequence", func(b Benchmarker) {
		metronStreamWriter := endtoend.NewMetronStreamWriter()