Пример #1
0
    def test_cas(self):

        for curr in zkutil.cas_loop(self.zk, self.path):
            curr.v += 2

        final_val, zstat = self.zk.get(self.path)
        dd(final_val, zstat)
        self.assertEqual('3', final_val)
    def test_cas(self):

        for curr in zkutil.cas_loop(self.zk, self.path):
            curr.v += 2

        final_val, zstat = self.zk.get(self.path)
        dd(final_val, zstat)
        self.assertEqual('3', final_val)
Пример #3
0
    def test_cas_non_json(self):

        for curr in zkutil.cas_loop(self.zk, self.path, json=False):
            self.assertIsInstance(curr.v, str)
            curr.v += 'a'

        final_val, zstat = self.zk.get(self.path)
        dd(final_val, zstat)
        self.assertEqual('1a', final_val)
Пример #4
0
    def test_cas_abort(self):

        for curr in zkutil.cas_loop(self.zk, self.path):
            curr.v += 2
            break

        final_val, zstat = self.zk.get(self.path)
        dd(final_val, zstat)
        self.assertEqual('1', final_val, 'a break statement cancel set_val()')
    def test_cas_non_json(self):

        for curr in zkutil.cas_loop(self.zk, self.path, json=False):
            self.assertIsInstance(curr.v, str)
            curr.v += 'a'

        final_val, zstat = self.zk.get(self.path)
        dd(final_val, zstat)
        self.assertEqual('1a', final_val)
    def test_cas_abort(self):

        for curr in zkutil.cas_loop(self.zk, self.path):
            curr.v += 2
            break

        final_val, zstat = self.zk.get(self.path)
        dd(final_val, zstat)
        self.assertEqual('1', final_val, 'a break statement cancel set_val()')
    def test_cas_create_zk(self):

        for first_arg in (
                '127.0.0.1:21811',
                {'hosts': '127.0.0.1:21811'},
                zkutil.ZKConf(hosts='127.0.0.1:21811'),
        ):
            self.zk.set(self.path, '1')

            for curr in zkutil.cas_loop(first_arg, self.path):
                curr.v += 2

            final_val, zstat = self.zk.get(self.path)
            dd(final_val, zstat)
            self.assertEqual('3', final_val)
Пример #8
0
    def test_cas_create_zk(self):

        for first_arg in (
                '127.0.0.1:21811',
            {
                'hosts': '127.0.0.1:21811'
            },
                zkutil.ZKConf(hosts='127.0.0.1:21811'),
        ):
            self.zk.set(self.path, '1')

            for curr in zkutil.cas_loop(first_arg, self.path):
                curr.v += 2

            final_val, zstat = self.zk.get(self.path)
            dd(final_val, zstat)
            self.assertEqual('3', final_val)
Пример #9
0
 def _update():
     for ii in range(10):
         for curr in zkutil.cas_loop('127.0.0.1:21811', self.path):
             curr.v += 1
Пример #10
0
 def _update():
     for ii in range(10):
         for curr in zkutil.cas_loop('127.0.0.1:21811', self.path):
             curr.v += 1