Skip to content

Commit

Permalink
GEODE-6764: Fix tests broken and flaky on Windows (apache#3577)
Browse files Browse the repository at this point in the history
- ExportConfigCommandTest was broken by refactorings around removing
  LegacyCommandResult.
- AvailablePortHelperIntegrationTest has always been flaky on Windows.
  By default, Windows uses a bunch more ports than Linux, so some of
  these tests just don't work reliably as larger port ranges are not
  open and available on Windows.
  • Loading branch information
jdeppe-pivotal authored and onichols-pivotal committed Aug 21, 2019
1 parent 5ec7445 commit 9c35290
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableUDPPort;
import static org.apache.geode.internal.AvailablePortHelper.initializeUniquePortRange;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assume.assumeFalse;

import java.io.IOException;
import java.net.InetSocketAddress;
Expand All @@ -42,6 +43,7 @@
import org.junit.runner.RunWith;

import org.apache.geode.internal.AvailablePort.Keeper;
import org.apache.geode.internal.lang.SystemUtils;

@RunWith(JUnitParamsRunner.class)
public class AvailablePortHelperIntegrationTest {
Expand Down Expand Up @@ -266,6 +268,10 @@ public void getRandomAvailableTCPPort_returnsUniqueValues(final boolean useMembe
@Parameters({"true", "false"})
public void initializeUniquePortRange_willReturnSamePortsForSameRange(
final boolean useMembershipPortRange) {
assumeFalse(
"Windows has ports scattered throughout the range that makes this test difficult to pass consistently",
SystemUtils.isWindows());

for (int i = 0; i < 100; ++i) {
initializeUniquePortRange(i);
int[] testPorts = getRandomAvailableTCPPorts(3, useMembershipPortRange);
Expand All @@ -278,6 +284,10 @@ public void initializeUniquePortRange_willReturnSamePortsForSameRange(
@Parameters({"true", "false"})
public void initializeUniquePortRange_willReturnUniquePortsForUniqueRanges(
final boolean useMembershipPortRange) {
assumeFalse(
"Windows has ports scattered throughout the range that makes this test difficult to pass consistently",
SystemUtils.isWindows());

Set<Integer> ports = new HashSet<>();

for (int i = 0; i < 100; ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ public void before() throws Exception {
public void incorrectDirectoryShowsError() throws Exception {
String wrongDir = temp.newFile().getAbsolutePath();
gfsh.executeAndAssertThat(command, "export config --dir=" + wrongDir).statusIsError()
.containsOutput(wrongDir.replace("\\", "\\\\") + " is not a directory");
.containsOutput(wrongDir + " is not a directory");
}
}

0 comments on commit 9c35290

Please sign in to comment.