XComp commented on code in PR #23764:
URL: https://github.com/apache/flink/pull/23764#discussion_r1401826621
##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/highavailability/KubernetesTestFixture.java:
##########
@@ -76,10 +74,8 @@ class KubernetesTestFixture {
configuration.setString(KubernetesConfigOptions.CLUSTER_ID, clusterId);
flinkKubeClient = createFlinkKubeClient();
- configMapSharedWatcher =
- flinkKubeClient.createConfigMapSharedWatcher(
- KubernetesUtils.getConfigMapLabels(
- clusterId,
LABEL_CONFIGMAP_TYPE_HIGH_AVAILABILITY));
+ // use the configmap name as the informer
Review Comment:
```suggestion
```
nit: the comment doesn't seem to add any value
##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/TestingFlinkKubeClient.java:
##########
@@ -456,6 +450,8 @@ public static class TestingKubernetesConfigMapSharedWatcher
public TestingKubernetesConfigMapSharedWatcher(Map<String, String>
labels) {}
Review Comment:
```suggestion
public TestingKubernetesConfigMapSharedWatcher(Map<String, String>
labels) {}
```
This one is not used anymore and can be deleted.
##########
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/kubeclient/resources/KubernetesConfigMapSharedInformer.java:
##########
@@ -38,10 +39,21 @@ public KubernetesConfigMapSharedInformer(
super(client, getInformableConfigMaps(client, labels),
KubernetesConfigMap::new);
Review Comment:
What about removing this constructor and the then unused method
`getInformableConfigMaps(NamespacedKubernetesClient, Map<String, String>)` as
part of this change? This code won't be covered by any tests anymore.
##########
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++) {
Review Comment:
```suggestion
```
Can't we get rid of the for loop as well here? Or is there some value in
running this test multiple times? :thinking:
##########
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/highavailability/KubernetesLeaderElectionHaServices.java:
##########
@@ -46,7 +46,6 @@
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
-import static
org.apache.flink.kubernetes.utils.Constants.LABEL_CONFIGMAP_TYPE_HIGH_AVAILABILITY;
Review Comment:
I guess, `Constants.LABEL_CONFIGMAP_TYPE_KEY` would also be subject for
deletion.
##########
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/highavailability/KubernetesTestFixture.java:
##########
@@ -199,12 +195,11 @@ TestingFlinkKubeClient.Builder
createFlinkKubeClientBuilder() {
leaderConfig, callbackHandler);
})
.setCreateConfigMapSharedWatcherFunction(
- (labels) -> {
+ (name) -> {
Review Comment:
```suggestion
name -> {
```
nit
##########
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
```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.
```
##########
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/highavailability/KubernetesLeaderElectionHaServices.java:
##########
@@ -46,7 +46,6 @@
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
-import static
org.apache.flink.kubernetes.utils.Constants.LABEL_CONFIGMAP_TYPE_HIGH_AVAILABILITY;
Review Comment:
Can't we get rid of the HA label entirely, now? ...essentially, that
`Constants.LABEL_CONFIGMAP_TYPE_HIGH_AVAILABILITY` is removed. :thinking: We
still need the labeling for cleanup, though.
--
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]