Skip to content

Commit 1602044

Browse files
GEODE-10225: Gfsh start commands add exports on JDK 11+ (#7572)
PROBLEM When run on JDK 17, numerous acceptance tests fail because a launched locator or server requires access to the following packages: - java.base/sun.nio.ch - java.management/com.sun.jmx.remote.security SOLUTION - Add a `MemberJvmOptions` class that reports the JDK-dependent options required to launch a locator or server on the current process's JDK. - Change `StartLocatorCommand` and `StartServerCommand` to add those options to the command line when launching locators and servers. FUTURE Future PRs will likely put these opens/exports in an argument file, then configure these commands to use the argument file. We are deferring that until we identify additional needs for the argument file, so we can choose an appropriate location for the argument file. Co-authored-by: Dale Emery <demery@vmware.com> Co-authored-by: Kirk Lund <klund@apache.org> Co-authored-by: Kirk Lund <klund@apache.org>
1 parent 4fbc35c commit 1602044

File tree

9 files changed

+809
-359
lines changed

9 files changed

+809
-359
lines changed

geode-assembly/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/StartLocatorCommandIntegrationTest.java

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import java.io.IOException;
2727
import java.io.InputStream;
2828
import java.io.OutputStream;
29+
import java.util.Arrays;
30+
import java.util.List;
2931
import java.util.Properties;
3032

3133
import org.junit.Before;
@@ -40,6 +42,8 @@
4042

4143
public class StartLocatorCommandIntegrationTest {
4244
private static final String FAKE_HOSTNAME = "someFakeHostname";
45+
private static final String LOCATOR_LAUNCHER_CLASS_NAME =
46+
"org.apache.geode.distributed.LocatorLauncher";
4347

4448
@Rule
4549
public GfshParserRule commandRule = new GfshParserRule();
@@ -91,11 +95,14 @@ public void startLocatorRespectsJmxManagerHostnameForClients() throws Exception
9195
public void startWithBindAddress() throws Exception {
9296
commandRule.executeAndAssertThat(spy, "start locator --bind-address=127.0.0.1");
9397

94-
ArgumentCaptor<String[]> commandLines = ArgumentCaptor.forClass(String[].class);
95-
verify(spy).getProcess(any(), commandLines.capture());
98+
ArgumentCaptor<String[]> commandLineCaptor = ArgumentCaptor.forClass(String[].class);
99+
verify(spy).getProcess(any(), commandLineCaptor.capture());
96100

97-
String[] lines = commandLines.getValue();
98-
assertThat(lines[12]).isEqualTo("--bind-address=127.0.0.1");
101+
List<String> commandLine = Arrays.asList(commandLineCaptor.getValue());
102+
String expectedBindAddressOption = "--bind-address=127.0.0.1";
103+
assertThat(commandLine)
104+
.containsOnlyOnce(LOCATOR_LAUNCHER_CLASS_NAME, expectedBindAddressOption)
105+
.containsSubsequence(LOCATOR_LAUNCHER_CLASS_NAME, expectedBindAddressOption);
99106
}
100107

101108
@Test
@@ -104,9 +111,13 @@ public void startLocatorRespectsHostnameForClients() throws Exception {
104111
.addOption("hostname-for-clients", FAKE_HOSTNAME).toString();
105112

106113
commandRule.executeAndAssertThat(spy, startLocatorCommand);
107-
ArgumentCaptor<String[]> commandLines = ArgumentCaptor.forClass(String[].class);
108-
verify(spy).getProcess(any(), commandLines.capture());
109-
String[] lines = commandLines.getValue();
110-
assertThat(lines).containsOnlyOnce("--hostname-for-clients=" + FAKE_HOSTNAME);
114+
115+
ArgumentCaptor<String[]> commandLine = ArgumentCaptor.forClass(String[].class);
116+
verify(spy).getProcess(any(), commandLine.capture());
117+
118+
String expectedHostNameOption = "--hostname-for-clients=" + FAKE_HOSTNAME;
119+
assertThat(commandLine.getValue())
120+
.containsOnlyOnce(LOCATOR_LAUNCHER_CLASS_NAME, expectedHostNameOption)
121+
.containsSubsequence(LOCATOR_LAUNCHER_CLASS_NAME, expectedHostNameOption);
111122
}
112123
}

geode-assembly/src/integrationTest/java/org/apache/geode/management/internal/cli/commands/StartServerCommandIntegrationTest.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636

3737
public class StartServerCommandIntegrationTest {
3838
private static final String FAKE_HOSTNAME = "someFakeHostname";
39+
private static final String SERVER_LAUNCHER_CLASS_NAME =
40+
"org.apache.geode.distributed.ServerLauncher";
3941

4042
@Rule
4143
public GfshParserRule commandRule = new GfshParserRule();
@@ -83,9 +85,12 @@ public void startServerRespectsHostnameForClients() throws Exception {
8385
.addOption("hostname-for-clients", FAKE_HOSTNAME).toString();
8486

8587
commandRule.executeAndAssertThat(spy, startServerCommand);
86-
ArgumentCaptor<String[]> commandLines = ArgumentCaptor.forClass(String[].class);
87-
verify(spy).getProcess(any(), commandLines.capture());
88-
String[] lines = commandLines.getValue();
89-
assertThat(lines).containsOnlyOnce("--hostname-for-clients=" + FAKE_HOSTNAME);
88+
ArgumentCaptor<String[]> commandLine = ArgumentCaptor.forClass(String[].class);
89+
verify(spy).getProcess(any(), commandLine.capture());
90+
91+
String expectedHostNameOption = "--hostname-for-clients=" + FAKE_HOSTNAME;
92+
assertThat(commandLine.getValue())
93+
.containsOnlyOnce(SERVER_LAUNCHER_CLASS_NAME, expectedHostNameOption)
94+
.containsSubsequence(SERVER_LAUNCHER_CLASS_NAME, expectedHostNameOption);
9095
}
9196
}

0 commit comments

Comments
 (0)