Search in sources :

Example 1 with KsqlConfig

use of io.confluent.ksql.util.KsqlConfig in project ksql by confluentinc.

the class IntegrationTestHarness method start.

public void start() throws Exception {
    embeddedKafkaCluster = new EmbeddedSingleNodeKafkaCluster();
    embeddedKafkaCluster.start();
    Map<String, Object> configMap = new HashMap<>();
    configMap.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, embeddedKafkaCluster.bootstrapServers());
    configMap.put("application.id", "KSQL");
    configMap.put("commit.interval.ms", 0);
    configMap.put("cache.max.bytes.buffering", 0);
    configMap.put("auto.offset.reset", "earliest");
    configMap.put(StreamsConfig.STATE_DIR_CONFIG, TestUtils.tempDirectory().getPath());
    this.ksqlConfig = new KsqlConfig(configMap);
    this.adminClient = AdminClient.create(ksqlConfig.getKsqlAdminClientConfigProps());
    this.topicClient = new KafkaTopicClientImpl(adminClient);
}
Also used : EmbeddedSingleNodeKafkaCluster(io.confluent.ksql.testutils.EmbeddedSingleNodeKafkaCluster) HashMap(java.util.HashMap) KsqlConfig(io.confluent.ksql.util.KsqlConfig) KafkaTopicClientImpl(io.confluent.ksql.util.KafkaTopicClientImpl)

Example 2 with KsqlConfig

use of io.confluent.ksql.util.KsqlConfig in project ksql by confluentinc.

the class JoinIntTest method before.

@Before
public void before() throws Exception {
    testHarness = new IntegrationTestHarness();
    testHarness.start();
    Map<String, Object> ksqlStreamConfigProps = new HashMap<>();
    ksqlStreamConfigProps.putAll(testHarness.ksqlConfig.getKsqlStreamConfigProps());
    // turn caching off to improve join consistency
    ksqlStreamConfigProps.put(StreamsConfig.CACHE_MAX_BYTES_BUFFERING_CONFIG, 0);
    ksqlStreamConfigProps.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "latest");
    ksqlContext = KsqlContext.create(new KsqlConfig(ksqlStreamConfigProps), testHarness.schemaRegistryClient);
    /**
     * Setup test data
     */
    testHarness.createTopic(itemTableTopicJson);
    testHarness.createTopic(itemTableTopicAvro);
    itemDataProvider = new ItemDataProvider();
    testHarness.publishTestData(itemTableTopicJson, itemDataProvider, now - 500);
    testHarness.publishTestData(itemTableTopicAvro, itemDataProvider, now - 500, DataSource.DataSourceSerDe.AVRO);
    testHarness.createTopic(orderStreamTopicJson);
    testHarness.createTopic(orderStreamTopicAvro);
    orderDataProvider = new OrderDataProvider();
    testHarness.publishTestData(orderStreamTopicJson, orderDataProvider, now);
    testHarness.publishTestData(orderStreamTopicAvro, orderDataProvider, now, DataSource.DataSourceSerDe.AVRO);
    createStreams();
}
Also used : OrderDataProvider(io.confluent.ksql.util.OrderDataProvider) ItemDataProvider(io.confluent.ksql.util.ItemDataProvider) HashMap(java.util.HashMap) KsqlConfig(io.confluent.ksql.util.KsqlConfig) Before(org.junit.Before)

Example 3 with KsqlConfig

use of io.confluent.ksql.util.KsqlConfig in project ksql by confluentinc.

the class JsonFormatTest method before.

@Before
public void before() throws Exception {
    Map<String, Object> configMap = new HashMap<>();
    configMap.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, CLUSTER.bootstrapServers());
    configMap.put("application.id", "KSQL");
    configMap.put("commit.interval.ms", 0);
    configMap.put("cache.max.bytes.buffering", 0);
    configMap.put("auto.offset.reset", "earliest");
    KsqlConfig ksqlConfig = new KsqlConfig(configMap);
    adminClient = AdminClient.create(ksqlConfig.getKsqlAdminClientConfigProps());
    topicClient = new KafkaTopicClientImpl(adminClient);
    ksqlEngine = new KsqlEngine(ksqlConfig, topicClient);
    metaStore = ksqlEngine.getMetaStore();
    createInitTopics();
    produceInitData();
    execInitCreateStreamQueries();
}
Also used : KsqlEngine(io.confluent.ksql.KsqlEngine) HashMap(java.util.HashMap) KsqlConfig(io.confluent.ksql.util.KsqlConfig) KafkaTopicClientImpl(io.confluent.ksql.util.KafkaTopicClientImpl) Before(org.junit.Before)

Example 4 with KsqlConfig

use of io.confluent.ksql.util.KsqlConfig in project ksql by confluentinc.

the class SecureIntegrationTest method before.

@Before
public void before() throws Exception {
    SECURE_CLUSTER.clearAcls();
    outputTopic = "TEST_" + COUNTER.incrementAndGet();
    topicClient = new KafkaTopicClientImpl(AdminClient.create(new KsqlConfig(getKsqlConfig(SUPER_USER)).getKsqlAdminClientConfigProps()));
    produceInitData();
}
Also used : KsqlConfig(io.confluent.ksql.util.KsqlConfig) KafkaTopicClientImpl(io.confluent.ksql.util.KafkaTopicClientImpl) Before(org.junit.Before)

Example 5 with KsqlConfig

use of io.confluent.ksql.util.KsqlConfig in project ksql by confluentinc.

the class JoinNodeTest method shouldBuildTableNodeWithCorrectAutoCommitOffsetPolicy.

@Test
public void shouldBuildTableNodeWithCorrectAutoCommitOffsetPolicy() {
    setupTopicClientExpectations(1, 1);
    buildJoin();
    KsqlConfig ksqlConfig = mock(KsqlConfig.class);
    KafkaTopicClient kafkaTopicClient = mock(KafkaTopicClient.class);
    FunctionRegistry functionRegistry = mock(FunctionRegistry.class);
    class RightTable extends PlanNode {

        final Schema schema;

        public RightTable(final PlanNodeId id, Schema schema) {
            super(id);
            this.schema = schema;
        }

        @Override
        public Schema getSchema() {
            return schema;
        }

        @Override
        public Field getKeyField() {
            return null;
        }

        @Override
        public List<PlanNode> getSources() {
            return null;
        }

        @Override
        public SchemaKStream buildStream(StreamsBuilder builder, KsqlConfig ksqlConfig, KafkaTopicClient kafkaTopicClient, FunctionRegistry functionRegistry, Map<String, Object> props, SchemaRegistryClient schemaRegistryClient) {
            if (props.containsKey(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG) && props.get(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG).toString().equalsIgnoreCase("EARLIEST")) {
                return mock(SchemaKTable.class);
            } else {
                throw new KsqlException("auto.offset.reset should be set to EARLIEST.");
            }
        }

        @Override
        protected int getPartitions(KafkaTopicClient kafkaTopicClient) {
            return 1;
        }
    }
    RightTable rightTable = new RightTable(new PlanNodeId("1"), joinNode.getRight().getSchema());
    JoinNode testJoinNode = new JoinNode(joinNode.getId(), joinNode.getType(), joinNode.getLeft(), rightTable, joinNode.getLeftKeyFieldName(), joinNode.getRightKeyFieldName(), joinNode.getLeftAlias(), joinNode.getRightAlias());
    testJoinNode.tableForJoin(builder, ksqlConfig, kafkaTopicClient, functionRegistry, new HashMap<>(), new MockSchemaRegistryClient());
}
Also used : MockSchemaRegistryClient(io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient) Schema(org.apache.kafka.connect.data.Schema) KsqlConfig(io.confluent.ksql.util.KsqlConfig) KsqlException(io.confluent.ksql.util.KsqlException) StreamsBuilder(org.apache.kafka.streams.StreamsBuilder) FunctionRegistry(io.confluent.ksql.function.FunctionRegistry) KafkaTopicClient(io.confluent.ksql.util.KafkaTopicClient) HashMap(java.util.HashMap) Map(java.util.Map) SchemaRegistryClient(io.confluent.kafka.schemaregistry.client.SchemaRegistryClient) MockSchemaRegistryClient(io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient) Test(org.junit.Test)

Aggregations

KsqlConfig (io.confluent.ksql.util.KsqlConfig)29 HashMap (java.util.HashMap)13 MockSchemaRegistryClient (io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient)11 SchemaRegistryClient (io.confluent.kafka.schemaregistry.client.SchemaRegistryClient)9 Before (org.junit.Before)9 Test (org.junit.Test)9 KafkaTopicClientImpl (io.confluent.ksql.util.KafkaTopicClientImpl)8 KsqlEngine (io.confluent.ksql.KsqlEngine)7 FunctionRegistry (io.confluent.ksql.function.FunctionRegistry)6 List (java.util.List)5 StreamsBuilder (org.apache.kafka.streams.StreamsBuilder)5 GenericRow (io.confluent.ksql.GenericRow)4 KafkaTopicClient (io.confluent.ksql.util.KafkaTopicClient)4 Map (java.util.Map)4 KafkaAvroDeserializer (io.confluent.kafka.serializers.KafkaAvroDeserializer)2 KsqlTopic (io.confluent.ksql.metastore.KsqlTopic)2 MetaStoreImpl (io.confluent.ksql.metastore.MetaStoreImpl)2 MockKafkaTopicClient (io.confluent.ksql.rest.server.mock.MockKafkaTopicClient)2 KsqlException (io.confluent.ksql.util.KsqlException)2 GenericData (org.apache.avro.generic.GenericData)2