XComp commented on a change in pull request #18543:
URL: https://github.com/apache/flink/pull/18543#discussion_r794271632



##########
File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/highavailability/JobResultStoreContractTest.java
##########
@@ -0,0 +1,163 @@
+/*
+ * 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.runtime.highavailability;
+
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.runtime.jobmaster.JobResult;
+import org.apache.flink.runtime.testutils.TestingJobResultStore;
+
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.util.NoSuchElementException;
+import java.util.stream.Collectors;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatNoException;
+import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
+
+/**
+ * This interface defines a series of tests for any implementation of the 
{@link JobResultStore} to
+ * determine whether they correctly implement the contracts defined by the 
interface.
+ */
+public interface JobResultStoreContractTest {
+
+    JobResultEntry DUMMY_JOB_RESULT_ENTRY =
+            new JobResultEntry(TestingJobResultStore.DUMMY_JOB_RESULT);
+
+    JobResultStore createJobResultStore() throws IOException;
+
+    @Test
+    default void testStoreDirtyJobResult() throws IOException {
+        JobResultStore jobResultStore = createJobResultStore();
+        jobResultStore.createDirtyResult(DUMMY_JOB_RESULT_ENTRY);
+        
assertThat(jobResultStore.hasDirtyJobResultEntry(DUMMY_JOB_RESULT_ENTRY.getJobId()))
+                .isTrue();
+    }

Review comment:
       just to add more context: Here, the motivation is to have less code that 
needs to be maintained. In an ideal world we would like to have each code path 
tested through a single test. That has the benefit of only changing a single 
test if that specific codepath was adapted.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to