~ubuntu-branches/ubuntu/vivid/ironic/vivid-updates

« back to all changes in this revision

Viewing changes to ironic/tests/test_hash_ring.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2015-01-05 12:21:37 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20150105122137-171bqrdpcxqipunk
Tags: 2015.1~b1-0ubuntu1
* New upstream beta release:
  - d/control: Align version requirements with upstream release.
* d/watch: Update uversionmangle to deal with kilo beta versioning
  changes.
* d/control: Bumped Standards-Version to 3.9.6, no changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#    License for the specific language governing permissions and limitations
14
14
#    under the License.
15
15
 
 
16
import hashlib
 
17
 
 
18
import mock
16
19
from oslo.config import cfg
17
20
from testtools import matchers
18
21
 
19
22
from ironic.common import exception
20
23
from ironic.common import hash_ring
21
 
from ironic.db import api as dbapi
22
24
from ironic.tests import base
23
25
from ironic.tests.db import base as db_base
24
26
 
34
36
    #                fake -> foo, bar, baz
35
37
    #                fake-again -> bar, baz, foo
36
38
 
 
39
    @mock.patch.object(hashlib, 'md5')
 
40
    def test__hash2int_returns_int(self, mock_md5):
 
41
        CONF.set_override('hash_partition_exponent', 0)
 
42
        r1 = 32 * 'a'
 
43
        r2 = 32 * 'b'
 
44
        mock_md5.return_value.hexdigest.side_effect = [r1, r2]
 
45
 
 
46
        hosts = ['foo', 'bar']
 
47
        replicas = 1
 
48
        ring = hash_ring.HashRing(hosts, replicas=replicas)
 
49
 
 
50
        self.assertIn(int(r1, 16), ring._host_hashes)
 
51
        self.assertIn(int(r2, 16), ring._host_hashes)
 
52
 
37
53
    def test_create_ring(self):
38
54
        hosts = ['foo', 'bar']
39
55
        replicas = 2
199
215
    def setUp(self):
200
216
        super(HashRingManagerTestCase, self).setUp()
201
217
        self.ring_manager = hash_ring.HashRingManager()
202
 
        self.dbapi = dbapi.get_instance()
203
218
 
204
219
    def register_conductors(self):
205
220
        self.dbapi.register_conductor({