def test_a_lock_goes_invalid_if_majority_not_attained(self):
        lock = self.redlock_with_51_servers_up_49_down.lock('test_goes_invalid', seconds_to_ms(30))
        assert_that(self.redlock_with_51_servers_up_49_down.is_valid(lock), is_(True))

        twenty_five_servers_where_lock_is_valid = [s for s in self.redlock_with_51_servers_up_49_down.servers if
                                                   s.get(lock.resource) == lock.key][:25]

        for server in twenty_five_servers_where_lock_is_valid:
            server.delete(lock.resource)

        assert_that(self.redlock_with_51_servers_up_49_down.is_valid(lock), is_(False))
예제 #2
0
    def test_a_lock_goes_invalid_if_majority_not_attained(self):
        lock = self.redlock_with_51_servers_up_49_down.lock(
            'test_goes_invalid', seconds_to_ms(30))
        assert_that(self.redlock_with_51_servers_up_49_down.is_valid(lock),
                    is_(True))

        twenty_five_servers_where_lock_is_valid = [
            s for s in self.redlock_with_51_servers_up_49_down.servers
            if s.get(lock.resource) == lock.key
        ][:25]

        for server in twenty_five_servers_where_lock_is_valid:
            server.delete(lock.resource)

        assert_that(self.redlock_with_51_servers_up_49_down.is_valid(lock),
                    is_(False))
 def test_a_lock_is_always_valid_within_its_validity_time(self):
     lock = self.redlock.lock('test_regular_lock', seconds_to_ms(30))
     assert_that(self.redlock.is_valid(lock), is_(True))
예제 #4
0
 def test_a_lock_is_always_valid_within_its_validity_time(self):
     lock = self.redlock.lock('test_regular_lock', seconds_to_ms(30))
     assert_that(self.redlock.is_valid(lock), is_(True))