tillrohrmann commented on a change in pull request #11854: URL: https://github.com/apache/flink/pull/11854#discussion_r426152374
########## File path: flink-runtime/src/test/java/org/apache/flink/runtime/externalresource/ExternalResourceUtilsTest.java ########## @@ -0,0 +1,247 @@ +/* + * 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.externalresource; + +import org.apache.flink.api.common.externalresource.ExternalResourceDriver; +import org.apache.flink.api.common.externalresource.ExternalResourceDriverFactory; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.configuration.ExternalResourceOptions; +import org.apache.flink.core.plugin.PluginManager; +import org.apache.flink.core.plugin.TestingPluginManager; +import org.apache.flink.util.TestLogger; + +import org.apache.commons.collections.IteratorUtils; +import org.junit.Test; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsInstanceOf.instanceOf; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +/** + * Tests for the {@link ExternalResourceUtils} class. + */ +public class ExternalResourceUtilsTest extends TestLogger { + + private static final String RESOURCE_NAME_1 = "foo"; + private static final String RESOURCE_NAME_2 = "bar"; + private static final List<String> RESOURCE_LIST = Arrays.asList(RESOURCE_NAME_1, RESOURCE_NAME_2); + private static final long RESOURCE_AMOUNT_1 = 2L; + private static final long RESOURCE_AMOUNT_2 = 1L; + private static final String RESOURCE_CONFIG_KEY_1 = "flink1"; + private static final String RESOURCE_CONFIG_KEY_2 = "flink2"; + private static final String SUFFIX = "flink.config-key"; + + @Test + public void testGetExternalResourcesWithConfigKeyNotSpecifiedOrEmpty() { + final Configuration config = new Configuration(); + final String resourceConfigKey = ""; + + config.set(ExternalResourceOptions.EXTERNAL_RESOURCE_LIST, RESOURCE_LIST); + config.setLong(ExternalResourceOptions.keyWithResourceNameAndSuffix(RESOURCE_NAME_1, ExternalResourceOptions.EXTERNAL_RESOURCE_AMOUNT_SUFFIX), RESOURCE_AMOUNT_1); Review comment: I think it is not bad to introduce more names. This should not be a reason to not do it if it helps the readability. I think my main problem was that `SUFFIX` also contains part of the actually expected config option key, namely `.config-key`. Moreover, `SUFFIX` does not say what it is. So it is actually not super easy to see which config option will be configured with `ExternalResourceOptions.keyWithResourceNameAndSuffix(RESOURCE_NAME_1, SUFFIX)`. ---------------------------------------------------------------- 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: [email protected]
