func main() { cmdsToStop = []*exec.Cmd{} registerSignalHandler() nats = natsrunner.NewNATSRunner(4222) nats.Start() fakeCC := desiredstateserver.NewDesiredStateServer() go fakeCC.SpinUp(6001) // etcd = storerunner.NewETCDClusterRunner(4001, 1) // etcd.Start() conf, _ := config.FromFile("./config.json") adapter := storeadapter.NewETCDStoreAdapter(conf.StoreURLs, workerpool.NewWorkerPool(30)) adapter.Connect() store = storepackage.NewStore(conf, adapter, fakelogger.NewFakeLogger()) r := rand.New(rand.NewSource(time.Now().Unix())) num, err := strconv.Atoi(os.Args[1]) if err != nil { panic(err) } sim := simulator.New(num, 10, r, nats.MessageBus, fakeCC) //start all the HM components (make them pipe to stdout) start("listen", false) start("fetch_desired", true) start("analyze", true) start("send", true) start("serve_metrics", false) start("serve_api", false) time.Sleep(time.Second) go Tick(sim) go Fetch() select {} }
var _ = Describe("Desired State", func() { var ( store Store etcdAdapter storeadapter.StoreAdapter conf config.Config app1 app.App app2 app.App app3 app.App ) BeforeEach(func() { var err error conf, err = config.DefaultConfig() Ω(err).ShouldNot(HaveOccured()) etcdAdapter = storeadapter.NewETCDStoreAdapter(etcdRunner.NodeURLS(), conf.StoreMaxConcurrentRequests) err = etcdAdapter.Connect() Ω(err).ShouldNot(HaveOccured()) app1 = app.NewApp() app2 = app.NewApp() app3 = app.NewApp() store = NewStore(conf, etcdAdapter) }) AfterEach(func() { etcdAdapter.Disconnect() }) Describe("Saving desired state ", func() {
var _ = Describe("Detailed Store Performance", func() { for _, storeType := range storeTypes { storeType := storeType for _, nodes := range nodeCounts { nodes := nodes for _, concurrency := range concurrencies { concurrency := concurrency Context(fmt.Sprintf("With %d %s nodes (%d concurrent requests at a time)", nodes, storeType, concurrency), func() { var storeAdapter storeadapter.StoreAdapter BeforeEach(func() { if storeType == "ETCD" { storeRunner = storerunner.NewETCDClusterRunner(5001, nodes) storeRunner.Start() storeAdapter = storeadapter.NewETCDStoreAdapter(storeRunner.NodeURLS(), workerpool.NewWorkerPool(concurrency)) err := storeAdapter.Connect() Ω(err).ShouldNot(HaveOccured()) } else if storeType == "Zookeeper" { storeRunner = storerunner.NewZookeeperClusterRunner(2181, nodes) storeRunner.Start() storeAdapter = storeadapter.NewZookeeperStoreAdapter(storeRunner.NodeURLS(), workerpool.NewWorkerPool(concurrency), &timeprovider.RealTimeProvider{}, time.Second) err := storeAdapter.Connect() Ω(err).ShouldNot(HaveOccured()) } }) AfterEach(func() { storeAdapter.Disconnect() storeRunner.Stop()
var nodeCounts = []int{1, 3, 5, 7} var _ = Describe("Store Performance", func() { for _, storeType := range storeTypes { storeType := storeType for _, nodes := range nodeCounts { nodes := nodes Context(fmt.Sprintf("With %d %s nodes", nodes, storeType), func() { var storeAdapter storeadapter.StoreAdapter BeforeEach(func() { if storeType == "ETCD" { storeRunner = storerunner.NewETCDClusterRunner(5001, nodes) storeRunner.Start() storeAdapter = storeadapter.NewETCDStoreAdapter(storeRunner.NodeURLS(), 100) err := storeAdapter.Connect() Ω(err).ShouldNot(HaveOccured()) } else if storeType == "Zookeeper" { storeRunner = storerunner.NewZookeeperClusterRunner(2181, nodes) storeRunner.Start() storeAdapter = storeadapter.NewZookeeperStoreAdapter(storeRunner.NodeURLS(), 100, &timeprovider.RealTimeProvider{}, time.Second) err := storeAdapter.Connect() Ω(err).ShouldNot(HaveOccured()) } }) AfterEach(func() { storeAdapter.Disconnect() storeRunner.Stop()