mateczagany commented on code in PR #30141:
URL: https://github.com/apache/flink/pull/30141#discussion_r4719012192
##########
flink-runtime/src/test/java/org/apache/flink/runtime/source/coordinator/SourceCoordinatorAlignmentTest.java:
##########
@@ -277,6 +278,66 @@ void
testLateCloseOfPreviousCoordinatorKeepsEntryOfCurrentOne() throws Exception
current.announceCombinedWatermark();
assertLatestWatermarkAlignmentEvent(0, 1200);
+ @Test
Review Comment:
The new test method is inserted inside the previous test method
##########
flink-runtime/src/test/java/org/apache/flink/runtime/operators/coordination/CoordinatorStoreImplTest.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * 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.operators.coordination;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Unit tests for {@link CoordinatorStoreImpl}. */
+class CoordinatorStoreImplTest {
+
+ @Test
+ void testApplyOnAbsentKeyDoesNotInsertEntry() {
+ CoordinatorStoreImpl store = new CoordinatorStoreImpl();
+
+ Object result = store.apply("missing", value -> value == null ?
"absent" : "present");
+
+ assertThat(result).isEqualTo("absent");
+ assertThat(store.containsKey("missing")).isFalse();
+ }
+
+ @Test
+ void testApplyIsAtomicWithComputeIfPresent() throws Exception {
+ CoordinatorStoreImpl store = new CoordinatorStoreImpl();
+ StringBuilder mutableValue = new StringBuilder("a");
+ store.putIfAbsent("k", mutableValue);
+
+ AtomicBoolean stop = new AtomicBoolean(false);
+ AtomicReference<Throwable> failure = new AtomicReference<>();
Review Comment:
Instead of this thread, `AtomicReference<Throwable>`, the try/catch/finally
and the latch `readerDone`, you could just use `CheckedThread` to save a few
lines here
--
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]