Cleaned up unit tests
This commit is contained in:
parent
e27fdbb369
commit
8caef6611c
@ -94,15 +94,6 @@ object AeronClient {
|
||||
@Throws(Exception::class)
|
||||
@JvmStatic
|
||||
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()
|
||||
configuration.subscriptionPort = 2000
|
||||
configuration.publicationPort = 2001
|
||||
@ -136,7 +127,6 @@ object AeronClient {
|
||||
|
||||
runBlocking {
|
||||
client.connect("127.0.0.1") // UDP connection via loopback
|
||||
// client.connect() // IPC connection
|
||||
}
|
||||
|
||||
|
||||
@ -146,11 +136,11 @@ object AeronClient {
|
||||
// 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 - IPC/local
|
||||
runBlocking {
|
||||
while (!client.isShutdown()) {
|
||||
client.send("ECHO " + java.lang.Long.toUnsignedString(client.crypto.secureRandom.nextLong(), 16))
|
||||
}
|
||||
}
|
||||
// runBlocking {
|
||||
// while (!client.isShutdown()) {
|
||||
// client.send("ECHO " + java.lang.Long.toUnsignedString(client.crypto.secureRandom.nextLong(), 16))
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// connection needs to know
|
||||
|
@ -96,12 +96,12 @@ object AeronServer {
|
||||
}
|
||||
|
||||
server.onError { throwable ->
|
||||
println("has error")
|
||||
println("from test: has error")
|
||||
throwable.printStackTrace()
|
||||
}
|
||||
|
||||
server.onError { connection, throwable ->
|
||||
println("has error")
|
||||
println("from test: has connection error")
|
||||
throwable.printStackTrace()
|
||||
}
|
||||
|
||||
|
@ -83,8 +83,8 @@ abstract class BaseTest {
|
||||
|
||||
// rootLogger.setLevel(Level.OFF);
|
||||
|
||||
// rootLogger.level = Level.INFO;
|
||||
rootLogger.level = Level.TRACE;
|
||||
rootLogger.level = Level.INFO;
|
||||
// rootLogger.level = Level.TRACE;
|
||||
// rootLogger.level = Level.DEBUG
|
||||
// rootLogger.level = Level.ALL;
|
||||
|
||||
|
@ -20,7 +20,7 @@ class DisconnectReconnectTest : BaseTest() {
|
||||
|
||||
val server: Server<Connection> = Server(configuration)
|
||||
addEndPoint(server)
|
||||
server.bind(false)
|
||||
server.bind()
|
||||
|
||||
server.onConnect { connection ->
|
||||
connection.logger.error("Disconnecting after 2 seconds.")
|
||||
|
@ -112,7 +112,7 @@ class ListenerTest : BaseTest() {
|
||||
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)
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class PingPongTest : BaseTest() {
|
||||
|
||||
val server: Server<Connection> = Server(configuration)
|
||||
addEndPoint(server)
|
||||
server.bind(false)
|
||||
server.bind()
|
||||
|
||||
server.onError { _, throwable ->
|
||||
fail = "Error during processing. $throwable"
|
||||
|
@ -36,7 +36,7 @@ class SerializationValidationTest : BaseTest() {
|
||||
server.onMessage<FinishedCommand> { connection, message ->
|
||||
stopEndPoints()
|
||||
}
|
||||
server.bind(false)
|
||||
server.bind()
|
||||
}
|
||||
|
||||
|
||||
@ -74,7 +74,7 @@ class SerializationValidationTest : BaseTest() {
|
||||
server.onMessage<TestObject> { connection, message ->
|
||||
stopEndPoints()
|
||||
}
|
||||
server.bind(false)
|
||||
server.bind()
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,12 +21,10 @@ import dorkbox.network.Server
|
||||
import dorkbox.network.connection.Connection
|
||||
import dorkbox.network.rmi.RemoteObject
|
||||
import dorkbox.network.serialization.Serialization
|
||||
import dorkbox.util.exceptions.SecurityException
|
||||
import dorkboxTest.network.BaseTest
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import java.io.IOException
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
|
||||
class RmiDelayedInvocationSpamTest : BaseTest() {
|
||||
@ -34,22 +32,42 @@ class RmiDelayedInvocationSpamTest : BaseTest() {
|
||||
|
||||
private val RMI_ID = 12251
|
||||
|
||||
var async = true
|
||||
|
||||
@Test
|
||||
@Throws(SecurityException::class, IOException::class)
|
||||
fun rmiNetwork() {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(SecurityException::class, IOException::class)
|
||||
fun rmiLocal() {
|
||||
// rmi(object : Config() {
|
||||
// fun apply(configuration: Configuration) {
|
||||
// configuration.localChannelName = EndPoint.LOCAL_CHANNEL
|
||||
// }
|
||||
// })
|
||||
fun rmiIpcAsync() {
|
||||
runBlocking {
|
||||
async = true
|
||||
rmi()
|
||||
}
|
||||
}
|
||||
|
||||
fun register(serialization: Serialization) {
|
||||
@ -63,10 +81,8 @@ class RmiDelayedInvocationSpamTest : BaseTest() {
|
||||
suspend fun rmi(config: (Configuration) -> Unit = {}) {
|
||||
val server: Server<Connection>
|
||||
|
||||
val async = false
|
||||
|
||||
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 {
|
||||
val configuration = serverConfig()
|
||||
@ -77,7 +93,7 @@ class RmiDelayedInvocationSpamTest : BaseTest() {
|
||||
addEndPoint(server)
|
||||
|
||||
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!
|
||||
// if we close the client first, the connection will be closed, and the responses will never arrive to the server
|
||||
server.close()
|
||||
stopEndPoints()
|
||||
}
|
||||
|
||||
|
@ -20,11 +20,9 @@ import dorkbox.network.Configuration
|
||||
import dorkbox.network.Server
|
||||
import dorkbox.network.connection.Connection
|
||||
import dorkbox.network.serialization.Serialization
|
||||
import dorkbox.util.exceptions.SecurityException
|
||||
import dorkboxTest.network.BaseTest
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Test
|
||||
import java.io.IOException
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
class RmiDelayedInvocationTest : BaseTest() {
|
||||
@ -32,21 +30,19 @@ class RmiDelayedInvocationTest : BaseTest() {
|
||||
private val OBJ_ID = 123
|
||||
|
||||
@Test
|
||||
@Throws(SecurityException::class, IOException::class)
|
||||
fun rmiNetwork() {
|
||||
runBlocking {
|
||||
rmi()
|
||||
rmi() { configuration ->
|
||||
configuration.enableIpcForLoopback = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(SecurityException::class, IOException::class)
|
||||
fun rmiLocal() {
|
||||
// rmi(object : Config() {
|
||||
// fun apply(configuration: Configuration) {
|
||||
// configuration.localChannelName = EndPoint.LOCAL_CHANNEL
|
||||
// }
|
||||
// })
|
||||
fun rmiIpc() {
|
||||
runBlocking {
|
||||
rmi()
|
||||
}
|
||||
}
|
||||
|
||||
fun register(serialization: Serialization) {
|
||||
@ -67,7 +63,7 @@ class RmiDelayedInvocationTest : BaseTest() {
|
||||
addEndPoint(server)
|
||||
|
||||
server.saveGlobalObject(TestObjectImpl(iterateLock), OBJ_ID)
|
||||
server.bind(false)
|
||||
server.bind()
|
||||
}
|
||||
|
||||
run {
|
||||
|
@ -18,12 +18,10 @@ package dorkboxTest.network.rmi
|
||||
import dorkbox.network.Client
|
||||
import dorkbox.network.Server
|
||||
import dorkbox.network.connection.Connection
|
||||
import dorkbox.util.exceptions.SecurityException
|
||||
import dorkboxTest.network.BaseTest
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import java.io.IOException
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
|
||||
@ -35,19 +33,6 @@ class RmiNestedTest : BaseTest() {
|
||||
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.
|
||||
*
|
||||
@ -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
|
||||
fun rmiNetworkGlobal() {
|
||||
rmiGlobal()
|
||||
rmiGlobal() { configuration ->
|
||||
configuration.enableIpcForLoopback = false
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun rmiNetworkConnection() {
|
||||
rmi { configuration ->
|
||||
configuration.enableIpcForLoopback = false
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun rmiIpcNetworkGlobal() {
|
||||
rmiGlobal()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun rmiIPcNetworkConnection() {
|
||||
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 = {}) {
|
||||
run {
|
||||
@ -79,8 +83,7 @@ class RmiSimpleTest : BaseTest() {
|
||||
|
||||
val server = Server<Connection>(configuration)
|
||||
addEndPoint(server)
|
||||
|
||||
server.bind(false)
|
||||
server.bind()
|
||||
|
||||
server.onMessage<MessageWithTestCow> { connection, m ->
|
||||
System.err.println("Received finish signal for test for: Client -> Server")
|
||||
@ -146,7 +149,7 @@ class RmiSimpleTest : BaseTest() {
|
||||
|
||||
val server = Server<Connection>(configuration)
|
||||
addEndPoint(server)
|
||||
server.bind(false)
|
||||
server.bind()
|
||||
|
||||
server.onMessage<MessageWithTestCow> { connection, m ->
|
||||
System.err.println("Received finish signal for test for: Client -> Server")
|
||||
|
@ -105,8 +105,7 @@ object TestClient {
|
||||
|
||||
runBlocking {
|
||||
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