Exemplo n.º 1
0
	"github.com/cloudfoundry/gosteno"
	"github.com/cloudfoundry/storeadapter"
	"github.com/cloudfoundry/storeadapter/fakestoreadapter"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Elector", func() {
	var fakeStore *fakestoreadapter.FakeStoreAdapter
	var logger *gosteno.Logger
	var testingSink *gosteno.TestingSink

	BeforeEach(func() {
		gosteno.EnterTestMode()
		testingSink = gosteno.GetMeTheGlobalTestSink()

		fakeStore = fakestoreadapter.New()
		logger = gosteno.NewLogger("test")
	})

	Context("at initialization", func() {
		It("connects to the store", func() {
			elector.NewElector("name", fakeStore, 1*time.Millisecond, logger)
			Expect(fakeStore.DidConnect).To(BeTrue())
		})

		Context("when store connection fails", func() {
			BeforeEach(func() {
				fakeStore.ConnectErr = errors.New("connection error")
Exemplo n.º 2
0
	"runtime"
	"strings"
	"time"

	"github.com/cloudfoundry/gosteno"
	"github.com/cloudfoundry/hm9000/cfcomponent/instrumentation"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("cfcomponent", func() {
	var logger *gosteno.Logger

	BeforeEach(func() {
		gosteno.EnterTestMode(gosteno.LOG_DEBUG)
		logger = gosteno.NewLogger("testlogger")
	})

	It("ip address default", func() {
		component, err := NewComponent(logger, "loggregator", 0, GoodHealthMonitor{}, 0, nil, nil)
		Expect(err).NotTo(HaveOccurred())
		Expect(component.IpAddress).NotTo(BeEmpty())
		Expect(component.IpAddress).NotTo(Equal("0.0.0.0"))
		Expect(component.IpAddress).NotTo(Equal("127.0.0.1"))
	})

	It("status port default", func() {
		component, err := NewComponent(logger, "loggregator", 0, GoodHealthMonitor{}, 0, nil, nil)
		Expect(err).NotTo(HaveOccurred())
		Expect(component.StatusPort).NotTo(Equal(uint32(0)))