Esempio n. 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.Fatal("Invalid duration %s\n", *interval)
	}

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

	reporter := metricsreporter.New(duration, os.Stdout)
	writer := messagewriter.NewMessageWriter(51161, "", reporter)
	reader := messagereader.NewMessageReader(3457, reporter)
	exp := experiment.New(writer, reader, *writeRate)

	announceToEtcd()

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

	timer := time.NewTimer(stopAfterDuration)
	<-timer.C
	exp.Stop()
	reporter.Stop()
}
Esempio n. 2
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.Fatal("Invalid duration %s\n", *interval)
	}

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

	reporter := metricsreporter.New(duration, os.Stdout)
	writer := messagewriter.NewMessageWriter(*dopplerIncomingDropsondePort, sharedSecret, reporter)
	ip, err := localip.LocalIP()
	if err != nil {
		panic(err)
	}
	reader := websocketmessagereader.New(fmt.Sprintf("%s:%d", ip, *dopplerOutgoingPort), reporter)
	defer reader.Close()
	exp := experiment.New(writer, reader, *writeRate)

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

	timer := time.NewTimer(stopAfterDuration)
	<-timer.C
	exp.Stop()
	reporter.Stop()

}
Esempio n. 3
0
import (
	"tools/metronbenchmark/messagewriter"

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

var _ = Describe("MessageWriter", func() {
	var reporter *fakeReporter
	BeforeEach(func() {
		reporter = &fakeReporter{}
	})

	It("should keep track of the total sent messages", func() {
		msgWriter := messagewriter.NewMessageWriter(51161, "", reporter)
		msgWriter.Send()
		msgWriter.Send()
		msgWriter.Send()
		msgWriter.Send()
		msgWriter.Send()
		msgWriter.Send()
		msgWriter.Send()
		msgWriter.Send()

		Expect(reporter.totalSent).To(Equal(8))
	})

	It("should not increment total sent messages", func() {
		messagewriter.NewMessageWriter(51161, "", reporter)
		Expect(reporter.totalSent).To(Equal(0))