ExecutorEnvironmentalVariables { public List<Protos.Environment.Variable> getList() { return envList; } ExecutorEnvironmentalVariables(Configuration configuration);  ExecutorEnvironmentalVariables(Configuration configuration, long lNodeId); List<Protos.Environment.Variable> getList(); static final String JAVA_OPTS; static final String ES_HEAP; static final int EXTERNAL_VOLUME_NOT_CONFIGURED; static final String ELASTICSEARCH_NODE_ID; static final String DVDI_VOLUME_NAME; static final String DVDI_VOLUME_DRIVER; static final String DVDI_VOLUME_OPTS; static final String DVDI_VOLUME_CONTAINERPATH; }
@Test public void ensureOver1GBHeapIs256MB() throws Exception { int ram = 2048; Mockito.when(configuration.getMem()).thenReturn((double) ram); ExecutorEnvironmentalVariables env = new ExecutorEnvironmentalVariables(configuration); for (Protos.Environment.Variable var : env.getList()) { if (var.getName().equals(ExecutorEnvironmentalVariables.ES_HEAP)) { String val = var.getValue(); Pattern pattern = Pattern.compile("(\\d*)m"); Matcher matcher = pattern.matcher(val); assertTrue(matcher.matches()); assertEquals(Integer.toString(ram - 256), matcher.group(1)); } } }
@Test public void ensureUnder1GBIsLessThan256MB() throws Exception { int ram = 512; Mockito.when(configuration.getMem()).thenReturn((double) ram); ExecutorEnvironmentalVariables env = new ExecutorEnvironmentalVariables(configuration); for (Protos.Environment.Variable var : env.getList()) { if (var.getName().equals(ExecutorEnvironmentalVariables.ES_HEAP)) { String val = var.getValue(); Pattern pattern = Pattern.compile("(\\d*)m"); Matcher matcher = pattern.matcher(val); assertTrue(matcher.matches()); assertEquals(Integer.toString(ram - ram / 4), matcher.group(1)); assertTrue(ram - Integer.parseInt(matcher.group(1)) < 256); assertTrue(ram - Integer.parseInt(matcher.group(1)) < ram); assertTrue(ram - Integer.parseInt(matcher.group(1)) > 0); } } }