Search in sources :

Example 1 with IntegrationTestingConfig

use of org.apache.druid.testing.IntegrationTestingConfig in project druid by druid-io.

the class SuiteListener method onStart.

@Override
public void onStart(ISuite suite) {
    Injector injector = DruidTestModuleFactory.getInjector();
    IntegrationTestingConfig config = injector.getInstance(IntegrationTestingConfig.class);
    DruidClusterAdminClient druidClusterAdminClient = injector.getInstance(DruidClusterAdminClient.class);
    druidClusterAdminClient.waitUntilCoordinatorReady();
    druidClusterAdminClient.waitUntilIndexerReady();
    druidClusterAdminClient.waitUntilBrokerReady();
    String routerHost = config.getRouterUrl();
    if (null != routerHost) {
        druidClusterAdminClient.waitUntilRouterReady();
    }
    Lifecycle lifecycle = injector.getInstance(Lifecycle.class);
    try {
        lifecycle.start();
    } catch (Exception e) {
        LOG.error(e, "");
        throw new RuntimeException(e);
    }
}
Also used : Injector(com.google.inject.Injector) Lifecycle(org.apache.druid.java.util.common.lifecycle.Lifecycle) IntegrationTestingConfig(org.apache.druid.testing.IntegrationTestingConfig)

Example 2 with IntegrationTestingConfig

use of org.apache.druid.testing.IntegrationTestingConfig in project druid by druid-io.

the class AbstractKafkaIndexingServiceTest method generateStreamIngestionPropsTransform.

@Override
Function<String, String> generateStreamIngestionPropsTransform(String streamName, String fullDatasourceName, String parserType, String parserOrInputFormat, IntegrationTestingConfig config) {
    final Map<String, Object> consumerConfigs = KafkaConsumerConfigs.getConsumerProperties();
    final Properties consumerProperties = new Properties();
    consumerProperties.putAll(consumerConfigs);
    consumerProperties.setProperty("bootstrap.servers", config.getKafkaInternalHost());
    KafkaUtil.addPropertiesFromTestConfig(config, consumerProperties);
    return spec -> {
        try {
            spec = StringUtils.replace(spec, "%%DATASOURCE%%", fullDatasourceName);
            spec = StringUtils.replace(spec, "%%STREAM_TYPE%%", "kafka");
            spec = StringUtils.replace(spec, "%%TOPIC_KEY%%", "topic");
            spec = StringUtils.replace(spec, "%%TOPIC_VALUE%%", streamName);
            if (AbstractStreamIndexingTest.INPUT_FORMAT.equals(parserType)) {
                spec = StringUtils.replace(spec, "%%INPUT_FORMAT%%", parserOrInputFormat);
                spec = StringUtils.replace(spec, "%%PARSER%%", "null");
            } else if (AbstractStreamIndexingTest.INPUT_ROW_PARSER.equals(parserType)) {
                spec = StringUtils.replace(spec, "%%PARSER%%", parserOrInputFormat);
                spec = StringUtils.replace(spec, "%%INPUT_FORMAT%%", "null");
            }
            spec = StringUtils.replace(spec, "%%USE_EARLIEST_KEY%%", "useEarliestOffset");
            spec = StringUtils.replace(spec, "%%STREAM_PROPERTIES_KEY%%", "consumerProperties");
            spec = StringUtils.replace(spec, "%%SCHEMA_REGISTRY_HOST%%", StringUtils.format("http://%s", config.getSchemaRegistryInternalHost()));
            return StringUtils.replace(spec, "%%STREAM_PROPERTIES_VALUE%%", jsonMapper.writeValueAsString(consumerProperties));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    };
}
Also used : IntegrationTestingConfig(org.apache.druid.testing.IntegrationTestingConfig) Properties(java.util.Properties) KafkaAdminClient(org.apache.druid.testing.utils.KafkaAdminClient) Map(java.util.Map) KafkaConsumerConfigs(org.apache.druid.indexing.kafka.KafkaConsumerConfigs) StringUtils(org.apache.druid.java.util.common.StringUtils) Preconditions(com.google.common.base.Preconditions) KafkaEventWriter(org.apache.druid.testing.utils.KafkaEventWriter) KafkaUtil(org.apache.druid.testing.utils.KafkaUtil) StreamEventWriter(org.apache.druid.testing.utils.StreamEventWriter) Function(java.util.function.Function) StreamAdminClient(org.apache.druid.testing.utils.StreamAdminClient) Properties(java.util.Properties)

Aggregations

IntegrationTestingConfig (org.apache.druid.testing.IntegrationTestingConfig)2 Preconditions (com.google.common.base.Preconditions)1 Injector (com.google.inject.Injector)1 Map (java.util.Map)1 Properties (java.util.Properties)1 Function (java.util.function.Function)1 KafkaConsumerConfigs (org.apache.druid.indexing.kafka.KafkaConsumerConfigs)1 StringUtils (org.apache.druid.java.util.common.StringUtils)1 Lifecycle (org.apache.druid.java.util.common.lifecycle.Lifecycle)1 KafkaAdminClient (org.apache.druid.testing.utils.KafkaAdminClient)1 KafkaEventWriter (org.apache.druid.testing.utils.KafkaEventWriter)1 KafkaUtil (org.apache.druid.testing.utils.KafkaUtil)1 StreamAdminClient (org.apache.druid.testing.utils.StreamAdminClient)1 StreamEventWriter (org.apache.druid.testing.utils.StreamEventWriter)1