Make RdeUploadActionTest compatible with IPv6-only mode

This fixes an issue where RdeUploadActionTest relies on connecting to a local dummy SFTP server via the IPv4 loopback (127.0.0.1), which causes the test to fail on machines that only support IPv6.  This updates the test to use just "localhost" instead.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=148698178
This commit is contained in:
nickfelt 2017-02-27 14:53:39 -08:00 committed by Ben McIlwain
parent c7a62e9b98
commit 93b5cfb71b

View file

@ -254,7 +254,7 @@ public class RdeUploadActionTest {
@Test @Test
public void testSocketConnection() throws Exception { public void testSocketConnection() throws Exception {
int port = sftpd.serve("user", "password", folder.getRoot()); int port = sftpd.serve("user", "password", folder.getRoot());
try (Socket socket = new Socket("::1", port)) { try (Socket socket = new Socket("localhost", port)) {
assertThat(socket.isConnected()).isTrue(); assertThat(socket.isConnected()).isTrue();
} }
} }
@ -278,7 +278,7 @@ public class RdeUploadActionTest {
// XXX: For any port other than 22, JSch will reformat the hostname IPv6 style which causes // XXX: For any port other than 22, JSch will reformat the hostname IPv6 style which causes
// known host matching to fail. // known host matching to fail.
int port = sftpd.serve("user", "password", folder.getRoot()); int port = sftpd.serve("user", "password", folder.getRoot());
URI uploadUrl = URI.create(String.format("sftp://user:password@127.0.0.1:%d/", port)); URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port));
DateTime stagingCursor = DateTime.parse("2010-10-18TZ"); DateTime stagingCursor = DateTime.parse("2010-10-18TZ");
DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
persistResource( persistResource(
@ -299,7 +299,7 @@ public class RdeUploadActionTest {
@Test @Test
public void testRunWithLock_failsAfterThreeAttempts() throws Exception { public void testRunWithLock_failsAfterThreeAttempts() throws Exception {
int port = sftpd.serve("user", "password", folder.getRoot()); int port = sftpd.serve("user", "password", folder.getRoot());
URI uploadUrl = URI.create(String.format("sftp://user:password@127.0.0.1:%d/", port)); URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port));
DateTime stagingCursor = DateTime.parse("2010-10-18TZ"); DateTime stagingCursor = DateTime.parse("2010-10-18TZ");
DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
persistResource( persistResource(
@ -313,7 +313,7 @@ public class RdeUploadActionTest {
@Test @Test
public void testRunWithLock_copiesOnGcs() throws Exception { public void testRunWithLock_copiesOnGcs() throws Exception {
int port = sftpd.serve("user", "password", folder.getRoot()); int port = sftpd.serve("user", "password", folder.getRoot());
URI uploadUrl = URI.create(String.format("sftp://user:password@127.0.0.1:%d/", port)); URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port));
DateTime stagingCursor = DateTime.parse("2010-10-18TZ"); DateTime stagingCursor = DateTime.parse("2010-10-18TZ");
DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
persistResource( persistResource(
@ -341,7 +341,7 @@ public class RdeUploadActionTest {
RdeRevision.saveRevision("tld", DateTime.parse("2010-10-17TZ"), FULL, 1); RdeRevision.saveRevision("tld", DateTime.parse("2010-10-17TZ"), FULL, 1);
}}); }});
int port = sftpd.serve("user", "password", folder.getRoot()); int port = sftpd.serve("user", "password", folder.getRoot());
URI uploadUrl = URI.create(String.format("sftp://user:password@127.0.0.1:%d/", port)); URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port));
DateTime stagingCursor = DateTime.parse("2010-10-18TZ"); DateTime stagingCursor = DateTime.parse("2010-10-18TZ");
DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
persistSimpleResource( persistSimpleResource(
@ -361,7 +361,7 @@ public class RdeUploadActionTest {
public void testRunWithLock_producesValidSignature() throws Exception { public void testRunWithLock_producesValidSignature() throws Exception {
assumeTrue(hasCommand("gpg --version")); assumeTrue(hasCommand("gpg --version"));
int port = sftpd.serve("user", "password", folder.getRoot()); int port = sftpd.serve("user", "password", folder.getRoot());
URI uploadUrl = URI.create(String.format("sftp://user:password@127.0.0.1:%d/", port)); URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port));
DateTime stagingCursor = DateTime.parse("2010-10-18TZ"); DateTime stagingCursor = DateTime.parse("2010-10-18TZ");
DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
persistResource( persistResource(