Files
deb-python-taskflow/taskflow/tests/unit/persistence/test_zake_persistence.py
Joshua Harlow b473d9ac6b Some zookeeper persistence improvements/adjustments
- Only use zake in unit-tests by providing a client
  to the backend as a fake client. This avoids cases
  where a real client should be provided; and if not
  provided then a error should be thrown. This avoids
  potential misuse of zake (which really is only designed
  for testing usage and not for actual usage in production).
- Add a kazoo_utils file that will be shared to make
  kazoo clients and to parse hosts into a kazoo friendly
  format for other usages of kazoo clients that will be
  appearing soon.
- Ensure basic assertions when creating the zk backend,
  don't allow empty paths, require absolute paths.
- Update exc_wrapper to have slightly more descriptive
  messages that identify more of what the original errors
  category was.
- Create initial paths on upgrade() to mirror what other
  backends are doing in their upgrade() function. Other
  backends do their initial steps to upgrade there backends
  in this function (ie sqlalchemy does its migrations here
  so it seems to be consistent place to make sure zookeeper
  paths are created correctly).

Change-Id: Iabafe73c059b4719617f01bd1ee35795f71ca21d
2014-02-02 18:20:50 -08:00

48 lines
1.6 KiB
Python

# -*- coding: utf-8 -*-
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright (C) 2014 AT&T Labs All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import contextlib
from zake import fake_client
from taskflow.persistence import backends
from taskflow.persistence.backends import impl_zookeeper
from taskflow import test
from taskflow.tests.unit.persistence import base
class ZakePersistenceTest(test.TestCase, base.PersistenceTestMixin):
def _get_connection(self):
return self._backend.get_connection()
def setUp(self):
super(ZakePersistenceTest, self).setUp()
conf = {
"path": "/taskflow",
}
client = fake_client.FakeClient()
client.start()
self._backend = impl_zookeeper.ZkBackend(conf, client=client)
conn = self._backend.get_connection()
conn.upgrade()
def test_zk_persistence_entry_point(self):
conf = {'connection': 'zookeeper:'}
with contextlib.closing(backends.fetch(conf)) as be:
self.assertIsInstance(be, impl_zookeeper.ZkBackend)