summaryrefslogtreecommitdiffstats
path: root/jrt/tests
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2019-02-27 19:30:52 +0100
committerGitHub <noreply@github.com>2019-02-27 19:30:52 +0100
commitaf26e7921e852ba6335a62bcf160339adfa195aa (patch)
tree4eb67d98b4081f90129ed10075fe465a2aac5a73 /jrt/tests
parentbfe00f042aab30166e507f8b71590be688d26443 (diff)
Revert "async tls handshake in jrt"
Diffstat (limited to 'jrt/tests')
-rw-r--r--jrt/tests/com/yahoo/jrt/LatencyTest.java84
1 files changed, 0 insertions, 84 deletions
diff --git a/jrt/tests/com/yahoo/jrt/LatencyTest.java b/jrt/tests/com/yahoo/jrt/LatencyTest.java
deleted file mode 100644
index a1f71bda013..00000000000
--- a/jrt/tests/com/yahoo/jrt/LatencyTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-package com.yahoo.jrt;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.logging.Logger;
-
-import static com.yahoo.jrt.CryptoUtils.createTestTlsContext;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class LatencyTest {
- private static final Logger log = Logger.getLogger(LatencyTest.class.getName());
-
- private static class Server implements AutoCloseable {
- private Supervisor orb;
- private Acceptor acceptor;
- public Server(CryptoEngine crypto) throws ListenFailedException {
- orb = new Supervisor(new Transport(crypto));
- acceptor = orb.listen(new Spec(0));
- orb.addMethod(new Method("inc", "i", "i", this, "rpc_inc"));
- }
- public Target connect() {
- return orb.connect(new Spec("localhost", acceptor.port()));
- }
- public void rpc_inc(Request req) {
- req.returnValues().add(new Int32Value(req.parameters().get(0).asInt32() + 1));
- }
- public void close() {
- acceptor.shutdown().join();
- orb.transport().shutdown().join();
- }
- }
-
- private void measureLatency(String prefix, Server server, boolean reconnect) {
- int value = 100;
- List<Double> list = new ArrayList<>();
- Target target = server.connect();
- for (int i = 0; i < 64; ++i) {
- long before = System.nanoTime();
- if (reconnect) {
- target.close();
- target = server.connect();
- }
- Request req = new Request("inc");
- req.parameters().add(new Int32Value(value));
- target.invokeSync(req, 60.0);
- assertTrue(req.checkReturnTypes("i"));
- assertEquals(value + 1, req.returnValues().get(0).asInt32());
- value++;
- long duration = System.nanoTime() - before;
- list.add(duration / 1000000.0);
- }
- target.close();
- Collections.sort(list);
- log.info(prefix + "invocation latency: " + list.get(list.size() / 2) + " ms");
- }
-
- @org.junit.Test
- public void testNullCryptoLatency() throws ListenFailedException {
- try (Server server = new Server(new NullCryptoEngine())) {
- measureLatency("[null crypto, no reconnect] ", server, false);
- measureLatency("[null crypto, reconnect] ", server, true);
- }
- }
-
- @org.junit.Test
- public void testXorCryptoLatency() throws ListenFailedException {
- try (Server server = new Server(new XorCryptoEngine())) {
- measureLatency("[xor crypto, no reconnect] ", server, false);
- measureLatency("[xor crypto, reconnect] ", server, true);
- }
- }
-
- @org.junit.Test
- public void testTlsCryptoLatency() throws ListenFailedException {
- try (Server server = new Server(new TlsCryptoEngine(createTestTlsContext()))) {
- measureLatency("[tls crypto, no reconnect] ", server, false);
- measureLatency("[tls crypto, reconnect] ", server, true);
- }
- }
-}