confluentinc / ksql

The database purpose-built for stream processing applications.
https://ksqldb.io
Other
128 stars 1.04k forks source link

Confluent 6.1.0: ksql-test-runner: can't set ksql.suppress.enabled to true so we can unit test EMIT FINAL #7276

Open webcentricds opened 3 years ago

webcentricds commented 3 years ago

Describe the bug ksql-test-runner no way to set ksql.suppress.enabled to true so we can unit test EMIT FINAL

To Reproduce Steps to reproduce the behavior, include:

  1. Inputs: create.ksql.sql: --------------------------------------------------------------------
    
    CREATE STREAM `s1` (
    ID STRING KEY,
    FK1 STRING,
    FK2 STRING,
    ELAPSED_SECONDS INT)
    WITH (KAFKA_TOPIC='test_topic_1', VALUE_FORMAT='JSON');

CREATE TABLE LOJ_STREAM WITH (KAFKA_TOPIC='test_topic_2', VALUE_FORMAT='JSON') AS SELECT s1.ID, s1.FK1, s1.FK2, max(s1.ELAPSED_SECONDS) as ELAPSED_SECONDS from s1 as s1 WINDOW TUMBLING (SIZE 30 SECONDS) GROUP BY s1.ID, s1.FK1, s1.FK2 EMIT FINAL;

input.json: ---------------------------------------------------------------------------
```sql
{
  "inputs": [
    {
      "topic": "test_topic_1",
      "timestamp": 123,
      "key": "key1",
      "value": {
        "FK1": "fk1-1",
        "FK2": "fk2-1",
        "ELAPSED_SECONDS": 13
      }
    },
    {
      "topic": "test_topic_1",
      "timestamp": 1123,
      "key": "key1",
      "value": {
        "FK1": "fk1-1",
        "FK2": "fk2-1",
        "ELAPSED_SECONDS": 28
      }
    },
    {
      "topic": "test_topic_1",
      "timestamp": 2123,
      "key": "key1",
      "value": {
        "FK1": "fk1-1",
        "FK2": "fk2-1",
        "ELAPSED_SECONDS": 20
      }
    }
  ]
}

output.json: -------------------------------------------------------------------------

{
  "outputs": [
    {
      "topic": "test_topic_2",
      "timestamp": 123,
      "key": "key1|+|fk1-1|+|fk2-1",
      "window": {"start": 0, "end": 30000, "type": "time"},
      "value": {
        "ELAPSED_SECONDS": 13
      }
    },
    {
      "topic": "test_topic_2",
      "timestamp": 1123,
      "key": "key1|+|fk1-1|+|fk2-1",
      "window": {"start": 0, "end": 30000, "type": "time"},
      "value": {
        "ELAPSED_SECONDS": 28
      }
    },
    {
      "topic": "test_topic_2",
      "timestamp": 2123,
      "key": "key1|+|fk1-1|+|fk2-1",
      "window": {"start": 0, "end": 30000, "type": "time"},
      "value": {
        "ELAPSED_SECONDS": 28
      }
    }
  ]
}

run.sh: --------------------------------------------------------------------------------

#!/usr/bin/env bash

/Users/denglish/Installers/Confluent/6.1.0/extracted/confluent-6.1.0/bin/ksql-test-runner -s create.ksql.sql -i input.json -o output.json | grep '>>>'

Expected behavior I expect the test to run, and give me a status of pass or fail. If failed, a specific reason for failure in terms of input and output. What I don't expect to get the error message: Test failed: Suppression is currently disabled. You can enable it by setting ksql.suppress.enabled to true.

Actual behaviour

OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
    >>>>> Test failed: Suppression is currently disabled. You can enable it by setting ksql.suppress.enabled to true
Statement: CREATE TABLE LOJ_STREAM WITH (KAFKA_TOPIC='test_topic_2', VALUE_FORMAT='JSON') AS SELECT
  S1.ID ID,
  S1.FK1 FK1,
  S1.FK2 FK2,
  MAX(S1.ELAPSED_SECONDS) ELAPSED_SECONDS
FROM `s1` S1
WINDOW TUMBLING ( SIZE 30 SECONDS )
GROUP BY S1.ID, S1.FK1, S1.FK2
EMIT FINAL

Additional context I have tried everything I can think of to try to set the ksql.suppress.enabled variable to true.

  1. Add "properties" section in input.json
  2. Use KSQL_OPTS in command line. i.e.: KSQL_OPTS="-Dksql.suppress.enabled=true" /Users/denglish/Installers/Confluent/6.1.0/extracted/confluent-6.1.0/bin/ksql-test-runner -s create.ksql.sql -i input.json -o output.json | grep '>>>'
  3. Adding to ksql-server.properties: ~/gitDevelopment/DAE/ksql-test-bench/src/test/ksql/unit-tests/group-by-tumbling/01-publish-intermediates$ ▶ tail -n 1 ~/Installers/Confluent/6.1.0/extracted/confluent-6.1.0/etc/ksqldb/ksql-server.properties: ksql.suppress.enabled=true
webcentricds commented 3 years ago

Looking at the code, looks like above attempts at setting the parameter were in vain:

  1. Looks like we are passing in null for the properties in a test case.
  2. Another opportunity to inject properties here in TestExecutor potentially?
vcrfxia commented 3 years ago

Hi @webcentricds , thanks for reporting this. As you've noted, the ksql-test-runner does not support setting custom properties at this time, including both server properties such as ksql.suppress.enabled and also query-level properties. I'm afraid I don't know of any workarounds at this time. (The ksql-test-runner has a number of gaps and will need a bit of an overhaul in order to support more use cases such as yours. Contributions always welcome!)

webcentricds commented 3 years ago

Hi Victoria!

  I think I would like to submit a PR (for branch off of 6.2.x I assume?).  Is this easy?  Or do I need to be given permissions?  Never done an Apache Open Source submission, but EXCITED to do my first!

  Anywhere where the "ksql-test-runner gaps" are documented?

   

    -----Original message----- From: Victoria Xia Sent: Friday, April 2 2021, 5:56 pm To: confluentinc/ksql Cc: David English; Mention Subject: Re: [confluentinc/ksql] Confluent 6.1.0: ksql-test-runner: can't set ksql.suppress.enabled to true so we can unit test EMIT FINAL (#7276)     Hi @webcentricds , thanks for reporting this. As you've noted, the ksql-test-runner does not support setting custom properties at this time, including both server properties such as ksql.suppress.enabled and also query-level properties. I'm afraid I don't know of any workarounds at this time. (The ksql-test-runner has a number of gaps and will need a bit of an overhaul in order to support more use cases such as yours. Contributions always welcome!)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

vcrfxia commented 3 years ago

Hi @webcentricds , thanks for your interest! ksqlDB is not an Apache project but it is built on Apache Kafka and Kafka Streams so we draw inspiration for many of our engineering practices from the Apache procedures. If you'd like to contribute, you can fork the repo and open a PR against the master branch. Check out the contributing guide for more. Here's a Github issue filter for issues relating to the ksql-test-runner: https://github.com/confluentinc/ksql/issues?q=is%3Aopen+is%3Aissue+label%3Aksql-test-runner

neuromantik33 commented 2 years ago

I'm also interested in this feature and be willing to contribute as it can be quite tedious to have to create the output json for all triggering events, when the only thing I desire is the final window event.