Skip to content

Commit

Permalink
Remove unnecessary config field
Browse files Browse the repository at this point in the history
  • Loading branch information
marychatte committed Dec 20, 2022
1 parent a532c45 commit 7e7720b
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 46 deletions.
Expand Up @@ -44,7 +44,7 @@ class CIOSustainabilityTest : SustainabilityTestSuite<CIOApplicationEngine, CIOA
}
}

class CIOConfigTest : ConfigTestSuite(CIO, { CIOApplicationEngine.Configuration() })
class CIOConfigTest : ConfigTestSuite(CIO)

class CIOConnectionTest : ConnectionTestSuite(CIO)

Expand Down
Expand Up @@ -37,16 +37,6 @@ public interface ApplicationEngine {
* Specifies the minimum size of a thread pool used to process application calls.
*/
public var callGroupSize: Int = parallelism

/**
* Specifies the maximum amount of time for activity to cool down in milliseconds.
*/
public var shutdownGracePeriodMillis: Long = 500

/**
* Specifies the maximum amount of time to wait until a server stops gracefully in milliseconds.
*/
public var shutdownTimeoutMillis: Long = 500
}

/**
Expand Down
Expand Up @@ -130,12 +130,6 @@ public fun BaseApplicationEngine.Configuration.loadCommonConfiguration(deploymen
deploymentConfig.propertyOrNull("workerGroupSize")?.getString()?.toInt()?.let {
workerGroupSize = it
}
deploymentConfig.propertyOrNull("shutdownGracePeriod")?.getString()?.toLong()?.let {
shutdownGracePeriodMillis = it
}
deploymentConfig.propertyOrNull("shutdownTimeout")?.getString()?.toLong()?.let {
shutdownTimeoutMillis = it
}
}

internal fun String.splitPair(ch: Char): Pair<String, String>? = indexOf(ch).let { idx ->
Expand Down
Expand Up @@ -88,7 +88,7 @@ class JettyHttpServerJvmTest : HttpServerJvmTestSuite<JettyApplicationEngine, Je
class JettySustainabilityTest :
SustainabilityTestSuite<JettyApplicationEngine, JettyApplicationEngineBase.Configuration>(Jetty)

class JettyConfigTest : ConfigTestSuite(Jetty, { JettyApplicationEngineBase.Configuration() })
class JettyConfigTest : ConfigTestSuite(Jetty)

class JettyConnectionTest : ConnectionTestSuite(Jetty)

Expand Down
Expand Up @@ -104,7 +104,7 @@ class NettySustainabilityTest : SustainabilityTestSuite<NettyApplicationEngine,
}
}

class NettyConfigTest : ConfigTestSuite(Netty, { NettyApplicationEngine.Configuration() })
class NettyConfigTest : ConfigTestSuite(Netty)

class NettyConnectionTest : ConnectionTestSuite(Netty)

Expand Down
Expand Up @@ -4,8 +4,6 @@

package io.ktor.server.testing.suites

import com.typesafe.config.*
import io.ktor.server.config.*
import io.ktor.server.engine.*
import kotlinx.coroutines.*
import org.junit.*
Expand All @@ -15,10 +13,7 @@ import kotlin.system.*

var count = 0

abstract class ConfigTestSuite(
val engine: ApplicationEngineFactory<*, *>,
val configuration: () -> BaseApplicationEngine.Configuration
) {
abstract class ConfigTestSuite(val engine: ApplicationEngineFactory<*, *>) {

@Test
fun testStartOnceWhenException() {
Expand Down Expand Up @@ -64,24 +59,4 @@ abstract class ConfigTestSuite(

assertTrue("Stop time is $time", time < 100)
}

@Test
fun testCommonEngineConfiguration() {
val config = HoconApplicationConfig(
ConfigFactory.parseString(
"""
ktor {
deployment {
shutdownGracePeriod: 2000,
shutdownTimeout: 6000
}
}
""".trimIndent()
)
)

val configuration = configuration().apply { loadCommonConfiguration(config.config("ktor.deployment")) }
assertEquals(2000, configuration.shutdownGracePeriodMillis)
assertEquals(6000, configuration.shutdownTimeoutMillis)
}
}
Expand Up @@ -167,7 +167,7 @@ class TomcatSustainabilityTestSuite :
}
}

class TomcatConfigTest : ConfigTestSuite(Tomcat, { TomcatApplicationEngine.Configuration() })
class TomcatConfigTest : ConfigTestSuite(Tomcat)

class TomcatConnectionTest : ConnectionTestSuite(Tomcat)

Expand Down

0 comments on commit 7e7720b

Please sign in to comment.