Example #1
0
File: dump.go Project: Zhann/hm9000
func Walk(store storeadapter.StoreAdapter, dirKey string, callback func(storeadapter.StoreNode)) {
	nodes, err := store.List(dirKey)
	if err != nil {
		return
	}

	for _, node := range nodes {
		if node.Key == "/_etcd" {
			continue
		}
		if node.Dir {
			Walk(store, node.Key, callback)
		} else {
			callback(node)
		}
	}
}
Example #2
0
	. "github.com/cloudfoundry/hm9000/store"
	. "github.com/cloudfoundry/hm9000/testhelpers/custommatchers"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/cloudfoundry/hm9000/config"
	"github.com/cloudfoundry/hm9000/models"
	"github.com/cloudfoundry/hm9000/storeadapter"
	"github.com/cloudfoundry/hm9000/testhelpers/app"
)

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()
Example #3
0
import (
	"github.com/cloudfoundry/hm9000/config"
	"github.com/cloudfoundry/hm9000/models"
	. "github.com/cloudfoundry/hm9000/store"
	"github.com/cloudfoundry/hm9000/storeadapter"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"encoding/json"
	"time"
)

var _ = Describe("Freshness", func() {
	var (
		store       Store
		etcdAdapter storeadapter.StoreAdapter
		conf        config.Config
	)

	conf, _ = config.DefaultConfig()

	BeforeEach(func() {
		etcdAdapter = storeadapter.NewETCDStoreAdapter(etcdRunner.NodeURLS(), conf.StoreMaxConcurrentRequests)
		err := etcdAdapter.Connect()
		Ω(err).ShouldNot(HaveOccured())

		store = NewStore(conf, etcdAdapter)
	})

	Describe("Bumping freshness", func() {
		bumpingFreshness := func(key string, ttl uint64, bump func(store Store, timestamp time.Time) error) {
Example #4
0
import (
	. "github.com/cloudfoundry/hm9000/store"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/cloudfoundry/hm9000/config"
	"github.com/cloudfoundry/hm9000/models"
	"github.com/cloudfoundry/hm9000/storeadapter"
	"github.com/cloudfoundry/hm9000/testhelpers/app"
)

var _ = Describe("Actual State", func() {
	var (
		store       Store
		etcdAdapter storeadapter.StoreAdapter
		conf        config.Config
		heartbeat1  models.InstanceHeartbeat
		heartbeat2  models.InstanceHeartbeat
		heartbeat3  models.InstanceHeartbeat
	)

	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())

		a := app.NewApp()
		heartbeat1 = a.GetInstance(0).Heartbeat(17)
		heartbeat2 = a.GetInstance(1).Heartbeat(12)
var numRecords = 512
var storeTypes = []string{"ETCD", "Zookeeper"}
var nodeCounts = []int{1, 3, 5, 7}
var concurrencies = []int{1, 5, 10, 15, 20, 25, 30}
var recordSizes = []int{128, 256, 512, 1024, 2048, 4096}

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()
Example #6
0
	"github.com/cloudfoundry/hm9000/testhelpers/storerunner"

	"fmt"
	"time"
)

var storeTypes = []string{"ETCD", "Zookeeper"}
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()
Example #7
0
import (
	. "github.com/cloudfoundry/hm9000/analyzer"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/cloudfoundry/hm9000/config"
	"github.com/cloudfoundry/hm9000/models"
	"github.com/cloudfoundry/hm9000/storeadapter"
	"github.com/cloudfoundry/hm9000/testhelpers/app"
)

var _ = Describe("Analyzer", func() {
	var (
		analyzer         *Analyzer
		etcdStoreAdapter storeadapter.StoreAdapter
		conf             config.Config
		a1               app.App
		a2               app.App
	)

	BeforeEach(func() {
		var err error
		conf, err = config.DefaultConfig()
		Ω(err).ShouldNot(HaveOccured())

		etcdStoreAdapter = storeadapter.NewETCDStoreAdapter(etcdRunner.NodeURLS(), conf.StoreMaxConcurrentRequests)
		err = etcdStoreAdapter.Connect()
		Ω(err).ShouldNot(HaveOccured())

		a1 = app.NewApp()
		a2 = app.NewApp()
Example #8
0
package hm_test

import (
	"github.com/cloudfoundry/hm9000/config"
	. "github.com/cloudfoundry/hm9000/hm"
	"github.com/cloudfoundry/hm9000/storeadapter"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Walk", func() {
	var etcdStoreAdapter storeadapter.StoreAdapter
	BeforeEach(func() {
		conf, _ := config.DefaultConfig()
		etcdStoreAdapter = storeadapter.NewETCDStoreAdapter(etcdRunner.NodeURLS(), conf.StoreMaxConcurrentRequests)
		err := etcdStoreAdapter.Connect()
		Ω(err).ShouldNot(HaveOccured())

		etcdStoreAdapter.Set([]storeadapter.StoreNode{
			storeadapter.StoreNode{Key: "/desired-fresh", Value: []byte("123"), TTL: 0},
			storeadapter.StoreNode{Key: "/actual-fresh", Value: []byte("456"), TTL: 0},
			storeadapter.StoreNode{Key: "/desired/guid1", Value: []byte("guid1"), TTL: 0},
			storeadapter.StoreNode{Key: "/desired/guid2", Value: []byte("guid2"), TTL: 0},
			storeadapter.StoreNode{Key: "/menu/oj", Value: []byte("sweet"), TTL: 0},
			storeadapter.StoreNode{Key: "/menu/breakfast/pancakes", Value: []byte("tasty"), TTL: 0},
			storeadapter.StoreNode{Key: "/menu/breakfast/waffles", Value: []byte("delish"), TTL: 0},
		})
	})

	It("can recurse through keys in the store", func() {
		visited := make(map[string]string)