Exemplo n.º 1
0
    def test_get_children_default_watcher(self):
        watcher = mock()
        z = pookeeper.allocate(self.hosts, watcher=watcher)

        z.create('/pookie', CREATOR_ALL_ACL, Persistent(), data=_random_data())
        z.get_children('/pookie', watch=True)

        z.create('/pookie/bear', CREATOR_ALL_ACL, Persistent(), data=_random_data())
        z.get_children('/pookie', watch=True)

        z.set_data('/pookie', _random_data())
        z.set_data('/pookie/bear', _random_data())

        # One is for when we do and the other is for when we don't chroot
        z.get_children('/pookie', watch=True)
        z.get_children('/pookie/bear', watch=True)

        z.delete('/pookie/bear')
        z.delete('/pookie')

        z.close()

        mockito.verify(watcher).session_connected(matchers.any(long), matchers.any(str), False)
        mockito.verify(watcher, times=2).children_changed('/pookie')
        mockito.verify(watcher).node_deleted('/pookie/bear')
        mockito.verify(watcher).connection_closed()
        verifyNoMoreInteractions(watcher)
def test_excutingWithNoCommandsJustLogsIn():
    json = '{\
        "hostname" : "<ip>",\
        "username" : "root",\
        "password" : null\
    }'
    cliProcessingJson, UserObject, CliObject, cli, user = setupCliProcessingJson(json)
    cliProcessingJson.execute(UserObject.called, CliObject.called)
    verify(cli).connectWithSsh()
    verify(cli).closeCliConnectionTo()
    verifyNoMoreInteractions(user)
Exemplo n.º 3
0
    def test_set_data_watcher(self):
        watcher = mock()
        z = pookeeper.allocate(self.hosts)

        z.create('/pookie', CREATOR_ALL_ACL, Ephemeral(), data=_random_data())

        stat = z.exists('/pookie')
        stat = z.set_data('/pookie', _random_data(), stat.version)
        z.get_data('/pookie', watcher=watcher)
        stat = z.set_data('/pookie', _random_data(), stat.version)
        z.get_data('/pookie', watcher=watcher)
        z.delete('/pookie', stat.version)

        z.close()

        inorder.verify(watcher).data_changed('/pookie')
        inorder.verify(watcher).node_deleted('/pookie')
        verifyNoMoreInteractions(watcher)
Exemplo n.º 4
0
    def test_set_data_default_watcher(self):
        watcher = mock()
        z = pookeeper.allocate(self.hosts, watcher=watcher)

        z.create('/pookie', CREATOR_ALL_ACL, Ephemeral(), data=_random_data())

        stat = z.exists('/pookie')
        stat = z.set_data('/pookie', _random_data(), stat.version)
        z.get_data('/pookie', watch=True)
        stat = z.set_data('/pookie', _random_data(), stat.version)
        z.get_data('/pookie', watch=True)
        z.delete('/pookie', stat.version)

        z.close()

        inorder.verify(watcher).session_connected(matchers.any(long), matchers.any(str), False)
        inorder.verify(watcher).data_changed('/pookie')
        inorder.verify(watcher).node_deleted('/pookie')
        inorder.verify(watcher).connection_closed()
        verifyNoMoreInteractions(watcher)
Exemplo n.º 5
0
    def test_exists_watcher(self):
        watcher = mock()
        z = pookeeper.allocate(self.hosts)

        assert not z.exists('/pookie', watcher=watcher)
        z.create('/pookie', CREATOR_ALL_ACL, Ephemeral(), data=_random_data())

        stat = z.exists('/pookie', watcher=watcher)
        stat = z.set_data('/pookie', _random_data(), stat.version)
        # This data change will be ignored since the watch has been reset
        z.set_data('/pookie', _random_data(), stat.version)
        stat = z.exists('/pookie', watcher=watcher)
        z.delete('/pookie', stat.version)

        z.close()

        inorder.verify(watcher).node_created('/pookie')
        inorder.verify(watcher).data_changed('/pookie')
        inorder.verify(watcher).node_deleted('/pookie')
        verifyNoMoreInteractions(watcher)