From 0f399305868f5093b0a1fa0038ee492ff5650015 Mon Sep 17 00:00:00 2001 From: Kirill Gevorkyan <26010098+kgevorkyan@users.noreply.github.com> Date: Mon, 29 Aug 2022 15:41:04 +0300 Subject: [PATCH 01/13] WIP ### What's done: * WIP --- .../backend/controllers/LnkContestProjectController.kt | 6 +++--- .../save/backend/service/LnkContestProjectService.kt | 2 +- .../com/saveourtool/save/entities/LnkContestProject.kt | 8 ++++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/LnkContestProjectController.kt b/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/LnkContestProjectController.kt index 63dde489c8..b772891685 100644 --- a/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/LnkContestProjectController.kt +++ b/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/LnkContestProjectController.kt @@ -114,8 +114,8 @@ class LnkContestProjectController( @Parameters( Parameter(name = "contestName", `in` = ParameterIn.PATH, description = "name of a contest", required = true), ) - @ApiResponse(responseCode = "200", description = "Successfully fetched projects avaliable for contest.") - fun getAvaliableProjectsForContest( + @ApiResponse(responseCode = "200", description = "Successfully fetched projects available for contest.") + fun getAvailableProjectsForContest( @PathVariable contestName: String, authentication: Authentication, ): Mono> = Mono.fromCallable { @@ -141,7 +141,7 @@ class LnkContestProjectController( Parameter(name = "projectName", `in` = ParameterIn.PATH, description = "name of a project", required = true), ) @ApiResponse(responseCode = "200", description = "Successfully fetched contests avaliable for project.") - fun getAvaliableContestsForProject( + fun getAvailableContestsForProject( @PathVariable organizationName: String, @PathVariable projectName: String, authentication: Authentication, diff --git a/save-backend/src/main/kotlin/com/saveourtool/save/backend/service/LnkContestProjectService.kt b/save-backend/src/main/kotlin/com/saveourtool/save/backend/service/LnkContestProjectService.kt index f6c9462c5c..82fb0958a2 100644 --- a/save-backend/src/main/kotlin/com/saveourtool/save/backend/service/LnkContestProjectService.kt +++ b/save-backend/src/main/kotlin/com/saveourtool/save/backend/service/LnkContestProjectService.kt @@ -54,7 +54,7 @@ class LnkContestProjectService( fun saveLnkContestProject(project: Project, contest: Contest): Boolean = if (lnkContestProjectRepository.findByContestAndProject(contest, project).isPresent) { false } else { - lnkContestProjectRepository.save(LnkContestProject(project, contest)) + lnkContestProjectRepository.save(LnkContestProject(project, contest, null, 0)) true } } diff --git a/save-cloud-common/src/jvmMain/kotlin/com/saveourtool/save/entities/LnkContestProject.kt b/save-cloud-common/src/jvmMain/kotlin/com/saveourtool/save/entities/LnkContestProject.kt index 4acbcabe00..a98d8eeabd 100644 --- a/save-cloud-common/src/jvmMain/kotlin/com/saveourtool/save/entities/LnkContestProject.kt +++ b/save-cloud-common/src/jvmMain/kotlin/com/saveourtool/save/entities/LnkContestProject.kt @@ -7,6 +7,8 @@ import javax.persistence.ManyToOne /** * @property project * @property contest + * @property bestExecution + * @property bestScore */ @Entity class LnkContestProject( @@ -17,6 +19,12 @@ class LnkContestProject( @ManyToOne @JoinColumn(name = "contest_id") var contest: Contest, + + @ManyToOne + @JoinColumn(name = "execution_id") + var bestExecution: Execution?, + + var bestScore: Int, ) : BaseEntity() { /** * Get [ContestResult] From 72bfe4018af2e99c02ad4686f4af11eee1ab7fcc Mon Sep 17 00:00:00 2001 From: Kirill Gevorkyan <26010098+kgevorkyan@users.noreply.github.com> Date: Mon, 29 Aug 2022 18:51:42 +0300 Subject: [PATCH 02/13] WIP ### What's done: * WIP --- .../save/execution/ExecutionType.kt | 25 ------------------- .../saveourtool/save/execution/TestingType.kt | 14 +++++++++++ .../basic/TestResourcesSelection.kt | 10 +------- 3 files changed, 15 insertions(+), 34 deletions(-) delete mode 100644 save-cloud-common/src/commonMain/kotlin/com/saveourtool/save/execution/ExecutionType.kt create mode 100644 save-cloud-common/src/commonMain/kotlin/com/saveourtool/save/execution/TestingType.kt diff --git a/save-cloud-common/src/commonMain/kotlin/com/saveourtool/save/execution/ExecutionType.kt b/save-cloud-common/src/commonMain/kotlin/com/saveourtool/save/execution/ExecutionType.kt deleted file mode 100644 index 52a9f4e0c0..0000000000 --- a/save-cloud-common/src/commonMain/kotlin/com/saveourtool/save/execution/ExecutionType.kt +++ /dev/null @@ -1,25 +0,0 @@ -package com.saveourtool.save.execution - -import kotlinx.serialization.Serializable - -/** - * Type oj execution - */ -@Serializable -enum class ExecutionType { - /** - * Project on contest - */ - CONTEST, - - /** - * Project from git - */ - GIT, - - /** - * Project by binary file - */ - STANDARD, - ; -} diff --git a/save-cloud-common/src/commonMain/kotlin/com/saveourtool/save/execution/TestingType.kt b/save-cloud-common/src/commonMain/kotlin/com/saveourtool/save/execution/TestingType.kt new file mode 100644 index 0000000000..2fa7e26c7f --- /dev/null +++ b/save-cloud-common/src/commonMain/kotlin/com/saveourtool/save/execution/TestingType.kt @@ -0,0 +1,14 @@ +package com.saveourtool.save.execution + +import kotlinx.serialization.Serializable + +/** + * Types of testing (that can be selected by user) + */ +@Serializable +enum class TestingType { + CONTEST_MODE, + PRIVATE_TESTS, + PUBLIC_TESTS, + ; +} diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/TestResourcesSelection.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/TestResourcesSelection.kt index bccf29c166..718c6f0f15 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/TestResourcesSelection.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/TestResourcesSelection.kt @@ -7,6 +7,7 @@ package com.saveourtool.save.frontend.components.basic import com.saveourtool.save.entities.ContestDto +import com.saveourtool.save.execution.TestingType import com.saveourtool.save.frontend.components.basic.testsuiteselector.showPrivateTestSuitesSelectorModal import com.saveourtool.save.frontend.components.basic.testsuiteselector.showPublicTestSuitesSelectorModal import com.saveourtool.save.frontend.components.inputform.InputTypes @@ -26,15 +27,6 @@ import react.dom.html.ReactHTML.select val testResourcesSelection = prepareTestResourcesSelection() -/** - * Types of testing (that can be selected by user) - */ -enum class TestingType { - CONTEST_MODE, - PRIVATE_TESTS, - PUBLIC_TESTS, - ; -} /** * Properties for test resources From 9b69e4a5d6975281544007ae6143cf2d00e94a99 Mon Sep 17 00:00:00 2001 From: Kirill Gevorkyan <26010098+kgevorkyan@users.noreply.github.com> Date: Mon, 29 Aug 2022 18:56:05 +0300 Subject: [PATCH 03/13] WIP ### What's done: * WIP --- .../kotlin/com/saveourtool/save/apicli/ArgsParsing.kt | 6 +++--- save-api-cli/src/main/resources/evaluated-tool.properties | 6 +++--- save-api-cli/src/main/resources/web-client.properties | 2 +- .../kotlin/com/saveourtool/save/api/SaveCloudClient.kt | 8 ++++---- .../kotlin/com/saveourtool/save/api/utils/RequestUtils.kt | 8 ++++---- .../saveourtool/save/backend/service/ExecutionService.kt | 5 ++--- .../kotlin/com/saveourtool/save/backend/CloneRepoTest.kt | 4 ++-- .../save/backend/controller/ExecutionControllerTest.kt | 4 ++-- .../kotlin/com/saveourtool/save/execution/ExecutionDto.kt | 4 ++-- .../kotlin/com/saveourtool/save/entities/Execution.kt | 8 ++++---- .../components/basic/ExecutionStatisticsValuesTest.kt | 4 ++-- .../controller/agents/AgentsControllerTest.kt | 4 ++-- 12 files changed, 31 insertions(+), 32 deletions(-) diff --git a/save-api-cli/src/main/kotlin/com/saveourtool/save/apicli/ArgsParsing.kt b/save-api-cli/src/main/kotlin/com/saveourtool/save/apicli/ArgsParsing.kt index 8f0d067a2a..872b54c69b 100644 --- a/save-api-cli/src/main/kotlin/com/saveourtool/save/apicli/ArgsParsing.kt +++ b/save-api-cli/src/main/kotlin/com/saveourtool/save/apicli/ArgsParsing.kt @@ -7,7 +7,7 @@ package com.saveourtool.save.apicli import com.saveourtool.save.api.authorization.Authorization -import com.saveourtool.save.execution.ExecutionType +import com.saveourtool.save.execution.TestingType import org.slf4j.LoggerFactory @@ -22,7 +22,7 @@ private val log = LoggerFactory.getLogger(object {}.javaClass.enclosingClass::cl */ data class CliArguments( val authorization: Authorization, - val mode: ExecutionType, + val mode: TestingType, ) /** @@ -60,7 +60,7 @@ fun parseArguments(args: Array): CliArguments? { ) val mode by parser.option( - ArgType.Choice(), + ArgType.Choice(), fullName = "mode", shortName = "m", description = "Mode of execution: git/standard" diff --git a/save-api-cli/src/main/resources/evaluated-tool.properties b/save-api-cli/src/main/resources/evaluated-tool.properties index 63cf0115bf..93fcd8497c 100644 --- a/save-api-cli/src/main/resources/evaluated-tool.properties +++ b/save-api-cli/src/main/resources/evaluated-tool.properties @@ -2,11 +2,11 @@ # Required # Name of organization -organizationName=saveourtool.com +organizationName=Huawei # Required # Name of project -projectName=Diktat +projectName=save # Optional # SDK @@ -26,7 +26,7 @@ gitUrl=https://github.com/saveourtool/save-cli # Optional # Path to additional files in your file system, separated by `;` -additionalFiles=/path/file1;/path/file2 +additionalFiles=/mnt/c/Users/g00626552/Desktop/ktlint;/mnt/c/Users/g00626552/Desktop/diktat.jar;/mnt/c/Users/g00626552/Desktop/info.txt # -------------------------- Git Mode -------------------------- # diff --git a/save-api-cli/src/main/resources/web-client.properties b/save-api-cli/src/main/resources/web-client.properties index 93820d7577..14fec3ee48 100644 --- a/save-api-cli/src/main/resources/web-client.properties +++ b/save-api-cli/src/main/resources/web-client.properties @@ -1 +1 @@ -backendUrl=https://saveourtool.com:443 \ No newline at end of file +backendUrl=http://localhost:5800 \ No newline at end of file diff --git a/save-api/src/main/kotlin/com/saveourtool/save/api/SaveCloudClient.kt b/save-api/src/main/kotlin/com/saveourtool/save/api/SaveCloudClient.kt index 6271a4ed7f..ca445d24ad 100644 --- a/save-api/src/main/kotlin/com/saveourtool/save/api/SaveCloudClient.kt +++ b/save-api/src/main/kotlin/com/saveourtool/save/api/SaveCloudClient.kt @@ -20,7 +20,7 @@ import com.saveourtool.save.entities.GitDto import com.saveourtool.save.entities.Project import com.saveourtool.save.execution.ExecutionDto import com.saveourtool.save.execution.ExecutionStatus -import com.saveourtool.save.execution.ExecutionType +import com.saveourtool.save.execution.TestingType import io.ktor.client.* import io.ktor.http.* @@ -38,7 +38,7 @@ import kotlinx.coroutines.delay class SaveCloudClient( webClientProperties: WebClientProperties, private val evaluatedToolProperties: EvaluatedToolProperties, - private val executionType: ExecutionType, + private val executionType: TestingType, authorization: Authorization, ) { private val log = LoggerFactory.getLogger(SaveCloudClient::class.java) @@ -88,10 +88,10 @@ class SaveCloudClient( * @return pair of organization and submitted execution request */ private suspend fun submitExecution( - executionType: ExecutionType, + executionType: TestingType, additionalFiles: List? ): ExecutionRequestBase? { - val executionRequest = if (executionType == ExecutionType.GIT) { + val executionRequest = if (executionType == TestingType.PUBLIC_TESTS) { buildExecutionRequest() } else { val userProvidedTestSuites = verifyTestSuites() ?: return null diff --git a/save-api/src/main/kotlin/com/saveourtool/save/api/utils/RequestUtils.kt b/save-api/src/main/kotlin/com/saveourtool/save/api/utils/RequestUtils.kt index 5132085fdd..45bb32861e 100644 --- a/save-api/src/main/kotlin/com/saveourtool/save/api/utils/RequestUtils.kt +++ b/save-api/src/main/kotlin/com/saveourtool/save/api/utils/RequestUtils.kt @@ -13,7 +13,7 @@ import com.saveourtool.save.entities.ExecutionRequestBase import com.saveourtool.save.entities.ExecutionRequestForStandardSuites import com.saveourtool.save.entities.Project import com.saveourtool.save.execution.ExecutionDto -import com.saveourtool.save.execution.ExecutionType +import com.saveourtool.save.execution.TestingType import com.saveourtool.save.testsuite.TestSuiteDto import com.saveourtool.save.utils.LocalDateTimeSerializer import com.saveourtool.save.utils.extractUserNameAndSource @@ -118,8 +118,8 @@ suspend fun HttpClient.getStandardTestSuites( */ @OptIn(InternalAPI::class) @Suppress("TOO_LONG_FUNCTION") -suspend fun HttpClient.submitExecution(executionType: ExecutionType, executionRequest: ExecutionRequestBase, additionalFiles: List?): HttpResponse { - val endpoint = if (executionType == ExecutionType.GIT) { +suspend fun HttpClient.submitExecution(executionType: TestingType, executionRequest: ExecutionRequestBase, additionalFiles: List?): HttpResponse { + val endpoint = if (executionType == TestingType.PUBLIC_TESTS) { "/api/$v1/submitExecutionRequest" } else { "/api/$v1/executionRequestStandardTests" @@ -131,7 +131,7 @@ suspend fun HttpClient.submitExecution(executionType: ExecutionType, executionRe append(HttpHeaders.ContentType, ContentType.Application.Json) } setBody(MultiPartFormDataContent(formData { - if (executionType == ExecutionType.GIT) { + if (executionType == TestingType.PUBLIC_TESTS) { append( "executionRequest", json.encodeToString(executionRequest as ExecutionRequest), diff --git a/save-backend/src/main/kotlin/com/saveourtool/save/backend/service/ExecutionService.kt b/save-backend/src/main/kotlin/com/saveourtool/save/backend/service/ExecutionService.kt index 119ca30ddb..c4f792de2e 100644 --- a/save-backend/src/main/kotlin/com/saveourtool/save/backend/service/ExecutionService.kt +++ b/save-backend/src/main/kotlin/com/saveourtool/save/backend/service/ExecutionService.kt @@ -7,7 +7,7 @@ import com.saveourtool.save.entities.Execution import com.saveourtool.save.entities.Organization import com.saveourtool.save.entities.Project import com.saveourtool.save.execution.ExecutionStatus -import com.saveourtool.save.execution.ExecutionType +import com.saveourtool.save.execution.TestingType import com.saveourtool.save.utils.debug import com.saveourtool.save.utils.orNotFound @@ -211,8 +211,7 @@ class ExecutionService( status = ExecutionStatus.PENDING, testSuiteIds = formattedTestSuiteIds, batchSize = configProperties.initialBatchSize, - // FIXME: remove this type - type = ExecutionType.GIT, + type = TestingType.PUBLIC_TESTS, version = version, allTests = allTests, runningTests = 0, diff --git a/save-backend/src/test/kotlin/com/saveourtool/save/backend/CloneRepoTest.kt b/save-backend/src/test/kotlin/com/saveourtool/save/backend/CloneRepoTest.kt index ce65f627ab..798459888a 100644 --- a/save-backend/src/test/kotlin/com/saveourtool/save/backend/CloneRepoTest.kt +++ b/save-backend/src/test/kotlin/com/saveourtool/save/backend/CloneRepoTest.kt @@ -15,7 +15,7 @@ import com.saveourtool.save.domain.Jdk import com.saveourtool.save.domain.ProjectCoordinates import com.saveourtool.save.domain.toFileInfo import com.saveourtool.save.entities.* -import com.saveourtool.save.execution.ExecutionType +import com.saveourtool.save.execution.TestingType import com.saveourtool.save.testsuite.TestSuitesSourceSnapshotKey import com.saveourtool.save.testutils.checkQueues import com.saveourtool.save.testutils.cleanup @@ -227,7 +227,7 @@ class CloneRepoTest { executionRepository.findAll().shouldExist { it.project.name == project.name && it.project.organization == project.organization && - it.type == ExecutionType.GIT && + it.type == TestingType.PUBLIC_TESTS && it.sdk == sdk.toString() } } diff --git a/save-backend/src/test/kotlin/com/saveourtool/save/backend/controller/ExecutionControllerTest.kt b/save-backend/src/test/kotlin/com/saveourtool/save/backend/controller/ExecutionControllerTest.kt index a1f52b6957..621ea73cb1 100644 --- a/save-backend/src/test/kotlin/com/saveourtool/save/backend/controller/ExecutionControllerTest.kt +++ b/save-backend/src/test/kotlin/com/saveourtool/save/backend/controller/ExecutionControllerTest.kt @@ -8,7 +8,7 @@ import com.saveourtool.save.backend.utils.MySqlExtension import com.saveourtool.save.backend.utils.mutateMockedUser import com.saveourtool.save.execution.ExecutionDto import com.saveourtool.save.execution.ExecutionStatus -import com.saveourtool.save.execution.ExecutionType +import com.saveourtool.save.execution.TestingType import com.saveourtool.save.execution.ExecutionUpdateDto import com.saveourtool.save.utils.debug import com.saveourtool.save.utils.getLogger @@ -97,7 +97,7 @@ class ExecutionControllerTest { .expectBody() .consumeWith { requireNotNull(it.responseBody) - assertEquals(ExecutionType.GIT, it.responseBody!!.type) + assertEquals(TestingType.PUBLIC_TESTS, it.responseBody!!.type) } } diff --git a/save-cloud-common/src/commonMain/kotlin/com/saveourtool/save/execution/ExecutionDto.kt b/save-cloud-common/src/commonMain/kotlin/com/saveourtool/save/execution/ExecutionDto.kt index 7f5fc8fb47..3c840179a8 100644 --- a/save-cloud-common/src/commonMain/kotlin/com/saveourtool/save/execution/ExecutionDto.kt +++ b/save-cloud-common/src/commonMain/kotlin/com/saveourtool/save/execution/ExecutionDto.kt @@ -24,7 +24,7 @@ import kotlinx.serialization.Serializable data class ExecutionDto( val id: Long, val status: ExecutionStatus, - val type: ExecutionType, + val type: TestingType, val version: String?, val startTime: Long, val endTime: Long?, @@ -42,7 +42,7 @@ data class ExecutionDto( val empty = ExecutionDto( id = -1, status = ExecutionStatus.PENDING, - type = ExecutionType.STANDARD, + type = TestingType.PRIVATE_TESTS, version = null, startTime = -1, endTime = null, diff --git a/save-cloud-common/src/jvmMain/kotlin/com/saveourtool/save/entities/Execution.kt b/save-cloud-common/src/jvmMain/kotlin/com/saveourtool/save/entities/Execution.kt index 9888db2273..8565ca106c 100644 --- a/save-cloud-common/src/jvmMain/kotlin/com/saveourtool/save/entities/Execution.kt +++ b/save-cloud-common/src/jvmMain/kotlin/com/saveourtool/save/entities/Execution.kt @@ -4,7 +4,7 @@ import com.saveourtool.save.domain.FileKey import com.saveourtool.save.domain.Sdk import com.saveourtool.save.execution.ExecutionDto import com.saveourtool.save.execution.ExecutionStatus -import com.saveourtool.save.execution.ExecutionType +import com.saveourtool.save.execution.TestingType import com.saveourtool.save.utils.DATABASE_DELIMITER import java.time.LocalDateTime import java.time.ZoneOffset @@ -59,7 +59,7 @@ class Execution( var batchSize: Int?, @Enumerated(EnumType.STRING) - var type: ExecutionType, + var type: TestingType, var version: String?, @@ -93,7 +93,7 @@ class Execution( var batchSizeForAnalyzer: String?, -) : BaseEntity() { + ) : BaseEntity() { /** * @return Execution dto */ @@ -155,7 +155,7 @@ class Execution( status = ExecutionStatus.RUNNING, testSuiteIds = null, batchSize = 20, - type = ExecutionType.GIT, + type = TestingType.PUBLIC_TESTS, version = null, allTests = 0, runningTests = 0, diff --git a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/basic/ExecutionStatisticsValuesTest.kt b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/basic/ExecutionStatisticsValuesTest.kt index 19029a3de4..6f0c029d3d 100644 --- a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/basic/ExecutionStatisticsValuesTest.kt +++ b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/basic/ExecutionStatisticsValuesTest.kt @@ -2,7 +2,7 @@ package com.saveourtool.save.frontend.components.basic import com.saveourtool.save.execution.ExecutionDto import com.saveourtool.save.execution.ExecutionStatus -import com.saveourtool.save.execution.ExecutionType +import com.saveourtool.save.execution.TestingType import kotlin.test.Test import kotlin.test.assertEquals @@ -25,7 +25,7 @@ class ExecutionStatisticsValuesTest { val executionDto = ExecutionDto( id = -1, status = ExecutionStatus.RUNNING, - type = ExecutionType.GIT, + type = TestingType.PUBLIC_TESTS, version = "N/A", startTime = 0L, endTime = null, diff --git a/save-orchestrator/src/test/kotlin/com/saveourtool/save/orchestrator/controller/agents/AgentsControllerTest.kt b/save-orchestrator/src/test/kotlin/com/saveourtool/save/orchestrator/controller/agents/AgentsControllerTest.kt index 93231cb00b..eb773a2d45 100644 --- a/save-orchestrator/src/test/kotlin/com/saveourtool/save/orchestrator/controller/agents/AgentsControllerTest.kt +++ b/save-orchestrator/src/test/kotlin/com/saveourtool/save/orchestrator/controller/agents/AgentsControllerTest.kt @@ -3,7 +3,7 @@ package com.saveourtool.save.orchestrator.controller.agents import com.saveourtool.save.entities.Execution import com.saveourtool.save.entities.Project import com.saveourtool.save.execution.ExecutionStatus -import com.saveourtool.save.execution.ExecutionType +import com.saveourtool.save.execution.TestingType import com.saveourtool.save.orchestrator.config.Beans import com.saveourtool.save.orchestrator.config.ConfigProperties import com.saveourtool.save.orchestrator.controller.AgentsController @@ -75,7 +75,7 @@ class AgentsControllerTest { fun `should build image, query backend and start containers`() { val project = Project.stub(null) val execution = Execution.stub(project).apply { - type = ExecutionType.STANDARD + type = TestingType.PRIVATE_TESTS status = ExecutionStatus.PENDING testSuiteIds = "1" id = 42L From c7f770a61f6f1a708df8975c481b8efc383d39a7 Mon Sep 17 00:00:00 2001 From: Kirill Gevorkyan <26010098+kgevorkyan@users.noreply.github.com> Date: Tue, 30 Aug 2022 12:01:00 +0300 Subject: [PATCH 04/13] WIP ### What's done: * WIP --- db/test-data/execution-insert.xml | 12 ++++++------ .../com/saveourtool/save/api/SaveCloudClient.kt | 16 ++++++++-------- save-backend/Backend-API.md | 2 +- .../frontend/components/views/ProjectView.kt | 1 + 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/db/test-data/execution-insert.xml b/db/test-data/execution-insert.xml index 0d83473590..b3676be27b 100644 --- a/db/test-data/execution-insert.xml +++ b/db/test-data/execution-insert.xml @@ -15,7 +15,7 @@ - + @@ -42,7 +42,7 @@ - + @@ -69,7 +69,7 @@ - + @@ -96,7 +96,7 @@ - + @@ -123,7 +123,7 @@ - + @@ -151,7 +151,7 @@ - + diff --git a/save-api/src/main/kotlin/com/saveourtool/save/api/SaveCloudClient.kt b/save-api/src/main/kotlin/com/saveourtool/save/api/SaveCloudClient.kt index ca445d24ad..e47df7c02b 100644 --- a/save-api/src/main/kotlin/com/saveourtool/save/api/SaveCloudClient.kt +++ b/save-api/src/main/kotlin/com/saveourtool/save/api/SaveCloudClient.kt @@ -38,7 +38,7 @@ import kotlinx.coroutines.delay class SaveCloudClient( webClientProperties: WebClientProperties, private val evaluatedToolProperties: EvaluatedToolProperties, - private val executionType: TestingType, + private val testingType: TestingType, authorization: Authorization, ) { private val log = LoggerFactory.getLogger(SaveCloudClient::class.java) @@ -65,9 +65,9 @@ class SaveCloudClient( } ?: { "without additional files" } - log.info("Starting submit execution $msg, type: $executionType") + log.info("Starting submit execution $msg, type: $testingType") - val executionRequest = submitExecution(executionType, additionalFileInfoList) ?: return + val executionRequest = submitExecution(testingType, additionalFileInfoList) ?: return // Sending requests, which checks current state, until results will be received // TODO: in which form do we actually need results? @@ -81,23 +81,23 @@ class SaveCloudClient( } /** - * Submit execution according [executionType] + * Submit execution according [testingType] * - * @param executionType + * @param testingType * @param additionalFiles * @return pair of organization and submitted execution request */ private suspend fun submitExecution( - executionType: TestingType, + testingType: TestingType, additionalFiles: List? ): ExecutionRequestBase? { - val executionRequest = if (executionType == TestingType.PUBLIC_TESTS) { + val executionRequest = if (testingType == TestingType.PUBLIC_TESTS) { buildExecutionRequest() } else { val userProvidedTestSuites = verifyTestSuites() ?: return null buildExecutionRequestForStandardSuites(userProvidedTestSuites) } - val response = httpClient.submitExecution(executionType, executionRequest, additionalFiles) + val response = httpClient.submitExecution(testingType, executionRequest, additionalFiles) if (response.status != HttpStatusCode.OK && response.status != HttpStatusCode.Accepted) { log.error("Can't submit execution=$executionRequest! Response status: ${response.status}") return null diff --git a/save-backend/Backend-API.md b/save-backend/Backend-API.md index deb3f403d0..5480880199 100644 --- a/save-backend/Backend-API.md +++ b/save-backend/Backend-API.md @@ -266,7 +266,7 @@ The response format will look like: { "id": 42, # execution id "status": "FINISHED", # execution status, i.e. running, finished and so on - "type":"GIT", # execution type + "type":"PUBLIC_TESTS", # testing type "version": "264e5feb8f4c6410d70536d6fc4bdf090df62287", # commit hash "startTime": 1651856549, # start time of execution in Unix format "endTime": 1651856797, # end time of execution in Unix format diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ProjectView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ProjectView.kt index 54ebfa02ab..005290aec5 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ProjectView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ProjectView.kt @@ -9,6 +9,7 @@ package com.saveourtool.save.frontend.components.views import com.saveourtool.save.domain.* import com.saveourtool.save.entities.* import com.saveourtool.save.execution.ExecutionDto +import com.saveourtool.save.execution.TestingType import com.saveourtool.save.frontend.components.RequestStatusContext import com.saveourtool.save.frontend.components.basic.* import com.saveourtool.save.frontend.components.basic.projects.projectInfoMenu From 5f7769df02a4d207d9727a972754bba5d58ba99e Mon Sep 17 00:00:00 2001 From: Kirill Gevorkyan <26010098+kgevorkyan@users.noreply.github.com> Date: Tue, 30 Aug 2022 13:07:04 +0300 Subject: [PATCH 05/13] WIP ### What's done: * WIP --- .../save/backend/controllers/RunExecutionController.kt | 2 ++ .../save/frontend/components/views/ProjectView.kt | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/RunExecutionController.kt b/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/RunExecutionController.kt index 8f1198c297..d1dc6435a5 100644 --- a/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/RunExecutionController.kt +++ b/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/RunExecutionController.kt @@ -20,6 +20,7 @@ import com.saveourtool.save.utils.switchIfEmptyToResponseException import com.saveourtool.save.v1 import com.fasterxml.jackson.databind.ObjectMapper +import com.saveourtool.save.execution.TestingType import io.micrometer.core.instrument.MeterRegistry import org.slf4j.Logger import org.springframework.http.HttpStatus @@ -68,6 +69,7 @@ class RunExecutionController( @PostMapping("/trigger") fun trigger( @RequestBody request: RunExecutionRequest, + @RequestParam testingType: TestingType, authentication: Authentication, ): Mono = Mono.just(request.projectCoordinates) .validateAccess(authentication) { it } diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ProjectView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ProjectView.kt index 005290aec5..a7b94c2682 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ProjectView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ProjectView.kt @@ -329,14 +329,14 @@ class ProjectView : AbstractView(f @Suppress("ComplexMethod", "TOO_LONG_FUNCTION") private fun submitExecutionRequest() { when (state.testingType) { - TestingType.PRIVATE_TESTS -> submitExecutionRequestByTestSuiteIds(state.selectedPrivateTestSuiteIds) - TestingType.PUBLIC_TESTS -> submitExecutionRequestByTestSuiteIds(state.selectedPublicTestSuiteIds) - TestingType.CONTEST_MODE -> submitExecutionRequestByTestSuiteIds(state.selectedContest.testSuiteIds) + TestingType.PRIVATE_TESTS -> submitExecutionRequestByTestSuiteIds(state.selectedPrivateTestSuiteIds, state.testingType) + TestingType.PUBLIC_TESTS -> submitExecutionRequestByTestSuiteIds(state.selectedPublicTestSuiteIds, state.testingType) + TestingType.CONTEST_MODE -> submitExecutionRequestByTestSuiteIds(state.selectedContest.testSuiteIds, state.testingType) else -> throw IllegalStateException("Not supported testing type: ${state.testingType}") } } - private fun submitExecutionRequestByTestSuiteIds(selectedTestSuiteIds: List) { + private fun submitExecutionRequestByTestSuiteIds(selectedTestSuiteIds: List, testingType: TestingType) { val selectedSdk = "${state.selectedSdk}:${state.selectedSdkVersion}".toSdk() val executionRequest = RunExecutionRequest( projectCoordinates = ProjectCoordinates( From 32cfff5dbe50aed9dea6f46e4bf1e441e1efb6a6 Mon Sep 17 00:00:00 2001 From: Kirill Gevorkyan <26010098+kgevorkyan@users.noreply.github.com> Date: Tue, 30 Aug 2022 16:42:27 +0300 Subject: [PATCH 06/13] WIP ### What's done: * WIP --- .../save/backend/controllers/RunExecutionController.kt | 3 ++- .../saveourtool/save/backend/service/ExecutionService.kt | 7 ++++++- .../save/frontend/components/views/ProjectView.kt | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/RunExecutionController.kt b/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/RunExecutionController.kt index d1dc6435a5..b169b53526 100644 --- a/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/RunExecutionController.kt +++ b/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/RunExecutionController.kt @@ -81,7 +81,8 @@ class RunExecutionController( username = authentication.username(), sdk = request.sdk, execCmd = request.execCmd, - batchSizeForAnalyzer = request.batchSizeForAnalyzer + batchSizeForAnalyzer = request.batchSizeForAnalyzer, + testingType = testingType ) } .subscribeOn(Schedulers.boundedElastic()) diff --git a/save-backend/src/main/kotlin/com/saveourtool/save/backend/service/ExecutionService.kt b/save-backend/src/main/kotlin/com/saveourtool/save/backend/service/ExecutionService.kt index c4f792de2e..2d944a4d8c 100644 --- a/save-backend/src/main/kotlin/com/saveourtool/save/backend/service/ExecutionService.kt +++ b/save-backend/src/main/kotlin/com/saveourtool/save/backend/service/ExecutionService.kt @@ -135,6 +135,7 @@ class ExecutionService( * @param sdk * @param execCmd * @param batchSizeForAnalyzer + * @param testingType * @return new [Execution] with provided values */ @Suppress("LongParameterList", "TOO_MANY_PARAMETERS") @@ -147,6 +148,7 @@ class ExecutionService( sdk: Sdk, execCmd: String?, batchSizeForAnalyzer: String?, + testingType: TestingType ): Execution { val project = with(projectCoordinates) { projectService.findByNameAndOrganizationName(projectName, organizationName).orNotFound { @@ -165,6 +167,7 @@ class ExecutionService( sdk = sdk.toString(), execCmd = execCmd, batchSizeForAnalyzer = batchSizeForAnalyzer, + testingType = testingType ) } @@ -187,6 +190,7 @@ class ExecutionService( sdk = execution.sdk, execCmd = execution.execCmd, batchSizeForAnalyzer = execution.batchSizeForAnalyzer, + testingType = execution.type, ) @Suppress("LongParameterList", "TOO_MANY_PARAMETERS") @@ -200,6 +204,7 @@ class ExecutionService( sdk: String, execCmd: String?, batchSizeForAnalyzer: String?, + testingType: TestingType ): Execution { val user = userRepository.findByName(username).orNotFound { "Not found user $username" @@ -211,7 +216,7 @@ class ExecutionService( status = ExecutionStatus.PENDING, testSuiteIds = formattedTestSuiteIds, batchSize = configProperties.initialBatchSize, - type = TestingType.PUBLIC_TESTS, + type = testingType, version = version, allTests = allTests, runningTests = 0, diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ProjectView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ProjectView.kt index a7b94c2682..0bb7b2d49b 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ProjectView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ProjectView.kt @@ -349,7 +349,7 @@ class ProjectView : AbstractView(f execCmd = state.execCmd, batchSizeForAnalyzer = state.batchSizeForAnalyzer ) - submitRequest("/run/trigger", jsonHeaders, Json.encodeToString(executionRequest)) + submitRequest("/run/trigger?testingType=${testingType}", jsonHeaders, Json.encodeToString(executionRequest)) } private fun submitRequest(url: String, headers: Headers, body: dynamic) { From 036a0c1fd46fea25451643270f66298ec9580f33 Mon Sep 17 00:00:00 2001 From: Peter Trifanov Date: Fri, 2 Sep 2022 17:04:01 +0300 Subject: [PATCH 07/13] Add liquibase changeset for best execution; cleanup * Add changeset * Change mapping `ManyToOne` -> `OneToOne` * Remove debug data --- db/v-2/tables/lnk-contest-project.xml | 9 +++++++++ .../src/main/resources/evaluated-tool.properties | 4 ++-- save-api-cli/src/main/resources/web-client.properties | 2 +- .../com/saveourtool/save/entities/LnkContestProject.kt | 5 +++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/db/v-2/tables/lnk-contest-project.xml b/db/v-2/tables/lnk-contest-project.xml index 7e1bb984d4..449f82a300 100644 --- a/db/v-2/tables/lnk-contest-project.xml +++ b/db/v-2/tables/lnk-contest-project.xml @@ -37,4 +37,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/save-api-cli/src/main/resources/evaluated-tool.properties b/save-api-cli/src/main/resources/evaluated-tool.properties index 93fcd8497c..d94047328f 100644 --- a/save-api-cli/src/main/resources/evaluated-tool.properties +++ b/save-api-cli/src/main/resources/evaluated-tool.properties @@ -2,7 +2,7 @@ # Required # Name of organization -organizationName=Huawei +organizationName=saveourtool.com # Required # Name of project @@ -26,7 +26,7 @@ gitUrl=https://github.com/saveourtool/save-cli # Optional # Path to additional files in your file system, separated by `;` -additionalFiles=/mnt/c/Users/g00626552/Desktop/ktlint;/mnt/c/Users/g00626552/Desktop/diktat.jar;/mnt/c/Users/g00626552/Desktop/info.txt +additionalFiles=/path/file1;/path/file2 # -------------------------- Git Mode -------------------------- # diff --git a/save-api-cli/src/main/resources/web-client.properties b/save-api-cli/src/main/resources/web-client.properties index 14fec3ee48..93820d7577 100644 --- a/save-api-cli/src/main/resources/web-client.properties +++ b/save-api-cli/src/main/resources/web-client.properties @@ -1 +1 @@ -backendUrl=http://localhost:5800 \ No newline at end of file +backendUrl=https://saveourtool.com:443 \ No newline at end of file diff --git a/save-cloud-common/src/jvmMain/kotlin/com/saveourtool/save/entities/LnkContestProject.kt b/save-cloud-common/src/jvmMain/kotlin/com/saveourtool/save/entities/LnkContestProject.kt index 33a3d591ce..57aefc0ba5 100644 --- a/save-cloud-common/src/jvmMain/kotlin/com/saveourtool/save/entities/LnkContestProject.kt +++ b/save-cloud-common/src/jvmMain/kotlin/com/saveourtool/save/entities/LnkContestProject.kt @@ -3,6 +3,7 @@ package com.saveourtool.save.entities import javax.persistence.Entity import javax.persistence.JoinColumn import javax.persistence.ManyToOne +import javax.persistence.OneToOne /** * @property project @@ -20,8 +21,8 @@ class LnkContestProject( @JoinColumn(name = "contest_id") var contest: Contest, - @ManyToOne - @JoinColumn(name = "execution_id") + @OneToOne + @JoinColumn(name = "best_execution_id") var bestExecution: Execution?, var bestScore: Int, From ce64d9da47f5c6f60b76a58995a748f6eaf5c841 Mon Sep 17 00:00:00 2001 From: Peter Trifanov Date: Fri, 2 Sep 2022 17:22:13 +0300 Subject: [PATCH 08/13] Support TestingType in old API --- .../save/backend/controllers/CloneRepositoryController.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/CloneRepositoryController.kt b/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/CloneRepositoryController.kt index d691857c63..3eaea88eab 100644 --- a/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/CloneRepositoryController.kt +++ b/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/CloneRepositoryController.kt @@ -6,6 +6,7 @@ import com.saveourtool.save.backend.storage.TestSuitesSourceSnapshotStorage import com.saveourtool.save.backend.utils.blockingToMono import com.saveourtool.save.domain.* import com.saveourtool.save.entities.* +import com.saveourtool.save.execution.TestingType import com.saveourtool.save.testsuite.TestSuitesSourceSnapshotKey import com.saveourtool.save.utils.getLogger import com.saveourtool.save.utils.orNotFound @@ -27,6 +28,7 @@ import reactor.kotlin.core.util.function.component2 */ @RestController @RequestMapping("/api") +@Deprecated("All new logic should use RunExecutionController's endpoints") class CloneRepositoryController( private val testSuitesService: TestSuitesService, private val testSuitesSourceService: TestSuitesSourceService, @@ -50,6 +52,7 @@ class CloneRepositoryController( ): Mono = sendToTrigger( executionRequest, + TestingType.PRIVATE_TESTS, authentication, files, { true } @@ -87,6 +90,7 @@ class CloneRepositoryController( ): Mono = sendToTrigger( executionRequestForStandardSuites, + TestingType.PUBLIC_TESTS, authentication, files, { it.name in executionRequestForStandardSuites.testSuites } @@ -97,6 +101,7 @@ class CloneRepositoryController( @Suppress("TOO_LONG_FUNCTION", "TOO_MANY_LINES_IN_LAMBDA") private fun sendToTrigger( executionRequest: T, + testingType: TestingType, authentication: Authentication, shortFiles: Flux, testSuitesFilter: (TestSuite) -> Boolean, @@ -143,7 +148,7 @@ class CloneRepositoryController( ) } .flatMap { - runExecutionController.trigger(it, authentication) + runExecutionController.trigger(it, testingType, authentication) } } From d380928224ab8e874cbebf6e9abf0b77172db358 Mon Sep 17 00:00:00 2001 From: Peter Trifanov Date: Fri, 2 Sep 2022 17:22:25 +0300 Subject: [PATCH 09/13] Code style --- .../save/backend/controllers/CloneRepositoryController.kt | 2 +- .../save/backend/controllers/RunExecutionController.kt | 3 ++- .../save/frontend/components/basic/TestResourcesSelection.kt | 3 +-- .../saveourtool/save/frontend/components/views/ProjectView.kt | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/CloneRepositoryController.kt b/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/CloneRepositoryController.kt index 3eaea88eab..034b31c00b 100644 --- a/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/CloneRepositoryController.kt +++ b/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/CloneRepositoryController.kt @@ -98,7 +98,7 @@ class CloneRepositoryController( testSuitesSourceService.getStandardTestSuitesSources() } - @Suppress("TOO_LONG_FUNCTION", "TOO_MANY_LINES_IN_LAMBDA") + @Suppress("TOO_LONG_FUNCTION", "TOO_MANY_LINES_IN_LAMBDA", "TOO_MANY_PARAMETERS") private fun sendToTrigger( executionRequest: T, testingType: TestingType, diff --git a/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/RunExecutionController.kt b/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/RunExecutionController.kt index b169b53526..2f63c8403f 100644 --- a/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/RunExecutionController.kt +++ b/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/RunExecutionController.kt @@ -12,6 +12,7 @@ import com.saveourtool.save.entities.Execution import com.saveourtool.save.entities.RunExecutionRequest import com.saveourtool.save.execution.ExecutionStatus import com.saveourtool.save.execution.ExecutionUpdateDto +import com.saveourtool.save.execution.TestingType import com.saveourtool.save.permission.Permission import com.saveourtool.save.utils.debug import com.saveourtool.save.utils.getLogger @@ -20,7 +21,6 @@ import com.saveourtool.save.utils.switchIfEmptyToResponseException import com.saveourtool.save.v1 import com.fasterxml.jackson.databind.ObjectMapper -import com.saveourtool.save.execution.TestingType import io.micrometer.core.instrument.MeterRegistry import org.slf4j.Logger import org.springframework.http.HttpStatus @@ -64,6 +64,7 @@ class RunExecutionController( /** * @param request incoming request from frontend * @param authentication + * @param testingType type for this execution * @return response with ID of created [Execution] */ @PostMapping("/trigger") diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/TestResourcesSelection.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/TestResourcesSelection.kt index 308a0710dd..2624733f97 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/TestResourcesSelection.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/TestResourcesSelection.kt @@ -2,7 +2,7 @@ * Utility methods for creation of the module window for the selection of test resources */ -@file:Suppress("WildcardImport", "FILE_WILDCARD_IMPORTS") +@file:Suppress("WildcardImport", "FILE_WILDCARD_IMPORTS", "FILE_NAME_MATCH_CLASS") package com.saveourtool.save.frontend.components.basic @@ -27,7 +27,6 @@ import react.dom.html.ReactHTML.select val testResourcesSelection = prepareTestResourcesSelection() - /** * Properties for test resources */ diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ProjectView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ProjectView.kt index e69b48d696..58a98ba4b5 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ProjectView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ProjectView.kt @@ -351,7 +351,7 @@ class ProjectView : AbstractView(f execCmd = state.execCmd, batchSizeForAnalyzer = state.batchSizeForAnalyzer ) - submitRequest("/run/trigger?testingType=${testingType}", jsonHeaders, Json.encodeToString(executionRequest)) + submitRequest("/run/trigger?testingType=$testingType", jsonHeaders, Json.encodeToString(executionRequest)) } private fun submitRequest(url: String, headers: Headers, body: dynamic) { From ffbe599ece99d391884975b509b26f2d707aa28b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 2 Sep 2022 14:31:02 +0000 Subject: [PATCH 10/13] Update backend-api-docs.json --- save-backend/backend-api-docs.json | 39 +++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/save-backend/backend-api-docs.json b/save-backend/backend-api-docs.json index 14c8d1e958..b8ab77db44 100644 --- a/save-backend/backend-api-docs.json +++ b/save-backend/backend-api-docs.json @@ -795,7 +795,8 @@ } } } - } + }, + "deprecated": true } }, "/api/v1/run/trigger": { @@ -804,6 +805,21 @@ "run-execution-controller" ], "operationId": "trigger", + "parameters": [ + { + "name": "testingType", + "in": "query", + "required": true, + "schema": { + "type": "string", + "enum": [ + "CONTEST_MODE", + "PRIVATE_TESTS", + "PUBLIC_TESTS" + ] + } + } + ], "requestBody": { "content": { "application/json": { @@ -2103,7 +2119,8 @@ } } } - } + }, + "deprecated": true } }, "/api/v1/execution/delete": { @@ -4861,7 +4878,7 @@ ], "summary": "Get contests that can be participated.", "description": "Get list of contest names that a given project can participate in.", - "operationId": "getAvaliableContestsForProject", + "operationId": "getAvailableContestsForProject", "parameters": [ { "name": "organizationName", @@ -5648,7 +5665,7 @@ ], "summary": "Get projects that can participate in contest.", "description": "Get list of user\u0027s projects that can participate in a given contest.", - "operationId": "getAvaliableProjectsForContest", + "operationId": "getAvailableProjectsForContest", "parameters": [ { "name": "contestName", @@ -5668,7 +5685,7 @@ ], "responses": { "200": { - "description": "Successfully fetched projects avaliable for contest.", + "description": "Successfully fetched projects available for contest.", "content": { "*/*": { "schema": { @@ -7347,9 +7364,9 @@ "type": { "type": "string", "enum": [ - "CONTEST", - "GIT", - "STANDARD" + "CONTEST_MODE", + "PRIVATE_TESTS", + "PUBLIC_TESTS" ] }, "version": { @@ -7533,9 +7550,9 @@ "type": { "type": "string", "enum": [ - "CONTEST", - "GIT", - "STANDARD" + "CONTEST_MODE", + "PRIVATE_TESTS", + "PUBLIC_TESTS" ] }, "version": { From 9428b737a82ae84e935ce1b4ebc427ab6292b852 Mon Sep 17 00:00:00 2001 From: Peter Trifanov Date: Fri, 2 Sep 2022 17:32:14 +0300 Subject: [PATCH 11/13] Code style --- .../save/backend/controllers/CloneRepositoryController.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/CloneRepositoryController.kt b/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/CloneRepositoryController.kt index 034b31c00b..f22a331a4e 100644 --- a/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/CloneRepositoryController.kt +++ b/save-backend/src/main/kotlin/com/saveourtool/save/backend/controllers/CloneRepositoryController.kt @@ -98,7 +98,12 @@ class CloneRepositoryController( testSuitesSourceService.getStandardTestSuitesSources() } - @Suppress("TOO_LONG_FUNCTION", "TOO_MANY_LINES_IN_LAMBDA", "TOO_MANY_PARAMETERS") + @Suppress( + "TOO_LONG_FUNCTION", + "TOO_MANY_LINES_IN_LAMBDA", + "TOO_MANY_PARAMETERS", + "LongParameterList", + ) private fun sendToTrigger( executionRequest: T, testingType: TestingType, From 3cd754d7b824213557af22518c8756149dff8136 Mon Sep 17 00:00:00 2001 From: Peter Trifanov Date: Fri, 2 Sep 2022 17:55:00 +0300 Subject: [PATCH 12/13] Fix mixed `PUBLIC` and `PRIVATE` testing types --- db/test-data/execution-insert.xml | 12 ++++++------ .../com/saveourtool/save/backend/CloneRepoTest.kt | 2 +- .../backend/controller/ExecutionControllerTest.kt | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/db/test-data/execution-insert.xml b/db/test-data/execution-insert.xml index 0de7885eb1..8126d0be91 100644 --- a/db/test-data/execution-insert.xml +++ b/db/test-data/execution-insert.xml @@ -15,7 +15,7 @@ - + @@ -43,7 +43,7 @@ - + @@ -71,7 +71,7 @@ - + @@ -99,7 +99,7 @@ - + @@ -127,7 +127,7 @@ - + @@ -156,7 +156,7 @@ - + diff --git a/save-backend/src/test/kotlin/com/saveourtool/save/backend/CloneRepoTest.kt b/save-backend/src/test/kotlin/com/saveourtool/save/backend/CloneRepoTest.kt index 798459888a..36128b2a15 100644 --- a/save-backend/src/test/kotlin/com/saveourtool/save/backend/CloneRepoTest.kt +++ b/save-backend/src/test/kotlin/com/saveourtool/save/backend/CloneRepoTest.kt @@ -227,7 +227,7 @@ class CloneRepoTest { executionRepository.findAll().shouldExist { it.project.name == project.name && it.project.organization == project.organization && - it.type == TestingType.PUBLIC_TESTS && + it.type == TestingType.PRIVATE_TESTS && it.sdk == sdk.toString() } } diff --git a/save-backend/src/test/kotlin/com/saveourtool/save/backend/controller/ExecutionControllerTest.kt b/save-backend/src/test/kotlin/com/saveourtool/save/backend/controller/ExecutionControllerTest.kt index 621ea73cb1..f49deafaa8 100644 --- a/save-backend/src/test/kotlin/com/saveourtool/save/backend/controller/ExecutionControllerTest.kt +++ b/save-backend/src/test/kotlin/com/saveourtool/save/backend/controller/ExecutionControllerTest.kt @@ -97,7 +97,7 @@ class ExecutionControllerTest { .expectBody() .consumeWith { requireNotNull(it.responseBody) - assertEquals(TestingType.PUBLIC_TESTS, it.responseBody!!.type) + assertEquals(TestingType.PRIVATE_TESTS, it.responseBody!!.type) } } From e0f1eca1fe3e4890bcef7cc63007a665564dfe01 Mon Sep 17 00:00:00 2001 From: Peter Trifanov Date: Mon, 5 Sep 2022 11:43:11 +0300 Subject: [PATCH 13/13] Fix mixed up `PRIVATE_` and `PUBLIC_` testing types --- .../main/kotlin/com/saveourtool/save/api/SaveCloudClient.kt | 2 +- .../kotlin/com/saveourtool/save/api/utils/RequestUtils.kt | 4 ++-- save-backend/Backend-API.md | 2 +- .../kotlin/com/saveourtool/save/execution/ExecutionDto.kt | 2 +- .../components/basic/ExecutionStatisticsValuesTest.kt | 2 +- .../orchestrator/controller/agents/AgentsControllerTest.kt | 3 +-- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/save-api/src/main/kotlin/com/saveourtool/save/api/SaveCloudClient.kt b/save-api/src/main/kotlin/com/saveourtool/save/api/SaveCloudClient.kt index e47df7c02b..e0f9e3f17b 100644 --- a/save-api/src/main/kotlin/com/saveourtool/save/api/SaveCloudClient.kt +++ b/save-api/src/main/kotlin/com/saveourtool/save/api/SaveCloudClient.kt @@ -91,7 +91,7 @@ class SaveCloudClient( testingType: TestingType, additionalFiles: List? ): ExecutionRequestBase? { - val executionRequest = if (testingType == TestingType.PUBLIC_TESTS) { + val executionRequest = if (testingType == TestingType.PRIVATE_TESTS) { buildExecutionRequest() } else { val userProvidedTestSuites = verifyTestSuites() ?: return null diff --git a/save-api/src/main/kotlin/com/saveourtool/save/api/utils/RequestUtils.kt b/save-api/src/main/kotlin/com/saveourtool/save/api/utils/RequestUtils.kt index 45bb32861e..fe8b452551 100644 --- a/save-api/src/main/kotlin/com/saveourtool/save/api/utils/RequestUtils.kt +++ b/save-api/src/main/kotlin/com/saveourtool/save/api/utils/RequestUtils.kt @@ -119,7 +119,7 @@ suspend fun HttpClient.getStandardTestSuites( @OptIn(InternalAPI::class) @Suppress("TOO_LONG_FUNCTION") suspend fun HttpClient.submitExecution(executionType: TestingType, executionRequest: ExecutionRequestBase, additionalFiles: List?): HttpResponse { - val endpoint = if (executionType == TestingType.PUBLIC_TESTS) { + val endpoint = if (executionType == TestingType.PRIVATE_TESTS) { "/api/$v1/submitExecutionRequest" } else { "/api/$v1/executionRequestStandardTests" @@ -131,7 +131,7 @@ suspend fun HttpClient.submitExecution(executionType: TestingType, executionRequ append(HttpHeaders.ContentType, ContentType.Application.Json) } setBody(MultiPartFormDataContent(formData { - if (executionType == TestingType.PUBLIC_TESTS) { + if (executionType == TestingType.PRIVATE_TESTS) { append( "executionRequest", json.encodeToString(executionRequest as ExecutionRequest), diff --git a/save-backend/Backend-API.md b/save-backend/Backend-API.md index 5480880199..6f4b240312 100644 --- a/save-backend/Backend-API.md +++ b/save-backend/Backend-API.md @@ -266,7 +266,7 @@ The response format will look like: { "id": 42, # execution id "status": "FINISHED", # execution status, i.e. running, finished and so on - "type":"PUBLIC_TESTS", # testing type + "type":"PRIVATE_TESTS", # testing type "version": "264e5feb8f4c6410d70536d6fc4bdf090df62287", # commit hash "startTime": 1651856549, # start time of execution in Unix format "endTime": 1651856797, # end time of execution in Unix format diff --git a/save-cloud-common/src/commonMain/kotlin/com/saveourtool/save/execution/ExecutionDto.kt b/save-cloud-common/src/commonMain/kotlin/com/saveourtool/save/execution/ExecutionDto.kt index ff1205f9dd..3cb95e4ec3 100644 --- a/save-cloud-common/src/commonMain/kotlin/com/saveourtool/save/execution/ExecutionDto.kt +++ b/save-cloud-common/src/commonMain/kotlin/com/saveourtool/save/execution/ExecutionDto.kt @@ -44,7 +44,7 @@ data class ExecutionDto( val empty = ExecutionDto( id = -1, status = ExecutionStatus.PENDING, - type = TestingType.PRIVATE_TESTS, + type = TestingType.PUBLIC_TESTS, version = null, startTime = -1, endTime = null, diff --git a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/basic/ExecutionStatisticsValuesTest.kt b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/basic/ExecutionStatisticsValuesTest.kt index 4952c0741d..04a8ade36e 100644 --- a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/basic/ExecutionStatisticsValuesTest.kt +++ b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/basic/ExecutionStatisticsValuesTest.kt @@ -25,7 +25,7 @@ class ExecutionStatisticsValuesTest { val executionDto = ExecutionDto( id = -1, status = ExecutionStatus.RUNNING, - type = TestingType.PUBLIC_TESTS, + type = TestingType.PRIVATE_TESTS, version = "N/A", startTime = 0L, endTime = null, diff --git a/save-orchestrator/src/test/kotlin/com/saveourtool/save/orchestrator/controller/agents/AgentsControllerTest.kt b/save-orchestrator/src/test/kotlin/com/saveourtool/save/orchestrator/controller/agents/AgentsControllerTest.kt index eb773a2d45..1dd3fbe15f 100644 --- a/save-orchestrator/src/test/kotlin/com/saveourtool/save/orchestrator/controller/agents/AgentsControllerTest.kt +++ b/save-orchestrator/src/test/kotlin/com/saveourtool/save/orchestrator/controller/agents/AgentsControllerTest.kt @@ -75,7 +75,7 @@ class AgentsControllerTest { fun `should build image, query backend and start containers`() { val project = Project.stub(null) val execution = Execution.stub(project).apply { - type = TestingType.PRIVATE_TESTS + type = TestingType.PUBLIC_TESTS status = ExecutionStatus.PENDING testSuiteIds = "1" id = 42L @@ -248,7 +248,6 @@ class AgentsControllerTest { } companion object { - @OptIn(ExperimentalPathApi::class) private val volume: String by lazy { createTempDirectory("executionLogs").toAbsolutePath().toString() }