From ab82a4474daf71e58d7878949acc2f58ddb4783c Mon Sep 17 00:00:00 2001 From: David Kleiven Date: Sat, 9 Dec 2023 11:25:18 +0100 Subject: [PATCH] Sensitivity job also runs slow run API --- src/main/ApiDataModels.kt | 12 ++---------- src/main/App.kt | 14 ++++++++------ src/test/AppTest.kt | 12 +++++++++--- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/main/ApiDataModels.kt b/src/main/ApiDataModels.kt index ec62c40..f03a5bc 100644 --- a/src/main/ApiDataModels.kt +++ b/src/main/ApiDataModels.kt @@ -2,12 +2,7 @@ package com.github.statnett.loadflowservice import com.powsybl.iidm.network.Network import com.powsybl.security.SecurityAnalysisResult -<<<<<<< HEAD -======= -import com.powsybl.security.json.SecurityAnalysisJsonModule import com.powsybl.sensitivity.SensitivityAnalysisResult -import kotlinx.serialization.KSerializer ->>>>>>> 1732bb9 (WIP: Serialize sensitivity analysis result) import kotlinx.serialization.Serializable /** @@ -75,15 +70,12 @@ data class LoadFlowServiceSecurityAnalysisResult( @Serializable(with = SecurityAnalysisResultSerializer::class) val securityAnalysisResult: SecurityAnalysisResult, val report: String -<<<<<<< HEAD ) : ComputationResult() -======= -) + @Serializable data class LoadFlowServiceSensitivityAnalysisResult( @Serializable(with = SensitivityAnalysisResultSerializer::class) val sensitivityAnalysisResult: SensitivityAnalysisResult, val report: String -) ->>>>>>> 1732bb9 (WIP: Serialize sensitivity analysis result) +): ComputationResult() diff --git a/src/main/App.kt b/src/main/App.kt index f2f306d..e52d7a3 100644 --- a/src/main/App.kt +++ b/src/main/App.kt @@ -98,12 +98,14 @@ fun Application.module() { sensParamCnt.parameters.setLoadFlowParameters(loadParamCnt.parameters) val network = networkFromFirstFile(files) - val result = runSensitivityAnalysis( - network, - sensFactorCnt.factors, - sensParamCnt.parameters, - contingencyCnt.contingencies - ) + val result = createTask(taskManager) { + runSensitivityAnalysis( + network, + sensFactorCnt.factors, + sensParamCnt.parameters, + contingencyCnt.contingencies + ) + } call.respond(result) } diff --git a/src/test/AppTest.kt b/src/test/AppTest.kt index 55e0ada..6d5fa95 100644 --- a/src/test/AppTest.kt +++ b/src/test/AppTest.kt @@ -310,9 +310,15 @@ class ApplicationTest { formData = sensitivityFormData.formData(config) ) assertEquals(HttpStatusCode.OK, response.status) - val body = response.bodyAsText() - assertTrue(body.contains("2")) - val result = Json.decodeFromString(response.body()) + + val taskInfo = Json.decodeFromString(response.body()) + + val runResult = retryOnError(50, 10) { + client.get(taskInfo.resultUrl) + } + assertEquals(HttpStatusCode.OK, runResult.status) + + val result = json.decodeFromString(runResult.body()) // There are two contingencies so when we have contingencies there should be three results // Otherwise one