func (r *ZkRegistry) zkConnect() (err error) { z, session, err := zk.Dial(r.zkServers, 10*time.Second) if err != nil { err = fmt.Errorf("ZkRegistry connection failed: %s", err) return } // Wait for connection. event := <-session if event.State != zk.STATE_CONNECTED { err = fmt.Errorf("ZkRegistry connection failed: %v", event) return } r.zk = z r.zkSession = session return }
Describe("EnsurePath", func() { var s *TestServer var z *zk.Conn BeforeEach(func() { port, err := netutils.UnusedPort() Expect(err).NotTo(HaveOccurred()) s, err = NewTestServer(port) Expect(err).NotTo(HaveOccurred()) if err != nil { return } zz, session, err := zk.Dial("localhost:"+strconv.Itoa(port), 5e9) Expect(err).NotTo(HaveOccurred()) Expect((<-session).State).To(Equal(zk.STATE_CONNECTED)) z = zz }) AfterEach(func() { z.Close() s.Stop() }) It("should ensure path", func() { perm := zk.WorldACL(zk.PERM_ALL)