'Test to validate that write failures from the coordinator are surfaced appropriately.
test_write_failures_from_coordinator Enable write failures on the various nodes using a custom jvm flag,
cassandra.test.fail_writes_ks. This will cause writes to fail on that specific node. Depending on the replication
factor of the keyspace, and the consistency level, we will expect the coordinator to send WriteFailure, or not.
@since 2.6.0, 3.7.0
@jira_ticket PYTHON-238, PYTHON-619
@expected_result Appropriate write failures from the coordinator
@test_category queries:basic'

def test_write_failures_from_coordinator(self):

    self._perform_cql_statement("\n                                                CREATE    KEYSPACE    testksfail\n                                                WITH    replication    =    {'class':    'SimpleStrategy',    'replication_factor':    '3'}\n                                                ", consistency_level=ConsistencyLevel.ALL, expected_exception=None)
    self._perform_cql_statement('\n                                                CREATE    TABLE    testksfail.test    (\n                                                                k    int    PRIMARY    KEY,\n                                                                v    int    )\n                                                ', consistency_level=ConsistencyLevel.ALL, expected_exception=None)
    failing_nodes = [self.node1]
    self.setFailingNodes(failing_nodes, 'testksfail')
    self._perform_cql_statement('\n                                                INSERT    INTO    testksfail.test    (k,    v)    VALUES        (1,    0    )\n                                                ', consistency_level=ConsistencyLevel.ALL, expected_exception=WriteFailure)
    self._perform_cql_statement('\n                                                INSERT    INTO    testksfail.test    (k,    v)    VALUES        (1,    0    )\n                                                ', consistency_level=ConsistencyLevel.QUORUM, expected_exception=None)
    failing_nodes = []
    self.setFailingNodes(failing_nodes, 'testksfail')
    self._perform_cql_statement('\n                                                DROP    KEYSPACE    testksfail\n                                                ', consistency_level=ConsistencyLevel.ANY, expected_exception=None)
