Cleaned up unit tests
This commit is contained in:
parent
e27fdbb369
commit
8caef6611c
@ -94,15 +94,6 @@ object AeronClient {
|
|||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
// val ntpClient = NtpClient()
|
|
||||||
// ntpClient.requestTime("time.mit.edu", 10_000)
|
|
||||||
//
|
|
||||||
// println("ROUNDTRIP: ${ntpClient.roundTripTime}")
|
|
||||||
// println("NTP : ${convertLongToTime(System.currentTimeMillis())}")
|
|
||||||
// println("NTP : ${convertLongToTime(ntpClient.ntpTime)}")
|
|
||||||
//
|
|
||||||
// if (true) return
|
|
||||||
|
|
||||||
val configuration = Configuration()
|
val configuration = Configuration()
|
||||||
configuration.subscriptionPort = 2000
|
configuration.subscriptionPort = 2000
|
||||||
configuration.publicationPort = 2001
|
configuration.publicationPort = 2001
|
||||||
@ -136,7 +127,6 @@ object AeronClient {
|
|||||||
|
|
||||||
runBlocking {
|
runBlocking {
|
||||||
client.connect("127.0.0.1") // UDP connection via loopback
|
client.connect("127.0.0.1") // UDP connection via loopback
|
||||||
// client.connect() // IPC connection
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -146,11 +136,11 @@ object AeronClient {
|
|||||||
// send - unreliable
|
// send - unreliable
|
||||||
// send - priority (0-255 -- 255 is MAX priority) when sending, max is always sent immediately, then lower priority is sent if there is no backpressure from the MediaDriver.
|
// send - priority (0-255 -- 255 is MAX priority) when sending, max is always sent immediately, then lower priority is sent if there is no backpressure from the MediaDriver.
|
||||||
// send - IPC/local
|
// send - IPC/local
|
||||||
runBlocking {
|
// runBlocking {
|
||||||
while (!client.isShutdown()) {
|
// while (!client.isShutdown()) {
|
||||||
client.send("ECHO " + java.lang.Long.toUnsignedString(client.crypto.secureRandom.nextLong(), 16))
|
// client.send("ECHO " + java.lang.Long.toUnsignedString(client.crypto.secureRandom.nextLong(), 16))
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
// connection needs to know
|
// connection needs to know
|
||||||
|
@ -96,12 +96,12 @@ object AeronServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
server.onError { throwable ->
|
server.onError { throwable ->
|
||||||
println("has error")
|
println("from test: has error")
|
||||||
throwable.printStackTrace()
|
throwable.printStackTrace()
|
||||||
}
|
}
|
||||||
|
|
||||||
server.onError { connection, throwable ->
|
server.onError { connection, throwable ->
|
||||||
println("has error")
|
println("from test: has connection error")
|
||||||
throwable.printStackTrace()
|
throwable.printStackTrace()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,8 +83,8 @@ abstract class BaseTest {
|
|||||||
|
|
||||||
// rootLogger.setLevel(Level.OFF);
|
// rootLogger.setLevel(Level.OFF);
|
||||||
|
|
||||||
// rootLogger.level = Level.INFO;
|
rootLogger.level = Level.INFO;
|
||||||
rootLogger.level = Level.TRACE;
|
// rootLogger.level = Level.TRACE;
|
||||||
// rootLogger.level = Level.DEBUG
|
// rootLogger.level = Level.DEBUG
|
||||||
// rootLogger.level = Level.ALL;
|
// rootLogger.level = Level.ALL;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ class DisconnectReconnectTest : BaseTest() {
|
|||||||
|
|
||||||
val server: Server<Connection> = Server(configuration)
|
val server: Server<Connection> = Server(configuration)
|
||||||
addEndPoint(server)
|
addEndPoint(server)
|
||||||
server.bind(false)
|
server.bind()
|
||||||
|
|
||||||
server.onConnect { connection ->
|
server.onConnect { connection ->
|
||||||
connection.logger.error("Disconnecting after 2 seconds.")
|
connection.logger.error("Disconnecting after 2 seconds.")
|
||||||
|
@ -112,7 +112,7 @@ class ListenerTest : BaseTest() {
|
|||||||
serverDisconnect.value = true
|
serverDisconnect.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
server.bind(false)
|
server.bind()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ class MultipleServerTest : BaseTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
server.bind(false)
|
server.bind()
|
||||||
|
|
||||||
serverAeronDir = File(configuration.aeronLogDirectory.toString() + count)
|
serverAeronDir = File(configuration.aeronLogDirectory.toString() + count)
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ class PingPongTest : BaseTest() {
|
|||||||
|
|
||||||
val server: Server<Connection> = Server(configuration)
|
val server: Server<Connection> = Server(configuration)
|
||||||
addEndPoint(server)
|
addEndPoint(server)
|
||||||
server.bind(false)
|
server.bind()
|
||||||
|
|
||||||
server.onError { _, throwable ->
|
server.onError { _, throwable ->
|
||||||
fail = "Error during processing. $throwable"
|
fail = "Error during processing. $throwable"
|
||||||
|
@ -36,7 +36,7 @@ class SerializationValidationTest : BaseTest() {
|
|||||||
server.onMessage<FinishedCommand> { connection, message ->
|
server.onMessage<FinishedCommand> { connection, message ->
|
||||||
stopEndPoints()
|
stopEndPoints()
|
||||||
}
|
}
|
||||||
server.bind(false)
|
server.bind()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ class SerializationValidationTest : BaseTest() {
|
|||||||
server.onMessage<TestObject> { connection, message ->
|
server.onMessage<TestObject> { connection, message ->
|
||||||
stopEndPoints()
|
stopEndPoints()
|
||||||
}
|
}
|
||||||
server.bind(false)
|
server.bind()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,12 +21,10 @@ import dorkbox.network.Server
|
|||||||
import dorkbox.network.connection.Connection
|
import dorkbox.network.connection.Connection
|
||||||
import dorkbox.network.rmi.RemoteObject
|
import dorkbox.network.rmi.RemoteObject
|
||||||
import dorkbox.network.serialization.Serialization
|
import dorkbox.network.serialization.Serialization
|
||||||
import dorkbox.util.exceptions.SecurityException
|
|
||||||
import dorkboxTest.network.BaseTest
|
import dorkboxTest.network.BaseTest
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.io.IOException
|
|
||||||
import java.util.concurrent.atomic.AtomicLong
|
import java.util.concurrent.atomic.AtomicLong
|
||||||
|
|
||||||
class RmiDelayedInvocationSpamTest : BaseTest() {
|
class RmiDelayedInvocationSpamTest : BaseTest() {
|
||||||
@ -34,22 +32,42 @@ class RmiDelayedInvocationSpamTest : BaseTest() {
|
|||||||
|
|
||||||
private val RMI_ID = 12251
|
private val RMI_ID = 12251
|
||||||
|
|
||||||
|
var async = true
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(SecurityException::class, IOException::class)
|
|
||||||
fun rmiNetwork() {
|
fun rmiNetwork() {
|
||||||
runBlocking {
|
runBlocking {
|
||||||
|
async = false
|
||||||
|
rmi { configuration ->
|
||||||
|
configuration.enableIpcForLoopback = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun rmiNetworkAync() {
|
||||||
|
runBlocking {
|
||||||
|
async = true
|
||||||
|
rmi { configuration ->
|
||||||
|
configuration.enableIpcForLoopback = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun rmiIpc() {
|
||||||
|
runBlocking {
|
||||||
|
async = false
|
||||||
rmi()
|
rmi()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(SecurityException::class, IOException::class)
|
fun rmiIpcAsync() {
|
||||||
fun rmiLocal() {
|
runBlocking {
|
||||||
// rmi(object : Config() {
|
async = true
|
||||||
// fun apply(configuration: Configuration) {
|
rmi()
|
||||||
// configuration.localChannelName = EndPoint.LOCAL_CHANNEL
|
}
|
||||||
// }
|
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun register(serialization: Serialization) {
|
fun register(serialization: Serialization) {
|
||||||
@ -63,10 +81,8 @@ class RmiDelayedInvocationSpamTest : BaseTest() {
|
|||||||
suspend fun rmi(config: (Configuration) -> Unit = {}) {
|
suspend fun rmi(config: (Configuration) -> Unit = {}) {
|
||||||
val server: Server<Connection>
|
val server: Server<Connection>
|
||||||
|
|
||||||
val async = false
|
|
||||||
|
|
||||||
val mod = if (async) 10_000L else 200L
|
val mod = if (async) 10_000L else 200L
|
||||||
val totalRuns = if (async) 1_000_000 else 700
|
val totalRuns = if (async) 1_000_000 else 1_000
|
||||||
|
|
||||||
run {
|
run {
|
||||||
val configuration = serverConfig()
|
val configuration = serverConfig()
|
||||||
@ -77,7 +93,7 @@ class RmiDelayedInvocationSpamTest : BaseTest() {
|
|||||||
addEndPoint(server)
|
addEndPoint(server)
|
||||||
|
|
||||||
server.saveGlobalObject(TestObjectImpl(counter), RMI_ID)
|
server.saveGlobalObject(TestObjectImpl(counter), RMI_ID)
|
||||||
server.bind(false)
|
server.bind()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -116,7 +132,6 @@ class RmiDelayedInvocationSpamTest : BaseTest() {
|
|||||||
|
|
||||||
// have to do this first, so it will wait for the client responses!
|
// have to do this first, so it will wait for the client responses!
|
||||||
// if we close the client first, the connection will be closed, and the responses will never arrive to the server
|
// if we close the client first, the connection will be closed, and the responses will never arrive to the server
|
||||||
server.close()
|
|
||||||
stopEndPoints()
|
stopEndPoints()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,11 +20,9 @@ import dorkbox.network.Configuration
|
|||||||
import dorkbox.network.Server
|
import dorkbox.network.Server
|
||||||
import dorkbox.network.connection.Connection
|
import dorkbox.network.connection.Connection
|
||||||
import dorkbox.network.serialization.Serialization
|
import dorkbox.network.serialization.Serialization
|
||||||
import dorkbox.util.exceptions.SecurityException
|
|
||||||
import dorkboxTest.network.BaseTest
|
import dorkboxTest.network.BaseTest
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.io.IOException
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger
|
import java.util.concurrent.atomic.AtomicInteger
|
||||||
|
|
||||||
class RmiDelayedInvocationTest : BaseTest() {
|
class RmiDelayedInvocationTest : BaseTest() {
|
||||||
@ -32,21 +30,19 @@ class RmiDelayedInvocationTest : BaseTest() {
|
|||||||
private val OBJ_ID = 123
|
private val OBJ_ID = 123
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(SecurityException::class, IOException::class)
|
|
||||||
fun rmiNetwork() {
|
fun rmiNetwork() {
|
||||||
runBlocking {
|
runBlocking {
|
||||||
rmi()
|
rmi() { configuration ->
|
||||||
|
configuration.enableIpcForLoopback = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(SecurityException::class, IOException::class)
|
fun rmiIpc() {
|
||||||
fun rmiLocal() {
|
runBlocking {
|
||||||
// rmi(object : Config() {
|
rmi()
|
||||||
// fun apply(configuration: Configuration) {
|
}
|
||||||
// configuration.localChannelName = EndPoint.LOCAL_CHANNEL
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun register(serialization: Serialization) {
|
fun register(serialization: Serialization) {
|
||||||
@ -67,7 +63,7 @@ class RmiDelayedInvocationTest : BaseTest() {
|
|||||||
addEndPoint(server)
|
addEndPoint(server)
|
||||||
|
|
||||||
server.saveGlobalObject(TestObjectImpl(iterateLock), OBJ_ID)
|
server.saveGlobalObject(TestObjectImpl(iterateLock), OBJ_ID)
|
||||||
server.bind(false)
|
server.bind()
|
||||||
}
|
}
|
||||||
|
|
||||||
run {
|
run {
|
||||||
|
@ -18,12 +18,10 @@ package dorkboxTest.network.rmi
|
|||||||
import dorkbox.network.Client
|
import dorkbox.network.Client
|
||||||
import dorkbox.network.Server
|
import dorkbox.network.Server
|
||||||
import dorkbox.network.connection.Connection
|
import dorkbox.network.connection.Connection
|
||||||
import dorkbox.util.exceptions.SecurityException
|
|
||||||
import dorkboxTest.network.BaseTest
|
import dorkboxTest.network.BaseTest
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.io.IOException
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger
|
import java.util.concurrent.atomic.AtomicInteger
|
||||||
|
|
||||||
|
|
||||||
@ -35,19 +33,6 @@ class RmiNestedTest : BaseTest() {
|
|||||||
private val idCounter = AtomicInteger()
|
private val idCounter = AtomicInteger()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@Throws(SecurityException::class, IOException::class)
|
|
||||||
fun rmiIPC() {
|
|
||||||
// TODO("DO IPC STUFF!")
|
|
||||||
// rmi(new Config() {
|
|
||||||
// @Override
|
|
||||||
// public
|
|
||||||
// void apply(final Configuration configuration) {
|
|
||||||
// configuration.localChannelName = EndPoint.LOCAL_CHANNEL;
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In this test the server has two objects in an object space.
|
* In this test the server has two objects in an object space.
|
||||||
*
|
*
|
||||||
@ -93,7 +78,7 @@ class RmiNestedTest : BaseTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
server.bind(false)
|
server.bind()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -163,7 +148,7 @@ class RmiNestedTest : BaseTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
server.bind(false)
|
server.bind()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -232,7 +217,7 @@ class RmiNestedTest : BaseTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
server.bind(false)
|
server.bind()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,23 +50,27 @@ class RmiSimpleTest : BaseTest() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun rmiNetworkGlobal() {
|
fun rmiNetworkGlobal() {
|
||||||
rmiGlobal()
|
rmiGlobal() { configuration ->
|
||||||
|
configuration.enableIpcForLoopback = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun rmiNetworkConnection() {
|
fun rmiNetworkConnection() {
|
||||||
|
rmi { configuration ->
|
||||||
|
configuration.enableIpcForLoopback = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun rmiIpcNetworkGlobal() {
|
||||||
|
rmiGlobal()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun rmiIPcNetworkConnection() {
|
||||||
rmi()
|
rmi()
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// @Throws(SecurityException::class, IOException::class, InterruptedException::class)
|
|
||||||
// fun rmiIPC() {
|
|
||||||
// rmi { configuration ->
|
|
||||||
// if (configuration is ServerConfiguration) {
|
|
||||||
// configuration.listenIpAddress = LOOPBACK
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
fun rmi(config: (Configuration) -> Unit = {}) {
|
fun rmi(config: (Configuration) -> Unit = {}) {
|
||||||
run {
|
run {
|
||||||
@ -79,8 +83,7 @@ class RmiSimpleTest : BaseTest() {
|
|||||||
|
|
||||||
val server = Server<Connection>(configuration)
|
val server = Server<Connection>(configuration)
|
||||||
addEndPoint(server)
|
addEndPoint(server)
|
||||||
|
server.bind()
|
||||||
server.bind(false)
|
|
||||||
|
|
||||||
server.onMessage<MessageWithTestCow> { connection, m ->
|
server.onMessage<MessageWithTestCow> { connection, m ->
|
||||||
System.err.println("Received finish signal for test for: Client -> Server")
|
System.err.println("Received finish signal for test for: Client -> Server")
|
||||||
@ -146,7 +149,7 @@ class RmiSimpleTest : BaseTest() {
|
|||||||
|
|
||||||
val server = Server<Connection>(configuration)
|
val server = Server<Connection>(configuration)
|
||||||
addEndPoint(server)
|
addEndPoint(server)
|
||||||
server.bind(false)
|
server.bind()
|
||||||
|
|
||||||
server.onMessage<MessageWithTestCow> { connection, m ->
|
server.onMessage<MessageWithTestCow> { connection, m ->
|
||||||
System.err.println("Received finish signal for test for: Client -> Server")
|
System.err.println("Received finish signal for test for: Client -> Server")
|
||||||
|
@ -105,8 +105,7 @@ object TestClient {
|
|||||||
|
|
||||||
runBlocking {
|
runBlocking {
|
||||||
client.connect(BaseTest.LOOPBACK)
|
client.connect(BaseTest.LOOPBACK)
|
||||||
}
|
client.waitForClose()
|
||||||
|
}
|
||||||
client.waitForShutdown()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,6 @@ object TestServer {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
server.bind(false)
|
server.bind()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user