rkhachatryan commented on a change in pull request #14943:
URL: https://github.com/apache/flink/pull/14943#discussion_r583606966



##########
File path: 
flink-state-backends/flink-statebackend-changelog/src/test/java/org/apache/flink/state/changelog/ChangelogDelegateHashMapTest.java
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.state.changelog;
+
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.common.typeutils.base.IntSerializer;
+import org.apache.flink.runtime.execution.Environment;
+import org.apache.flink.runtime.state.CheckpointableKeyedStateBackend;
+import org.apache.flink.runtime.state.HashMapStateBackendTest;
+import org.apache.flink.runtime.state.KeyGroupRange;
+import org.apache.flink.runtime.state.heap.HeapAggregatingState;
+import org.apache.flink.runtime.state.heap.HeapListState;
+import org.apache.flink.runtime.state.heap.HeapMapState;
+import org.apache.flink.runtime.state.heap.HeapReducingState;
+import org.apache.flink.runtime.state.heap.HeapValueState;
+
+import org.junit.Test;
+
+import static 
org.apache.flink.state.changelog.ChangelogStateBackendTestUtils.assertAggregatingState;
+import static 
org.apache.flink.state.changelog.ChangelogStateBackendTestUtils.assertListState;
+import static 
org.apache.flink.state.changelog.ChangelogStateBackendTestUtils.assertMapState;
+import static 
org.apache.flink.state.changelog.ChangelogStateBackendTestUtils.assertReducingState;
+import static 
org.apache.flink.state.changelog.ChangelogStateBackendTestUtils.assertValueState;
+
+/** Tests for {@link ChangelogStateBackend} delegating {@link 
HashMapStateBackendTest}. */
+public class ChangelogDelegateHashMapTest extends HashMapStateBackendTest {
+
+    @Override
+    protected <K> CheckpointableKeyedStateBackend<K> createKeyedBackend(
+            TypeSerializer<K> keySerializer,
+            int numberOfKeyGroups,
+            KeyGroupRange keyGroupRange,
+            Environment env)
+            throws Exception {
+
+        return ChangelogStateBackendTestUtils.createKeyedBackend(
+                getStateBackend(), keySerializer, numberOfKeyGroups, 
keyGroupRange, env);
+    }
+
+    @Test
+    public void testDelegatedValueState() throws Exception {
+        assertValueState(createKeyedBackend(IntSerializer.INSTANCE), 
HeapValueState.class);

Review comment:
       I see some issues with ChangelogDelegate.*Tests:
   1. Production code is made public (e.g. `HeapValueState`, 
`RocksDBValueState`)
   2. Explicit assertions about each delegated backend implementation details 
(so changing RocksDb state class will break the tests)
   3. A lot of code duplication
   
   Why not have just one test class that would assert for every state type the 
returned delegated state
   is the same as delegating:
   
   ```
   StateBackend delegatedBackend = new HashMapStateBackend(); // implementation 
doesn't matter
   State delegatedState = 
delegatedBackend.createKeyedStateBackend(...).getPartitionedState(...);
   
   ChangelogStateBackend changelogBackend = new 
ChangelogStateBackend(delegatedBackend);
   ChangelogValueState changeLogState = 
changelogBackend.createKeyedStateBackend().getPartitionedState();
   
   assertEquals(delegatedState.getClass(), 
changeLogState.getDelegatedValueState().getClass());
   ```
   
   (while still having almost empty sublasses to run `StateBackendTestBase` 
again different backend combinations)




----------------------------------------------------------------
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.

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


Reply via email to