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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations