xintongsong commented on a change in pull request #13644: URL: https://github.com/apache/flink/pull/13644#discussion_r508360227
########## File path: flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/TestingFlinkKubeClient.java ########## @@ -103,6 +121,52 @@ public KubernetesWatch watchPodsAndDoCallback(Map<String, String> labels, WatchC return watchPodsAndDoCallbackFunction.apply(labels, podCallbackHandler); } + @Override + public CompletableFuture<Void> createConfigMap(KubernetesConfigMap configMap) { + configMapStore.putIfAbsent(configMap.getName(), configMap); + return CompletableFuture.completedFuture(null); + } + + @Override + public Optional<KubernetesConfigMap> getConfigMap(String name) { + final KubernetesConfigMap configMap = configMapStore.get(name); + if (configMap == null) { + return Optional.empty(); + } + return Optional.of(new MockKubernetesConfigMap(configMap.getName(), new HashMap<>(configMap.getData()))); + } + + @Override + public CompletableFuture<Boolean> checkAndUpdateConfigMap( + String configMapName, + Predicate<KubernetesConfigMap> checker, + FunctionWithException<KubernetesConfigMap, KubernetesConfigMap, ?> function) { + return getConfigMap(configMapName).map(FunctionUtils.uncheckedFunction( + configMap -> { + final boolean shouldUpdate = checker.test(configMap); + if (shouldUpdate) { + configMapStore.put(configMap.getName(), function.apply(configMap)); + } + return CompletableFuture.completedFuture(shouldUpdate); + })) + .orElseThrow(() -> new FlinkRuntimeException("ConfigMap " + configMapName + " not exists.")); + } Review comment: Either `configMapStore#remove(name)` or passing in `configMapStore` requires the map to be accessed from both internal and external of the testing client. Then we would also need to deal with the concurrent access issue. I would vote for the `Function` approach, to avoid adding maintaining overhead for future efforts. ---------------------------------------------------------------- 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: us...@infra.apache.org