public void ZooKeeperConnectionCreatesAndGetsCreateTime() { var prodConfig = this.ZooKeeperBasedSyncProdConfig; using (IZooKeeperConnection connection = new ZooKeeperConnection(prodConfig.ZooKeeper.ZkConnect)) { connection.Connect(null); string pathName = "/" + Guid.NewGuid(); connection.Create(pathName, null, CreateMode.Persistent); long createTime = connection.GetCreateTime(pathName); Assert.Greater(createTime, 0); connection.Delete(pathName); } }
public void ZooKeeperConnectionCreatesAndDeletesPath() { var prodConfig = this.ZooKeeperBasedSyncProdConfig; using (IZooKeeperConnection connection = new ZooKeeperConnection(prodConfig.ZooKeeper.ZkConnect)) { connection.Connect(null); string pathName = "/" + Guid.NewGuid(); connection.Create(pathName, null, CreateMode.Persistent); Assert.IsTrue(connection.Exists(pathName, false)); connection.Delete(pathName); Assert.IsFalse(connection.Exists(pathName, false)); } }
public void ZooKeeperConnectionCreatesAndGetsChildren() { var prodConfig = this.ZooKeeperBasedSyncProdConfig; using (IZooKeeperConnection connection = new ZooKeeperConnection(prodConfig.ZooKeeper.ZkConnect)) { connection.Connect(null); string child = Guid.NewGuid().ToString(); string pathName = "/" + child; connection.Create(pathName, null, CreateMode.Persistent); IList <string> children = connection.GetChildren("/", false); Assert.Greater(children.Count, 0); Assert.IsTrue(children.Contains(child)); connection.Delete(pathName); } }
public void ZooKeeperConnectionWritesAndReadsData() { var prodConfig = this.ZooKeeperBasedSyncProdConfig; using (IZooKeeperConnection connection = new ZooKeeperConnection(prodConfig.ZooKeeper.ZkConnect)) { connection.Connect(null); string child = Guid.NewGuid().ToString(); string pathName = "/" + child; connection.Create(pathName, null, CreateMode.Persistent); var sourceData = new byte[] { 1, 2 }; connection.WriteData(pathName, sourceData); byte[] resultData = connection.ReadData(pathName, null, false); Assert.IsNotNull(resultData); Assert.AreEqual(sourceData[0], resultData[0]); Assert.AreEqual(sourceData[1], resultData[1]); connection.Delete(pathName); } }