Esempio n. 1
0
func NewSimulator(conf *config.Config, storeRunner storerunner.StoreRunner, store store.Store, desiredStateServer *desiredstateserver.DesiredStateServer, cliRunner *CLIRunner, messageBus yagnats.NATSClient) *Simulator {
	desiredStateServer.Reset()

	return &Simulator{
		currentTimestamp:       100,
		conf:                   conf,
		storeRunner:            storeRunner,
		store:                  store,
		desiredStateServer:     desiredStateServer,
		cliRunner:              cliRunner,
		TicksToAttainFreshness: int(conf.ActualFreshnessTTLInHeartbeats) + 1,
		TicksToExpireHeartbeat: int(conf.HeartbeatTTLInHeartbeats),
		GracePeriod:            int(conf.GracePeriodInHeartbeats),
		messageBus:             messageBus,
	}
}
package desiredstatefetcher_test

import (
	"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