XComp commented on code in PR #23764:
URL: https://github.com/apache/flink/pull/23764#discussion_r1401885433
##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/resources/KubernetesSharedInformerITCase.java:
##########
@@ -72,56 +71,41 @@ void setUp() throws Exception {
@AfterEach
void tearDown() throws Exception {
ExecutorUtils.gracefulShutdown(5, TimeUnit.SECONDS,
watchCallbackExecutorService);
- client.deleteConfigMapsByLabels(labels).get();
+ client.deleteConfigMap(configMapName).get();
}
@Test
@Timeout(120000)
public void testWatch() throws Exception {
try (KubernetesConfigMapSharedWatcher watcher =
- client.createConfigMapSharedWatcher(labels)) {
+ client.createConfigMapSharedWatcher(configMapName)) {
for (int i = 0; i < 10; i++) {
- List<TestingCallbackHandler> callbackHandlers = new
ArrayList<>();
- List<Watch> watchers = new ArrayList<>();
-
- watchInRange(watcher, callbackHandlers, watchers, 0, 20);
- createConfigMapsInRange(0, 5);
- watchInRange(watcher, callbackHandlers, watchers, 20, 40);
- createConfigMapsInRange(5, 10);
- updateConfigMapInRange(0, 10, ImmutableMap.of("foo", "bar"));
- for (TestingCallbackHandler handler : callbackHandlers) {
- handler.addFuture.get();
- handler.addOrUpdateFuture.get();
-
assertThat(handler.assertFuture).isNotCompletedExceptionally();
+ Tuple2<TestingCallbackHandler, Watch> results =
watch(configMapName, watcher);
+ TestingCallbackHandler handler = results.f0;
+ createConfigMap(configMapName);
+ updateConfigMap(configMapName, ImmutableMap.of("foo", "bar"));
+
+ handler.addFuture.get();
+ handler.addOrUpdateFuture.get();
+ assertThat(handler.assertFuture).isNotCompletedExceptionally();
+
+ client.deleteConfigMap(configMapName).get();
+ handler.deleteFuture.get();
+ if (handler.assertFuture.isCompletedExceptionally()) {
+ handler.assertFuture.get();
Review Comment:
```suggestion
createConfigMap(configMapName);
FlinkAssertions.assertThatFuture(handler.addFuture)
.as("The creation of the ConfigMap should have been
processed, eventually.")
.eventuallySucceeds();
updateConfigMap(configMapName, ImmutableMap.of("foo",
"bar"));
FlinkAssertions.assertThatFuture(handler.addOrUpdateFuture)
.as("The update of the ConfigMap should have been
processed, eventually.")
.eventuallySucceeds();
assertThat(handler.assertFuture).isNotCompletedExceptionally();
client.deleteConfigMap(configMapName).get();
FlinkAssertions.assertThatFuture(handler.deleteFuture)
.as("The deletion of the ConfigMap should have been
processed, eventually.")
.eventuallySucceeds();
FlinkAssertions.assertThatFuture(handler.assertFuture).as("No error should have
appeared while processing the data.").eventuallySucceeds();
```
I know that this is a bit out-of-scope of this PR, but I'm wondering whether
we could make this test a bit more readable. It's hard to grasp why certain
future are meant to complete.
--
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]