def test_protocol_downgrade_test(self): lower = ProtocolVersion.get_lower_supported(ProtocolVersion.DSE_V2) self.assertEqual(ProtocolVersion.DSE_V1, lower) lower = ProtocolVersion.get_lower_supported(ProtocolVersion.DSE_V1) self.assertEqual(ProtocolVersion.V5, lower) lower = ProtocolVersion.get_lower_supported(ProtocolVersion.V5) self.assertEqual(ProtocolVersion.V4, lower) lower = ProtocolVersion.get_lower_supported(ProtocolVersion.V4) self.assertEqual(ProtocolVersion.V3, lower) lower = ProtocolVersion.get_lower_supported(ProtocolVersion.V3) self.assertEqual(ProtocolVersion.V2, lower) lower = ProtocolVersion.get_lower_supported(ProtocolVersion.V2) self.assertEqual(ProtocolVersion.V1, lower) lower = ProtocolVersion.get_lower_supported(ProtocolVersion.V1) self.assertEqual(0, lower) self.assertTrue( ProtocolVersion.uses_error_code_map(ProtocolVersion.DSE_V1)) self.assertTrue( ProtocolVersion.uses_int_query_flags(ProtocolVersion.DSE_V1)) self.assertFalse( ProtocolVersion.uses_error_code_map(ProtocolVersion.V4)) self.assertFalse( ProtocolVersion.uses_int_query_flags(ProtocolVersion.V4))
def _perform_cql_statement(self, text, consistency_level, expected_exception, session=None): """ Simple helper method to preform cql statements and check for expected exception @param text CQl statement to execute @param consistency_level Consistency level at which it is to be executed @param expected_exception Exception expected to be throw or none """ if session is None: session = self.session statement = SimpleStatement(text) statement.consistency_level = consistency_level if expected_exception is None: self.execute_helper(session, statement) else: with self.assertRaises(expected_exception) as cm: self.execute_helper(session, statement) if ProtocolVersion.uses_error_code_map(PROTOCOL_VERSION): if isinstance(cm.exception, ReadFailure): self.assertEqual( list(cm.exception.error_code_map.values())[0], 1) if isinstance(cm.exception, WriteFailure): self.assertEqual( list(cm.exception.error_code_map.values())[0], 0)
def recv_error_info(f, protocol_version): consistency = read_consistency_level(f) received_responses = read_int(f) required_responses = read_int(f) if ProtocolVersion.uses_error_code_map(protocol_version): error_code_map = read_error_code_map(f) failures = len(error_code_map) else: error_code_map = None failures = read_int(f) write_type = WriteType.name_to_value[read_string(f)] return { 'consistency': consistency, 'received_responses': received_responses, 'required_responses': required_responses, 'failures': failures, 'error_code_map': error_code_map, 'write_type': write_type }
def recv_error_info(f, protocol_version): consistency = read_consistency_level(f) received_responses = read_int(f) required_responses = read_int(f) if ProtocolVersion.uses_error_code_map(protocol_version): error_code_map = read_error_code_map(f) failures = len(error_code_map) else: error_code_map = None failures = read_int(f) data_retrieved = bool(read_byte(f)) return { 'consistency': consistency, 'received_responses': received_responses, 'required_responses': required_responses, 'failures': failures, 'error_code_map': error_code_map, 'data_retrieved': data_retrieved }
def _perform_cql_statement(self, text, consistency_level, expected_exception, session=None): """ Simple helper method to preform cql statements and check for expected exception @param text CQl statement to execute @param consistency_level Consistency level at which it is to be executed @param expected_exception Exception expected to be throw or none """ if session is None: session = self.session statement = SimpleStatement(text) statement.consistency_level = consistency_level if expected_exception is None: self.execute_helper(session, statement) else: with self.assertRaises(expected_exception) as cm: self.execute_helper(session, statement) if ProtocolVersion.uses_error_code_map(PROTOCOL_VERSION): if isinstance(cm.exception, ReadFailure): self.assertEqual(list(cm.exception.error_code_map.values())[0], 1) if isinstance(cm.exception, WriteFailure): self.assertEqual(list(cm.exception.error_code_map.values())[0], 0)