You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/07/01 09:49:53 UTC

[GitHub] [flink] mddxhj opened a new pull request, #20129: [FLINK-27941][connectors][test] kinesis connector test module migrate…

mddxhj opened a new pull request, #20129:
URL: https://github.com/apache/flink/pull/20129

   … to junit5
   
   <!--
   *Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   *Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
     Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   ## What is the purpose of the change
   
   *(For example: This pull request makes task deployment go through the blob server, rather than through RPC. That way we avoid re-transferring them on each deployment (during recovery).)*
   
   
   ## Brief change log
   
   *(for example:)*
     - *The TaskInfo is stored in the blob store on job creation time as a persistent artifact*
     - *Deployments RPC transmits only the blob storage reference*
     - *TaskManagers retrieve the TaskInfo from the blob cache*
   
   
   ## Verifying this change
   
   Please make sure both new and modified tests in this PR follows the conventions defined in our code quality guide: https://flink.apache.org/contributing/code-style-and-quality-common.html#testing
   
   *(Please pick either of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (100MB)*
     - *Extended integration test for recovery after master (JobManager) failure*
     - *Added test that validates that TaskInfo is transferred only once across recoveries*
     - *Manually verified the change by running a 4 node cluster with 2 JobManagers and 4 TaskManagers, a stateful streaming program, and killing one JobManager and two TaskManagers during the execution, verifying that recovery happens correctly.*
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (yes / no)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / no)
     - The serializers: (yes / no / don't know)
     - The runtime per-record code paths (performance sensitive): (yes / no / don't know)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / no / don't know)
     - The S3 file system connector: (yes / no / don't know)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (yes / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] Myasuka commented on a diff in pull request #20129: [FLINK-27941][kinesis][test] Migrate tests to junit5

Posted by GitBox <gi...@apache.org>.
Myasuka commented on code in PR #20129:
URL: https://github.com/apache/flink/pull/20129#discussion_r912371260


##########
flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/FlinkKinesisConsumerMigrationTest.java:
##########
@@ -44,18 +44,17 @@
 import com.amazonaws.services.kinesis.model.Shard;
 import org.junit.Ignore;
 import org.junit.Test;

Review Comment:
   I think we should move these two imports to junit5 based.



##########
flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/util/AWSUtilTest.java:
##########
@@ -45,14 +43,13 @@
 import static org.apache.flink.streaming.connectors.kinesis.model.SentinelSequenceNumber.SENTINEL_AT_TIMESTAMP_SEQUENCE_NUM;
 import static org.apache.flink.streaming.connectors.kinesis.model.SentinelSequenceNumber.SENTINEL_LATEST_SEQUENCE_NUM;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 /** Tests for AWSUtil. */
 @RunWith(PowerMockRunner.class)
 @PrepareForTest(AWSUtil.class)

Review Comment:
   I think this `PowerMockRunner` could be removed safely in this test case.



##########
flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/util/JobManagerWatermarkTrackerTest.java:
##########
@@ -18,23 +18,23 @@
 package org.apache.flink.streaming.connectors.kinesis.util;
 
 import org.apache.flink.configuration.Configuration;
-import org.apache.flink.runtime.testutils.MiniClusterResource;
 import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
 import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
 import org.apache.flink.streaming.api.functions.sink.SinkFunction;
 import org.apache.flink.streaming.api.functions.source.RichSourceFunction;
+import org.apache.flink.test.junit5.MiniClusterExtension;
 
-import org.junit.ClassRule;
 import org.junit.Test;

Review Comment:
   We should use `org.junit.jupiter.api.Test`



##########
flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/FlinkKinesisConsumerMigrationTest.java:
##########
@@ -109,10 +104,6 @@ public static Collection<FlinkVersion> parameters() {
                 FlinkVersion.v1_15);
     }
 
-    public FlinkKinesisConsumerMigrationTest(FlinkVersion testMigrateVersion) {
-        this.testMigrateVersion = testMigrateVersion;
-    }
-
     /** Manually run this to write binary snapshot data. */
     @Ignore

Review Comment:
   Should use `Disabled` to replace.



##########
flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/util/KinesisConfigUtilTest.java:
##########
@@ -23,9 +23,7 @@
 import org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils;
 
 import com.amazonaws.services.kinesis.producer.KinesisProducerConfiguration;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
 import org.junit.runner.RunWith;
 import org.powermock.modules.junit4.PowerMockRunner;

Review Comment:
   I tried to remove this in this test, and it seems okay.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] reswqa commented on a diff in pull request #20129: [FLINK-27941][kinesis][test] Migrate tests to junit5

Posted by GitBox <gi...@apache.org>.
reswqa commented on code in PR #20129:
URL: https://github.com/apache/flink/pull/20129#discussion_r912126079


##########
flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/FlinkKinesisConsumerMigrationTest.java:
##########
@@ -66,7 +65,6 @@
  * <p>For regenerating the binary snapshot files run {@link #writeSnapshot()} on the corresponding
  * Flink release-* branch.
  */
-@RunWith(Parameterized.class)
 public class FlinkKinesisConsumerMigrationTest {

Review Comment:
   ```suggestion
   class FlinkKinesisConsumerMigrationTest {
   ```



##########
flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/FlinkKinesisConsumerMigrationTest.java:
##########
@@ -66,7 +65,6 @@
  * <p>For regenerating the binary snapshot files run {@link #writeSnapshot()} on the corresponding
  * Flink release-* branch.
  */
-@RunWith(Parameterized.class)
 public class FlinkKinesisConsumerMigrationTest {

Review Comment:
   Test class should be package-private in junit5



##########
flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/KinesisConsumerTest.java:
##########
@@ -23,21 +23,19 @@
 import org.apache.flink.util.Collector;
 import org.apache.flink.util.TestLogger;
 
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
 
 import java.io.IOException;
 import java.util.Properties;
 
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
 /**
  * Tests for {@link FlinkKinesisConsumer}. In contrast to tests in {@link FlinkKinesisConsumerTest}
  * it does not use power mock, which makes it possible to use e.g. the {@link ExpectedException}.
  */
 public class KinesisConsumerTest extends TestLogger {

Review Comment:
   ```suggestion
   @ExtendWith(TestLoggerExtension.class)
   class KinesisConsumerTest {
   ```



##########
flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/FlinkKinesisConsumerMigrationTest.java:
##########
@@ -131,8 +122,9 @@ public void writeSnapshot() throws Exception {
                 new HashMap<>());
     }
 
-    @Test
-    public void testRestoreWithEmptyState() throws Exception {
+    @ParameterizedTest
+    @MethodSource("flinkVersionProvider")
+    public void testRestoreWithEmptyState(FlinkVersion flinkVersion) throws Exception {

Review Comment:
   ```suggestion
       void testRestoreWithEmptyState(FlinkVersion flinkVersion) throws Exception {
   ```



##########
flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/FlinkKinesisConsumerMigrationTest.java:
##########
@@ -131,8 +122,9 @@ public void writeSnapshot() throws Exception {
                 new HashMap<>());
     }
 
-    @Test
-    public void testRestoreWithEmptyState() throws Exception {
+    @ParameterizedTest
+    @MethodSource("flinkVersionProvider")
+    public void testRestoreWithEmptyState(FlinkVersion flinkVersion) throws Exception {

Review Comment:
   If there is no special reason, the test method should be marked as package-private



##########
flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/metrics/PollingRecordPublisherMetricsReporterTest.java:
##########
@@ -37,7 +37,7 @@ public class PollingRecordPublisherMetricsReporterTest {
 
     @Mock private MetricGroup metricGroup;
 
-    @Before
+    @BeforeEach
     public void setUp() {

Review Comment:
   Lifecycle method should marked as package-private also.



##########
flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/metrics/PollingRecordPublisherMetricsReporterTest.java:
##########
@@ -37,7 +37,7 @@ public class PollingRecordPublisherMetricsReporterTest {
 
     @Mock private MetricGroup metricGroup;
 
-    @Before
+    @BeforeEach
     public void setUp() {

Review Comment:
   ```suggestion
       void setUp() {
   ```



##########
flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/util/KinesisConfigUtilTest.java:
##########
@@ -23,9 +23,7 @@
 import org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils;
 
 import com.amazonaws.services.kinesis.producer.KinesisProducerConfiguration;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
 import org.junit.runner.RunWith;
 import org.powermock.modules.junit4.PowerMockRunner;

Review Comment:
   I'm not sure whether it's reasonable to still use `org.powermock.modules.junit4.PowerMockRunner` here. To be honest, I don't know which class should be used to replace it. You'd better confirm it again.



##########
flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/internals/publisher/fanout/FanOutShardSubscriberTest.java:
##########
@@ -23,143 +23,174 @@
 
 import com.amazonaws.http.timers.client.SdkInterruptedException;
 import io.netty.handler.timeout.ReadTimeoutException;
-import org.junit.Rule;
 import org.junit.Test;

Review Comment:
   Why org.junit.Test still exist



##########
flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/FlinkKinesisConsumerMigrationTest.java:
##########
@@ -131,8 +122,9 @@ public void writeSnapshot() throws Exception {
                 new HashMap<>());
     }
 
-    @Test
-    public void testRestoreWithEmptyState() throws Exception {
+    @ParameterizedTest
+    @MethodSource("flinkVersionProvider")
+    public void testRestoreWithEmptyState(FlinkVersion flinkVersion) throws Exception {

Review Comment:
   In JUnit 5, test classes, test methods, and lifecycle methods are not required to be public, but they must not be private. And the [JUnit5 user guide ](https://junit.org/junit5/docs/snapshot/user-guide/#writing-tests-classes-and-methods)recommends omitting the public modifier for them unless there is a technical reason – for example, when a test class is extended by a test class in another package. So please follow this rule in the migration.



##########
flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/FlinkKinesisProducerTest.java:
##########
@@ -62,19 +61,20 @@
 /** Suite of {@link FlinkKinesisProducer} tests. */
 public class FlinkKinesisProducerTest extends TestLogger {
 
-    @Rule public ExpectedException exception = ExpectedException.none();
-
     // ----------------------------------------------------------------------
     // Tests to verify serializability
     // ----------------------------------------------------------------------
 
     @Test
     public void testCreateWithNonSerializableDeserializerFails() {
-        exception.expect(IllegalArgumentException.class);
-        exception.expectMessage("The provided serialization schema is not serializable");
-
-        new FlinkKinesisProducer<>(
-                new NonSerializableSerializationSchema(), TestUtils.getStandardProperties());
+        assertThatThrownBy(
+                        () -> {
+                            new FlinkKinesisProducer<>(
+                                    new NonSerializableSerializationSchema(),
+                                    TestUtils.getStandardProperties());
+                        })

Review Comment:
   ```suggestion
           assertThatThrownBy(
                           () ->
                               new FlinkKinesisProducer<>(
                                       new NonSerializableSerializationSchema(),
                                       TestUtils.getStandardProperties()))
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] flinkbot commented on pull request #20129: [FLINK-27941][connectors][test] kinesis connector test module migrate…

Posted by GitBox <gi...@apache.org>.
flinkbot commented on PR #20129:
URL: https://github.com/apache/flink/pull/20129#issuecomment-1172167351

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "7c1591353ac6ef0cfd45b84ec3b546a550a54f31",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "7c1591353ac6ef0cfd45b84ec3b546a550a54f31",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 7c1591353ac6ef0cfd45b84ec3b546a550a54f31 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] XComp commented on pull request #20129: [FLINK-27941][kinesis][test] Migrate tests to junit5

Posted by GitBox <gi...@apache.org>.
XComp commented on PR #20129:
URL: https://github.com/apache/flink/pull/20129#issuecomment-1271237397

   @mddxhj Are you still working on this issue?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org