Search in sources :

Example 1 with MasterZooKeeperRegistrar

use of com.spotify.helios.master.MasterZooKeeperRegistrar in project helios by spotify.

the class ZooKeeperAclInitializerTest method testInitializeAcl.

@Test
public void testInitializeAcl() throws Exception {
    // setup the initial helios tree
    final ZooKeeperClient zkClient = new DefaultZooKeeperClient(zk.curatorWithSuperAuth());
    zkClient.ensurePath(Paths.configId(CLUSTER_ID));
    new MasterZooKeeperRegistrar("helios-master").tryToRegister(zkClient);
    // to start with, nothing should have permissions
    for (final String path : zkClient.listRecursive("/")) {
        assertEquals(ZooDefs.Ids.OPEN_ACL_UNSAFE, zkClient.getAcl(path));
    }
    // initialize ACL's
    ZooKeeperAclInitializer.initializeAcl(zk.connectString(), CLUSTER_ID, MASTER_USER, MASTER_PASSWORD, AGENT_USER, AGENT_PASSWORD);
    for (final String path : zkClient.listRecursive("/")) {
        final List<ACL> expected = aclProvider.getAclForPath(path);
        final List<ACL> actual = zkClient.getAcl(path);
        assertEquals(expected.size(), actual.size());
        assertTrue(expected.containsAll(actual));
    }
}
Also used : ZooKeeperClient(com.spotify.helios.servicescommon.coordination.ZooKeeperClient) DefaultZooKeeperClient(com.spotify.helios.servicescommon.coordination.DefaultZooKeeperClient) MasterZooKeeperRegistrar(com.spotify.helios.master.MasterZooKeeperRegistrar) ACL(org.apache.zookeeper.data.ACL) DefaultZooKeeperClient(com.spotify.helios.servicescommon.coordination.DefaultZooKeeperClient) Test(org.junit.Test)

Aggregations

MasterZooKeeperRegistrar (com.spotify.helios.master.MasterZooKeeperRegistrar)1 DefaultZooKeeperClient (com.spotify.helios.servicescommon.coordination.DefaultZooKeeperClient)1 ZooKeeperClient (com.spotify.helios.servicescommon.coordination.ZooKeeperClient)1 ACL (org.apache.zookeeper.data.ACL)1 Test (org.junit.Test)1