Skip to content

Commit

Permalink
[hotfix][core][test] Prioritize configurations over system properties…
Browse files Browse the repository at this point in the history
… for enabling fine-grained resource management.
  • Loading branch information
xintongsong committed Mar 24, 2021
1 parent 797b382 commit 7c5448c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,15 @@ public static boolean isFineGrainedResourceManagementEnabled(Configuration confi
// TODO We need to bind fine-grained with declarative because in the first step we implement
// the feature base on the declarative protocol. We would be able to support both protocols
// and no longer need this binding after FLINK-20838.
return isDeclarativeResourceManagementEnabled(configuration)
&& (configuration.get(ENABLE_FINE_GRAINED_RESOURCE_MANAGEMENT)
|| System.getProperties().containsKey("flink.tests.enable-fine-grained"));
if (!isDeclarativeResourceManagementEnabled(configuration)) {
return false;
}

if (configuration.contains(ENABLE_FINE_GRAINED_RESOURCE_MANAGEMENT)) {
return configuration.get(ENABLE_FINE_GRAINED_RESOURCE_MANAGEMENT);
} else {
return System.getProperties().containsKey("flink.tests.enable-fine-grained");
}
}

/** The mode of how to handle user code attempting to exit JVM. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,15 @@
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.MemorySize;
import org.apache.flink.configuration.TaskManagerOptions;
import org.apache.flink.core.testutils.CommonTestUtils;
import org.apache.flink.runtime.clusterframework.types.ResourceID;
import org.apache.flink.runtime.resourcemanager.ResourceManagerRuntimeServicesConfiguration;
import org.apache.flink.util.ConfigurationException;
import org.apache.flink.util.TestLogger;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import javax.annotation.Nullable;

import java.util.Map;

import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
Expand All @@ -47,25 +42,10 @@ public class ActiveResourceManagerFactoryTest extends TestLogger {
private static final MemorySize TOTAL_FLINK_SIZE = MemorySize.ofMebiBytes(2 * 1024);
private static final MemorySize TOTAL_PROCESS_SIZE = MemorySize.ofMebiBytes(3 * 1024);

private static Map<String, String> systemEnv;

@BeforeClass
public static void setupClass() {
systemEnv = System.getenv();
System.clearProperty("flink.tests.disable-declarative");
System.clearProperty("flink.tests.enable-fine-grained");
}

@AfterClass
public static void teardownClass() {
if (systemEnv != null) {
CommonTestUtils.setEnv(systemEnv, true);
}
}

@Test
public void testGetEffectiveConfigurationForResourceManagerCoarseGrained() {
final Configuration config = new Configuration();
config.set(ClusterOptions.ENABLE_DECLARATIVE_RESOURCE_MANAGEMENT, false);
config.set(ClusterOptions.ENABLE_FINE_GRAINED_RESOURCE_MANAGEMENT, false);
config.set(TaskManagerOptions.TOTAL_FLINK_MEMORY, TOTAL_FLINK_SIZE);
config.set(TaskManagerOptions.TOTAL_PROCESS_MEMORY, TOTAL_PROCESS_SIZE);
Expand Down

0 comments on commit 7c5448c

Please sign in to comment.