Ejemplo n.º 1
0
func TestStoreAdapter(t *testing.T) {
	registerSignalHandler()
	RegisterFailHandler(Fail)

	etcdPort := 5000 + (config.GinkgoConfig.ParallelNode-1)*10
	etcdRunner = storerunner.NewETCDClusterRunner(etcdPort, 5)

	zookeeperPort := 2181 + (config.GinkgoConfig.ParallelNode-1)*10
	zookeeperRunner = storerunner.NewZookeeperClusterRunner(zookeeperPort, 1)

	etcdRunner.Start()
	zookeeperRunner.Start()

	RunSpecs(t, "Store Adapter Suite")

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

					randomBytes := func(sizeInBytes int) []byte {