From 3c07185b5b1f0c601b6254c51f0fab8e43e50a25 Mon Sep 17 00:00:00 2001 From: Natchica Date: Thu, 2 Jan 2025 16:33:45 +0100 Subject: [PATCH 01/13] Update dependencies and project compatibility to Java 17 --- CHANGELOG.md | 18 ++++++++++++++++ Dockerfile | 2 +- build.gradle | 20 +++++++++++------- iexec-core-library/build.gradle | 4 ++-- iexec-task-api/build.gradle | 4 ++-- src/main/java/com/iexec/core/Application.java | 14 ++++++++++--- .../com/iexec/core/chain/IexecHubService.java | 2 +- .../iexec/core/chain/WalletConfiguration.java | 2 -- .../BlockchainAdapterClientConfig.java | 2 -- .../ConfigServerClientConfig.java | 2 -- .../ConfigurationRepositoryMigration.java | 21 ++++++++++++------- .../PublicConfigurationService.java | 3 +-- .../ResultRepositoryConfiguration.java | 2 -- .../configuration/WorkerConfiguration.java | 2 -- .../replicate/ReplicateSupplyService.java | 2 +- .../java/com/iexec/core/task/TaskService.java | 2 +- .../iexec/core/version/VersionController.java | 3 +-- .../com/iexec/core/worker/WorkerService.java | 2 +- src/main/resources/application.yml | 4 ++-- .../ConfigurationRepositoryMigrationTest.java | 19 +++++++---------- .../iexec/core/logs/TaskLogsServiceTests.java | 2 +- 21 files changed, 75 insertions(+), 57 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index adb1e5da9..56eb33020 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file. ## [[NEXT]](https://github.com/iExecBlockchainComputing/iexec-core/releases/tag/vNEXT) 2025 +### Quality + +- Update base image from Eclipse Temurin `11.0.24_8-jre-focal` to `17.0.13_11-jre-focal` +- Update source and target compatibility to Java 17. (#728) +- Migrated to Jakarta EE APIs. (#728) +- Add `org.mockito:mockito-core:5.2.0` and `org.mockito:mockito-inline5.2.0` dependencies for tests. (#728) +- Configuration server is now optional by default. (#728) +- Update deprecated `mongock.change-logs-scan-package` to `mongock.migration-scan-package`. (#728) + +### Dependency Upgrades + +- Update Spring Boot to `3.0.13`. (#728) +- Update Spring Cloud to `2022.0.5`. (#728) +- Update Mongock to `5.4.0`. (#728) +- Update `com.github.cloudyrock.mongock:mongock-spring-v5` to `io.mongock:mongock-springboot-v3`. (#728) +- Update `com.github.cloudyrock.mongock:mongodb-springdata-v2-driver` to `io.mongock:mongodb-springdata-v4-driver`. (#728) +- Update `org.springdoc:springdoc-openapi-ui:1.7.0` to `org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0`. (#728) + ## [[8.6.0]](https://github.com/iExecBlockchainComputing/iexec-core/releases/tag/v8.6.0) 2024-12-23 ### New Features diff --git a/Dockerfile b/Dockerfile index 48cf2b554..c8e1478a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM eclipse-temurin:11.0.24_8-jre-focal +FROM eclipse-temurin:17.0.13_11-jre-focal ARG jar diff --git a/build.gradle b/build.gradle index e510712e8..7e150a1a2 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ plugins { id 'java' id 'io.freefair.lombok' version '8.10.2' - id 'org.springframework.boot' version '2.7.18' + id 'org.springframework.boot' version '3.0.13' id 'io.spring.dependency-management' version '1.1.6' id 'jacoco' id 'org.sonarqube' version '5.1.0.4882' @@ -9,9 +9,10 @@ plugins { } ext { - springCloudVersion = '2021.0.8' + springCloudVersion = '2022.0.5' jjwtVersion = '0.11.5' - mongockVersion = '4.2.7.BETA' + mongockVersion = '5.4.0' + mockitoVersion = '5.2.0' testContainersVersion = '1.20.4' } @@ -40,8 +41,8 @@ allprojects { toolchain { languageVersion.set(JavaLanguageVersion.of(17)) } - sourceCompatibility = "11" - targetCompatibility = "11" + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } } @@ -75,7 +76,7 @@ dependencies { implementation "org.springframework.retry:spring-retry" // Spring Doc - implementation 'org.springdoc:springdoc-openapi-ui:1.7.0' + implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0' // apache commons.lang3 implementation 'org.apache.commons:commons-lang3' @@ -95,8 +96,8 @@ dependencies { runtimeOnly 'io.micrometer:micrometer-registry-prometheus' // mongock - implementation "com.github.cloudyrock.mongock:mongock-spring-v5:${mongockVersion}" - implementation "com.github.cloudyrock.mongock:mongodb-springdata-v2-driver:${mongockVersion}" + implementation "io.mongock:mongock-springboot-v3:${mongockVersion}" + implementation "io.mongock:mongodb-springdata-v4-driver:${mongockVersion}" // vavr implementation 'io.vavr:vavr:0.10.4' @@ -120,6 +121,9 @@ testing { dependencies { implementation 'org.springframework.boot:spring-boot-starter-test' + implementation "org.mockito:mockito-core:$mockitoVersion" + implementation "org.mockito:mockito-inline:$mockitoVersion" + // awaitility implementation 'org.awaitility:awaitility' diff --git a/iexec-core-library/build.gradle b/iexec-core-library/build.gradle index 738ff4c20..b477c1dfd 100644 --- a/iexec-core-library/build.gradle +++ b/iexec-core-library/build.gradle @@ -13,8 +13,8 @@ dependencies { } java { - sourceCompatibility = "11" - targetCompatibility = "11" + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 withJavadocJar() withSourcesJar() } diff --git a/iexec-task-api/build.gradle b/iexec-task-api/build.gradle index 0316445cf..8de8f7381 100644 --- a/iexec-task-api/build.gradle +++ b/iexec-task-api/build.gradle @@ -11,8 +11,8 @@ dependencies { } java { - sourceCompatibility = "11" - targetCompatibility = "11" + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 withJavadocJar() withSourcesJar() } diff --git a/src/main/java/com/iexec/core/Application.java b/src/main/java/com/iexec/core/Application.java index a21c6879d..dd6e1499f 100644 --- a/src/main/java/com/iexec/core/Application.java +++ b/src/main/java/com/iexec/core/Application.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,12 +16,15 @@ package com.iexec.core; -import io.changock.runner.spring.v5.config.EnableChangock; +import io.mongock.driver.mongodb.springdata.v4.SpringDataMongoV4Driver; +import io.mongock.runner.springboot.EnableMongock; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.ConfigurationPropertiesScan; +import org.springframework.context.annotation.Bean; +import org.springframework.data.mongodb.core.MongoTemplate; -@EnableChangock +@EnableMongock @SpringBootApplication @ConfigurationPropertiesScan public class Application { @@ -30,4 +33,9 @@ public static void main(String[] args) { SpringApplication.run(Application.class, args); } + @Bean + public SpringDataMongoV4Driver mongockDriver(MongoTemplate mongoTemplate) { + return SpringDataMongoV4Driver.withDefaultLock(mongoTemplate); + } + } diff --git a/src/main/java/com/iexec/core/chain/IexecHubService.java b/src/main/java/com/iexec/core/chain/IexecHubService.java index 3b9d89003..9475733ef 100644 --- a/src/main/java/com/iexec/core/chain/IexecHubService.java +++ b/src/main/java/com/iexec/core/chain/IexecHubService.java @@ -21,6 +21,7 @@ import com.iexec.commons.poco.contract.generated.IexecHubContract; import com.iexec.commons.poco.utils.BytesUtils; import io.reactivex.Flowable; +import jakarta.annotation.PreDestroy; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.web3j.abi.EventEncoder; @@ -29,7 +30,6 @@ import org.web3j.protocol.core.methods.request.EthFilter; import org.web3j.protocol.core.methods.response.TransactionReceipt; -import javax.annotation.PreDestroy; import java.math.BigInteger; import java.time.Instant; import java.util.Date; diff --git a/src/main/java/com/iexec/core/chain/WalletConfiguration.java b/src/main/java/com/iexec/core/chain/WalletConfiguration.java index 4d7cdacaf..59b243d5a 100644 --- a/src/main/java/com/iexec/core/chain/WalletConfiguration.java +++ b/src/main/java/com/iexec/core/chain/WalletConfiguration.java @@ -20,11 +20,9 @@ import com.iexec.commons.poco.chain.SignerService; import lombok.Value; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.ConstructorBinding; import org.springframework.context.annotation.Bean; @Value -@ConstructorBinding @ConfigurationProperties(prefix = "wallet") public class WalletConfiguration { String encryptedFilePath; diff --git a/src/main/java/com/iexec/core/chain/adapter/BlockchainAdapterClientConfig.java b/src/main/java/com/iexec/core/chain/adapter/BlockchainAdapterClientConfig.java index 83093c394..d58db79fa 100644 --- a/src/main/java/com/iexec/core/chain/adapter/BlockchainAdapterClientConfig.java +++ b/src/main/java/com/iexec/core/chain/adapter/BlockchainAdapterClientConfig.java @@ -23,13 +23,11 @@ import lombok.Data; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.ConstructorBinding; import org.springframework.context.annotation.Bean; import java.time.Duration; @Data -@ConstructorBinding @ConfigurationProperties(prefix = "blockchain-adapter") public class BlockchainAdapterClientConfig { diff --git a/src/main/java/com/iexec/core/configuration/ConfigServerClientConfig.java b/src/main/java/com/iexec/core/configuration/ConfigServerClientConfig.java index f19978c96..ccd7f371d 100644 --- a/src/main/java/com/iexec/core/configuration/ConfigServerClientConfig.java +++ b/src/main/java/com/iexec/core/configuration/ConfigServerClientConfig.java @@ -22,11 +22,9 @@ import feign.Logger; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.ConstructorBinding; import org.springframework.context.annotation.Bean; @Data -@ConstructorBinding @ConfigurationProperties(prefix = "config-server") public class ConfigServerClientConfig { diff --git a/src/main/java/com/iexec/core/configuration/ConfigurationRepositoryMigration.java b/src/main/java/com/iexec/core/configuration/ConfigurationRepositoryMigration.java index 5ccc1727b..cd2e1b258 100644 --- a/src/main/java/com/iexec/core/configuration/ConfigurationRepositoryMigration.java +++ b/src/main/java/com/iexec/core/configuration/ConfigurationRepositoryMigration.java @@ -1,5 +1,5 @@ /* - * Copyright 2021 IEXEC BLOCKCHAIN TECH + * Copyright 2021-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,25 +16,25 @@ package com.iexec.core.configuration; -import com.github.cloudyrock.mongock.driver.mongodb.springdata.v2.decorator.impl.MongockTemplate; import com.mongodb.client.MongoCollection; -import io.changock.migration.api.annotations.ChangeLog; -import io.changock.migration.api.annotations.ChangeSet; +import io.mongock.api.annotations.ChangeUnit; +import io.mongock.api.annotations.Execution; +import io.mongock.api.annotations.RollbackExecution; import lombok.extern.slf4j.Slf4j; import org.bson.Document; +import org.springframework.data.mongodb.core.MongoTemplate; import java.math.BigInteger; @Slf4j -@ChangeLog(order = "001") +@ChangeUnit(order = "001", id = "moveFromReplayField", author = "iexec") public class ConfigurationRepositoryMigration { - public static final String CURRENT_AUTHOR = "iexec"; public static final String CONFIGURATION_COLLECTION_NAME = "configuration"; public static final String LEGACY_FROM_REPLAY_FIELD_NAME = "fromReplay"; - @ChangeSet(order = "001", id = "moveFromReplayField", author = CURRENT_AUTHOR) - public boolean moveFromReplayField(MongockTemplate mongockTemplate, ReplayConfigurationRepository replayConfigurationRepository) { + @Execution + public boolean moveFromReplayField(MongoTemplate mongockTemplate, ReplayConfigurationRepository replayConfigurationRepository) { if (replayConfigurationRepository.count() > 0) { log.info("Migration of fromReplay field is useless (already up-to-date)"); return false; @@ -64,4 +64,9 @@ public boolean moveFromReplayField(MongockTemplate mongockTemplate, ReplayConfig return true; } + @RollbackExecution + public void rollback(ReplayConfigurationRepository replayConfigurationRepository) { + replayConfigurationRepository.deleteAll(); + } + } diff --git a/src/main/java/com/iexec/core/configuration/PublicConfigurationService.java b/src/main/java/com/iexec/core/configuration/PublicConfigurationService.java index 1e12b3512..620018043 100644 --- a/src/main/java/com/iexec/core/configuration/PublicConfigurationService.java +++ b/src/main/java/com/iexec/core/configuration/PublicConfigurationService.java @@ -19,12 +19,11 @@ import com.iexec.commons.poco.chain.SignerService; import com.iexec.core.chain.ChainConfig; import com.iexec.core.config.PublicConfiguration; +import jakarta.annotation.PostConstruct; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.web3j.crypto.Hash; -import javax.annotation.PostConstruct; - /** * This simple service will generate a random session id when the scheduler is started, it will be send to workers when * they ping the scheduler. If they see that the session id has changed, it means that the scheduler has restarted. diff --git a/src/main/java/com/iexec/core/configuration/ResultRepositoryConfiguration.java b/src/main/java/com/iexec/core/configuration/ResultRepositoryConfiguration.java index fcf2fa14c..2805f3c2b 100644 --- a/src/main/java/com/iexec/core/configuration/ResultRepositoryConfiguration.java +++ b/src/main/java/com/iexec/core/configuration/ResultRepositoryConfiguration.java @@ -23,10 +23,8 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.ConstructorBinding; @Value -@ConstructorBinding @ConfigurationProperties(prefix = "result-repository") @Slf4j public class ResultRepositoryConfiguration { diff --git a/src/main/java/com/iexec/core/configuration/WorkerConfiguration.java b/src/main/java/com/iexec/core/configuration/WorkerConfiguration.java index cd11ab0cb..1ff4c8cf2 100644 --- a/src/main/java/com/iexec/core/configuration/WorkerConfiguration.java +++ b/src/main/java/com/iexec/core/configuration/WorkerConfiguration.java @@ -18,12 +18,10 @@ import lombok.Value; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.ConstructorBinding; import java.util.List; @Value -@ConstructorBinding @ConfigurationProperties(prefix = "workers") public class WorkerConfiguration { long askForReplicatePeriod; diff --git a/src/main/java/com/iexec/core/replicate/ReplicateSupplyService.java b/src/main/java/com/iexec/core/replicate/ReplicateSupplyService.java index 27c8288b9..f9467dbee 100644 --- a/src/main/java/com/iexec/core/replicate/ReplicateSupplyService.java +++ b/src/main/java/com/iexec/core/replicate/ReplicateSupplyService.java @@ -36,12 +36,12 @@ import com.iexec.core.task.update.TaskUpdateRequestManager; import com.iexec.core.worker.Worker; import com.iexec.core.worker.WorkerService; +import jakarta.annotation.PreDestroy; import lombok.extern.slf4j.Slf4j; import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.retry.annotation.Retryable; import org.springframework.stereotype.Service; -import javax.annotation.PreDestroy; import java.util.*; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; diff --git a/src/main/java/com/iexec/core/task/TaskService.java b/src/main/java/com/iexec/core/task/TaskService.java index 5c8451208..cf4b3ecbc 100644 --- a/src/main/java/com/iexec/core/task/TaskService.java +++ b/src/main/java/com/iexec/core/task/TaskService.java @@ -26,6 +26,7 @@ import com.mongodb.client.result.UpdateResult; import io.micrometer.core.instrument.Gauge; import io.micrometer.core.instrument.Metrics; +import jakarta.annotation.PostConstruct; import lombok.extern.slf4j.Slf4j; import org.bson.Document; import org.springframework.context.ApplicationEventPublisher; @@ -38,7 +39,6 @@ import org.springframework.data.mongodb.core.query.Update; import org.springframework.stereotype.Service; -import javax.annotation.PostConstruct; import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; diff --git a/src/main/java/com/iexec/core/version/VersionController.java b/src/main/java/com/iexec/core/version/VersionController.java index cfb9d7d21..f6b3de1e8 100644 --- a/src/main/java/com/iexec/core/version/VersionController.java +++ b/src/main/java/com/iexec/core/version/VersionController.java @@ -18,13 +18,12 @@ import io.micrometer.core.instrument.Gauge; import io.micrometer.core.instrument.Metrics; +import jakarta.annotation.PostConstruct; import org.springframework.boot.info.BuildProperties; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; -import javax.annotation.PostConstruct; - @RestController public class VersionController { diff --git a/src/main/java/com/iexec/core/worker/WorkerService.java b/src/main/java/com/iexec/core/worker/WorkerService.java index 1ac759a26..16215afe0 100644 --- a/src/main/java/com/iexec/core/worker/WorkerService.java +++ b/src/main/java/com/iexec/core/worker/WorkerService.java @@ -20,6 +20,7 @@ import com.iexec.core.configuration.WorkerConfiguration; import com.mongodb.client.result.UpdateResult; import io.micrometer.core.instrument.Metrics; +import jakarta.annotation.PostConstruct; import lombok.Data; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -30,7 +31,6 @@ import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; -import javax.annotation.PostConstruct; import java.time.Instant; import java.time.temporal.ChronoUnit; import java.util.*; diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 0caea3c33..0828942ea 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -8,13 +8,13 @@ spring: host: ${MONGO_HOST:localhost} port: ${MONGO_PORT:13002} auto-index-creation: true # Auto-index creation is disabled by default starting with Spring Data MongoDB 3.x. - config.import: "configserver:${IEXEC_PLATFORM_REGISTRY:http://localhost:8888}" # configserver:http://platform-registry:8888 + config.import: "optional:configserver:${IEXEC_PLATFORM_REGISTRY:http://localhost:8888}" # configserver:http://platform-registry:8888 cloud.config: profile: ${IEXEC_PLATFORM_REGISTRY_STACK:} # mainnet, bellecour3, 1234, .. label: ${IEXEC_PLATFORM_REGISTRY_LABEL:} # main, develop, v10, 07998be mongock: runner-type: InitializingBean - change-logs-scan-package: + migration-scan-package: - com.iexec.core.configuration cron: diff --git a/src/test/java/com/iexec/core/configuration/ConfigurationRepositoryMigrationTest.java b/src/test/java/com/iexec/core/configuration/ConfigurationRepositoryMigrationTest.java index d8ac5ee0f..ab61a9395 100644 --- a/src/test/java/com/iexec/core/configuration/ConfigurationRepositoryMigrationTest.java +++ b/src/test/java/com/iexec/core/configuration/ConfigurationRepositoryMigrationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2021 IEXEC BLOCKCHAIN TECH + * Copyright 2021-2024 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,20 +16,21 @@ package com.iexec.core.configuration; -import com.github.cloudyrock.mongock.driver.mongodb.springdata.v2.decorator.impl.MongockTemplate; import com.mongodb.client.FindIterable; import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoDatabase; import org.bson.Document; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.MockitoAnnotations; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.data.mongodb.core.MongoTemplate; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.when; +@ExtendWith(MockitoExtension.class) class ConfigurationRepositoryMigrationTest { @Mock @@ -42,17 +43,11 @@ class ConfigurationRepositoryMigrationTest { private FindIterable findIterable; @Mock - private MongockTemplate mongockTemplate; + private MongoTemplate mongockTemplate; @Mock private ReplayConfigurationRepository replayConfigurationRepository; - @BeforeEach - void init() { - MockitoAnnotations.openMocks(this); - } - - @Test void shouldMoveFromReplayField() { when(replayConfigurationRepository.count()).thenReturn(0L); @@ -92,4 +87,4 @@ void shouldNotMoveFromReplayFieldSinceMissingFieldInLegacy() { Assertions.assertFalse(isUpdated); } -} \ No newline at end of file +} diff --git a/src/test/java/com/iexec/core/logs/TaskLogsServiceTests.java b/src/test/java/com/iexec/core/logs/TaskLogsServiceTests.java index da44241f8..7c36dd572 100644 --- a/src/test/java/com/iexec/core/logs/TaskLogsServiceTests.java +++ b/src/test/java/com/iexec/core/logs/TaskLogsServiceTests.java @@ -141,4 +141,4 @@ void shouldGetComputeLogs() { assertThat(actualLogs.getStderr()).isEqualTo(STDERR); } //endregion -} \ No newline at end of file +} From 0c766f3c6340ab764f0f2fb6dcd4200143f3a796 Mon Sep 17 00:00:00 2001 From: Natchica Date: Thu, 2 Jan 2025 17:32:22 +0100 Subject: [PATCH 02/13] Add test for better test coverage on new code --- .../ConfigurationRepositoryMigrationTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/test/java/com/iexec/core/configuration/ConfigurationRepositoryMigrationTest.java b/src/test/java/com/iexec/core/configuration/ConfigurationRepositoryMigrationTest.java index ab61a9395..a037b0548 100644 --- a/src/test/java/com/iexec/core/configuration/ConfigurationRepositoryMigrationTest.java +++ b/src/test/java/com/iexec/core/configuration/ConfigurationRepositoryMigrationTest.java @@ -28,6 +28,7 @@ import org.springframework.data.mongodb.core.MongoTemplate; import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) @@ -48,6 +49,7 @@ class ConfigurationRepositoryMigrationTest { @Mock private ReplayConfigurationRepository replayConfigurationRepository; + // region execution @Test void shouldMoveFromReplayField() { when(replayConfigurationRepository.count()).thenReturn(0L); @@ -86,5 +88,15 @@ void shouldNotMoveFromReplayFieldSinceMissingFieldInLegacy() { .moveFromReplayField(mongockTemplate, replayConfigurationRepository); Assertions.assertFalse(isUpdated); } + // endregion + + // region rollback + @Test + void shouldSuccessfullyRollback() { + ConfigurationRepositoryMigration migration = new ConfigurationRepositoryMigration(); + migration.rollback(replayConfigurationRepository); + verify(replayConfigurationRepository).deleteAll(); + } + // endregion } From ca9658d90c45ecbad6772d01fb386628e78f843a Mon Sep 17 00:00:00 2001 From: Natchica Date: Fri, 3 Jan 2025 15:09:12 +0100 Subject: [PATCH 03/13] Clean test dependencies --- CHANGELOG.md | 5 ----- build.gradle | 8 ++------ 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56eb33020..2bd0d9813 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,18 +9,13 @@ All notable changes to this project will be documented in this file. - Update base image from Eclipse Temurin `11.0.24_8-jre-focal` to `17.0.13_11-jre-focal` - Update source and target compatibility to Java 17. (#728) - Migrated to Jakarta EE APIs. (#728) -- Add `org.mockito:mockito-core:5.2.0` and `org.mockito:mockito-inline5.2.0` dependencies for tests. (#728) - Configuration server is now optional by default. (#728) -- Update deprecated `mongock.change-logs-scan-package` to `mongock.migration-scan-package`. (#728) ### Dependency Upgrades - Update Spring Boot to `3.0.13`. (#728) - Update Spring Cloud to `2022.0.5`. (#728) - Update Mongock to `5.4.0`. (#728) -- Update `com.github.cloudyrock.mongock:mongock-spring-v5` to `io.mongock:mongock-springboot-v3`. (#728) -- Update `com.github.cloudyrock.mongock:mongodb-springdata-v2-driver` to `io.mongock:mongodb-springdata-v4-driver`. (#728) -- Update `org.springdoc:springdoc-openapi-ui:1.7.0` to `org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0`. (#728) ## [[8.6.0]](https://github.com/iExecBlockchainComputing/iexec-core/releases/tag/v8.6.0) 2024-12-23 diff --git a/build.gradle b/build.gradle index 7e150a1a2..20aca17cf 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,6 @@ ext { springCloudVersion = '2022.0.5' jjwtVersion = '0.11.5' mongockVersion = '5.4.0' - mockitoVersion = '5.2.0' testContainersVersion = '1.20.4' } @@ -119,14 +118,11 @@ testing { test { useJUnitJupiter() dependencies { - implementation 'org.springframework.boot:spring-boot-starter-test' - - implementation "org.mockito:mockito-core:$mockitoVersion" - implementation "org.mockito:mockito-inline:$mockitoVersion" - // awaitility implementation 'org.awaitility:awaitility' + implementation 'org.springframework.boot:spring-boot-starter-test' + // mongo implementation "org.testcontainers:junit-jupiter:$testContainersVersion" implementation "org.testcontainers:mongodb:$testContainersVersion" From 1584468ae888cb589a6294e989ab5c13057cf275 Mon Sep 17 00:00:00 2001 From: Natchica Date: Fri, 3 Jan 2025 15:15:07 +0100 Subject: [PATCH 04/13] Correct copyright licence date --- src/main/java/com/iexec/core/chain/IexecHubService.java | 2 +- src/main/java/com/iexec/core/chain/WalletConfiguration.java | 2 +- .../iexec/core/chain/adapter/BlockchainAdapterClientConfig.java | 2 +- .../com/iexec/core/configuration/ConfigServerClientConfig.java | 2 +- .../iexec/core/configuration/PublicConfigurationService.java | 2 +- .../iexec/core/configuration/ResultRepositoryConfiguration.java | 2 +- .../java/com/iexec/core/configuration/WorkerConfiguration.java | 2 +- .../java/com/iexec/core/replicate/ReplicateSupplyService.java | 2 +- src/main/java/com/iexec/core/task/TaskService.java | 2 +- src/main/java/com/iexec/core/version/VersionController.java | 2 +- src/main/java/com/iexec/core/worker/WorkerService.java | 2 +- .../configuration/ConfigurationRepositoryMigrationTest.java | 2 +- src/test/java/com/iexec/core/logs/TaskLogsServiceTests.java | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/iexec/core/chain/IexecHubService.java b/src/main/java/com/iexec/core/chain/IexecHubService.java index 9475733ef..55afcb534 100644 --- a/src/main/java/com/iexec/core/chain/IexecHubService.java +++ b/src/main/java/com/iexec/core/chain/IexecHubService.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/iexec/core/chain/WalletConfiguration.java b/src/main/java/com/iexec/core/chain/WalletConfiguration.java index 59b243d5a..772db244e 100644 --- a/src/main/java/com/iexec/core/chain/WalletConfiguration.java +++ b/src/main/java/com/iexec/core/chain/WalletConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 IEXEC BLOCKCHAIN TECH + * Copyright 2024-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/iexec/core/chain/adapter/BlockchainAdapterClientConfig.java b/src/main/java/com/iexec/core/chain/adapter/BlockchainAdapterClientConfig.java index d58db79fa..764f7cd7d 100644 --- a/src/main/java/com/iexec/core/chain/adapter/BlockchainAdapterClientConfig.java +++ b/src/main/java/com/iexec/core/chain/adapter/BlockchainAdapterClientConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2021-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/iexec/core/configuration/ConfigServerClientConfig.java b/src/main/java/com/iexec/core/configuration/ConfigServerClientConfig.java index ccd7f371d..ef70bfbf8 100644 --- a/src/main/java/com/iexec/core/configuration/ConfigServerClientConfig.java +++ b/src/main/java/com/iexec/core/configuration/ConfigServerClientConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 IEXEC BLOCKCHAIN TECH + * Copyright 2024-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/iexec/core/configuration/PublicConfigurationService.java b/src/main/java/com/iexec/core/configuration/PublicConfigurationService.java index 620018043..9a11338a9 100644 --- a/src/main/java/com/iexec/core/configuration/PublicConfigurationService.java +++ b/src/main/java/com/iexec/core/configuration/PublicConfigurationService.java @@ -1,5 +1,5 @@ /* - * Copyright 2022-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2022-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/iexec/core/configuration/ResultRepositoryConfiguration.java b/src/main/java/com/iexec/core/configuration/ResultRepositoryConfiguration.java index 2805f3c2b..2be56e832 100644 --- a/src/main/java/com/iexec/core/configuration/ResultRepositoryConfiguration.java +++ b/src/main/java/com/iexec/core/configuration/ResultRepositoryConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/iexec/core/configuration/WorkerConfiguration.java b/src/main/java/com/iexec/core/configuration/WorkerConfiguration.java index 1ff4c8cf2..096b10f66 100644 --- a/src/main/java/com/iexec/core/configuration/WorkerConfiguration.java +++ b/src/main/java/com/iexec/core/configuration/WorkerConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/iexec/core/replicate/ReplicateSupplyService.java b/src/main/java/com/iexec/core/replicate/ReplicateSupplyService.java index f9467dbee..0fcf4672a 100644 --- a/src/main/java/com/iexec/core/replicate/ReplicateSupplyService.java +++ b/src/main/java/com/iexec/core/replicate/ReplicateSupplyService.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/iexec/core/task/TaskService.java b/src/main/java/com/iexec/core/task/TaskService.java index cf4b3ecbc..b55c6c5fc 100644 --- a/src/main/java/com/iexec/core/task/TaskService.java +++ b/src/main/java/com/iexec/core/task/TaskService.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/iexec/core/version/VersionController.java b/src/main/java/com/iexec/core/version/VersionController.java index f6b3de1e8..6f7e51740 100644 --- a/src/main/java/com/iexec/core/version/VersionController.java +++ b/src/main/java/com/iexec/core/version/VersionController.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/iexec/core/worker/WorkerService.java b/src/main/java/com/iexec/core/worker/WorkerService.java index 16215afe0..0432bc431 100644 --- a/src/main/java/com/iexec/core/worker/WorkerService.java +++ b/src/main/java/com/iexec/core/worker/WorkerService.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/iexec/core/configuration/ConfigurationRepositoryMigrationTest.java b/src/test/java/com/iexec/core/configuration/ConfigurationRepositoryMigrationTest.java index a037b0548..24ed870ad 100644 --- a/src/test/java/com/iexec/core/configuration/ConfigurationRepositoryMigrationTest.java +++ b/src/test/java/com/iexec/core/configuration/ConfigurationRepositoryMigrationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2021-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/iexec/core/logs/TaskLogsServiceTests.java b/src/test/java/com/iexec/core/logs/TaskLogsServiceTests.java index 7c36dd572..798728443 100644 --- a/src/test/java/com/iexec/core/logs/TaskLogsServiceTests.java +++ b/src/test/java/com/iexec/core/logs/TaskLogsServiceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2022-2023 IEXEC BLOCKCHAIN TECH + * Copyright 2022-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From b39b40f57a2f3b5a34ef319b90ee8e17ef8c4b8f Mon Sep 17 00:00:00 2001 From: Natchica Date: Tue, 7 Jan 2025 10:51:46 +0100 Subject: [PATCH 05/13] Clean dependencies use --- CHANGELOG.md | 10 ++++------ build.gradle | 12 ++++++++++-- gradle.properties | 4 ++-- iexec-core-library/build.gradle | 1 - iexec-task-api/build.gradle | 3 --- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bd0d9813..51415da2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,16 +6,14 @@ All notable changes to this project will be documented in this file. ### Quality -- Update base image from Eclipse Temurin `11.0.24_8-jre-focal` to `17.0.13_11-jre-focal` -- Update source and target compatibility to Java 17. (#728) -- Migrated to Jakarta EE APIs. (#728) +- Upgrade to base image from Eclipse Temurin 17.0.13_11-jre-focal. (#728) - Configuration server is now optional by default. (#728) ### Dependency Upgrades -- Update Spring Boot to `3.0.13`. (#728) -- Update Spring Cloud to `2022.0.5`. (#728) -- Update Mongock to `5.4.0`. (#728) +- Upgrade to Spring Boot 3.0.13. (#728) +- Upgrade to Spring Cloud 2022.0.5. (#728) +- Upgrade to Mongock 5.4.0. (#728) ## [[8.6.0]](https://github.com/iExecBlockchainComputing/iexec-core/releases/tag/v8.6.0) 2024-12-23 diff --git a/build.gradle b/build.gradle index 20aca17cf..d8b888879 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,13 @@ +buildscript { + ext { + springBootVersion = '3.0.13' + } +} + plugins { id 'java' id 'io.freefair.lombok' version '8.10.2' - id 'org.springframework.boot' version '3.0.13' + id 'org.springframework.boot' version "${springBootVersion}" id 'io.spring.dependency-management' version '1.1.6' id 'jacoco' id 'org.sonarqube' version '5.1.0.4882' @@ -52,6 +58,8 @@ dependencyManagement { } dependencies { + implementation platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}") + // iexec implementation "com.iexec.commons:iexec-commons-poco:$iexecCommonsPocoVersion" implementation "com.iexec.common:iexec-common:$iexecCommonVersion" @@ -75,7 +83,7 @@ dependencies { implementation "org.springframework.retry:spring-retry" // Spring Doc - implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0' + implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0' // apache commons.lang3 implementation 'org.apache.commons:commons-lang3' diff --git a/gradle.properties b/gradle.properties index 69f5cd4a6..773a1ea2d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ version=8.6.0 -iexecCommonsPocoVersion=4.2.0 -iexecCommonVersion=8.6.0 +iexecCommonsPocoVersion=4.2.0-NEXT-SNAPSHOT +iexecCommonVersion=8.6.0-NEXT-SNAPSHOT iexecBlockchainAdapterVersion=8.6.0 iexecResultVersion=8.6.0 iexecSmsVersion=8.7.0 diff --git a/iexec-core-library/build.gradle b/iexec-core-library/build.gradle index b477c1dfd..972c78219 100644 --- a/iexec-core-library/build.gradle +++ b/iexec-core-library/build.gradle @@ -24,7 +24,6 @@ testing { test { useJUnitJupiter() dependencies { - implementation 'org.junit.jupiter:junit-jupiter:5.8.2' implementation 'org.assertj:assertj-core:3.22.0' } } diff --git a/iexec-task-api/build.gradle b/iexec-task-api/build.gradle index 8de8f7381..f9e451f3e 100644 --- a/iexec-task-api/build.gradle +++ b/iexec-task-api/build.gradle @@ -21,9 +21,6 @@ testing { suites { test { useJUnitJupiter() - dependencies { - implementation 'org.junit.jupiter:junit-jupiter:5.8.2' - } } } } From 5c0afc2f55bd98d5d0a5ece2626b7fc9c0d22767 Mon Sep 17 00:00:00 2001 From: Natchica Date: Tue, 7 Jan 2025 10:56:45 +0100 Subject: [PATCH 06/13] Correct CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51415da2e..9aa8726ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file. ### Quality -- Upgrade to base image from Eclipse Temurin 17.0.13_11-jre-focal. (#728) +- Upgrade to Eclipse Temurin 17.0.13_11-jre-focal. (#728) - Configuration server is now optional by default. (#728) ### Dependency Upgrades From a2143f9a73db1aedcace241df45fd586b350ab8e Mon Sep 17 00:00:00 2001 From: Natchica Date: Tue, 7 Jan 2025 11:01:30 +0100 Subject: [PATCH 07/13] Update and correct CHANGELOG --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9aa8726ca..0d91a683a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,14 +6,15 @@ All notable changes to this project will be documented in this file. ### Quality -- Upgrade to Eclipse Temurin 17.0.13_11-jre-focal. (#728) - Configuration server is now optional by default. (#728) ### Dependency Upgrades +- Upgrade to `eclipse-temurin:17.0.13_11-jre-focal`. (#728) - Upgrade to Spring Boot 3.0.13. (#728) - Upgrade to Spring Cloud 2022.0.5. (#728) - Upgrade to Mongock 5.4.0. (#728) +- Upgrade to `org.springdoc:springdoc-openapi-starter-webmvc-ui` 2.6.0. (#728) ## [[8.6.0]](https://github.com/iExecBlockchainComputing/iexec-core/releases/tag/v8.6.0) 2024-12-23 From 9158486b74a9554886cb7385f54879185f777854 Mon Sep 17 00:00:00 2001 From: Natchica Date: Tue, 7 Jan 2025 12:08:33 +0100 Subject: [PATCH 08/13] Correct Sonar Issues --- .../com/iexec/core/replicate/ReplicateSupplyService.java | 3 +-- src/main/java/com/iexec/core/task/TaskService.java | 4 ++-- src/main/java/com/iexec/core/worker/WorkerService.java | 5 ++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/iexec/core/replicate/ReplicateSupplyService.java b/src/main/java/com/iexec/core/replicate/ReplicateSupplyService.java index 0fcf4672a..c980c2bec 100644 --- a/src/main/java/com/iexec/core/replicate/ReplicateSupplyService.java +++ b/src/main/java/com/iexec/core/replicate/ReplicateSupplyService.java @@ -38,7 +38,6 @@ import com.iexec.core.worker.WorkerService; import jakarta.annotation.PreDestroy; import lombok.extern.slf4j.Slf4j; -import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.retry.annotation.Retryable; import org.springframework.stereotype.Service; @@ -85,7 +84,7 @@ public ReplicateSupplyService(ReplicatesService replicatesService, * - released before any `continue` or `return` * */ - @Retryable(value = {OptimisticLockingFailureException.class}, maxAttempts = 5) + @Retryable(maxAttempts = 5) Optional getAvailableReplicateTaskSummary(long workerLastBlock, String walletAddress) { // return empty if the worker is not sync //TODO Check if worker node is sync diff --git a/src/main/java/com/iexec/core/task/TaskService.java b/src/main/java/com/iexec/core/task/TaskService.java index b55c6c5fc..865356b83 100644 --- a/src/main/java/com/iexec/core/task/TaskService.java +++ b/src/main/java/com/iexec/core/task/TaskService.java @@ -292,7 +292,7 @@ private Optional findPrioritizedTask(List statuses, public List updateMultipleTasksByQuery(Query query, Update update) { return mongoTemplate.find(query, Task.class).stream() .map(task -> updateSingleTask(task, update)) - .collect(Collectors.toList()); + .toList(); } /** @@ -311,7 +311,7 @@ public List getChainTaskIdsOfTasksExpiredBefore(Date expirationDate) { return taskRepository.findChainTaskIdsByFinalDeadlineBefore(expirationDate) .stream() .map(Task::getChainTaskId) - .collect(Collectors.toList()); + .toList(); } /** diff --git a/src/main/java/com/iexec/core/worker/WorkerService.java b/src/main/java/com/iexec/core/worker/WorkerService.java index 0432bc431..cc057c8e2 100644 --- a/src/main/java/com/iexec/core/worker/WorkerService.java +++ b/src/main/java/com/iexec/core/worker/WorkerService.java @@ -36,7 +36,6 @@ import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; /** * Manage {@link Worker} objects. @@ -164,7 +163,7 @@ public List getLostWorkers() { .stream() .filter(entry -> entry.getValue().getLastAliveDate().getTime() < oneMinuteAgo.getTime()) .map(Map.Entry::getKey) - .collect(Collectors.toList()); + .toList(); return workerRepository.findByWalletAddressIn(lostWorkers); } @@ -175,7 +174,7 @@ public List getAliveWorkers() { .stream() .filter(entry -> entry.getValue().getLastAliveDate().getTime() > oneMinuteAgo.getTime()) .map(Map.Entry::getKey) - .collect(Collectors.toList()); + .toList(); return workerRepository.findByWalletAddressIn(aliveWorkers); } From 8bba16472bbf94b1f707fe8c9f4ff72bdbea5a01 Mon Sep 17 00:00:00 2001 From: Natchica Date: Wed, 8 Jan 2025 18:14:05 +0100 Subject: [PATCH 09/13] Clean deprecated code and correct sonar high priority issues --- Dockerfile | 5 ++- iexec-core-library/build.gradle | 8 ++++- iexec-task-api/build.gradle | 6 ++++ .../com/iexec/core/replicate/Replicate.java | 5 ++- .../replicate/ReplicateSupplyService.java | 3 +- .../core/replicate/ReplicatesController.java | 25 ++++++--------- .../iexec/core/replicate/ReplicatesList.java | 5 ++- .../core/replicate/ReplicatesService.java | 16 +++++----- .../com/iexec/core/result/ResultService.java | 4 +-- .../core/security/WebSecurityConfig.java | 6 ++-- .../com/iexec/core/task/TaskController.java | 6 ++-- .../core/task/update/TaskUpdateManager.java | 21 ++++++------- ...ndFinalizationUnnotifiedDetectorTests.java | 6 ++-- .../ContributionUnnotifiedDetectorTests.java | 5 ++- .../RevealUnnotifiedDetectorTests.java | 5 ++- .../ReplicateSupplyServiceTests.java | 31 +++++++++---------- .../core/security/JwtTokenProviderTests.java | 9 +++--- .../com/iexec/core/task/TaskServiceTests.java | 7 ++--- .../task/update/TaskUpdateManagerTests.java | 11 +++---- .../update/TaskUpdateRequestManagerTests.java | 7 ++--- .../iexec/core/worker/WorkerServiceTests.java | 5 ++- 21 files changed, 95 insertions(+), 101 deletions(-) diff --git a/Dockerfile b/Dockerfile index c8e1478a6..284cfb978 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,9 +2,8 @@ FROM eclipse-temurin:17.0.13_11-jre-focal ARG jar -RUN test -n "$jar" - -RUN apt-get update \ +RUN test -n "$jar" \ + && apt-get update \ && apt-get install -y --no-install-recommends curl \ && rm -rf /var/lib/apt/lists/* diff --git a/iexec-core-library/build.gradle b/iexec-core-library/build.gradle index 972c78219..9acc44d7e 100644 --- a/iexec-core-library/build.gradle +++ b/iexec-core-library/build.gradle @@ -5,7 +5,13 @@ plugins { id 'maven-publish' } +ext { + springBootVersion = '3.0.13' +} + dependencies { + implementation platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}") + implementation "com.iexec.commons:iexec-commons-poco:$iexecCommonsPocoVersion" implementation "com.iexec.common:iexec-common:$iexecCommonVersion" // TODO remove this later when migration has been done @@ -24,7 +30,7 @@ testing { test { useJUnitJupiter() dependencies { - implementation 'org.assertj:assertj-core:3.22.0' + implementation 'org.assertj:assertj-core' } } } diff --git a/iexec-task-api/build.gradle b/iexec-task-api/build.gradle index f9e451f3e..e0f52efb9 100644 --- a/iexec-task-api/build.gradle +++ b/iexec-task-api/build.gradle @@ -5,7 +5,13 @@ plugins { id 'maven-publish' } +ext { + springBootVersion = '3.0.13' +} + dependencies { + implementation platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}") + implementation "com.iexec.commons:iexec-commons-poco:$iexecCommonsPocoVersion" implementation "com.iexec.common:iexec-common:$iexecCommonVersion" } diff --git a/src/main/java/com/iexec/core/replicate/Replicate.java b/src/main/java/com/iexec/core/replicate/Replicate.java index 25d6255fa..cc191be31 100644 --- a/src/main/java/com/iexec/core/replicate/Replicate.java +++ b/src/main/java/com/iexec/core/replicate/Replicate.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,6 @@ import java.util.Arrays; import java.util.Date; import java.util.List; -import java.util.stream.Collectors; import static com.iexec.common.replicate.ReplicateStatus.CREATED; import static com.iexec.common.replicate.ReplicateStatus.WORKER_LOST; @@ -69,7 +68,7 @@ public ReplicateStatus getLastRelevantStatus() { List statusList = statusUpdateList.stream() .map(ReplicateStatusUpdate::getStatus) - .collect(Collectors.toList()); + .toList(); List ignoredStatuses = Arrays.asList( ReplicateStatus.WORKER_LOST, diff --git a/src/main/java/com/iexec/core/replicate/ReplicateSupplyService.java b/src/main/java/com/iexec/core/replicate/ReplicateSupplyService.java index c980c2bec..0fce6adda 100644 --- a/src/main/java/com/iexec/core/replicate/ReplicateSupplyService.java +++ b/src/main/java/com/iexec/core/replicate/ReplicateSupplyService.java @@ -38,6 +38,7 @@ import com.iexec.core.worker.WorkerService; import jakarta.annotation.PreDestroy; import lombok.extern.slf4j.Slf4j; +import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.retry.annotation.Retryable; import org.springframework.stereotype.Service; @@ -84,7 +85,7 @@ public ReplicateSupplyService(ReplicatesService replicatesService, * - released before any `continue` or `return` * */ - @Retryable(maxAttempts = 5) + @Retryable(retryFor = OptimisticLockingFailureException.class, maxAttempts = 5) Optional getAvailableReplicateTaskSummary(long workerLastBlock, String walletAddress) { // return empty if the worker is not sync //TODO Check if worker node is sync diff --git a/src/main/java/com/iexec/core/replicate/ReplicatesController.java b/src/main/java/com/iexec/core/replicate/ReplicatesController.java index e43638135..238d9c7fd 100644 --- a/src/main/java/com/iexec/core/replicate/ReplicatesController.java +++ b/src/main/java/com/iexec/core/replicate/ReplicatesController.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -155,21 +155,16 @@ public ResponseEntity updateReplicateStatus( return ResponseEntity.ok(updateResult.get()); } - switch (updateResult.getLeft()) { - case ALREADY_REPORTED: - return ResponseEntity.status(HttpStatus.ALREADY_REPORTED) - .body(TaskNotificationType.PLEASE_WAIT); - case NO_ERROR: + return switch (updateResult.getLeft()) { + case ALREADY_REPORTED -> ResponseEntity.status(HttpStatus.ALREADY_REPORTED) + .body(TaskNotificationType.PLEASE_WAIT); + case NO_ERROR -> { log.warn("An error has been detected on replicate update but no error is returned" + " [chainTaskId:{}, statusUpdate:{}]", chainTaskId, statusUpdate); - return ResponseEntity.internalServerError().build(); - case UNKNOWN_REPLICATE: - case UNKNOWN_TASK: - case BAD_WORKFLOW_TRANSITION: - case GENERIC_CANT_UPDATE: - default: - return ResponseEntity.status(HttpStatus.ACCEPTED) - .body(TaskNotificationType.PLEASE_ABORT); - } + yield ResponseEntity.internalServerError().build(); + } + default -> ResponseEntity.status(HttpStatus.ACCEPTED) + .body(TaskNotificationType.PLEASE_ABORT); + }; } } diff --git a/src/main/java/com/iexec/core/replicate/ReplicatesList.java b/src/main/java/com/iexec/core/replicate/ReplicatesList.java index a701a933f..aa78d0587 100644 --- a/src/main/java/com/iexec/core/replicate/ReplicatesList.java +++ b/src/main/java/com/iexec/core/replicate/ReplicatesList.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,6 @@ import org.springframework.data.mongodb.core.mapping.Document; import java.util.*; -import java.util.stream.Collectors; import static com.iexec.common.replicate.ReplicateStatus.*; @@ -95,7 +94,7 @@ public int getNbReplicatesContainingStatus(ReplicateStatus... listStatus) { for (Replicate replicate : replicates) { List listReplicateStatus = replicate.getStatusUpdateList().stream() .map(ReplicateStatusUpdate::getStatus) - .collect(Collectors.toList()); + .toList(); for (ReplicateStatus status : listStatus) { if (listReplicateStatus.contains(status)) { addressReplicates.add(replicate.getWalletAddress()); diff --git a/src/main/java/com/iexec/core/replicate/ReplicatesService.java b/src/main/java/com/iexec/core/replicate/ReplicatesService.java index 71723aa5b..abc1ea799 100644 --- a/src/main/java/com/iexec/core/replicate/ReplicatesService.java +++ b/src/main/java/com/iexec/core/replicate/ReplicatesService.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -190,16 +190,16 @@ public ReplicateStatusUpdateError canUpdateReplicateStatus(Replicate replicate, boolean canUpdate = true; switch (newStatus) { - case CONTRIBUTE_FAILED: - case REVEAL_FAILED: + case CONTRIBUTE_FAILED, + REVEAL_FAILED: canUpdate = false; break; - case CONTRIBUTE_AND_FINALIZE_DONE: - case RESULT_UPLOAD_FAILED: + case CONTRIBUTE_AND_FINALIZE_DONE, + RESULT_UPLOAD_FAILED: canUpdate = verifyStatus(chainTaskId, walletAddress, newStatus, updateReplicateStatusArgs); break; - case CONTRIBUTED: - case REVEALED: + case CONTRIBUTED, + REVEALED: canUpdate = canUpdateToBlockchainSuccess(chainTaskId, replicate, statusUpdate, updateReplicateStatusArgs); break; case RESULT_UPLOADED: @@ -262,7 +262,7 @@ public UpdateReplicateStatusArgs computeUpdateReplicateStatusArgs(String chainTa .build(); } - @Retryable(value = {OptimisticLockingFailureException.class}, maxAttempts = 100) + @Retryable(retryFor = OptimisticLockingFailureException.class, maxAttempts = 100) public Either updateReplicateStatus( String chainTaskId, String walletAddress, diff --git a/src/main/java/com/iexec/core/result/ResultService.java b/src/main/java/com/iexec/core/result/ResultService.java index cdc3c693f..b62b69724 100644 --- a/src/main/java/com/iexec/core/result/ResultService.java +++ b/src/main/java/com/iexec/core/result/ResultService.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ public ResultService(final ResultRepositoryConfiguration resultRepositoryConfigu this.taskService = taskService; } - @Retryable(value = FeignException.class) + @Retryable(retryFor = FeignException.class) public boolean isResultUploaded(final TaskDescription taskDescription) { final String chainTaskId = taskDescription.getChainTaskId(); final ResultProxyClient resultProxyClient = resultRepositoryConfiguration.createResultProxyClientFromURL(taskDescription.getDealParams().getIexecResultStorageProxy()); diff --git a/src/main/java/com/iexec/core/security/WebSecurityConfig.java b/src/main/java/com/iexec/core/security/WebSecurityConfig.java index 908d5bbfc..dd338c7fc 100644 --- a/src/main/java/com/iexec/core/security/WebSecurityConfig.java +++ b/src/main/java/com/iexec/core/security/WebSecurityConfig.java @@ -18,13 +18,13 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; +import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.web.SecurityFilterChain; @Configuration -@EnableGlobalMethodSecurity(prePostEnabled = true) +@EnableMethodSecurity(prePostEnabled = true) public class WebSecurityConfig { @Bean @@ -35,7 +35,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { // No session will be created or used by spring security http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); - http.authorizeRequests() + http.authorizeHttpRequests() .anyRequest().permitAll(); return http.build(); } diff --git a/src/main/java/com/iexec/core/task/TaskController.java b/src/main/java/com/iexec/core/task/TaskController.java index 18c1aaa32..648ada66e 100644 --- a/src/main/java/com/iexec/core/task/TaskController.java +++ b/src/main/java/com/iexec/core/task/TaskController.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,8 +35,6 @@ import org.springframework.web.bind.annotation.*; import org.web3j.utils.Numeric; -import java.util.stream.Collectors; - import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; import static org.springframework.http.ResponseEntity.notFound; @@ -76,7 +74,7 @@ public ResponseEntity getTask(@PathVariable("chainTaskId") String cha taskModel.setReplicates(replicatesService.getReplicates(chainTaskId) .stream() .map(this::buildReplicateModel) - .collect(Collectors.toList())); + .toList()); } return ok(taskModel); }).orElse(notFound().build()); diff --git a/src/main/java/com/iexec/core/task/update/TaskUpdateManager.java b/src/main/java/com/iexec/core/task/update/TaskUpdateManager.java index 7553adb7f..965efd42d 100644 --- a/src/main/java/com/iexec/core/task/update/TaskUpdateManager.java +++ b/src/main/java/com/iexec/core/task/update/TaskUpdateManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2021-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,6 @@ import java.util.List; import java.util.Optional; import java.util.function.Predicate; -import java.util.stream.Collectors; import static com.iexec.core.task.TaskStatus.*; @@ -136,12 +135,12 @@ void updateTask(String chainTaskId) { case FINALIZED: finalizedToCompleted(task); break; - case INITIALIZE_FAILED: - case RUNNING_FAILED: - case CONTRIBUTION_TIMEOUT: - case REOPEN_FAILED: - case RESULT_UPLOAD_TIMEOUT: - case FINALIZE_FAILED: + case INITIALIZE_FAILED, + RUNNING_FAILED, + CONTRIBUTION_TIMEOUT, + REOPEN_FAILED, + RESULT_UPLOAD_TIMEOUT, + FINALIZE_FAILED: toFailed(task); break; case FINAL_DEADLINE_REACHED: @@ -150,8 +149,8 @@ void updateTask(String chainTaskId) { // which will itself fire a generic "abort" notification toFailed(task, FINAL_DEADLINE_REACHED); break; - case COMPLETED: - case FAILED: + case COMPLETED, + FAILED: break; } log.debug("Task update process completed [chainTaskId:{}]", chainTaskId); @@ -521,7 +520,7 @@ private void running2RunningFailed(final Task task, final ReplicatesList replica .map(replicatesList::getReplicateOfWorker) .filter(Optional::isPresent) .map(Optional::get) - .collect(Collectors.toList()); + .toList(); // If at least an alive worker has not run the task, it is not a `RUNNING_FAILURE`. final boolean allAliveWorkersTried = replicatesOfAliveWorkers.size() == aliveWorkers.size(); diff --git a/src/test/java/com/iexec/core/detector/replicate/ContributionAndFinalizationUnnotifiedDetectorTests.java b/src/test/java/com/iexec/core/detector/replicate/ContributionAndFinalizationUnnotifiedDetectorTests.java index 7e8e50c71..e494cd4f5 100644 --- a/src/test/java/com/iexec/core/detector/replicate/ContributionAndFinalizationUnnotifiedDetectorTests.java +++ b/src/test/java/com/iexec/core/detector/replicate/ContributionAndFinalizationUnnotifiedDetectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2023-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,9 +81,9 @@ void init() { private Replicate getReplicateWithStatus(final ReplicateStatus replicateStatus) { Replicate replicate = new Replicate(WALLET_ADDRESS, CHAIN_TASK_ID); - ReplicateStatusUpdate statusUpdate = ReplicateStatusUpdate.builder() + ReplicateStatusUpdate replicateStatusUpdate = ReplicateStatusUpdate.builder() .modifier(WORKER).status(replicateStatus).build(); - replicate.setStatusUpdateList(Collections.singletonList(statusUpdate)); + replicate.setStatusUpdateList(Collections.singletonList(replicateStatusUpdate)); return replicate; } diff --git a/src/test/java/com/iexec/core/detector/replicate/ContributionUnnotifiedDetectorTests.java b/src/test/java/com/iexec/core/detector/replicate/ContributionUnnotifiedDetectorTests.java index 5c0ec4835..c00df9d47 100644 --- a/src/test/java/com/iexec/core/detector/replicate/ContributionUnnotifiedDetectorTests.java +++ b/src/test/java/com/iexec/core/detector/replicate/ContributionUnnotifiedDetectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,6 @@ import java.math.BigInteger; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; import static com.iexec.common.replicate.ReplicateStatus.*; import static com.iexec.common.replicate.ReplicateStatusModifier.WORKER; @@ -192,7 +191,7 @@ void shouldDetectMissedUpdateSinceOnChainDoneNotOffChainDone(ReplicateStatus rep .updateReplicateStatus(any(), any(), statusUpdate.capture()); final List newStatuses = statusUpdate.getAllValues().stream() .map(ReplicateStatusUpdate::getStatus) - .collect(Collectors.toList()); + .toList(); assertThat(newStatuses).isEqualTo(missingStatuses); } diff --git a/src/test/java/com/iexec/core/detector/replicate/RevealUnnotifiedDetectorTests.java b/src/test/java/com/iexec/core/detector/replicate/RevealUnnotifiedDetectorTests.java index f90170453..1bd1d2342 100644 --- a/src/test/java/com/iexec/core/detector/replicate/RevealUnnotifiedDetectorTests.java +++ b/src/test/java/com/iexec/core/detector/replicate/RevealUnnotifiedDetectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,6 @@ import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; import static com.iexec.common.replicate.ReplicateStatus.*; import static com.iexec.common.replicate.ReplicateStatusModifier.WORKER; @@ -196,7 +195,7 @@ void shouldDetectMissedUpdateSinceOnChainDoneNotOffChainDone(ReplicateStatus rep .updateReplicateStatus(any(), any(), statusUpdate.capture()); final List newStatuses = statusUpdate.getAllValues().stream() .map(ReplicateStatusUpdate::getStatus) - .collect(Collectors.toList()); + .toList(); assertThat(newStatuses).isEqualTo(missingStatuses); } diff --git a/src/test/java/com/iexec/core/replicate/ReplicateSupplyServiceTests.java b/src/test/java/com/iexec/core/replicate/ReplicateSupplyServiceTests.java index d8ae200ea..3dd6bd292 100644 --- a/src/test/java/com/iexec/core/replicate/ReplicateSupplyServiceTests.java +++ b/src/test/java/com/iexec/core/replicate/ReplicateSupplyServiceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,7 +48,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; -import java.util.stream.Collectors; import static com.iexec.common.replicate.ReplicateStatus.*; import static com.iexec.core.task.TaskStatus.RUNNING; @@ -71,7 +70,7 @@ class ReplicateSupplyServiceTests { private static final String NO_TEE_TAG = BytesUtils.EMPTY_HEX_STRING_32; private static final String TEE_TAG = TeeUtils.TEE_SCONE_ONLY_TAG; //any supported TEE tag private static final String ENCLAVE_CHALLENGE = "dummyEnclave"; - private static final long maxExecutionTime = 60000; + private static final long MAX_EXECUTION_TIME = 60000; long workerLastBlock = 12; @Mock @@ -144,7 +143,7 @@ void shouldNotGetReplicateSinceNoReplicatesList() { .build(); final Task runningTask = getStubTask(5); - runningTask.setMaxExecutionTime(maxExecutionTime); + runningTask.setMaxExecutionTime(MAX_EXECUTION_TIME); runningTask.setTag(NO_TEE_TAG); runningTask.setContributionDeadline(Date.from(Instant.now().plus(60, ChronoUnit.MINUTES))); runningTask.setEnclaveChallenge(BytesUtils.EMPTY_ADDRESS); @@ -178,7 +177,7 @@ void shouldNotGetReplicateSinceConsensusReachedOnChain() { ); final Task runningTask = getStubTask(5); - runningTask.setMaxExecutionTime(maxExecutionTime); + runningTask.setMaxExecutionTime(MAX_EXECUTION_TIME); runningTask.setTag(NO_TEE_TAG); runningTask.setContributionDeadline(Date.from(Instant.now().plus(60, ChronoUnit.MINUTES))); runningTask.setEnclaveChallenge(BytesUtils.EMPTY_ADDRESS); @@ -236,7 +235,7 @@ void shouldNotGetAnyReplicateSinceWorkerAlreadyParticipated() { .build(); final Task runningTask = getStubTask(5); - runningTask.setMaxExecutionTime(maxExecutionTime); + runningTask.setMaxExecutionTime(MAX_EXECUTION_TIME); runningTask.setTag(NO_TEE_TAG); runningTask.setContributionDeadline(Date.from(Instant.now().plus(60, ChronoUnit.MINUTES))); runningTask.setEnclaveChallenge(BytesUtils.EMPTY_ADDRESS); @@ -271,7 +270,7 @@ void shouldNotGetReplicateSinceDoesNotNeedMoreContributionsForConsensus() { int trust = 5; final Task runningTask = getStubTask(trust); - runningTask.setMaxExecutionTime(maxExecutionTime); + runningTask.setMaxExecutionTime(MAX_EXECUTION_TIME); runningTask.setTag(NO_TEE_TAG); runningTask.setContributionDeadline(Date.from(Instant.now().plus(60, ChronoUnit.MINUTES))); runningTask.setEnclaveChallenge(BytesUtils.EMPTY_ADDRESS); @@ -311,7 +310,7 @@ void shouldNotGetReplicateSinceEnclaveChallengeNeededButNotGenerated() { .build(); final Task runningTask = getStubTask(5); - runningTask.setMaxExecutionTime(maxExecutionTime); + runningTask.setMaxExecutionTime(MAX_EXECUTION_TIME); runningTask.setTag(TEE_TAG); runningTask.setContributionDeadline(Date.from(Instant.now().plus(60, ChronoUnit.MINUTES))); runningTask.setEnclaveChallenge(""); @@ -342,13 +341,13 @@ void shouldGetOnlyOneReplicateSinceOtherOneReachedConsensusDeadline() { int trust = 5; final Task task1 = getStubTask(trust); - task1.setMaxExecutionTime(maxExecutionTime); + task1.setMaxExecutionTime(MAX_EXECUTION_TIME); task1.setContributionDeadline(Date.from(Instant.now().plus(60, ChronoUnit.MINUTES))); task1.setTag(NO_TEE_TAG); task1.setEnclaveChallenge(BytesUtils.EMPTY_ADDRESS); final Task taskDeadlineReached = new Task(DAPP_NAME, COMMAND_LINE, trust, CHAIN_TASK_ID_2); - taskDeadlineReached.setMaxExecutionTime(maxExecutionTime); + taskDeadlineReached.setMaxExecutionTime(MAX_EXECUTION_TIME); taskDeadlineReached.setContributionDeadline(Date.from(Instant.now().minus(60, ChronoUnit.MINUTES))); taskDeadlineReached.setCurrentStatus(RUNNING); taskDeadlineReached.getDateStatusList().add(TaskStatusChange.builder().status(RUNNING).build()); @@ -391,7 +390,7 @@ void shouldNotGetReplicateWhenTaskIsAlreadyBeingAccessed() { .build(); final Task runningTask = getStubTask(5); - runningTask.setMaxExecutionTime(maxExecutionTime); + runningTask.setMaxExecutionTime(MAX_EXECUTION_TIME); runningTask.setTag(NO_TEE_TAG); runningTask.setContributionDeadline(Date.from(Instant.now().plus(60, ChronoUnit.MINUTES))); runningTask.setEnclaveChallenge(BytesUtils.EMPTY_ADDRESS); @@ -420,7 +419,7 @@ void shouldGetReplicateWithNoTee() { .build(); final Task runningTask = getStubTask(5); - runningTask.setMaxExecutionTime(maxExecutionTime); + runningTask.setMaxExecutionTime(MAX_EXECUTION_TIME); runningTask.setTag(NO_TEE_TAG); runningTask.setContributionDeadline(Date.from(Instant.now().plus(60, ChronoUnit.MINUTES))); runningTask.setEnclaveChallenge(BytesUtils.EMPTY_ADDRESS); @@ -462,7 +461,7 @@ void shouldGetReplicateWithTee() { .build(); final Task runningTask = getStubTask(5); - runningTask.setMaxExecutionTime(maxExecutionTime); + runningTask.setMaxExecutionTime(MAX_EXECUTION_TIME); runningTask.setTag(TEE_TAG); runningTask.setContributionDeadline(Date.from(Instant.now().plus(60, ChronoUnit.MINUTES))); runningTask.setEnclaveChallenge(ENCLAVE_CHALLENGE); @@ -504,7 +503,7 @@ void shouldTeeNeededTaskNotBeGivenToTeeDisabledWorker() { .build(); final Task runningTask = getStubTask(5); - runningTask.setMaxExecutionTime(maxExecutionTime); + runningTask.setMaxExecutionTime(MAX_EXECUTION_TIME); runningTask.setTag(TEE_TAG); runningTask.setContributionDeadline(Date.from(Instant.now().plus(60, ChronoUnit.MINUTES))); @@ -531,7 +530,7 @@ void shouldTeeNeededTaskBeGivenToTeeEnabledWorker() { .build(); final Task runningTask = getStubTask(5); - runningTask.setMaxExecutionTime(maxExecutionTime); + runningTask.setMaxExecutionTime(MAX_EXECUTION_TIME); runningTask.setTag(TEE_TAG); runningTask.setContributionDeadline(Date.from(Instant.now().plus(60, ChronoUnit.MINUTES))); runningTask.setEnclaveChallenge(ENCLAVE_CHALLENGE); @@ -953,7 +952,7 @@ void shouldTellReplicateToWaitSinceDetectedResultUpload() { .updateReplicateStatus(eq(CHAIN_TASK_ID), eq(WALLET_WORKER_1), statusUpdate.capture()); //RESULT UPLOADED final List statuses = statusUpdate.getAllValues().stream() .map(ReplicateStatusUpdate::getStatus) - .collect(Collectors.toList()); + .toList(); assertThat(statuses).isEqualTo(List.of(RESULT_UPLOADED, RECOVERING)); } diff --git a/src/test/java/com/iexec/core/security/JwtTokenProviderTests.java b/src/test/java/com/iexec/core/security/JwtTokenProviderTests.java index 1282b8a79..c2527b89f 100644 --- a/src/test/java/com/iexec/core/security/JwtTokenProviderTests.java +++ b/src/test/java/com/iexec/core/security/JwtTokenProviderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,6 @@ import org.springframework.test.util.ReflectionTestUtils; import java.security.SecureRandom; -import java.util.Base64; import java.util.Date; import java.util.concurrent.ConcurrentHashMap; @@ -69,14 +68,14 @@ void shouldResolveToken() { String bearerToken = "Bearer eb604db8eba185df03ea4f5"; String resolvedToken = jwtTokenProvider.resolveToken(bearerToken); assertThat(resolvedToken).isEqualTo(bearerToken.substring(7)); - } + } @Test void shouldNotResolveTokenSinceNotValidOne() { String notBearerToken = "Not " + jwtTokenProvider.getOrCreateToken(WALLET_ADDRESS); String resolvedToken = jwtTokenProvider.resolveToken(notBearerToken); assertThat(resolvedToken).isNull(); - } + } @Test void shouldNotResolveTokenSinceNullOne() { @@ -194,4 +193,4 @@ void shouldNotGetWalletAddressSinceNotValidBearerToken() { } //endregion -} \ No newline at end of file +} diff --git a/src/test/java/com/iexec/core/task/TaskServiceTests.java b/src/test/java/com/iexec/core/task/TaskServiceTests.java index e9a0f5322..2febf5ece 100644 --- a/src/test/java/com/iexec/core/task/TaskServiceTests.java +++ b/src/test/java/com/iexec/core/task/TaskServiceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +55,6 @@ import java.util.*; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicLong; -import java.util.stream.Collectors; import static com.iexec.core.task.TaskService.METRIC_TASKS_STATUSES_COUNT; import static com.iexec.core.task.TaskStatus.*; @@ -171,7 +170,7 @@ void shouldAddTaskASingleTime() { } catch (InterruptedException | TimeoutException e) { throw new RuntimeException(e); } - }).collect(Collectors.toList()); + }).toList(); // Check one execution has added the task, // while the others have failed. @@ -180,7 +179,7 @@ void shouldAddTaskASingleTime() { .stream() .filter(Optional::isPresent) .map(Optional::get) - .collect(Collectors.toList()); + .toList(); assertThat(nonEmptyResults).hasSize(1); assertThat(nonEmptyResults.get(0).getChainTaskId()).isEqualTo(expectedChainTaskId); diff --git a/src/test/java/com/iexec/core/task/update/TaskUpdateManagerTests.java b/src/test/java/com/iexec/core/task/update/TaskUpdateManagerTests.java index e8f77eb67..c763bb8d9 100644 --- a/src/test/java/com/iexec/core/task/update/TaskUpdateManagerTests.java +++ b/src/test/java/com/iexec/core/task/update/TaskUpdateManagerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2021-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,7 +73,6 @@ import java.util.Date; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import java.util.stream.Stream; import static com.iexec.common.replicate.ReplicateStatus.RESULT_UPLOAD_REQUESTED; @@ -834,7 +833,7 @@ void shouldUpdateRunning2RunningFailedOn1Worker() { .getReplicates() .stream() .map(r -> Worker.builder().walletAddress(r.getWalletAddress()).build()) - .collect(Collectors.toList()); + .toList(); mockChainTask(); when(replicatesService.getReplicatesList(task.getChainTaskId())).thenReturn(Optional.of(replicatesList)); @@ -869,7 +868,7 @@ void shouldUpdateRunning2RunningFailedOn2Workers() { .getReplicates() .stream() .map(r -> Worker.builder().walletAddress(r.getWalletAddress()).build()) - .collect(Collectors.toList()); + .toList(); mockChainTask(); when(replicatesService.getReplicatesList(task.getChainTaskId())).thenReturn(Optional.of(replicatesList)); @@ -957,7 +956,7 @@ void shouldNotUpdateRunning2AllWorkersFailedSinceOneStillComputing() { .getReplicates() .stream() .map(r -> Worker.builder().walletAddress(r.getWalletAddress()).build()) - .collect(Collectors.toList()); + .toList(); mockChainTask(); when(replicatesService.getReplicatesList(task.getChainTaskId())).thenReturn(Optional.of(replicatesList)); @@ -1815,7 +1814,7 @@ void shouldNotRequestUploadSinceUploadInProgress() { // region utils private static void assertThatTaskContainsStatuses(Task task, TaskStatus currentStatus, List changesList) { assertThat(task.getCurrentStatus()).isEqualTo(currentStatus); - assertThat(task.getDateStatusList().stream().map(TaskStatusChange::getStatus).collect(Collectors.toList())).isEqualTo(changesList); + assertThat(task.getDateStatusList().stream().map(TaskStatusChange::getStatus).toList()).isEqualTo(changesList); } private void mockChainTask() { diff --git a/src/test/java/com/iexec/core/task/update/TaskUpdateRequestManagerTests.java b/src/test/java/com/iexec/core/task/update/TaskUpdateRequestManagerTests.java index 1cd5579eb..b1dfca17e 100644 --- a/src/test/java/com/iexec/core/task/update/TaskUpdateRequestManagerTests.java +++ b/src/test/java/com/iexec/core/task/update/TaskUpdateRequestManagerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,6 @@ import java.util.*; import java.util.concurrent.*; import java.util.function.Consumer; -import java.util.stream.Collectors; import java.util.stream.Stream; import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; @@ -152,7 +151,7 @@ void shouldNotUpdateAtTheSameTime() { final List updates = Stream.of("1", "1", "2", "2", "1") .map(id -> buildTaskUpdate(id, TaskStatus.RUNNING, new Date(), taskUpdater)) - .collect(Collectors.toList()); + .toList(); updates.forEach(taskUpdateRequestManager.taskUpdateExecutor::execute); await().timeout(30, TimeUnit.SECONDS) @@ -167,7 +166,7 @@ void shouldNotUpdateAtTheSameTime() { for (int updateId : callsOrder) { log.info("[taskId:{}, updateId:{}]", taskForUpdateId.get(updateId), updateId); - final Map foundOutputsForKeyGroup = foundTaskUpdates.computeIfAbsent(taskForUpdateId.get(updateId), (key) -> new HashMap<>()); + final Map foundOutputsForKeyGroup = foundTaskUpdates.computeIfAbsent(taskForUpdateId.get(updateId), key -> new HashMap<>()); for (int alreadyFound : foundOutputsForKeyGroup.keySet()) { if (!Objects.equals(alreadyFound, updateId) && foundOutputsForKeyGroup.get(alreadyFound) < callsPerUpdate) { Assertions.fail("Synchronization has failed: %s has only %s out of %s occurrences while %s has been inserted.", diff --git a/src/test/java/com/iexec/core/worker/WorkerServiceTests.java b/src/test/java/com/iexec/core/worker/WorkerServiceTests.java index bcf023a59..f2dc05282 100644 --- a/src/test/java/com/iexec/core/worker/WorkerServiceTests.java +++ b/src/test/java/com/iexec/core/worker/WorkerServiceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2024 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2025 IEXEC BLOCKCHAIN TECH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,6 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; import java.util.stream.IntStream; import static org.assertj.core.api.Assertions.assertThat; @@ -338,7 +337,7 @@ void addMultipleTaskIds() { final List>> futures = IntStream.range(0, nThreads) .mapToObj(i -> executor.submit(() -> workerService.addChainTaskIdToWorker(new Date().getTime() + "", WORKER1))) - .collect(Collectors.toList()); + .toList(); Awaitility.await() .atMost(Duration.ofMinutes(1)) From 63df4cb3980684156fe35fed98ad67e261fab33d Mon Sep 17 00:00:00 2001 From: Natchica Date: Wed, 8 Jan 2025 18:18:56 +0100 Subject: [PATCH 10/13] Clean buid.gradle --- build.gradle | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index d8b888879..36d6534db 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,7 @@ -buildscript { - ext { - springBootVersion = '3.0.13' - } -} - plugins { id 'java' id 'io.freefair.lombok' version '8.10.2' - id 'org.springframework.boot' version "${springBootVersion}" + id 'org.springframework.boot' version '3.0.13' id 'io.spring.dependency-management' version '1.1.6' id 'jacoco' id 'org.sonarqube' version '5.1.0.4882' @@ -58,8 +52,6 @@ dependencyManagement { } dependencies { - implementation platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}") - // iexec implementation "com.iexec.commons:iexec-commons-poco:$iexecCommonsPocoVersion" implementation "com.iexec.common:iexec-common:$iexecCommonVersion" From 5946dcd8109290dec9177ef2f77413cf3acb3378 Mon Sep 17 00:00:00 2001 From: Natchica Date: Thu, 9 Jan 2025 17:57:31 +0100 Subject: [PATCH 11/13] Revert Dockerfile modification --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 284cfb978..c8e1478a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,9 @@ FROM eclipse-temurin:17.0.13_11-jre-focal ARG jar -RUN test -n "$jar" \ - && apt-get update \ +RUN test -n "$jar" + +RUN apt-get update \ && apt-get install -y --no-install-recommends curl \ && rm -rf /var/lib/apt/lists/* From 97be9b5462873e9f92ff9c02b8619eb17a3b75e1 Mon Sep 17 00:00:00 2001 From: Natchica Date: Fri, 10 Jan 2025 10:54:37 +0100 Subject: [PATCH 12/13] Correct libraries build.gradle --- iexec-core-library/build.gradle | 6 +----- iexec-task-api/build.gradle | 8 ++------ 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/iexec-core-library/build.gradle b/iexec-core-library/build.gradle index 9acc44d7e..824c80de1 100644 --- a/iexec-core-library/build.gradle +++ b/iexec-core-library/build.gradle @@ -5,12 +5,8 @@ plugins { id 'maven-publish' } -ext { - springBootVersion = '3.0.13' -} - dependencies { - implementation platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}") + implementation platform("org.springframework.boot:spring-boot-dependencies:3.0.13") implementation "com.iexec.commons:iexec-commons-poco:$iexecCommonsPocoVersion" implementation "com.iexec.common:iexec-common:$iexecCommonVersion" diff --git a/iexec-task-api/build.gradle b/iexec-task-api/build.gradle index e0f52efb9..5ca719570 100644 --- a/iexec-task-api/build.gradle +++ b/iexec-task-api/build.gradle @@ -5,13 +5,9 @@ plugins { id 'maven-publish' } -ext { - springBootVersion = '3.0.13' -} - dependencies { - implementation platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}") - + implementation platform("org.springframework.boot:spring-boot-dependencies:3.0.13") + implementation "com.iexec.commons:iexec-commons-poco:$iexecCommonsPocoVersion" implementation "com.iexec.common:iexec-common:$iexecCommonVersion" } From 3ae2d86761bae0a44097c8c51c2c6277ad82ec19 Mon Sep 17 00:00:00 2001 From: Natchica Date: Fri, 10 Jan 2025 15:13:47 +0100 Subject: [PATCH 13/13] Update CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d91a683a..b7c47a2c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ All notable changes to this project will be documented in this file. - Upgrade to Spring Boot 3.0.13. (#728) - Upgrade to Spring Cloud 2022.0.5. (#728) - Upgrade to Mongock 5.4.0. (#728) -- Upgrade to `org.springdoc:springdoc-openapi-starter-webmvc-ui` 2.6.0. (#728) +- Upgrade to Spring Doc OpenAPI 2.6.0. (#728) ## [[8.6.0]](https://github.com/iExecBlockchainComputing/iexec-core/releases/tag/v8.6.0) 2024-12-23