wangyang0918 commented on a change in pull request #13644: URL: https://github.com/apache/flink/pull/13644#discussion_r509017125
########## 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: Hmm. I know your concerns now. Then I will keep the `configMapStore` in `TestingFlinkKubeClient` internally. And add `Functions` for the flexibility, for example, throw an exception when `createConfigMap`. ---------------------------------------------------------------- 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