Merge pull request elastic/elasticsearch#1707 from ywelsch/enhance/forbid-sysout-for-tests
Remove System.out.println and Throwable.printStackTrace from tests Original commit: elastic/x-pack-elasticsearch@02aa9c7e28
This commit is contained in:
commit
85b3f13f29
|
@ -8,11 +8,13 @@ package org.elasticsearch.bench;
|
||||||
import org.elasticsearch.common.Randomness;
|
import org.elasticsearch.common.Randomness;
|
||||||
|
|
||||||
import com.carrotsearch.randomizedtesting.generators.RandomStrings;
|
import com.carrotsearch.randomizedtesting.generators.RandomStrings;
|
||||||
|
import org.elasticsearch.common.SuppressForbidden;
|
||||||
import org.elasticsearch.common.metrics.MeanMetric;
|
import org.elasticsearch.common.metrics.MeanMetric;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.shield.authc.support.Hasher;
|
import org.elasticsearch.shield.authc.support.Hasher;
|
||||||
import org.elasticsearch.shield.authc.support.SecuredString;
|
import org.elasticsearch.shield.authc.support.SecuredString;
|
||||||
|
|
||||||
|
@SuppressForbidden(reason = "benchmark")
|
||||||
public class HasherBenchmark {
|
public class HasherBenchmark {
|
||||||
|
|
||||||
private static final int WARMING_ITERS = 1000;
|
private static final int WARMING_ITERS = 1000;
|
||||||
|
@ -63,6 +65,7 @@ public class HasherBenchmark {
|
||||||
return metrics;
|
return metrics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressForbidden(reason = "benchmark")
|
||||||
private static class Metrics {
|
private static class Metrics {
|
||||||
|
|
||||||
final String name;
|
final String name;
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class EmailServer {
|
||||||
|
|
||||||
private final SMTPServer server;
|
private final SMTPServer server;
|
||||||
|
|
||||||
public EmailServer(String host, int port, final String username, final String password) {
|
public EmailServer(String host, int port, final String username, final String password, final ESLogger logger) {
|
||||||
server = new SMTPServer(new SimpleMessageListenerAdapter(new SimpleMessageListener() {
|
server = new SMTPServer(new SimpleMessageListenerAdapter(new SimpleMessageListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(String from, String recipient) {
|
public boolean accept(String from, String recipient) {
|
||||||
|
@ -58,8 +58,8 @@ public class EmailServer {
|
||||||
try {
|
try {
|
||||||
listener.on(msg);
|
listener.on(msg);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
logger.error("Unexpected failure", e);
|
||||||
fail(e.getMessage());
|
fail(e.getMessage());
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (MessagingException me) {
|
} catch (MessagingException me) {
|
||||||
|
@ -104,7 +104,7 @@ public class EmailServer {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPortNumber(int port) {
|
public boolean onPortNumber(int port) {
|
||||||
try {
|
try {
|
||||||
EmailServer server = new EmailServer("localhost", port, username, password);
|
EmailServer server = new EmailServer("localhost", port, username, password, logger);
|
||||||
server.start();
|
server.start();
|
||||||
emailServer.set(server);
|
emailServer.set(server);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
package org.elasticsearch.watcher.test.bench;
|
package org.elasticsearch.watcher.test.bench;
|
||||||
|
|
||||||
import org.elasticsearch.common.Randomness;
|
import org.elasticsearch.common.Randomness;
|
||||||
|
import org.elasticsearch.common.SuppressForbidden;
|
||||||
import org.elasticsearch.common.metrics.MeanMetric;
|
import org.elasticsearch.common.metrics.MeanMetric;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.watcher.support.clock.SystemClock;
|
import org.elasticsearch.watcher.support.clock.SystemClock;
|
||||||
|
@ -33,6 +34,7 @@ import static org.elasticsearch.watcher.trigger.schedule.Schedules.interval;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@SuppressForbidden(reason = "benchmark")
|
||||||
public class ScheduleEngineTriggerBenchmark {
|
public class ScheduleEngineTriggerBenchmark {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
|
@ -55,6 +55,7 @@ import static org.elasticsearch.watcher.trigger.schedule.Schedules.interval;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
|
@SuppressForbidden(reason = "benchmark")
|
||||||
public class WatcherScheduleEngineBenchmark {
|
public class WatcherScheduleEngineBenchmark {
|
||||||
|
|
||||||
private final static Settings SETTINGS = Settings.builder()
|
private final static Settings SETTINGS = Settings.builder()
|
||||||
|
@ -64,7 +65,6 @@ public class WatcherScheduleEngineBenchmark {
|
||||||
.put("http.cors.enabled", true)
|
.put("http.cors.enabled", true)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@SuppressForbidden(reason = "not really code or a test")
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
System.setProperty("es.logger.prefix", "");
|
System.setProperty("es.logger.prefix", "");
|
||||||
|
|
||||||
|
@ -252,6 +252,7 @@ public class WatcherScheduleEngineBenchmark {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressForbidden(reason = "benchmark")
|
||||||
private static class BenchStats {
|
private static class BenchStats {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
Loading…
Reference in New Issue