コード例 #1
0
			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))
				})
			})

			Context("when tls transport is disabled", func() {
				It("announces only udp and tcp values", func() {
コード例 #2
0
			legacyReleaseChan := announcer.AnnounceLegacy(localIp, time.Second, &conf, storeAdapter, loggertesthelper.Logger())
			defer close(legacyReleaseChan)

			Eventually(func() error {
				_, err := storeAdapter.Get(legacyETCDKey)
				return err
			}, 3).ShouldNot(HaveOccurred())
		})
	})

	Context("Store Transport", func() {
		Context("With EnableTlsTransport set to true", func() {
			It("stores udp and tcp transport in etcd", func() {
				conf.EnableTLSTransport = true
				conf.TLSListenerConfig = config.TLSListenerConfig{
					Port: 4567,
				}
				storeAdapter := setupAdapter(dopplerETCDKey, conf)

				stopChan := announcer.Announce(localIp, time.Second, &conf, storeAdapter, loggertesthelper.Logger())
				defer close(stopChan)

				dopplerMeta := createDopplerMeta(localIp, conf)

				Eventually(func() []byte {
					node, _ := storeAdapter.Get(dopplerETCDKey)
					return node.Value
				}, 3).Should(MatchJSON(dopplerMeta))
			})
		})