Exemplo n.º 1
0
    def test_unhealthy(self):
        """Results in a False when the quorum is unhealthy."""
        def execute(query, data, consistency):
            return defer.succeed([
                {'policyId': 'policy-uvwxyz',
                 'serverId': 'server-abc',
                 'state': 'OK'},
                {'policyId': 'policy-uvwxyz',
                 'serverId': 'server-def',
                 'state': 'OK'},
                {'policyId': 'policy-uvwxyz',
                 'serverId': 'server-ghi',
                 'state': 'Critical'},
                {'policyId': 'policy-uvwxyz',
                 'serverId': 'server-jkl',
                 'state': 'Critical'},
                {'policyId': 'policy-uvwxyz',
                 'serverId': 'server-mno',
                 'state': 'Critical'},
            ])

        self.client.execute.side_effect = execute

        d = cass.check_quorum_health(self.client, 'alarm-uvwxyz')

        result = self.successResultOf(d)
        self.assertFalse(result)
Exemplo n.º 2
0
    def test_healthy(self):
        """Results in a False when the quorum is healthy."""
        def execute(query, data, consistency):
            return defer.succeed([
                {'policyId': 'policy-uvwxyz',
                 'serverId': 'server-abc',
                 'state': 'OK'},
                {'policyId': 'policy-uvwxyz',
                 'serverId': 'server-def',
                 'state': 'OK'},
                {'policyId': 'policy-uvwxyz',
                 'serverId': 'server-ghi',
                 'state': 'OK'},
                {'policyId': 'policy-uvwxyz',
                 'serverId': 'server-jkl',
                 'state': 'Critical'},
                {'policyId': 'policy-uvwxyz',
                 'serverId': 'server-mno',
                 'state': 'Critical'},
            ])

        self.client.execute.side_effect = execute

        d = cass.check_quorum_health(self.client, 'policy-uvwxyz')

        result = self.successResultOf(d)
        self.assertTrue(result)

        self.client.execute.assert_called_once_with(
            'SELECT * FROM serverpolicies WHERE "policyId"=:policyId;',
            {'policyId': 'policy-uvwxyz'}, 1)
Exemplo n.º 3
0
 def check_quorum_health((policy_id, server_id)):
     _policy_id.append(policy_id)
     return cass.check_quorum_health(self._db, policy_id)