Search in sources :

Example 16 with GenericRecordImpl

use of com.datastax.oss.sink.pulsar.GenericRecordImpl in project pulsar-sink by datastax.

the class WriteTimestampAndTtlCCMIT method should_insert_record_with_ttl_provided_via_mapping.

/**
 * Test for KAF-107.
 */
@Test
void should_insert_record_with_ttl_provided_via_mapping() {
    taskConfigs.add(makeConnectorProperties("bigintcol=value.bigint, doublecol=value.double, __ttl = value.ttlcol"));
    RecordSchemaBuilder builder = org.apache.pulsar.client.api.schema.SchemaBuilder.record("MyBean");
    builder.field("bigint").type(SchemaType.INT64);
    builder.field("double").type(SchemaType.DOUBLE);
    builder.field("ttlcol").type(SchemaType.INT64);
    Schema schema = org.apache.pulsar.client.api.Schema.generic(builder.build(SchemaType.AVRO));
    Number ttlValue = 1_000_000L;
    GenericRecordImpl value = new GenericRecordImpl().put("bigint", 1234567L).put("double", 42.0).put("ttlcol", ttlValue.longValue());
    PulsarRecordImpl record = new PulsarRecordImpl("persistent://tenant/namespace/mytopic", null, value, schema, 153000987L);
    runTaskWithRecords(record);
    // Verify that the record was inserted properly in the database.
    List<Row> results = session.execute("SELECT bigintcol, doublecol, ttl(doublecol) FROM types").all();
    assertThat(results.size()).isEqualTo(1);
    Row row = results.get(0);
    assertThat(row.getLong("bigintcol")).isEqualTo(1234567L);
    assertThat(row.getDouble("doublecol")).isEqualTo(42.0);
    assertTtl(row.getInt(2), ttlValue);
}
Also used : RecordSchemaBuilder(org.apache.pulsar.client.api.schema.RecordSchemaBuilder) PulsarRecordImpl(com.datastax.oss.sink.pulsar.PulsarRecordImpl) Schema(org.apache.pulsar.client.api.Schema) GenericRecordImpl(com.datastax.oss.sink.pulsar.GenericRecordImpl) Row(com.datastax.oss.driver.api.core.cql.Row) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 17 with GenericRecordImpl

use of com.datastax.oss.sink.pulsar.GenericRecordImpl in project pulsar-sink by datastax.

the class PlaintextAuthCCMIT method should_insert_successfully_with_correct_credentials.

@ParameterizedTest(name = "[{index}] extras={0}")
@MethodSource("correctCredentialsProvider")
void should_insert_successfully_with_correct_credentials(Map<String, String> extras) {
    taskConfigs.add(makeConnectorProperties(extras));
    PulsarRecordImpl record = new PulsarRecordImpl("persistent://tenant/namespace/mytopic", null, new GenericRecordImpl().put("bigint", 5725368L), recordType);
    runTaskWithRecords(record);
    // Verify that the record was inserted properly in the database.
    List<Row> results = session.execute("SELECT bigintcol FROM types").all();
    assertThat(results.size()).isEqualTo(1);
    Row row = results.get(0);
    assertThat(row.getLong("bigintcol")).isEqualTo(5725368L);
    // auth.provider was coerced to the database
    assertThat(task.getInstanceState().getConfig().getAuthenticatorConfig().getProvider()).isEqualTo(Provider.PLAIN);
}
Also used : PulsarRecordImpl(com.datastax.oss.sink.pulsar.PulsarRecordImpl) GenericRecordImpl(com.datastax.oss.sink.pulsar.GenericRecordImpl) Row(com.datastax.oss.driver.api.core.cql.Row) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 18 with GenericRecordImpl

use of com.datastax.oss.sink.pulsar.GenericRecordImpl in project pulsar-sink by datastax.

the class SslEndToEndCCMIT method raw_bigint_value_using_base64_encoded_keystore.

@Test
void raw_bigint_value_using_base64_encoded_keystore() throws Exception {
    Map<String, String> extras = ImmutableMap.<String, String>builder().put(SslConfig.PROVIDER_OPT, "JDK").put(SslConfig.KEYSTORE_PATH_OPT, encodeFile(CcmBridge.DEFAULT_CLIENT_KEYSTORE_FILE)).put(SslConfig.KEYSTORE_PASSWORD_OPT, CcmBridge.DEFAULT_CLIENT_KEYSTORE_PASSWORD).put(SslConfig.HOSTNAME_VALIDATION_OPT, "false").put(SslConfig.TRUSTSTORE_PATH_OPT, encodeFile(CcmBridge.DEFAULT_CLIENT_TRUSTSTORE_FILE)).put(SslConfig.TRUSTSTORE_PASSWORD_OPT, CcmBridge.DEFAULT_CLIENT_TRUSTSTORE_PASSWORD).build();
    taskConfigs.add(makeConnectorProperties(extras));
    PulsarRecordImpl record = new PulsarRecordImpl("persistent://tenant/namespace/mytopic", null, new GenericRecordImpl().put("bigint", 5725368L), recordType);
    runTaskWithRecords(record);
    // Verify that the record was inserted properly in the database.
    List<Row> results = session.execute("SELECT bigintcol FROM types").all();
    assertThat(results.size()).isEqualTo(1);
    Row row = results.get(0);
    assertThat(row.getLong("bigintcol")).isEqualTo(5725368L);
}
Also used : PulsarRecordImpl(com.datastax.oss.sink.pulsar.PulsarRecordImpl) GenericRecordImpl(com.datastax.oss.sink.pulsar.GenericRecordImpl) Row(com.datastax.oss.driver.api.core.cql.Row) Test(org.junit.jupiter.api.Test)

Example 19 with GenericRecordImpl

use of com.datastax.oss.sink.pulsar.GenericRecordImpl in project pulsar-sink by datastax.

the class SslEndToEndCCMIT method raw_bigint_value_with_openssl_without_hostname_validation.

@Test
void raw_bigint_value_with_openssl_without_hostname_validation() {
    Map<String, String> extras = ImmutableMap.<String, String>builder().put(SslConfig.PROVIDER_OPT, "OpenSSL").put(SslConfig.HOSTNAME_VALIDATION_OPT, "false").put(SslConfig.OPENSSL_KEY_CERT_CHAIN_OPT, CcmBridge.DEFAULT_CLIENT_CERT_CHAIN_FILE.getAbsolutePath()).put(SslConfig.OPENSSL_PRIVATE_KEY_OPT, CcmBridge.DEFAULT_CLIENT_PRIVATE_KEY_FILE.getAbsolutePath()).put(SslConfig.TRUSTSTORE_PATH_OPT, CcmBridge.DEFAULT_CLIENT_TRUSTSTORE_FILE.getAbsolutePath()).put(SslConfig.TRUSTSTORE_PASSWORD_OPT, CcmBridge.DEFAULT_CLIENT_TRUSTSTORE_PASSWORD).build();
    taskConfigs.add(makeConnectorProperties(extras));
    PulsarRecordImpl record = new PulsarRecordImpl("persistent://tenant/namespace/mytopic", null, new GenericRecordImpl().put("bigint", 5725368L), recordType);
    runTaskWithRecords(record);
    // Verify that the record was inserted properly in the database.
    List<Row> results = session.execute("SELECT bigintcol FROM types").all();
    assertThat(results.size()).isEqualTo(1);
    Row row = results.get(0);
    assertThat(row.getLong("bigintcol")).isEqualTo(5725368L);
}
Also used : PulsarRecordImpl(com.datastax.oss.sink.pulsar.PulsarRecordImpl) GenericRecordImpl(com.datastax.oss.sink.pulsar.GenericRecordImpl) Row(com.datastax.oss.driver.api.core.cql.Row) Test(org.junit.jupiter.api.Test)

Example 20 with GenericRecordImpl

use of com.datastax.oss.sink.pulsar.GenericRecordImpl in project pulsar-sink by datastax.

the class CloudSniEndToEndIT method performInsert.

private void performInsert(ConsistencyLevel cl, Map<String, String> extras) {
    taskConfigs.add(makeCloudConnectorProperties("bigintcol=value.bigint", "types", extras, "mytopic", cl));
    PulsarRecordImpl record = new PulsarRecordImpl("persistent://tenant/namespace/mytopic", null, new GenericRecordImpl().put("bigint", 5725368L), recordType);
    runTaskWithRecords(record);
    // Verify that the record was inserted properly in the database.
    List<Row> results = session.execute("SELECT bigintcol FROM types").all();
    assertThat(results.size()).isEqualTo(1);
    Row row = results.get(0);
    assertThat(row.getLong("bigintcol")).isEqualTo(5725368L);
}
Also used : PulsarRecordImpl(com.datastax.oss.sink.pulsar.PulsarRecordImpl) GenericRecordImpl(com.datastax.oss.sink.pulsar.GenericRecordImpl) Row(com.datastax.oss.driver.api.core.cql.Row)

Aggregations

GenericRecordImpl (com.datastax.oss.sink.pulsar.GenericRecordImpl)56 PulsarRecordImpl (com.datastax.oss.sink.pulsar.PulsarRecordImpl)56 Test (org.junit.jupiter.api.Test)50 Row (com.datastax.oss.driver.api.core.cql.Row)46 RecordSchemaBuilder (org.apache.pulsar.client.api.schema.RecordSchemaBuilder)16 Schema (org.apache.pulsar.client.api.Schema)12 GenericSchema (org.apache.pulsar.client.api.schema.GenericSchema)9 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 UserDefinedType (com.datastax.oss.driver.api.core.type.UserDefinedType)5 UserDefinedTypeBuilder (com.datastax.oss.driver.internal.core.type.UserDefinedTypeBuilder)5 GenericRecord (org.apache.pulsar.client.api.schema.GenericRecord)4 Query (com.datastax.oss.simulacron.common.request.Query)3 MethodSource (org.junit.jupiter.params.provider.MethodSource)3 LineString (com.datastax.dse.driver.api.core.data.geometry.LineString)2 DefaultLineString (com.datastax.dse.driver.internal.core.data.geometry.DefaultLineString)2 InstanceState (com.datastax.oss.common.sink.state.InstanceState)2 InetSocketAddress (java.net.InetSocketAddress)2 HashMap (java.util.HashMap)2 Point (com.datastax.dse.driver.api.core.data.geometry.Point)1 Polygon (com.datastax.dse.driver.api.core.data.geometry.Polygon)1