diff --git a/runner/src/integrationTest/kotlin/com/cosmotech/runner/service/RunnerServiceIntegrationTest.kt b/runner/src/integrationTest/kotlin/com/cosmotech/runner/service/RunnerServiceIntegrationTest.kt index c9f94f2ed..52ae82591 100644 --- a/runner/src/integrationTest/kotlin/com/cosmotech/runner/service/RunnerServiceIntegrationTest.kt +++ b/runner/src/integrationTest/kotlin/com/cosmotech/runner/service/RunnerServiceIntegrationTest.kt @@ -55,7 +55,6 @@ import io.mockk.junit5.MockKExtension import io.mockk.mockk import io.mockk.mockkStatic import java.io.FileInputStream -import java.lang.IllegalStateException import java.time.Instant import java.util.* import kotlin.test.assertEquals @@ -1516,12 +1515,9 @@ class RunnerServiceIntegrationTest : CsmTestBase() { val run = runnerApiService.startRun(organizationSaved.id, workspaceSaved.id, runnerSaved.id) assertEquals(expectedRunId, run.id) - val exception = - assertThrows { - runnerApiService.stopRun(organizationSaved.id, workspaceSaved.id, runnerSaved.id) - } - - assertEquals("Run $expectedRunId can not be stopped as its already finished", exception.message) + assertDoesNotThrow { + runnerApiService.stopRun(organizationSaved.id, workspaceSaved.id, runnerSaved.id) + } } @Test @@ -1543,12 +1539,9 @@ class RunnerServiceIntegrationTest : CsmTestBase() { val run = runnerApiService.startRun(organizationSaved.id, workspaceSaved.id, runnerSaved.id) assertEquals(expectedRunId, run.id) - val exception = - assertThrows { - runnerApiService.stopRun(organizationSaved.id, workspaceSaved.id, runnerSaved.id) - } - - assertEquals("Run $expectedRunId can not be stopped as its already finished", exception.message) + assertDoesNotThrow { + runnerApiService.stopRun(organizationSaved.id, workspaceSaved.id, runnerSaved.id) + } } @Test diff --git a/runner/src/main/kotlin/com/cosmotech/runner/service/RunnerApiServiceImpl.kt b/runner/src/main/kotlin/com/cosmotech/runner/service/RunnerApiServiceImpl.kt index f15bfdd62..abd08deb2 100644 --- a/runner/src/main/kotlin/com/cosmotech/runner/service/RunnerApiServiceImpl.kt +++ b/runner/src/main/kotlin/com/cosmotech/runner/service/RunnerApiServiceImpl.kt @@ -23,6 +23,7 @@ import com.cosmotech.runner.domain.RunnerCreateRequest import com.cosmotech.runner.domain.RunnerRole import com.cosmotech.runner.domain.RunnerSecurity import com.cosmotech.runner.domain.RunnerUpdateRequest +import org.slf4j.LoggerFactory import org.springframework.context.event.EventListener import org.springframework.data.domain.PageRequest import org.springframework.stereotype.Service @@ -34,6 +35,9 @@ internal class RunnerApiServiceImpl( private val runnerServiceManager: RunnerServiceManager, private val datasetApiServiceInterface: DatasetApiServiceInterface ) : RunnerApiServiceInterface { + + private val logger = LoggerFactory.getLogger(RunnerApiServiceImpl::class.java) + override fun getRunnerService(): RunnerService = runnerServiceManager.getRunnerService() override fun createRunner( @@ -141,8 +145,8 @@ internal class RunnerApiServiceImpl( runnerService.stopLastRunOf(runnerInstance) return } - throw IllegalStateException( - "Run ${lastRunInfo.lastRunId} can not be stopped as its already finished") + + logger.debug("Run ${lastRunInfo.lastRunId} can not be stopped as its already finished") } override fun createRunnerAccessControl(