예제 #1
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)
예제 #2
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)
예제 #3
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)
예제 #4
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)
예제 #5
0
 def check_quorum_health((policy_id, server_id)):
     _policy_id.append(policy_id)
     return cass.check_quorum_health(self._db, policy_id)
예제 #6
0
파일: views.py 프로젝트: rackerlabs/bobby
 def check_quorum_health((policy_id, server_id)):
     _policy_id.append(policy_id)
     return cass.check_quorum_health(self._db, policy_id)