From b452d1f132c984806abd9dd0f0ee77b3ed6d92ec Mon Sep 17 00:00:00 2001 From: HÃ¥kon Hallingstad Date: Wed, 17 May 2017 22:28:36 +0200 Subject: Make logserver tests work with VPN Also, ignore directory made by test. --- .gitignore | 1 + .../lasterrorsholder/LastErrorsHolderTestCase.java | 3 ++- .../handlers/replicator/ReplicatorTestCase.java | 28 +++++++++++----------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 0f289299ac8..7bc8af51e33 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ Testing *_test_app /hadoop/dependency-reduced-pom.xml /vespa-hadoop/dependency-reduced-pom.xml +.preprocessed/ diff --git a/logserver/src/test/java/com/yahoo/logserver/handlers/lasterrorsholder/LastErrorsHolderTestCase.java b/logserver/src/test/java/com/yahoo/logserver/handlers/lasterrorsholder/LastErrorsHolderTestCase.java index a0e97c28f76..ba857c51f5c 100644 --- a/logserver/src/test/java/com/yahoo/logserver/handlers/lasterrorsholder/LastErrorsHolderTestCase.java +++ b/logserver/src/test/java/com/yahoo/logserver/handlers/lasterrorsholder/LastErrorsHolderTestCase.java @@ -53,7 +53,8 @@ public class LastErrorsHolderTestCase { Instant start = Instant.now(); while (Instant.now().isBefore(start.plus(Duration.ofMinutes(1)))) { try { - socket = SocketChannel.open(new InetSocketAddress(lastErrorsHolderPort)); + InetSocketAddress address = new InetSocketAddress("localhost", lastErrorsHolderPort); + socket = SocketChannel.open(address); break; } catch (Exception e) { Thread.sleep(100); diff --git a/logserver/src/test/java/com/yahoo/logserver/handlers/replicator/ReplicatorTestCase.java b/logserver/src/test/java/com/yahoo/logserver/handlers/replicator/ReplicatorTestCase.java index 37f25e47a1c..3f8ed840273 100644 --- a/logserver/src/test/java/com/yahoo/logserver/handlers/replicator/ReplicatorTestCase.java +++ b/logserver/src/test/java/com/yahoo/logserver/handlers/replicator/ReplicatorTestCase.java @@ -1,18 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.logserver.handlers.replicator; -import static org.junit.Assert.*; - -import java.io.IOException; -import java.net.InetSocketAddress; -import java.nio.ByteBuffer; -import java.nio.channels.SocketChannel; - -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - import com.yahoo.io.Listener; import com.yahoo.log.InvalidLogFormatException; import com.yahoo.log.LogLevel; @@ -21,6 +9,18 @@ import com.yahoo.logserver.Server; import com.yahoo.logserver.filter.LogFilter; import com.yahoo.logserver.filter.LogFilterManager; import com.yahoo.logserver.formatter.LogFormatterManager; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.nio.ByteBuffer; +import java.nio.channels.SocketChannel; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class ReplicatorTestCase { Server server; @@ -40,7 +40,7 @@ public class ReplicatorTestCase { long timeout = 60000; while (System.currentTimeMillis() < (start + timeout)) { try { - socket = SocketChannel.open(new InetSocketAddress(18321)); + socket = SocketChannel.open(new InetSocketAddress("localhost", 18321)); break; } catch (Exception e) { Thread.sleep(100); @@ -122,7 +122,7 @@ public class ReplicatorTestCase { assertTrue(conn.isLoggable(LogMessage. parseNativeFormat("1343996283.239582\texample.yahoo.com\t27301/7637\tconfig-sentinel\trunserver\terror\tbar"))); assertEquals(conn.description(), "No filter defined"); - assertEquals(conn.getRemoteHost(), "0.0.0.0"); + assertEquals(conn.getRemoteHost(), "localhost"); conn.onFormatter("nonexistant"); assertEquals(conn.formatter, LogFormatterManager.getLogFormatter("system.nullformatter")); // unchanged conn.onUse("nonexistant"); -- cgit v1.2.3