Check if config was reloaded, remove all upstream metrics if it was r… (#327)
This commit is contained in:
@@ -19,6 +19,7 @@ package io.emeraldpay.dshackle.upstream
|
||||
import io.emeraldpay.dshackle.Chain
|
||||
import io.emeraldpay.dshackle.config.ChainsConfig
|
||||
import io.emeraldpay.dshackle.config.UpstreamsConfig
|
||||
import io.emeraldpay.dshackle.reader.JsonRpcHttpReader
|
||||
import io.emeraldpay.dshackle.startup.QuorumForLabels
|
||||
import io.emeraldpay.dshackle.test.EthereumApiStub
|
||||
import io.emeraldpay.dshackle.test.TestingCommons
|
||||
@@ -51,7 +52,7 @@ class FilteredApisSpec extends Specification {
|
||||
[test: "baz"]
|
||||
].collect {
|
||||
def httpFactory = Mock(HttpFactory) {
|
||||
create(_, _) >> TestingCommons.api().tap { it.id = "${i++}" }
|
||||
create(_, _) >> Stub(JsonRpcHttpReader)
|
||||
}
|
||||
def connectorFactory = new GenericConnectorFactory(
|
||||
GenericConnectorFactory.ConnectorMode.RPC_ONLY,
|
||||
|
||||
@@ -17,8 +17,10 @@ import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.mockito.ArgumentCaptor
|
||||
import org.mockito.kotlin.any
|
||||
import org.mockito.kotlin.doReturn
|
||||
import org.mockito.kotlin.mock
|
||||
import org.mockito.kotlin.never
|
||||
import org.mockito.kotlin.times
|
||||
import org.mockito.kotlin.verify
|
||||
import org.mockito.kotlin.whenever
|
||||
@@ -99,7 +101,7 @@ class ReloadConfigTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `stop multistream of there are no upstreams left`() {
|
||||
fun `stop multistream if there are no upstreams left`() {
|
||||
val up1 = upstream("local1")
|
||||
val up2 = upstream("local2")
|
||||
val up3 = upstream("local3")
|
||||
@@ -154,6 +156,25 @@ class ReloadConfigTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `reload the same config cause to nothing`() {
|
||||
val initialConfigFile = ResourceUtils.getFile("classpath:configs/upstreams-initial.yaml")
|
||||
val initialConfig = upstreamsConfigReader.read(initialConfigFile.inputStream())!!
|
||||
mainConfig.upstreams = initialConfig
|
||||
|
||||
val reloadConfigUpstreamService = mock<ReloadConfigUpstreamService>()
|
||||
|
||||
val reloadConfig = ReloadConfigSetup(reloadConfigService, reloadConfigUpstreamService)
|
||||
|
||||
whenever(config.getConfigPath()).thenReturn(initialConfigFile)
|
||||
|
||||
reloadConfig.handle(Signal("HUP"))
|
||||
|
||||
verify(reloadConfigUpstreamService, never()).reloadUpstreams(any(), any(), any(), any())
|
||||
|
||||
assertEquals(initialConfig, mainConfig.upstreams)
|
||||
}
|
||||
|
||||
private fun upstream(id: String): Upstream =
|
||||
mock {
|
||||
on { getId() } doReturn id
|
||||
|
||||
Reference in New Issue
Block a user