summaryrefslogtreecommitdiffstats
path: root/configserver/src/test/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackageTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'configserver/src/test/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackageTest.java')
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackageTest.java33
1 files changed, 19 insertions, 14 deletions
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackageTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackageTest.java
index 458cdb82066..4b4b4b92627 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackageTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackageTest.java
@@ -14,6 +14,7 @@ import com.yahoo.config.provisioning.FlavorsConfig;
import com.yahoo.io.IOUtils;
import com.yahoo.path.Path;
import com.yahoo.text.Utf8;
+import com.yahoo.vespa.curator.Curator;
import com.yahoo.vespa.curator.mock.MockCurator;
import org.junit.Before;
import org.junit.Rule;
@@ -31,6 +32,8 @@ import java.util.Set;
import java.util.regex.Pattern;
import static com.yahoo.config.provision.serialization.AllocatedHostsSerializer.toJson;
+import static com.yahoo.vespa.config.server.zookeeper.ZKApplication.META_ZK_PATH;
+import static com.yahoo.vespa.config.server.zookeeper.ZKApplication.USERAPP_ZK_SUBPATH;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -59,20 +62,20 @@ public class ZKApplicationPackageTest {
Optional.of(DockerImage.fromString(dockerImage)))));
}
- private ConfigCurator configCurator;
+ private Curator curator;
@Rule
public TemporaryFolder tmpDir = new TemporaryFolder();
@Before
public void setup() {
- configCurator = ConfigCurator.create(new MockCurator());
+ curator = new MockCurator();
}
@Test
public void testBasicZKFeed() throws IOException {
- feed(configCurator, new File(APP));
- ZKApplicationPackage zkApp = new ZKApplicationPackage(configCurator, Path.fromString("/0"));
+ feed(curator, new File(APP));
+ ZKApplicationPackage zkApp = new ZKApplicationPackage(curator, Path.fromString("/0"));
assertTrue(Pattern.compile(".*<slobroks>.*",Pattern.MULTILINE+Pattern.DOTALL).matcher(IOUtils.readAll(zkApp.getServices())).matches());
assertTrue(Pattern.compile(".*<alias>.*",Pattern.MULTILINE+Pattern.DOTALL).matcher(IOUtils.readAll(zkApp.getHosts())).matches());
assertTrue(Pattern.compile(".*<slobroks>.*",Pattern.MULTILINE+Pattern.DOTALL).matcher(IOUtils.readAll(zkApp.getFile(Path.fromString("services.xml")).createReader())).matches());
@@ -103,13 +106,14 @@ public class ZKApplicationPackageTest {
assertEquals("mydisc", DeploymentSpec.fromXml(zkApp.getDeployment().get()).requireInstance("default").globalServiceId().get());
}
- private void feed(ConfigCurator zk, File dirToFeed) throws IOException {
+ private void feed(com.yahoo.vespa.curator.Curator zk, File dirToFeed) throws IOException {
assertTrue(dirToFeed.isDirectory());
- feedZooKeeper(zk, dirToFeed, "/0" + ConfigCurator.USERAPP_ZK_SUBPATH, null, true);
+ Path sessionPath = Path.fromString("/0");
+ feedZooKeeper(zk, dirToFeed, sessionPath.append(USERAPP_ZK_SUBPATH), null, true);
String metaData = "{\"deploy\":{\"user\":\"foo\",\"from\":\"bar\",\"timestamp\":1},\"application\":{\"id\":\"foo:foo:default\",\"checksum\":\"abc\",\"generation\":4,\"previousActiveGeneration\":3}}";
- zk.putData("/0", ConfigCurator.META_ZK_PATH, metaData);
- zk.putData("/0/" + ZKApplicationPackage.fileRegistryNode + "/3.0.0", "dummyfiles");
- zk.putData("/0/" + ZKApplicationPackage.allocatedHostsNode, toJson(ALLOCATED_HOSTS));
+ zk.set(sessionPath.append(META_ZK_PATH), Utf8.toBytes(metaData));
+ zk.set(sessionPath.append(ZKApplicationPackage.fileRegistryNode).append("/3.0.0"), Utf8.toBytes("dummyfiles"));
+ zk.set(sessionPath.append(ZKApplicationPackage.allocatedHostsNode), toJson(ALLOCATED_HOSTS));
}
private static class MockNodeFlavors extends NodeFlavors{
@@ -131,7 +135,7 @@ public class ZKApplicationPackageTest {
* @param filenameFilter A FilenameFilter which decides which files in dir are fed to zookeeper
* @param recurse recurse subdirectories
*/
- static void feedZooKeeper(ConfigCurator zk, File dir, String path, FilenameFilter filenameFilter, boolean recurse) {
+ static void feedZooKeeper(com.yahoo.vespa.curator.Curator zk, File dir, Path path, FilenameFilter filenameFilter, boolean recurse) {
try {
if (filenameFilter == null) {
filenameFilter = acceptsAllFileNameFilter;
@@ -141,12 +145,13 @@ public class ZKApplicationPackageTest {
}
for (File file : listFiles(dir, filenameFilter)) {
if (file.getName().startsWith(".")) continue; //.svn , .git ...
+ Path filePath = path.append(file.getName());
if (file.isFile()) {
- String contents = IOUtils.readFile(file);
- zk.putData(path, file.getName(), contents);
+ byte[] contents = IOUtils.readFileBytes(file);
+ zk.set(filePath, contents);
} else if (recurse && file.isDirectory()) {
- zk.createNode(path, file.getName());
- feedZooKeeper(zk, file, path + '/' + file.getName(), filenameFilter, recurse);
+ zk.create(filePath);
+ feedZooKeeper(zk, file, filePath, filenameFilter, recurse);
}
}
}