use of org.awaitility.Durations.ONE_MINUTE in project dsbulk by datastax.
the class SearchEndToEndCCMIT method normal_unload_of_search_enabled_table.
/**
* Test for DAT-365: regular unload of a search-enabled table should not contain the solr_query
* column.
*/
@Test
void normal_unload_of_search_enabled_table() {
session.execute("CREATE TABLE IF NOT EXISTS test_search2 (pk int, cc int, v varchar, PRIMARY KEY (pk, cc))");
session.execute("CREATE SEARCH INDEX IF NOT EXISTS ON test_search2 WITH COLUMNS v { indexed:true };");
session.execute("INSERT INTO test_search2 (pk, cc, v) VALUES (0, 0, 'foo')");
session.execute("INSERT INTO test_search2 (pk, cc, v) VALUES (0, 1, 'bar')");
session.execute("INSERT INTO test_search2 (pk, cc, v) VALUES (0, 2, 'qix')");
// Wait until index is built
await().atMost(ONE_MINUTE).until(() -> !session.execute("SELECT v FROM test_search2 WHERE solr_query = '{\"q\": \"v:foo\"}'").all().isEmpty());
List<String> args = new ArrayList<>();
args.add("unload");
args.add("--connector.name");
args.add("mock");
args.add("--schema.keyspace");
args.add(session.getKeyspace().map(CqlIdentifier::asInternal).orElseThrow(IllegalStateException::new));
args.add("--schema.table");
args.add("test_search2");
ExitStatus status = new DataStaxBulkLoader(addCommonSettings(args)).run();
assertStatus(status, STATUS_OK);
assertThat(records).hasSize(3).satisfies(record -> {
assertThat(record.fields()).hasSize(3);
assertThat(record.getFieldValue(new DefaultMappedField("pk"))).isEqualTo("0");
assertThat(record.getFieldValue(new DefaultMappedField("cc"))).isEqualTo("0");
assertThat(record.getFieldValue(new DefaultMappedField("v"))).isEqualTo("foo");
}, Index.atIndex(0)).satisfies(record -> {
assertThat(record.fields()).hasSize(3);
assertThat(record.getFieldValue(new DefaultMappedField("pk"))).isEqualTo("0");
assertThat(record.getFieldValue(new DefaultMappedField("cc"))).isEqualTo("1");
assertThat(record.getFieldValue(new DefaultMappedField("v"))).isEqualTo("bar");
}, Index.atIndex(1)).satisfies(record -> {
assertThat(record.fields()).hasSize(3);
assertThat(record.getFieldValue(new DefaultMappedField("pk"))).isEqualTo("0");
assertThat(record.getFieldValue(new DefaultMappedField("cc"))).isEqualTo("2");
assertThat(record.getFieldValue(new DefaultMappedField("v"))).isEqualTo("qix");
}, Index.atIndex(2));
}
Aggregations