Search in sources :

Example 1 with ReadTimeoutResult

use of com.datastax.oss.simulacron.common.result.ReadTimeoutResult in project dsbulk by datastax.

the class JsonEndToEndSimulacronIT method load_errors.

@Test
void load_errors() throws Exception {
    primeIpByCountryTable(simulacron);
    Map<String, Object> params = new HashMap<>();
    params.put("country_name", "Sweden");
    RequestPrime prime1 = createParameterizedQuery(INSERT_INTO_IP_BY_COUNTRY, params, new SuccessResult(emptyList(), new LinkedHashMap<>()));
    simulacron.prime(new Prime(prime1));
    // recoverable errors only
    params.put("country_name", "France");
    prime1 = createParameterizedQuery(INSERT_INTO_IP_BY_COUNTRY, params, new ReadTimeoutResult(LOCAL_ONE, 1, 0, false));
    simulacron.prime(new Prime(prime1));
    params.put("country_name", "Gregistan");
    prime1 = createParameterizedQuery(INSERT_INTO_IP_BY_COUNTRY, params, new WriteTimeoutResult(LOCAL_ONE, 0, 0, WriteType.BATCH_LOG));
    simulacron.prime(new Prime(prime1));
    params.put("country_name", "Andybaijan");
    prime1 = createParameterizedQuery(INSERT_INTO_IP_BY_COUNTRY, params, new WriteFailureResult(ONE, 0, 0, emptyMap(), WriteType.BATCH));
    simulacron.prime(new Prime(prime1));
    params = new HashMap<>();
    params.put("country_name", "United States");
    prime1 = createParameterizedQuery(INSERT_INTO_IP_BY_COUNTRY, params, new FunctionFailureResult("keyspace", "function", emptyList(), "bad function call"));
    simulacron.prime(new Prime(prime1));
    String[] args = { "load", "-c", "json", "--connector.json.url", StringUtils.quoteJson(JsonUtils.JSON_RECORDS_ERROR), "--driver.advanced.retry-policy.max-retries", "1", "--schema.keyspace", "ks1", "--schema.query", INSERT_INTO_IP_BY_COUNTRY, "--schema.mapping", IP_BY_COUNTRY_MAPPING_NAMED };
    ExitStatus status = new DataStaxBulkLoader(addCommonSettings(args)).run();
    assertStatus(status, STATUS_COMPLETED_WITH_ERRORS);
    // There are 24 rows of data, but two extra queries due to the retry for the write timeout and
    // the unavailable.
    validateQueryCount(simulacron, 26, "INSERT INTO ip_by_country", LOCAL_ONE);
    validateNumberOfBadRecords(4);
    validateExceptionsLog(4, "Source:", "load-errors.log");
}
Also used : Prime(com.datastax.oss.simulacron.common.stubbing.Prime) RequestPrime(com.datastax.oss.simulacron.common.cluster.RequestPrime) ReadTimeoutResult(com.datastax.oss.simulacron.common.result.ReadTimeoutResult) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) FunctionFailureResult(com.datastax.oss.simulacron.common.result.FunctionFailureResult) SuccessResult(com.datastax.oss.simulacron.common.result.SuccessResult) DataStaxBulkLoader(com.datastax.oss.dsbulk.runner.DataStaxBulkLoader) LinkedHashMap(java.util.LinkedHashMap) ExitStatus(com.datastax.oss.dsbulk.runner.ExitStatus) WriteFailureResult(com.datastax.oss.simulacron.common.result.WriteFailureResult) RequestPrime(com.datastax.oss.simulacron.common.cluster.RequestPrime) WriteTimeoutResult(com.datastax.oss.simulacron.common.result.WriteTimeoutResult) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with ReadTimeoutResult

use of com.datastax.oss.simulacron.common.result.ReadTimeoutResult in project dsbulk by datastax.

the class CSVEndToEndSimulacronIT method load_errors.

@Test
void load_errors() throws Exception {
    primeIpByCountryTable(simulacron);
    Map<String, Object> params = new HashMap<>();
    params.put("country_name", "Sweden");
    RequestPrime prime1 = createParameterizedQuery(INSERT_INTO_IP_BY_COUNTRY, params, new SuccessResult(emptyList(), new LinkedHashMap<>()));
    simulacron.prime(new Prime(prime1));
    // recoverable errors only
    params.put("country_name", "France");
    prime1 = createParameterizedQuery(INSERT_INTO_IP_BY_COUNTRY, params, new ReadTimeoutResult(LOCAL_ONE, 1, 0, false));
    simulacron.prime(new Prime(prime1));
    params.put("country_name", "Gregistan");
    prime1 = createParameterizedQuery(INSERT_INTO_IP_BY_COUNTRY, params, new WriteTimeoutResult(LOCAL_ONE, 0, 0, WriteType.BATCH_LOG));
    simulacron.prime(new Prime(prime1));
    params.put("country_name", "Andybaijan");
    prime1 = createParameterizedQuery(INSERT_INTO_IP_BY_COUNTRY, params, new WriteFailureResult(ONE, 0, 0, emptyMap(), WriteType.BATCH));
    simulacron.prime(new Prime(prime1));
    params = new HashMap<>();
    params.put("country_name", "United States");
    prime1 = createParameterizedQuery(INSERT_INTO_IP_BY_COUNTRY, params, new FunctionFailureResult("keyspace", "function", emptyList(), "bad function call"));
    simulacron.prime(new Prime(prime1));
    String[] args = { "load", "-header", "false", "--connector.csv.url", StringUtils.quoteJson(CsvUtils.CSV_RECORDS_ERROR), "--driver.advanced.retry-policy.max-retries", "1", "--schema.keyspace", "ks1", "--schema.query", INSERT_INTO_IP_BY_COUNTRY, "--schema.mapping", IP_BY_COUNTRY_MAPPING_INDEXED };
    ExitStatus status = new DataStaxBulkLoader(addCommonSettings(args)).run();
    assertStatus(status, STATUS_COMPLETED_WITH_ERRORS);
    // There are 24 rows of data, but two extra queries due to the retry for the write timeout and
    // the unavailable.
    validateQueryCount(simulacron, 26, "INSERT INTO ip_by_country", LOCAL_ONE);
    validateNumberOfBadRecords(4);
    validateExceptionsLog(4, "Source:", "load-errors.log");
}
Also used : Prime(com.datastax.oss.simulacron.common.stubbing.Prime) RequestPrime(com.datastax.oss.simulacron.common.cluster.RequestPrime) ReadTimeoutResult(com.datastax.oss.simulacron.common.result.ReadTimeoutResult) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) FunctionFailureResult(com.datastax.oss.simulacron.common.result.FunctionFailureResult) SuccessResult(com.datastax.oss.simulacron.common.result.SuccessResult) DataStaxBulkLoader(com.datastax.oss.dsbulk.runner.DataStaxBulkLoader) LinkedHashMap(java.util.LinkedHashMap) ExitStatus(com.datastax.oss.dsbulk.runner.ExitStatus) WriteFailureResult(com.datastax.oss.simulacron.common.result.WriteFailureResult) RequestPrime(com.datastax.oss.simulacron.common.cluster.RequestPrime) WriteTimeoutResult(com.datastax.oss.simulacron.common.result.WriteTimeoutResult) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

DataStaxBulkLoader (com.datastax.oss.dsbulk.runner.DataStaxBulkLoader)2 ExitStatus (com.datastax.oss.dsbulk.runner.ExitStatus)2 RequestPrime (com.datastax.oss.simulacron.common.cluster.RequestPrime)2 FunctionFailureResult (com.datastax.oss.simulacron.common.result.FunctionFailureResult)2 ReadTimeoutResult (com.datastax.oss.simulacron.common.result.ReadTimeoutResult)2 SuccessResult (com.datastax.oss.simulacron.common.result.SuccessResult)2 WriteFailureResult (com.datastax.oss.simulacron.common.result.WriteFailureResult)2 WriteTimeoutResult (com.datastax.oss.simulacron.common.result.WriteTimeoutResult)2 Prime (com.datastax.oss.simulacron.common.stubbing.Prime)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Test (org.junit.jupiter.api.Test)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2