flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] pnowojski commented on a change in pull request #6871: [FLINK-10583][table] Add base TwoInputStreamOperator with TTL operator.
Date Wed, 17 Oct 2018 15:01:02 GMT
pnowojski commented on a change in pull request #6871: [FLINK-10583][table] Add base TwoInputStreamOperator
with TTL operator.
URL: https://github.com/apache/flink/pull/6871#discussion_r225959340
 
 

 ##########
 File path: flink-libraries/flink-table/src/test/scala/org/apache/flink/table/runtime/harness/AbstractTwoInputStreamOperatorWithTTLTest.scala
 ##########
 @@ -0,0 +1,332 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.runtime.harness
+
+import java.lang.{Long => JLong}
+
+import org.apache.flink.api.common.state._
+import org.apache.flink.api.common.time.Time
+import org.apache.flink.api.common.typeinfo.BasicTypeInfo
+import org.apache.flink.runtime.state.VoidNamespace
+import org.apache.flink.streaming.api.operators.InternalTimer
+import org.apache.flink.streaming.api.scala.OutputTag
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord
+import org.apache.flink.streaming.util.KeyedTwoInputStreamOperatorTestHarness
+import org.apache.flink.table.api.StreamQueryConfig
+import org.apache.flink.table.runtime.harness.HarnessTestBase.{TestStreamQueryConfig, TupleRowKeySelector}
+import org.apache.flink.table.runtime.join.AbstractTwoInputStreamOperatorWithTTL
+import org.apache.flink.table.runtime.types.CRow
+import org.hamcrest.{Description, TypeSafeMatcher}
+import org.junit.Test
+import org.hamcrest.MatcherAssert.assertThat
+
+import scala.collection.JavaConverters._
+import org.apache.flink.api.scala._
+
+/**
+  * Tests for the [[AbstractTwoInputStreamOperatorWithTTL]].
+  */
+class AbstractTwoInputStreamOperatorWithTTLTest extends HarnessTestBase {
+
+  private var testHarness: KeyedTwoInputStreamOperatorTestHarness[JLong, CRow, CRow, CRow]
= _
+
+  private val streamQueryConfig = new TestStreamQueryConfig(
+    Time.milliseconds(2),
+    Time.milliseconds(4)
+  )
+
+  @Test
+  def normalScenarioWorks(): Unit = {
+    val operator: StubOperatorWithTTLTimers =
+      new StubOperatorWithTTLTimers(streamQueryConfig)
+
+    testHarness = createTestHarness(operator)
+
+    testHarness.open()
+
+    testHarness.setProcessingTime(1L)
+    testHarness.processElement1(new StreamRecord(CRow(1L: JLong, "hello"), 1))
+
+    testHarness.setProcessingTime(10L)
+    testHarness.close()
+
+    assertThat(operator, hasFiredTimers(5L))
+  }
+
+  @Test
+  def whenCurrentTimePlusMinRetentionSmallerThanCurrentCleanupTimeNoNewTimerRegistered():
Unit = {
+    val operator: StubOperatorWithTTLTimers =
 
 Review comment:
   Could you deduplicate the setup/closing logic of those methods? For example extract
   ```
       val operator: StubOperatorWithTTLTimers =
         new StubOperatorWithTTLTimers(streamQueryConfig)
        testHarness = createTestHarness(operator)
        testHarness.open()
   ```
   to a setup method or to `createStubHarnessWithTTLTimers()` method.
   
   If you pick the `setup` method, `close` could be moved to tearDown (but that would require
`testHarness` to be a field not a local variable.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message