})

			It("Panics if MaintainNode returns error", func() {
				err := errors.New("some etcd time out error")
				fakeadapter := &fakes.FakeStoreAdapter{}
				fakeadapter.MaintainNodeReturns(nil, nil, err)
				Expect(func() {
					dopplerservice.Announce(localIP, time.Second, &conf, fakeadapter, loggertesthelper.Logger())
				}).To(Panic())
			})

			Context("when tls transport is enabled", func() {
				It("announces udp, tcp, and tls values", func() {
					dopplerMeta := fmt.Sprintf(`{"version": 1, "endpoints":["udp://%[1]s:1234", "tcp://%[1]s:5678", "ws://%[1]s:8888", "tls://%[1]s:9012"]}`, localIP)

					conf.EnableTLSTransport = true
					conf.TLSListenerConfig = config.TLSListenerConfig{
						Port: 9012,
					}
					stopChan = dopplerservice.Announce(localIP, time.Second, &conf, etcdAdapter, loggertesthelper.Logger())

					Eventually(func() []byte {
						node, err := etcdAdapter.Get(dopplerKey)
						if err != nil {
							return nil
						}
						return node.Value
					}).Should(MatchJSON(dopplerMeta))
				})
			})
示例#2
0
		metronRunner.Protocols = protocols
		metronRunner.Start()
	})

	AfterEach(func() {
		close(stopTheWorld)
		close(stopAnnounce)

		metronRunner.Stop()
	})

	Describe("Metron panics", func() {
		Context("with Metron configured to requires TLS, and TLS disabled on Doppler", func() {
			BeforeEach(func() {
				protocols = []config.Protocol{"tls"}
				dopplerConfig.EnableTLSTransport = false
			})

			Context("with Doppler advertising only on legacy endpoint", func() {
				It("panics", func() {
					stopAnnounce = dopplerservice.AnnounceLegacy("127.0.0.1", time.Minute, dopplerConfig, etcdAdapter, logger)
					Eventually(metronRunner.Process.Wait()).Should(Receive())
				})
			})

			Context("with Doppler advertising UDP on meta endpoint", func() {
				It("panics", func() {
					stopAnnounce = dopplerservice.Announce("127.0.0.1", time.Minute, dopplerConfig, etcdAdapter, logger)
					Eventually(metronRunner.Process.Wait()).Should(Receive())
				})
			})