muralibasani commented on code in PR #24326:
URL: https://github.com/apache/kafka/pull/24326#discussion_r4701082448


##########
streams/src/test/java/org/apache/kafka/streams/state/internals/KeyValueTimestampedHeaderStoreToKeyValueTimestampStoreAdapterCompletenessTest.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * 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.kafka.streams.state.internals;
+
+import org.apache.kafka.streams.state.TimestampedKeyValueStoreWithHeaders;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static 
org.apache.kafka.streams.state.internals.StoreMethodSignatures.inheritedInterfaceDefaults;
+import static 
org.apache.kafka.streams.state.internals.StoreMethodSignatures.instanceMethods;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Requires every {@link TimestampedKeyValueStoreWithHeaders} method to be 
classified into a contract group,
+ * and every method except {@link #INHERITED_DEFAULTS} to be overridden by
+ * {@link KeyValueTimestampedHeaderStoreToKeyValueTimestampStoreAdapter} (or 
its {@link WrappedStateStore}
+ * base), so a dropped override fails this test rather than escaping to manual 
testing (KAFKA-20328).
+ * Behavioral assertions live in {@link 
KeyValueTimestampedHeaderStoreToKeyValueTimestampStoreAdapterTest}.
+ */
+public class 
KeyValueTimestampedHeaderStoreToKeyValueTimestampStoreAdapterCompletenessTest {
+
+    private static final Set<String> VALUE_CONVERTING = Set.of(
+        "get(Object)",
+        "delete(Object)",
+        "putIfAbsent(Object,Object)"
+    );
+
+    private static final Set<String> ITERATOR_WRAPPING = Set.of(
+        "range(Object,Object)",
+        "reverseRange(Object,Object)",
+        "all()",
+        "reverseAll()",
+        "prefixScan(Object,Serializer)"
+    );
+
+    private static final Set<String> HEADER_STRIPPING = Set.of(
+        "put(Object,Object)",
+        "putAll(List)"
+    );
+
+    private static final Set<String> DELEGATING = Set.of(
+        "approximateNumEntries()",
+        "name()",
+        "init(StateStoreContext,StateStore)",
+        "commit(Map)",
+        "managesOffsets()",
+        "committedOffset(TopicPartition)",
+        "approximateNumUncommittedBytes()",
+        "close()",
+        "persistent()",
+        "isOpen()",
+        "query(Query,PositionBound,QueryConfig)",
+        "getPosition()",
+        "flush()"
+    );
+
+    // readOnly is NOT harmless: the adapter inherits the default that returns 
`this`, so the isolation
+    // level never reaches the inner store and READ_COMMITTED reads can 
observe uncommitted writes.
+    // Same gap as KAFKA-21505 (which covers the byte-level header adapters); 
remove readOnly from here
+    // once the adapter overrides it.
+    private static final Set<String> INHERITED_DEFAULTS = Set.of(

Review Comment:
   Thanks, updated.



##########
streams/src/test/java/org/apache/kafka/streams/state/internals/WindowedTimestampedHeadersStoreToWindowedTimestampedStoreAdapterCompletenessTest.java:
##########
@@ -0,0 +1,120 @@
+/*
+ * 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.kafka.streams.state.internals;
+
+import org.apache.kafka.streams.state.TimestampedWindowStoreWithHeaders;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static 
org.apache.kafka.streams.state.internals.StoreMethodSignatures.inheritedInterfaceDefaults;
+import static 
org.apache.kafka.streams.state.internals.StoreMethodSignatures.instanceMethods;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Requires every {@link TimestampedWindowStoreWithHeaders} method to be 
classified into a contract group,
+ * and every method except {@link #INHERITED_DEFAULTS} to be overridden by
+ * {@link WindowedTimestampedHeadersStoreToWindowedTimestampedStoreAdapter} 
(or its {@link WrappedStateStore}
+ * base), so a dropped override fails this test rather than escaping to manual 
testing (KAFKA-20328). A
+ * dropped {@code backward*} override would inherit the {@code WindowStore} 
default that throws
+ * {@link UnsupportedOperationException}.
+ * Behavioral assertions live in {@link 
WindowedTimestampedHeadersStoreToWindowedTimestampedStoreAdapterTest}.
+ */
+public class 
WindowedTimestampedHeadersStoreToWindowedTimestampedStoreAdapterCompletenessTest
 {
+
+    private static final Set<String> VALUE_CONVERTING = Set.of(
+        "fetch(Object,long)"
+    );
+
+    private static final Set<String> ITERATOR_WRAPPING = Set.of(
+        "fetch(Object,long,long)",
+        "fetch(Object,Instant,Instant)",
+        "backwardFetch(Object,long,long)",
+        "backwardFetch(Object,Instant,Instant)",
+        "fetch(Object,Object,long,long)",
+        "fetch(Object,Object,Instant,Instant)",
+        "backwardFetch(Object,Object,long,long)",
+        "backwardFetch(Object,Object,Instant,Instant)",
+        "all()",
+        "backwardAll()",
+        "fetchAll(long,long)",
+        "fetchAll(Instant,Instant)",
+        "backwardFetchAll(long,long)",
+        "backwardFetchAll(Instant,Instant)"
+    );
+
+    private static final Set<String> HEADER_STRIPPING = Set.of(
+        "put(Object,Object,long)"
+    );
+
+    private static final Set<String> DELEGATING = Set.of(
+        "name()",
+        "init(StateStoreContext,StateStore)",
+        "commit(Map)",
+        "managesOffsets()",
+        "committedOffset(TopicPartition)",
+        "approximateNumUncommittedBytes()",
+        "close()",
+        "persistent()",
+        "isOpen()",
+        "query(Query,PositionBound,QueryConfig)",
+        "getPosition()",
+        "flush()"
+    );
+
+    // readOnly is NOT harmless: the adapter inherits the default that returns 
`this`, so the isolation
+    // level never reaches the inner store and READ_COMMITTED reads can 
observe uncommitted writes.
+    // Same gap as KAFKA-21505 (which covers the byte-level header adapters); 
remove readOnly from here
+    // once the adapter overrides it.
+    private static final Set<String> INHERITED_DEFAULTS = Set.of(

Review Comment:
   Updated.



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