Search in sources :

Example 1 with ONE_MINUTE

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));
}
Also used : ExitStatus(com.datastax.oss.dsbulk.runner.ExitStatus) StreamCapture(com.datastax.oss.dsbulk.tests.logging.StreamCapture) BeforeEach(org.junit.jupiter.api.BeforeEach) CqlIdentifier(com.datastax.oss.driver.api.core.CqlIdentifier) CCMRequirements(com.datastax.oss.dsbulk.tests.ccm.annotations.CCMRequirements) MockConnector(com.datastax.oss.dsbulk.runner.tests.MockConnector) CCMWorkload(com.datastax.oss.dsbulk.tests.ccm.annotations.CCMWorkload) ArrayList(java.util.ArrayList) CCMConfig(com.datastax.oss.dsbulk.tests.ccm.annotations.CCMConfig) CqlSession(com.datastax.oss.driver.api.core.CqlSession) EndToEndUtils.assertStatus(com.datastax.oss.dsbulk.runner.tests.EndToEndUtils.assertStatus) CCMCluster(com.datastax.oss.dsbulk.tests.ccm.CCMCluster) Tag(org.junit.jupiter.api.Tag) ONE_MINUTE(org.awaitility.Durations.ONE_MINUTE) Record(com.datastax.oss.dsbulk.connectors.api.Record) LogInterceptor(com.datastax.oss.dsbulk.tests.logging.LogInterceptor) StreamInterceptor(com.datastax.oss.dsbulk.tests.logging.StreamInterceptor) Awaitility.await(org.awaitility.Awaitility.await) TestAssertions.assertThat(com.datastax.oss.dsbulk.tests.assertions.TestAssertions.assertThat) StringUtils(com.datastax.oss.dsbulk.tests.utils.StringUtils) DefaultMappedField(com.datastax.oss.dsbulk.connectors.api.DefaultMappedField) DataStaxBulkLoader(com.datastax.oss.dsbulk.runner.DataStaxBulkLoader) CCMVersionRequirement(com.datastax.oss.dsbulk.tests.ccm.annotations.CCMVersionRequirement) Workload(com.datastax.oss.dsbulk.tests.ccm.CCMCluster.Workload) LogCapture(com.datastax.oss.dsbulk.tests.logging.LogCapture) Test(org.junit.jupiter.api.Test) STATUS_OK(com.datastax.oss.dsbulk.runner.ExitStatus.STATUS_OK) List(java.util.List) Type(com.datastax.oss.dsbulk.tests.ccm.CCMCluster.Type) ExitStatus(com.datastax.oss.dsbulk.runner.ExitStatus) Index(org.assertj.core.data.Index) WARN(org.slf4j.event.Level.WARN) STDERR(com.datastax.oss.dsbulk.tests.logging.StreamType.STDERR) DefaultMappedField(com.datastax.oss.dsbulk.connectors.api.DefaultMappedField) ArrayList(java.util.ArrayList) DataStaxBulkLoader(com.datastax.oss.dsbulk.runner.DataStaxBulkLoader) CqlIdentifier(com.datastax.oss.driver.api.core.CqlIdentifier) Test(org.junit.jupiter.api.Test)

Aggregations

CqlIdentifier (com.datastax.oss.driver.api.core.CqlIdentifier)1 CqlSession (com.datastax.oss.driver.api.core.CqlSession)1 DefaultMappedField (com.datastax.oss.dsbulk.connectors.api.DefaultMappedField)1 Record (com.datastax.oss.dsbulk.connectors.api.Record)1 DataStaxBulkLoader (com.datastax.oss.dsbulk.runner.DataStaxBulkLoader)1 ExitStatus (com.datastax.oss.dsbulk.runner.ExitStatus)1 STATUS_OK (com.datastax.oss.dsbulk.runner.ExitStatus.STATUS_OK)1 EndToEndUtils.assertStatus (com.datastax.oss.dsbulk.runner.tests.EndToEndUtils.assertStatus)1 MockConnector (com.datastax.oss.dsbulk.runner.tests.MockConnector)1 TestAssertions.assertThat (com.datastax.oss.dsbulk.tests.assertions.TestAssertions.assertThat)1 CCMCluster (com.datastax.oss.dsbulk.tests.ccm.CCMCluster)1 Type (com.datastax.oss.dsbulk.tests.ccm.CCMCluster.Type)1 Workload (com.datastax.oss.dsbulk.tests.ccm.CCMCluster.Workload)1 CCMConfig (com.datastax.oss.dsbulk.tests.ccm.annotations.CCMConfig)1 CCMRequirements (com.datastax.oss.dsbulk.tests.ccm.annotations.CCMRequirements)1 CCMVersionRequirement (com.datastax.oss.dsbulk.tests.ccm.annotations.CCMVersionRequirement)1 CCMWorkload (com.datastax.oss.dsbulk.tests.ccm.annotations.CCMWorkload)1 LogCapture (com.datastax.oss.dsbulk.tests.logging.LogCapture)1 LogInterceptor (com.datastax.oss.dsbulk.tests.logging.LogInterceptor)1 StreamCapture (com.datastax.oss.dsbulk.tests.logging.StreamCapture)1