func TestDesiredStateFetcher(t *testing.T) {
	stateServer = desiredstateserver.NewDesiredStateServer()
	go stateServer.SpinUp(6001)

	RegisterFailHandler(Fail)
	RunSpecs(t, "Desired State Fetcher Suite")
}
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 {}
}
Example #3
0
func (coordinator *MCATCoordinator) StartDesiredStateServer() {
	coordinator.StateServer = desiredstateserver.NewDesiredStateServer()
	go coordinator.StateServer.SpinUp(coordinator.DesiredStateServerPort)
}
	"net/http"
	"testing"
	"time"

	"github.com/cloudfoundry/hm9000/testhelpers/desiredstateserver"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var stateServer *desiredstateserver.DesiredStateServer

func TestDesiredStateFetcher(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "Desired State Fetcher Suite")
}

var _ = BeforeSuite(func() {
	stateServer = desiredstateserver.NewDesiredStateServer()
	go stateServer.SpinUp(6001)

	Eventually(func() int {
		before := time.Now()
		resp, err := http.Get("http://127.0.0.1:6001/bulk/counts")
		println("GET", time.Now().Sub(before).String())
		if err != nil {
			return 0
		}
		return resp.StatusCode
	}).Should(Equal(http.StatusOK))
})