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()
						storeRunner = nil
					})

					randomBytes := func(sizeInBytes int) []byte {
						seedBytes := []byte{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}
						randomBytes := make([]byte, sizeInBytes)
						for i := 0; i < sizeInBytes; i++ {
Exemplo n.º 2
0
			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()
					storeRunner = nil
				})

				for _, numApps := range []int{100, 1000, 3000, 10000, 30000} {
					numApps := numApps

					Measure(fmt.Sprintf("Read/Write Performance With %d Apps", numApps), func(b Benchmarker) {