From c1fa7bc40228b20feb31c87319705874d4e5600e Mon Sep 17 00:00:00 2001 From: Steven Sheehy <17552371+steven-sheehy@users.noreply.github.com> Date: Thu, 9 Jan 2025 10:24:14 -0600 Subject: [PATCH] Bump Spring Boot from 3.3.5 to 3.4.1 (#10067) * Add a `hedera.mirror.importer.db.partition.enabled=true` property * Bump Gradle from 8.10.1 to 8.11.1 * Bump Spring Boot from 3.3.5 to 3.4.1 * Bump Spring Cloud from 2023.0.4 to 2024.0.0 * Change deprecated `@MockBean` and `@SpyBean` to `@MockitoBean` and `@MockitoSpyBean` * Change property classes to mark nested properties with now required `@Valid` * Change to non-deprecated methods in `RandomStringUtils` * Rename `hedera.mirror.importer.db.maintenance.cron` to `hedera.mirror.importer.db.partition.cron` * Replace incompatible `testcontainers-redis` with a generic Redis container Signed-off-by: Steven Sheehy Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle.kts | 4 +- buildSrc/build.gradle.kts | 2 +- .../main/kotlin/java-conventions.gradle.kts | 13 ++---- docs/configuration.md | 5 ++- gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 3 +- .../common/config/CommonIntegrationTest.java | 1 - .../common/config/RedisTestConfiguration.java | 41 +++++++++++++++++++ .../mirror/common/domain/DomainBuilder.java | 4 +- hedera-mirror-grpc/build.gradle.kts | 1 - .../hedera/mirror/grpc/GrpcProperties.java | 2 + .../grpc/retriever/RetrieverProperties.java | 2 + .../mirror/grpc/GrpcIntegrationTest.java | 16 +------- hedera-mirror-importer/build.gradle.kts | 1 - .../mirror/importer/ImporterProperties.java | 2 + .../importer/db/PartitionMaintenance.java | 9 +++- .../importer/db/PartitionProperties.java | 32 +++++++++++++++ .../CommonDownloaderProperties.java | 2 + .../provider/LocalStreamFileProperties.java | 2 - .../parser/AbstractParserProperties.java | 3 ++ .../parser/CommonParserProperties.java | 41 +++++++++---------- .../record/entity/EntityProperties.java | 5 +++ .../entity/notify/NotifyProperties.java | 2 + .../record/entity/redis/RedisProperties.java | 2 + .../record/entity/sql/SqlProperties.java | 2 + .../record/sidecar/SidecarProperties.java | 2 + .../retention/RetentionProperties.java | 2 +- .../importer/ImporterIntegrationTest.java | 23 +---------- .../AbstractStakingMigrationTest.java | 3 +- ...ressBookServiceEndpointsMigrationTest.java | 3 +- .../AddBlockColumnsMigrationTest.java | 3 +- .../migration/AddNftHistoryMigrationTest.java | 3 +- .../AddNftHistoryRangesMigrationTest.java | 3 +- .../AddRootContractIdMigrationTest.java | 3 +- ...lEthereumTransactionHashMigrationTest.java | 2 +- ...ransactionContractResultMigrationTest.java | 3 +- ...nsactionHashDistributionMigrationTest.java | 3 +- .../migration/CleanupEntityMigrationTest.java | 3 +- .../ClearTokenMetadataMigrationTest.java | 3 +- ...LogsConvertTopicsToBytesMigrationTest.java | 3 +- .../ContractResultMigrationTest.java | 3 +- .../migration/ContractStateMigrationTest.java | 3 +- ...EthereumTransactionValueMigrationTest.java | 3 +- .../migration/CustomFeesMigrationTest.java | 3 +- ....java => DisablePartitionMaintenance.java} | 23 +++++------ .../EntityTimestampMigrationTest.java | 3 +- .../EntityTimestampMigrationV1_46_0Test.java | 3 +- ...xAirdropTokenAssociationMigrationTest.java | 3 +- .../FixAllowanceAmountsMigrationTest.java | 3 +- .../FixTokenAllowanceAmountMigrationTest.java | 3 +- .../migration/GasConsumedMigrationTest.java | 3 +- .../MissingEvmAddressMigrationTest.java | 3 +- .../NestNftTransferMigrationTest.java | 3 +- .../RemoveEntityTypeMigrationTest.java | 3 +- .../RemoveInvalidEntityMigrationTest.java | 3 +- ...rtDeletedTokenDissociateMigrationTest.java | 3 +- ...mePartitionBalanceTablesMigrationTest.java | 3 +- .../migration/TokenAccountMigrationTest.java | 3 +- ...picMessagePayerAccountIdMigrationTest.java | 3 +- ...TransferTransactionPayerMigrationTest.java | 3 +- .../parser/CommonParserPropertiesTest.java | 16 +++++--- .../parser/domain/RecordItemBuilder.java | 2 +- .../EntityRecordItemListenerScheduleTest.java | 2 +- .../performance/PerformanceProperties.java | 10 +++++ .../mirror/monitor/MonitorProperties.java | 6 +++ .../monitor/publish/PublishProperties.java | 2 + .../subscribe/SubscribeProperties.java | 5 ++- hedera-mirror-rest-java/build.gradle.kts | 2 +- .../mirror/restjava/RestJavaProperties.java | 3 ++ .../e2e/acceptance/client/TokenClient.java | 2 +- .../config/AcceptanceTestProperties.java | 2 + .../config/ClientConfiguration.java | 8 ++-- .../e2e/acceptance/steps/EstimateFeature.java | 6 +-- .../steps/EstimatePrecompileFeature.java | 3 +- hedera-mirror-web3/build.gradle.kts | 4 +- .../evm/config/ServicesConfiguration.java | 6 ++- .../mirror/web3/Web3IntegrationTest.java | 4 +- .../mirror/web3/config/LoggingFilterTest.java | 2 +- .../controller/ContractControllerTest.java | 10 ++--- .../controller/OpcodesControllerTest.java | 20 ++++----- ...ctContractCallServiceOpcodeTracerTest.java | 4 +- .../service/ContractCallAddressThisTest.java | 4 +- .../service/ContractCallEvmCodesTest.java | 4 +- 83 files changed, 265 insertions(+), 203 deletions(-) create mode 100644 hedera-mirror-common/src/test/java/com/hedera/mirror/common/config/RedisTestConfiguration.java create mode 100644 hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/db/PartitionProperties.java rename hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/{DisablePartitionMaintenanceConfiguration.java => DisablePartitionMaintenance.java} (53%) diff --git a/build.gradle.kts b/build.gradle.kts index 7cb1e3c027c..e311d6034ae 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -35,7 +35,6 @@ extra.apply { set("nodeJsVersion", "18.20.5") set("protobufVersion", "3.25.5") set("reactorGrpcVersion", "1.2.4") - set("tomcat.version", "10.1.34") // Temporary until next Spring Boot version set("vertxVersion", "4.5.11") set("tuweniVersion", "2.3.1") } @@ -69,7 +68,6 @@ dependencies { api("com.hedera.hashgraph:sdk:2.46.0") api("com.ongres.scram:client:2.1") api("com.playtika.testcontainers:embedded-google-pubsub:3.1.10") - api("com.redis.testcontainers:testcontainers-redis-junit-jupiter:1.4.6") api("com.salesforce.servicelibs:reactor-grpc-stub:$reactorGrpcVersion") api("commons-beanutils:commons-beanutils:1.9.4") api("commons-io:commons-io:2.18.0") @@ -100,7 +98,7 @@ dependencies { api("org.mapstruct:mapstruct-processor:$mapStructVersion") api("org.msgpack:jackson-dataformat-msgpack:0.9.8") api("org.springdoc:springdoc-openapi-webflux-ui:1.8.0") - api("org.springframework.cloud:spring-cloud-dependencies:2023.0.4") + api("org.springframework.cloud:spring-cloud-dependencies:2024.0.0") api("org.testcontainers:junit-jupiter:1.20.4") api("org.mockito:mockito-inline:5.2.0") api("software.amazon.awssdk:bom:2.29.45") diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 1f483736644..dcd7024d6b9 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -50,7 +50,7 @@ dependencies { implementation("org.openapitools:openapi-generator-gradle-plugin:7.10.0") implementation("org.owasp:dependency-check-gradle:11.1.1") implementation("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:6.0.1.5171") - implementation("org.springframework.boot:spring-boot-gradle-plugin:3.3.5") + implementation("org.springframework.boot:spring-boot-gradle-plugin:3.4.1") implementation("org.testcontainers:postgresql:1.20.4") implementation("org.web3j:web3j-gradle-plugin:4.12.3") } diff --git a/buildSrc/src/main/kotlin/java-conventions.gradle.kts b/buildSrc/src/main/kotlin/java-conventions.gradle.kts index 47d4894b66f..6b8cc215b7f 100644 --- a/buildSrc/src/main/kotlin/java-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/java-conventions.gradle.kts @@ -51,22 +51,17 @@ dependencies { testImplementation("org.springframework.boot:spring-boot-starter-test") } -tasks.compileJava { - // Disable serial, and this-escape warnings due to errors in generated code +tasks.withType { + // Disable serial and this-escape warnings due to errors in generated code options.compilerArgs.addAll( - listOf("-Werror", "-Xlint:all", "-Xlint:-serial,-this-escape,-preview") + listOf("-parameters", "-Werror", "-Xlint:all", "-Xlint:-this-escape,-preview") ) options.encoding = "UTF-8" sourceCompatibility = "21" targetCompatibility = "21" } -tasks.compileTestJava { - options.compilerArgs.addAll(listOf("-Werror", "-Xlint:all", "-Xlint:-this-escape,-preview")) - options.encoding = "UTF-8" - sourceCompatibility = "21" - targetCompatibility = "21" -} +tasks.compileJava { options.compilerArgs.add("-Xlint:-serial") } tasks.javadoc { options.encoding = "UTF-8" } diff --git a/docs/configuration.md b/docs/configuration.md index 8d285ee77df..dcbdc9bc3cf 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -39,17 +39,18 @@ value, it is recommended to only populate overridden properties in the custom `a | `hedera.mirror.importer.db.connectionInitSql` | set temp_buffers='256MB'; set timezone TO 'UTC'; | Sql ran on each connection initialized from the datasource | | `hedera.mirror.importer.db.host` | 127.0.0.1 | The IP or hostname used to connect to the database | | `hedera.mirror.importer.db.loadBalance` | true | Whether to enable pgpool load balancing. If false, it sends all reads to the primary db backend instead of load balancing them across the primary and replicas. | +| `hedera.mirror.importer.db.metricRefreshInterval` | 5m | The interval which we wait to refresh database statistics. Specified as a spring duration expression | | `hedera.mirror.importer.db.name` | mirror_node | The name of the database | | `hedera.mirror.importer.db.owner` | mirror_node | The username of the db user with owner permissions to create and modify the schema | | `hedera.mirror.importer.db.ownerPassword` | mirror_node_pass | The password for the owner user the processor uses to connect. | +| `hedera.mirror.importer.db.partition.cron` | 0 0 0 \* \* ? | The cron schedule for creating new partitions This is applicable to the v2 database schema | +| `hedera.mirror.importer.db.partition.enabled` | true | Whether new partitions should be created automatically. This is applicable to the v2 database schema | | `hedera.mirror.importer.db.password` | mirror_importer_pass | The database password for the Importer user the processor uses to connect. | | `hedera.mirror.importer.db.port` | 5432 | The port used to connect to the database | | `hedera.mirror.importer.db.restPassword` | mirror_api_pass | The database password the API uses to connect. | | `hedera.mirror.importer.db.restUsername` | mirror_api | The username the API uses to connect to the database | | `hedera.mirror.importer.db.schema` | public | The name of the custom schema database objects will be created in. This is applicable from v2 of the data schema | | `hedera.mirror.importer.db.username` | mirror_importer | The Importer username the processor uses to connect to the database | -| `hedera.mirror.importer.db.maintenance.cron` | 0 0 0 \* \* ? | The cron schedule for creating new partitions This is applicable from v2 of the data schema | -| `hedera.mirror.importer.db.metricRefreshInterval` | 5m | The interval which we wait to refresh database statistics. Specified as a spring duration expression | | `hedera.mirror.importer.downloader.accessKey` | "" | The cloud storage access key | | `hedera.mirror.importer.downloader.allowAnonymousAccess` | | Whether the cloud storage bucket allows for anonymous access. | | `hedera.mirror.importer.downloader.balance.enabled` | false | Whether to enable balance file downloads | diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0aaefbcaf0f..e2847c82004 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index f5feea6d6b1..f3b75f3b0d4 100755 --- a/gradlew +++ b/gradlew @@ -86,8 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s -' "$PWD" ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/hedera-mirror-common/src/test/java/com/hedera/mirror/common/config/CommonIntegrationTest.java b/hedera-mirror-common/src/test/java/com/hedera/mirror/common/config/CommonIntegrationTest.java index 366f4019b97..e0000d3cb2d 100644 --- a/hedera-mirror-common/src/test/java/com/hedera/mirror/common/config/CommonIntegrationTest.java +++ b/hedera-mirror-common/src/test/java/com/hedera/mirror/common/config/CommonIntegrationTest.java @@ -36,7 +36,6 @@ @SpringBootTest public abstract class CommonIntegrationTest { - public static final String REDIS_IMAGE = "redis:6-alpine"; protected final Logger log = LoggerFactory.getLogger(getClass()); @Resource diff --git a/hedera-mirror-common/src/test/java/com/hedera/mirror/common/config/RedisTestConfiguration.java b/hedera-mirror-common/src/test/java/com/hedera/mirror/common/config/RedisTestConfiguration.java new file mode 100644 index 00000000000..057089bf018 --- /dev/null +++ b/hedera-mirror-common/src/test/java/com/hedera/mirror/common/config/RedisTestConfiguration.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2025 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hedera.mirror.common.config; + +import org.slf4j.LoggerFactory; +import org.springframework.boot.testcontainers.service.connection.ServiceConnection; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.output.Slf4jLogConsumer; +import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.utility.DockerImageName; + +@Configuration(proxyBeanMethods = false) +public class RedisTestConfiguration { + @Bean + @Lazy + @ServiceConnection("redis") + GenericContainer redis() { + var logger = LoggerFactory.getLogger("RedisContainer"); + return new GenericContainer<>(DockerImageName.parse("redis:7.4")) + .waitingFor(Wait.forLogMessage(".*Ready to accept connections.*\\n", 1)) + .withExposedPorts(6379) + .withLogConsumer(new Slf4jLogConsumer(logger, true)); + } +} diff --git a/hedera-mirror-common/src/test/java/com/hedera/mirror/common/domain/DomainBuilder.java b/hedera-mirror-common/src/test/java/com/hedera/mirror/common/domain/DomainBuilder.java index 619acc73814..3ae5b9d8688 100644 --- a/hedera-mirror-common/src/test/java/com/hedera/mirror/common/domain/DomainBuilder.java +++ b/hedera-mirror-common/src/test/java/com/hedera/mirror/common/domain/DomainBuilder.java @@ -1187,11 +1187,11 @@ public byte[] nonZeroBytes(int length) { } public String text(int characters) { - return RandomStringUtils.randomAlphanumeric(characters); + return RandomStringUtils.secure().nextAlphanumeric(characters); } public String hash(int characters) { - return RandomStringUtils.random(characters, "0123456789abcdef"); + return RandomStringUtils.secure().next(characters, "0123456789abcdef"); } /** diff --git a/hedera-mirror-grpc/build.gradle.kts b/hedera-mirror-grpc/build.gradle.kts index 957f41e3220..804471bf7b4 100644 --- a/hedera-mirror-grpc/build.gradle.kts +++ b/hedera-mirror-grpc/build.gradle.kts @@ -51,7 +51,6 @@ dependencies { ) runtimeOnly("org.postgresql:postgresql") testImplementation(project(path = ":common", configuration = "testClasses")) - testImplementation("com.redis.testcontainers:testcontainers-redis-junit-jupiter") testImplementation("io.projectreactor:reactor-test") testImplementation("org.flywaydb:flyway-database-postgresql") testImplementation("org.springframework.boot:spring-boot-testcontainers") diff --git a/hedera-mirror-grpc/src/main/java/com/hedera/mirror/grpc/GrpcProperties.java b/hedera-mirror-grpc/src/main/java/com/hedera/mirror/grpc/GrpcProperties.java index 87d5b556e3e..40838f102e7 100644 --- a/hedera-mirror-grpc/src/main/java/com/hedera/mirror/grpc/GrpcProperties.java +++ b/hedera-mirror-grpc/src/main/java/com/hedera/mirror/grpc/GrpcProperties.java @@ -17,6 +17,7 @@ package com.hedera.mirror.grpc; import com.hedera.mirror.grpc.config.NettyProperties; +import jakarta.validation.Valid; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotNull; import java.time.Duration; @@ -38,5 +39,6 @@ public class GrpcProperties { private int entityCacheSize = 50_000; @NotNull + @Valid private NettyProperties netty = new NettyProperties(); } diff --git a/hedera-mirror-grpc/src/main/java/com/hedera/mirror/grpc/retriever/RetrieverProperties.java b/hedera-mirror-grpc/src/main/java/com/hedera/mirror/grpc/retriever/RetrieverProperties.java index bd11f2d1b2e..62f161abb54 100644 --- a/hedera-mirror-grpc/src/main/java/com/hedera/mirror/grpc/retriever/RetrieverProperties.java +++ b/hedera-mirror-grpc/src/main/java/com/hedera/mirror/grpc/retriever/RetrieverProperties.java @@ -16,6 +16,7 @@ package com.hedera.mirror.grpc.retriever; +import jakarta.validation.Valid; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotNull; import java.time.Duration; @@ -44,6 +45,7 @@ public class RetrieverProperties { private Duration timeout = Duration.ofSeconds(60L); @NotNull + @Valid private UnthrottledProperties unthrottled = new UnthrottledProperties(); @Data diff --git a/hedera-mirror-grpc/src/test/java/com/hedera/mirror/grpc/GrpcIntegrationTest.java b/hedera-mirror-grpc/src/test/java/com/hedera/mirror/grpc/GrpcIntegrationTest.java index 62d23a073f2..e5eb540249f 100644 --- a/hedera-mirror-grpc/src/test/java/com/hedera/mirror/grpc/GrpcIntegrationTest.java +++ b/hedera-mirror-grpc/src/test/java/com/hedera/mirror/grpc/GrpcIntegrationTest.java @@ -17,33 +17,21 @@ package com.hedera.mirror.grpc; import com.hedera.mirror.common.config.CommonIntegrationTest; +import com.hedera.mirror.common.config.RedisTestConfiguration; import com.hedera.mirror.grpc.GrpcIntegrationTest.Configuration; -import com.redis.testcontainers.RedisContainer; -import org.slf4j.LoggerFactory; import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.boot.testcontainers.service.connection.ServiceConnection; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Primary; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.support.TransactionOperations; import org.springframework.transaction.support.TransactionTemplate; -import org.testcontainers.containers.output.Slf4jLogConsumer; -import org.testcontainers.utility.DockerImageName; -@Import(Configuration.class) +@Import({Configuration.class, RedisTestConfiguration.class}) public abstract class GrpcIntegrationTest extends CommonIntegrationTest { @TestConfiguration(proxyBeanMethods = false) static class Configuration { - @Bean - @ServiceConnection("redis") - RedisContainer redis() { - var logger = LoggerFactory.getLogger(RedisContainer.class); - return new RedisContainer(DockerImageName.parse(REDIS_IMAGE)) - .withLogConsumer(new Slf4jLogConsumer(logger, true)); - } - @Bean @Primary TransactionOperations transactionOperations(PlatformTransactionManager transactionManager) { diff --git a/hedera-mirror-importer/build.gradle.kts b/hedera-mirror-importer/build.gradle.kts index 32fa5ac57c7..6b5954ae560 100644 --- a/hedera-mirror-importer/build.gradle.kts +++ b/hedera-mirror-importer/build.gradle.kts @@ -59,7 +59,6 @@ dependencies { testImplementation(project(path = ":common", configuration = "testClasses")) testImplementation("com.github.vertical-blank:sql-formatter") testImplementation("com.playtika.testcontainers:embedded-google-pubsub") - testImplementation("com.redis.testcontainers:testcontainers-redis-junit-jupiter") testImplementation("commons-beanutils:commons-beanutils") testImplementation("io.projectreactor:reactor-test") testImplementation("org.apache.commons:commons-math3") diff --git a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/ImporterProperties.java b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/ImporterProperties.java index 3ba1e23ba5b..b37164ee915 100644 --- a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/ImporterProperties.java +++ b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/ImporterProperties.java @@ -18,6 +18,7 @@ import com.hedera.mirror.importer.migration.MigrationProperties; import com.hedera.mirror.importer.util.Utility; +import jakarta.validation.Valid; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; @@ -60,6 +61,7 @@ public class ImporterProperties { private Path initialAddressBook; @NotNull + @Valid private Map migration = new CaseInsensitiveMap<>(); @NotBlank diff --git a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/db/PartitionMaintenance.java b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/db/PartitionMaintenance.java index 712499edf89..eb76abcc2eb 100644 --- a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/db/PartitionMaintenance.java +++ b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/db/PartitionMaintenance.java @@ -32,16 +32,23 @@ @Named @RequiredArgsConstructor public class PartitionMaintenance { + private static final String RUN_MAINTENANCE_QUERY = "call create_mirror_node_time_partitions()"; @Owner private final JdbcTemplate jdbcTemplate; + private final PartitionProperties partitionProperties; + @EventListener(ApplicationReadyEvent.class) @Leader @Retryable - @Scheduled(cron = "${hedera.mirror.importer.db.maintenance.cron:0 0 0 * * ?}") + @Scheduled(cron = "${hedera.mirror.importer.db.partition.cron:0 0 0 * * ?}") public synchronized void runMaintenance() { + if (!partitionProperties.isEnabled()) { + return; + } + log.info("Running partition maintenance"); Stopwatch stopwatch = Stopwatch.createStarted(); jdbcTemplate.execute(RUN_MAINTENANCE_QUERY); diff --git a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/db/PartitionProperties.java b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/db/PartitionProperties.java new file mode 100644 index 00000000000..fefd766dc86 --- /dev/null +++ b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/db/PartitionProperties.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2025 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hedera.mirror.importer.db; + +import jakarta.validation.constraints.NotBlank; +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.validation.annotation.Validated; + +@ConfigurationProperties("hedera.mirror.importer.db.partition") +@Data +@Validated +public class PartitionProperties { + @NotBlank + private String cron = "0 0 0 * * ?"; + + private boolean enabled = true; +} diff --git a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/downloader/CommonDownloaderProperties.java b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/downloader/CommonDownloaderProperties.java index 5ec56f22a1e..9e27d0f5339 100644 --- a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/downloader/CommonDownloaderProperties.java +++ b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/downloader/CommonDownloaderProperties.java @@ -19,6 +19,7 @@ import com.hedera.mirror.importer.ImporterProperties; import com.hedera.mirror.importer.ImporterProperties.HederaNetwork; import jakarta.annotation.PostConstruct; +import jakarta.validation.Valid; import jakarta.validation.constraints.Max; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotNull; @@ -86,6 +87,7 @@ public class CommonDownloaderProperties { private String secretKey; @NotNull + @Valid private List sources = new ArrayList<>(); @DurationMin(seconds = 1) diff --git a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/downloader/provider/LocalStreamFileProperties.java b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/downloader/provider/LocalStreamFileProperties.java index 107f016d58a..36df8e009ea 100644 --- a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/downloader/provider/LocalStreamFileProperties.java +++ b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/downloader/provider/LocalStreamFileProperties.java @@ -17,12 +17,10 @@ package com.hedera.mirror.importer.downloader.provider; import lombok.Data; -import lombok.RequiredArgsConstructor; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.validation.annotation.Validated; @Data -@RequiredArgsConstructor @Validated @ConfigurationProperties("hedera.mirror.importer.downloader.local") public class LocalStreamFileProperties { diff --git a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/AbstractParserProperties.java b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/AbstractParserProperties.java index 30fd6a1f838..04112cd33cf 100644 --- a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/AbstractParserProperties.java +++ b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/AbstractParserProperties.java @@ -16,6 +16,7 @@ package com.hedera.mirror.importer.parser; +import jakarta.validation.Valid; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotNull; import java.time.Duration; @@ -30,6 +31,7 @@ public abstract class AbstractParserProperties implements ParserProperties { @NotNull + @Valid protected BatchProperties batch = new BatchProperties(); protected boolean enabled = true; @@ -43,6 +45,7 @@ public abstract class AbstractParserProperties implements ParserProperties { protected Duration processingTimeout = Duration.ofSeconds(10L); @NotNull + @Valid protected RetryProperties retry = new RetryProperties(); @DurationMin(seconds = 1) diff --git a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/CommonParserProperties.java b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/CommonParserProperties.java index fba8b53aae2..fdd31b210a8 100644 --- a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/CommonParserProperties.java +++ b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/CommonParserProperties.java @@ -21,6 +21,7 @@ import com.hedera.mirror.common.domain.transaction.TransactionType; import com.hedera.mirror.importer.domain.TransactionFilterFields; import com.hedera.mirror.importer.exception.InvalidConfigurationException; +import jakarta.validation.Valid; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotNull; import java.util.ArrayList; @@ -30,18 +31,14 @@ import java.util.Objects; import java.util.Set; import java.util.function.Predicate; -import lombok.AccessLevel; -import lombok.Builder; import lombok.Data; import lombok.Getter; -import lombok.Value; import org.apache.commons.lang3.StringUtils; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.expression.AccessException; import org.springframework.expression.EvaluationContext; import org.springframework.expression.EvaluationException; import org.springframework.expression.Expression; -import org.springframework.expression.ExpressionParser; import org.springframework.expression.ParseException; import org.springframework.expression.TypeLocator; import org.springframework.expression.spel.SpelEvaluationException; @@ -52,18 +49,20 @@ import org.springframework.util.CollectionUtils; import org.springframework.validation.annotation.Validated; +@ConfigurationProperties("hedera.mirror.importer.parser") @Data @Validated -@ConfigurationProperties("hedera.mirror.importer.parser") public class CommonParserProperties { @Min(8192) private int bufferSize = 32768; // tested max byte size of buffer used by PGCopyOutputStream @NotNull + @Valid private Collection exclude = new ArrayList<>(); @NotNull + @Valid private Collection include = new ArrayList<>(); @Getter(lazy = true) @@ -87,40 +86,37 @@ private Predicate includeFilter() { return include.stream().map(TransactionFilter::getFilter).reduce(a -> false, Predicate::or); } - @Value + @Data + @Validated static class TransactionFilter { private static final StandardEvaluationContext evaluationContext = new StandardEvaluationContext(); - private static final ExpressionParser expressionParser = new SpelExpressionParser(); static { evaluationContext.setTypeLocator(new RestrictedTypeLocator()); evaluationContext.setPropertyAccessors(List.of(new RecordItemPropertyAccessor())); } - private final Collection entity; - private final String expression; + private Collection entity = new LinkedHashSet<>(); - @Getter(AccessLevel.NONE) - private final Expression parsedExpression; + private String expression; - private final Collection transaction; + @Getter(lazy = true) + private final Expression parsedExpression = parseExpression(); - @Builder - TransactionFilter(Collection entity, String expression, Collection transaction) { - this.entity = entity != null ? entity : new LinkedHashSet<>(); - this.expression = expression; - this.transaction = transaction != null ? transaction : new LinkedHashSet<>(); + private Collection transaction = new LinkedHashSet<>(); + private Expression parseExpression() { if (!StringUtils.isEmpty(expression)) { try { - this.parsedExpression = expressionParser.parseExpression(expression); + var expressionParser = new SpelExpressionParser(); + return expressionParser.parseExpression(expression); } catch (ParseException ex) { throw new InvalidConfigurationException("Transaction filter expression failed to parse", ex); } - } else { - this.parsedExpression = null; } + + return null; } Predicate getFilter() { @@ -144,12 +140,13 @@ private boolean matches(Collection entities) { } private boolean matchesExpression(RecordItem recordItem) { - if (parsedExpression == null) { + var expressionParsed = getParsedExpression(); + if (expressionParsed == null) { return true; } try { - Boolean result = parsedExpression.getValue(evaluationContext, recordItem, Boolean.class); + Boolean result = expressionParsed.getValue(evaluationContext, recordItem, Boolean.class); return Objects.requireNonNullElse(result, false); } catch (EvaluationException ex) { throw new InvalidConfigurationException( diff --git a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/record/entity/EntityProperties.java b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/record/entity/EntityProperties.java index 3ef62c0ceca..cc79430bea2 100644 --- a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/record/entity/EntityProperties.java +++ b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/record/entity/EntityProperties.java @@ -22,20 +22,25 @@ import com.hedera.mirror.common.domain.entity.EntityId; import com.hedera.mirror.common.domain.transaction.TransactionType; +import jakarta.validation.Valid; import jakarta.validation.constraints.NotNull; import java.util.EnumSet; import java.util.Set; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.validation.annotation.Validated; @Data @ConfigurationProperties("hedera.mirror.importer.parser.record.entity") +@Validated public class EntityProperties { @NotNull + @Valid private PersistProperties persist = new PersistProperties(); @Data + @Validated public static class PersistProperties { private boolean claims = false; diff --git a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/record/entity/notify/NotifyProperties.java b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/record/entity/notify/NotifyProperties.java index 43d20723175..009ca54f726 100644 --- a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/record/entity/notify/NotifyProperties.java +++ b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/record/entity/notify/NotifyProperties.java @@ -20,10 +20,12 @@ import com.hedera.mirror.importer.parser.record.entity.ConditionOnEntityRecordParser; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.validation.annotation.Validated; @Data @ConditionOnEntityRecordParser @ConfigurationProperties("hedera.mirror.importer.parser.record.entity.notify") +@Validated public class NotifyProperties implements BatchPublisherProperties { private boolean enabled = false; diff --git a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/record/entity/redis/RedisProperties.java b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/record/entity/redis/RedisProperties.java index 2804c247535..3008ec607b7 100644 --- a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/record/entity/redis/RedisProperties.java +++ b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/record/entity/redis/RedisProperties.java @@ -21,10 +21,12 @@ import jakarta.validation.constraints.Min; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.validation.annotation.Validated; @Data @ConditionOnEntityRecordParser @ConfigurationProperties("hedera.mirror.importer.parser.record.entity.redis") +@Validated public class RedisProperties implements BatchPublisherProperties { private boolean enabled = true; diff --git a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/record/entity/sql/SqlProperties.java b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/record/entity/sql/SqlProperties.java index edb36de63da..208e1f98181 100644 --- a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/record/entity/sql/SqlProperties.java +++ b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/record/entity/sql/SqlProperties.java @@ -19,10 +19,12 @@ import com.hedera.mirror.importer.parser.record.entity.ConditionOnEntityRecordParser; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.validation.annotation.Validated; @Data @ConditionOnEntityRecordParser @ConfigurationProperties("hedera.mirror.importer.parser.record.entity.sql") +@Validated public class SqlProperties { private boolean enabled = true; diff --git a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/record/sidecar/SidecarProperties.java b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/record/sidecar/SidecarProperties.java index e466ece0e8d..cdebe907636 100644 --- a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/record/sidecar/SidecarProperties.java +++ b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/parser/record/sidecar/SidecarProperties.java @@ -22,9 +22,11 @@ import java.util.Set; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.validation.annotation.Validated; @Data @ConfigurationProperties("hedera.mirror.importer.parser.record.sidecar") +@Validated public class SidecarProperties { private boolean enabled = false; diff --git a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/retention/RetentionProperties.java b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/retention/RetentionProperties.java index 7dd15caacd1..48fcba0f5d4 100644 --- a/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/retention/RetentionProperties.java +++ b/hedera-mirror-importer/src/main/java/com/hedera/mirror/importer/retention/RetentionProperties.java @@ -25,8 +25,8 @@ import org.springframework.stereotype.Component; import org.springframework.validation.annotation.Validated; +@Component("retentionProperties") @Data -@Component @ConfigurationProperties("hedera.mirror.importer.retention") @Validated public class RetentionProperties { diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/ImporterIntegrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/ImporterIntegrationTest.java index 3eafed5f99e..6b0d955865d 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/ImporterIntegrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/ImporterIntegrationTest.java @@ -19,13 +19,12 @@ import com.google.common.base.CaseFormat; import com.google.common.collect.Range; import com.hedera.mirror.common.config.CommonIntegrationTest; +import com.hedera.mirror.common.config.RedisTestConfiguration; import com.hedera.mirror.common.converter.EntityIdConverter; import com.hedera.mirror.common.domain.entity.EntityId; -import com.hedera.mirror.importer.ImporterIntegrationTest.Configuration; import com.hedera.mirror.importer.config.DateRangeCalculator; import com.hedera.mirror.importer.converter.JsonbToListConverter; import com.hedera.mirror.importer.parser.record.entity.ParserContext; -import com.redis.testcontainers.RedisContainer; import io.hypersistence.utils.hibernate.type.range.guava.PostgreSQLGuavaRangeType; import jakarta.annotation.Resource; import jakarta.persistence.Id; @@ -50,22 +49,16 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.postgresql.jdbc.PgArray; import org.postgresql.util.PGobject; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.boot.testcontainers.service.connection.ServiceConnection; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; import org.springframework.core.annotation.AnnotationUtils; import org.springframework.core.convert.support.DefaultConversionService; import org.springframework.jdbc.core.DataClassRowMapper; import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.RowMapper; -import org.testcontainers.containers.output.Slf4jLogConsumer; -import org.testcontainers.utility.DockerImageName; @ExtendWith(SoftAssertionsExtension.class) -@Import(Configuration.class) +@Import(RedisTestConfiguration.class) public abstract class ImporterIntegrationTest extends CommonIntegrationTest { private static final Map, String> DEFAULT_DOMAIN_CLASS_IDS = new ConcurrentHashMap<>(); @@ -169,16 +162,4 @@ private String getDefaultIdColumns(Class entityClass) { return !idColumns.isEmpty() ? idColumns : "id"; } - - @TestConfiguration(proxyBeanMethods = false) - static class Configuration { - - @Bean - @ServiceConnection("redis") - RedisContainer redis() { - var logger = LoggerFactory.getLogger(RedisContainer.class); - return new RedisContainer(DockerImageName.parse(REDIS_IMAGE)) - .withLogConsumer(new Slf4jLogConsumer(logger, true)); - } - } } diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/AbstractStakingMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/AbstractStakingMigrationTest.java index 9dfe65dfa9a..36610de840c 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/AbstractStakingMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/AbstractStakingMigrationTest.java @@ -25,10 +25,9 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; -import org.springframework.context.annotation.Import; import org.springframework.jdbc.core.RowMapper; -@Import(DisablePartitionMaintenanceConfiguration.class) +@DisablePartitionMaintenance abstract class AbstractStakingMigrationTest extends RecordFileMigrationTest { private static final RowMapper ENTITY_ROW_MAPPER = rowMapper(Entity.class); diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/AddAddressBookServiceEndpointsMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/AddAddressBookServiceEndpointsMigrationTest.java index 990d209a9fa..416386031f8 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/AddAddressBookServiceEndpointsMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/AddAddressBookServiceEndpointsMigrationTest.java @@ -43,14 +43,13 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.RowMapper; import org.springframework.test.context.TestPropertySource; +@DisablePartitionMaintenance @DisableRepeatableSqlMigration @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @RequiredArgsConstructor @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=1.37.0") diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/AddBlockColumnsMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/AddBlockColumnsMigrationTest.java index 27701bfaea7..98e469a6778 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/AddBlockColumnsMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/AddBlockColumnsMigrationTest.java @@ -33,7 +33,6 @@ import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.context.ApplicationContextInitializer; import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.Import; import org.springframework.core.env.Profiles; import org.springframework.core.io.Resource; import org.springframework.jdbc.core.JdbcTemplate; @@ -41,9 +40,9 @@ import org.springframework.util.StreamUtils; @ContextConfiguration(initializers = AddBlockColumnsMigrationTest.Initializer.class) +@DisablePartitionMaintenance @DisableRepeatableSqlMigration @RequiredArgsConstructor -@Import(DisablePartitionMaintenanceConfiguration.class) @Tag("migration") public class AddBlockColumnsMigrationTest extends RecordFileMigrationTest { diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/AddNftHistoryMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/AddNftHistoryMigrationTest.java index 61ba7bb3477..93fb6113caf 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/AddNftHistoryMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/AddNftHistoryMigrationTest.java @@ -39,14 +39,13 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.core.io.Resource; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.TestPropertySource; import org.springframework.util.StreamUtils; +@DisablePartitionMaintenance @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @RequiredArgsConstructor @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=1.81.0") diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/AddNftHistoryRangesMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/AddNftHistoryRangesMigrationTest.java index c5fa19bf03a..d2d42c6ee53 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/AddNftHistoryRangesMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/AddNftHistoryRangesMigrationTest.java @@ -31,14 +31,13 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.RowMapper; import org.springframework.test.context.TestPropertySource; +@DisablePartitionMaintenance @DisableRepeatableSqlMigration @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @RequiredArgsConstructor @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=1.87.2") diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/AddRootContractIdMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/AddRootContractIdMigrationTest.java index 5eacd604ef9..6eb30d08249 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/AddRootContractIdMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/AddRootContractIdMigrationTest.java @@ -33,14 +33,13 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.jdbc.core.BeanPropertyRowMapper; import org.springframework.jdbc.core.JdbcOperations; import org.springframework.test.context.TestPropertySource; +@DisablePartitionMaintenance @DisableRepeatableSqlMigration @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=1.51.0") class AddRootContractIdMigrationTest extends ImporterIntegrationTest { diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/BackfillEthereumTransactionHashMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/BackfillEthereumTransactionHashMigrationTest.java index c6048f34196..16a5ec38fe2 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/BackfillEthereumTransactionHashMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/BackfillEthereumTransactionHashMigrationTest.java @@ -39,12 +39,12 @@ import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; +import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import org.testcontainers.shaded.org.apache.commons.lang.ArrayUtils; @RequiredArgsConstructor @Tag("migration") diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/BackfillFailedEthereumTransactionContractResultMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/BackfillFailedEthereumTransactionContractResultMigrationTest.java index a0f12c08dad..1294e997447 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/BackfillFailedEthereumTransactionContractResultMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/BackfillFailedEthereumTransactionContractResultMigrationTest.java @@ -44,14 +44,13 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.core.io.Resource; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.TestPropertySource; import org.springframework.util.StreamUtils; +@DisablePartitionMaintenance @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @RequiredArgsConstructor @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=1.79.0") diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/ChangeTransactionHashDistributionMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/ChangeTransactionHashDistributionMigrationTest.java index 4b1e5a75e8c..ba48098112f 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/ChangeTransactionHashDistributionMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/ChangeTransactionHashDistributionMigrationTest.java @@ -33,15 +33,14 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.core.io.Resource; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.TestPropertySource; import org.springframework.util.StreamUtils; +@DisablePartitionMaintenance @DisableRepeatableSqlMigration @EnabledIfV2 -@Import(DisablePartitionMaintenanceConfiguration.class) @RequiredArgsConstructor @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=2.4.0") diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/CleanupEntityMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/CleanupEntityMigrationTest.java index 14166667c78..c1fe1130d06 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/CleanupEntityMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/CleanupEntityMigrationTest.java @@ -44,13 +44,12 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.jdbc.core.JdbcOperations; import org.springframework.test.context.TestPropertySource; +@DisablePartitionMaintenance @DisableRepeatableSqlMigration @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @RequiredArgsConstructor @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=1.35.5") diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/ClearTokenMetadataMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/ClearTokenMetadataMigrationTest.java index 9600cf67d90..6137378d408 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/ClearTokenMetadataMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/ClearTokenMetadataMigrationTest.java @@ -43,13 +43,12 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.core.io.Resource; import org.springframework.test.context.TestPropertySource; import org.springframework.util.StreamUtils; +@DisablePartitionMaintenance @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @RequiredArgsConstructor @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=1.97.1") diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/ContractLogsConvertTopicsToBytesMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/ContractLogsConvertTopicsToBytesMigrationTest.java index 3b3099f84cd..847f985573f 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/ContractLogsConvertTopicsToBytesMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/ContractLogsConvertTopicsToBytesMigrationTest.java @@ -37,14 +37,13 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.jdbc.core.BeanPropertyRowMapper; import org.springframework.jdbc.core.JdbcOperations; import org.springframework.test.context.TestPropertySource; +@DisablePartitionMaintenance @DisableRepeatableSqlMigration @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @RequiredArgsConstructor @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=1.51.1") diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/ContractResultMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/ContractResultMigrationTest.java index 69c4e4f18a3..405712eae60 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/ContractResultMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/ContractResultMigrationTest.java @@ -35,15 +35,14 @@ import org.apache.commons.codec.binary.Hex; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; import org.springframework.jdbc.core.DataClassRowMapper; import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.RowMapper; import org.springframework.test.context.TestPropertySource; +@DisablePartitionMaintenance @DisableRepeatableSqlMigration @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=1.46.7") class ContractResultMigrationTest extends ImporterIntegrationTest { diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/ContractStateMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/ContractStateMigrationTest.java index 2fda3368c71..d85bb8034db 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/ContractStateMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/ContractStateMigrationTest.java @@ -35,12 +35,11 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.TestPropertySource; +@DisablePartitionMaintenance @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @RequiredArgsConstructor @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=1.67.0") diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/ConvertEthereumTransactionValueMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/ConvertEthereumTransactionValueMigrationTest.java index b08202591c8..58b7276650f 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/ConvertEthereumTransactionValueMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/ConvertEthereumTransactionValueMigrationTest.java @@ -31,13 +31,12 @@ import lombok.RequiredArgsConstructor; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.TestPropertySource; +@DisablePartitionMaintenance @DisableRepeatableSqlMigration @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @RequiredArgsConstructor @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=1.59.2") diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/CustomFeesMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/CustomFeesMigrationTest.java index 34cca575ae6..48b8eedb48c 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/CustomFeesMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/CustomFeesMigrationTest.java @@ -47,7 +47,6 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.core.io.Resource; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.datasource.DataSourceTransactionManager; @@ -55,9 +54,9 @@ import org.springframework.transaction.support.TransactionTemplate; import org.springframework.util.StreamUtils; +@DisablePartitionMaintenance @RequiredArgsConstructor @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @Tag("migration") @TestPropertySource(properties = {"spring.flyway.target=1.85.1"}) class CustomFeesMigrationTest extends ImporterIntegrationTest { diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/DisablePartitionMaintenanceConfiguration.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/DisablePartitionMaintenance.java similarity index 53% rename from hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/DisablePartitionMaintenanceConfiguration.java rename to hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/DisablePartitionMaintenance.java index 035e3923a70..f1578d9b322 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/DisablePartitionMaintenanceConfiguration.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/DisablePartitionMaintenance.java @@ -16,18 +16,17 @@ package com.hedera.mirror.importer.migration; -import com.hedera.mirror.importer.db.PartitionMaintenance; -import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.boot.test.mock.mockito.MockBean; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import org.springframework.test.context.TestPropertySource; /** - * Configuration for migration tests whose target is before the migration that creates account_balance and token_balance - * partitions. Purpose is to disable partition maintenance job by a mock bean so the test application context won't fail - * to start. + * Disable migration tests whose target is before the migration that creates account_balance and token_balance + * partitions. */ -@TestConfiguration -public class DisablePartitionMaintenanceConfiguration { - - @MockBean - private PartitionMaintenance partitionMaintenance; -} +@Target({ElementType.TYPE}) +@TestPropertySource(properties = "hedera.mirror.importer.db.partition.enabled=false") +@Retention(RetentionPolicy.RUNTIME) +public @interface DisablePartitionMaintenance {} diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/EntityTimestampMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/EntityTimestampMigrationTest.java index f4066ef0828..f9384789df0 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/EntityTimestampMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/EntityTimestampMigrationTest.java @@ -38,14 +38,13 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.jdbc.core.BeanPropertyRowMapper; import org.springframework.jdbc.core.JdbcOperations; import org.springframework.test.context.TestPropertySource; +@DisablePartitionMaintenance @DisableRepeatableSqlMigration @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=1.39.2") class EntityTimestampMigrationTest extends ImporterIntegrationTest { diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/EntityTimestampMigrationV1_46_0Test.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/EntityTimestampMigrationV1_46_0Test.java index 29035a2114e..03251d09890 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/EntityTimestampMigrationV1_46_0Test.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/EntityTimestampMigrationV1_46_0Test.java @@ -39,14 +39,13 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.jdbc.core.BeanPropertyRowMapper; import org.springframework.jdbc.core.JdbcOperations; import org.springframework.test.context.TestPropertySource; +@DisablePartitionMaintenance @DisableRepeatableSqlMigration @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @TestPropertySource(properties = "spring.flyway.target=1.45.1") @Tag("migration") class EntityTimestampMigrationV1_46_0Test extends ImporterIntegrationTest { diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/FixAirdropTokenAssociationMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/FixAirdropTokenAssociationMigrationTest.java index b6e41d3f47f..fbd8d057de8 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/FixAirdropTokenAssociationMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/FixAirdropTokenAssociationMigrationTest.java @@ -51,13 +51,12 @@ import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.context.ApplicationContextInitializer; import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.Import; import org.springframework.core.env.Profiles; import org.springframework.test.context.ContextConfiguration; +@DisablePartitionMaintenance @ContextConfiguration(initializers = FixAirdropTokenAssociationMigrationTest.Initializer.class) @DisableRepeatableSqlMigration -@Import(DisablePartitionMaintenanceConfiguration.class) @Tag("migration") class FixAirdropTokenAssociationMigrationTest extends ImporterIntegrationTest { diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/FixAllowanceAmountsMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/FixAllowanceAmountsMigrationTest.java index f6fce6964a8..7b0c53fe34e 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/FixAllowanceAmountsMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/FixAllowanceAmountsMigrationTest.java @@ -36,14 +36,13 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.core.io.Resource; import org.springframework.jdbc.core.JdbcOperations; import org.springframework.test.context.TestPropertySource; import org.springframework.util.StreamUtils; +@DisablePartitionMaintenance @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @RequiredArgsConstructor @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=1.84.1") diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/FixTokenAllowanceAmountMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/FixTokenAllowanceAmountMigrationTest.java index 936f880c64a..a3043639337 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/FixTokenAllowanceAmountMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/FixTokenAllowanceAmountMigrationTest.java @@ -32,15 +32,14 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.core.io.Resource; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.TestPropertySource; import org.springframework.transaction.support.TransactionTemplate; import org.springframework.util.StreamUtils; +@DisablePartitionMaintenance @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @RequiredArgsConstructor @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=1.87.0") diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/GasConsumedMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/GasConsumedMigrationTest.java index 98bfa8b039e..7ad5865a9f5 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/GasConsumedMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/GasConsumedMigrationTest.java @@ -41,15 +41,14 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.core.io.Resource; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.TestPropertySource; import org.springframework.transaction.support.TransactionTemplate; import org.springframework.util.StreamUtils; +@DisablePartitionMaintenance @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @RequiredArgsConstructor @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=1.94.0") diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/MissingEvmAddressMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/MissingEvmAddressMigrationTest.java index c9c75154285..5d5b0e647d1 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/MissingEvmAddressMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/MissingEvmAddressMigrationTest.java @@ -38,12 +38,11 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; +@DisablePartitionMaintenance @DisableRepeatableSqlMigration @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=1.55.4") class MissingEvmAddressMigrationTest extends ImporterIntegrationTest { diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/NestNftTransferMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/NestNftTransferMigrationTest.java index 7565426b739..bf2aa329184 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/NestNftTransferMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/NestNftTransferMigrationTest.java @@ -47,15 +47,14 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.core.io.Resource; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import org.springframework.test.context.TestPropertySource; import org.springframework.util.StreamUtils; +@DisablePartitionMaintenance @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @RequiredArgsConstructor @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=1.80.1") diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/RemoveEntityTypeMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/RemoveEntityTypeMigrationTest.java index 033242e38b9..15af27b8456 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/RemoveEntityTypeMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/RemoveEntityTypeMigrationTest.java @@ -45,16 +45,15 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.jdbc.core.BeanPropertyRowMapper; import org.springframework.jdbc.core.JdbcOperations; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.TestPropertySource; +@DisablePartitionMaintenance @DisableRepeatableSqlMigration @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=1.46.11") @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/RemoveInvalidEntityMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/RemoveInvalidEntityMigrationTest.java index 646ad996fa6..c1dfb907167 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/RemoveInvalidEntityMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/RemoveInvalidEntityMigrationTest.java @@ -43,13 +43,12 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.jdbc.core.JdbcOperations; import org.springframework.test.context.TestPropertySource; +@DisablePartitionMaintenance @DisableRepeatableSqlMigration @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @RequiredArgsConstructor @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=1.31.1") diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/SupportDeletedTokenDissociateMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/SupportDeletedTokenDissociateMigrationTest.java index 1df7fae85cd..59134c6f665 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/SupportDeletedTokenDissociateMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/SupportDeletedTokenDissociateMigrationTest.java @@ -53,13 +53,12 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.jdbc.core.JdbcOperations; import org.springframework.test.context.TestPropertySource; +@DisablePartitionMaintenance @DisableRepeatableSqlMigration @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=1.44.1") class SupportDeletedTokenDissociateMigrationTest extends ImporterIntegrationTest { diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/TimePartitionBalanceTablesMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/TimePartitionBalanceTablesMigrationTest.java index e2fc031c346..debc48a4b64 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/TimePartitionBalanceTablesMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/TimePartitionBalanceTablesMigrationTest.java @@ -51,15 +51,14 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.core.io.Resource; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.TestPropertySource; import org.springframework.util.StreamUtils; +@DisablePartitionMaintenance @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @RequiredArgsConstructor @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=1.89.1") diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/TokenAccountMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/TokenAccountMigrationTest.java index 800c0646f86..483c2d1c489 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/TokenAccountMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/TokenAccountMigrationTest.java @@ -39,12 +39,11 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.TestPropertySource; +@DisablePartitionMaintenance @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @RequiredArgsConstructor @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=1.66.0") diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/TopicMessagePayerAccountIdMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/TopicMessagePayerAccountIdMigrationTest.java index ccbaac5a830..7ee2ed13004 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/TopicMessagePayerAccountIdMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/TopicMessagePayerAccountIdMigrationTest.java @@ -33,14 +33,13 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.jdbc.core.BeanPropertyRowMapper; import org.springframework.jdbc.core.JdbcOperations; import org.springframework.test.context.TestPropertySource; +@DisablePartitionMaintenance @DisableRepeatableSqlMigration @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=1.52.0") class TopicMessagePayerAccountIdMigrationTest extends ImporterIntegrationTest { diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/TransferTransactionPayerMigrationTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/TransferTransactionPayerMigrationTest.java index 256617b4759..4639604046c 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/TransferTransactionPayerMigrationTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/migration/TransferTransactionPayerMigrationTest.java @@ -55,13 +55,12 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; import org.springframework.jdbc.core.JdbcOperations; import org.springframework.test.context.TestPropertySource; +@DisablePartitionMaintenance @DisableRepeatableSqlMigration @EnabledIfV1 -@Import(DisablePartitionMaintenanceConfiguration.class) @RequiredArgsConstructor @Tag("migration") @TestPropertySource(properties = "spring.flyway.target=1.46.6") diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/parser/CommonParserPropertiesTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/parser/CommonParserPropertiesTest.java index 8050a663a55..d27e9adaf84 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/parser/CommonParserPropertiesTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/parser/CommonParserPropertiesTest.java @@ -288,7 +288,8 @@ void filterBoth(String entityId, RecordItem recordItem, boolean result) { @ParameterizedTest(name = "with expression {0}") @CsvSource({"sld&#$$", "transactionBody|consensusTimeStamp ge 32"}) void filterExpressionParseErrors(String expression) { - assertThatThrownBy(() -> filter(null, expression, null)) + var filter = filter(null, expression, null); + assertThatThrownBy(filter::getParsedExpression) .isInstanceOf(InvalidConfigurationException.class) .hasCauseInstanceOf(ParseException.class); } @@ -338,9 +339,14 @@ private Collection entities(String entityId) { } private TransactionFilter filter(String entity, String expression, TransactionType transaction) { - return new TransactionFilter( - StringUtils.isNotBlank(entity) ? List.of(EntityId.of(entity)) : null, - expression, - transaction != null ? List.of(transaction) : null); + var transactionFilter = new TransactionFilter(); + if (StringUtils.isNotBlank(entity)) { + transactionFilter.setEntity(List.of(EntityId.of(entity))); + } + transactionFilter.setExpression(expression); + if (transaction != null) { + transactionFilter.setTransaction(List.of(transaction)); + } + return transactionFilter; } } diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/parser/domain/RecordItemBuilder.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/parser/domain/RecordItemBuilder.java index 714c43b9c48..d9bcaa3e085 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/parser/domain/RecordItemBuilder.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/parser/domain/RecordItemBuilder.java @@ -1266,7 +1266,7 @@ private StorageChange.Builder storageChange() { } public String text(int characters) { - return RandomStringUtils.randomAlphanumeric(characters); + return RandomStringUtils.secure().nextAlphanumeric(characters); } public Timestamp timestamp() { diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/parser/record/entity/EntityRecordItemListenerScheduleTest.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/parser/record/entity/EntityRecordItemListenerScheduleTest.java index 6eb06525f27..6ce082a3822 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/parser/record/entity/EntityRecordItemListenerScheduleTest.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/parser/record/entity/EntityRecordItemListenerScheduleTest.java @@ -464,7 +464,7 @@ private Transaction scheduledTransaction() { private SignatureMap getSigMap(int signatureCount, boolean isEd25519) { SignatureMap.Builder builder = SignatureMap.newBuilder(); - String salt = RandomStringUtils.randomAlphabetic(5); + String salt = RandomStringUtils.secure().nextAlphabetic(5); for (int i = 0; i < signatureCount; i++) { SignaturePair.Builder signaturePairBuilder = SignaturePair.newBuilder(); diff --git a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/test/performance/PerformanceProperties.java b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/test/performance/PerformanceProperties.java index cfdfb91f8ce..378e44f78ee 100644 --- a/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/test/performance/PerformanceProperties.java +++ b/hedera-mirror-importer/src/test/java/com/hedera/mirror/importer/test/performance/PerformanceProperties.java @@ -17,6 +17,7 @@ package com.hedera.mirror.importer.test.performance; import com.hedera.mirror.common.domain.transaction.TransactionType; +import jakarta.validation.Valid; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; @@ -27,16 +28,20 @@ import lombok.Data; import org.hibernate.validator.constraints.time.DurationMin; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.validation.annotation.Validated; @ConfigurationProperties("hedera.mirror.importer.test.performance") @Data public class PerformanceProperties { + @Valid private DownloaderPerformanceProperties downloader = new DownloaderPerformanceProperties(); + @Valid private ParserPerformanceProperties parser = new ParserPerformanceProperties(); @NotNull + @Valid private Map> scenarios = Map.of(); public enum SubType { @@ -45,6 +50,7 @@ public enum SubType { } @Data + @Validated public static class DownloaderPerformanceProperties { private boolean enabled = true; @@ -58,6 +64,7 @@ public static class DownloaderPerformanceProperties { } @Data + @Validated public static class ParserPerformanceProperties { private boolean enabled = true; @@ -71,6 +78,7 @@ public static class ParserPerformanceProperties { } @Data + @Validated public static class PerformanceScenarioProperties { private String description; @@ -82,6 +90,7 @@ public static class PerformanceScenarioProperties { private boolean enabled = true; @NotNull + @Valid private List transactions = List.of(); public String getDescription() { @@ -95,6 +104,7 @@ public String getDescription() { } @Data + @Validated public static class PerformanceTransactionProperties { @Min(1) diff --git a/hedera-mirror-monitor/src/main/java/com/hedera/mirror/monitor/MonitorProperties.java b/hedera-mirror-monitor/src/main/java/com/hedera/mirror/monitor/MonitorProperties.java index b8a20ddc658..d244964ebcd 100644 --- a/hedera-mirror-monitor/src/main/java/com/hedera/mirror/monitor/MonitorProperties.java +++ b/hedera-mirror-monitor/src/main/java/com/hedera/mirror/monitor/MonitorProperties.java @@ -17,6 +17,7 @@ package com.hedera.mirror.monitor; import jakarta.annotation.Nullable; +import jakarta.validation.Valid; import jakarta.validation.constraints.NotNull; import java.util.LinkedHashSet; import java.util.Objects; @@ -31,17 +32,22 @@ public class MonitorProperties { @Nullable + @Valid private MirrorNodeProperties mirrorNode; @NotNull private HederaNetwork network = HederaNetwork.TESTNET; @NotNull + @Valid private Set nodes = new LinkedHashSet<>(); @NotNull + @Valid private OperatorProperties operator = new OperatorProperties(); + @NotNull + @Valid private NodeValidationProperties nodeValidation = new NodeValidationProperties(); public MirrorNodeProperties getMirrorNode() { diff --git a/hedera-mirror-monitor/src/main/java/com/hedera/mirror/monitor/publish/PublishProperties.java b/hedera-mirror-monitor/src/main/java/com/hedera/mirror/monitor/publish/PublishProperties.java index dfb81ca55fe..bf79476e2ba 100644 --- a/hedera-mirror-monitor/src/main/java/com/hedera/mirror/monitor/publish/PublishProperties.java +++ b/hedera-mirror-monitor/src/main/java/com/hedera/mirror/monitor/publish/PublishProperties.java @@ -17,6 +17,7 @@ package com.hedera.mirror.monitor.publish; import jakarta.annotation.PostConstruct; +import jakarta.validation.Valid; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotNull; import java.time.Duration; @@ -47,6 +48,7 @@ public class PublishProperties { private Duration nodeMaxBackoff = Duration.ofMinutes(1L); @NotNull + @Valid private Map scenarios = new LinkedHashMap<>(); @DurationMin(seconds = 1L) diff --git a/hedera-mirror-monitor/src/main/java/com/hedera/mirror/monitor/subscribe/SubscribeProperties.java b/hedera-mirror-monitor/src/main/java/com/hedera/mirror/monitor/subscribe/SubscribeProperties.java index d6fc47aa09d..92b4c7b2447 100644 --- a/hedera-mirror-monitor/src/main/java/com/hedera/mirror/monitor/subscribe/SubscribeProperties.java +++ b/hedera-mirror-monitor/src/main/java/com/hedera/mirror/monitor/subscribe/SubscribeProperties.java @@ -20,6 +20,7 @@ import com.hedera.mirror.monitor.subscribe.grpc.GrpcSubscriberProperties; import com.hedera.mirror.monitor.subscribe.rest.RestSubscriberProperties; import jakarta.annotation.PostConstruct; +import jakarta.validation.Valid; import jakarta.validation.constraints.Max; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotNull; @@ -45,14 +46,16 @@ public class SubscribeProperties { private boolean enabled = true; @NotNull + @Valid private Map grpc = new LinkedHashMap<>(); @NotNull + @Valid private Map rest = new LinkedHashMap<>(); @DurationMin(seconds = 1L) @NotNull - protected Duration statusFrequency = Duration.ofSeconds(10L); + private Duration statusFrequency = Duration.ofSeconds(10L); @PostConstruct void validate() { diff --git a/hedera-mirror-rest-java/build.gradle.kts b/hedera-mirror-rest-java/build.gradle.kts index 47403bde074..3e5c5a0a263 100644 --- a/hedera-mirror-rest-java/build.gradle.kts +++ b/hedera-mirror-rest-java/build.gradle.kts @@ -14,7 +14,7 @@ * limitations under the License. */ -description = "Hedera Mirror Node Rest Java" +description = "Hedera Mirror Node REST Java" plugins { id("openapi-conventions") diff --git a/hedera-mirror-rest-java/src/main/java/com/hedera/mirror/restjava/RestJavaProperties.java b/hedera-mirror-rest-java/src/main/java/com/hedera/mirror/restjava/RestJavaProperties.java index deec86cd720..3266ae097f7 100644 --- a/hedera-mirror-rest-java/src/main/java/com/hedera/mirror/restjava/RestJavaProperties.java +++ b/hedera-mirror-rest-java/src/main/java/com/hedera/mirror/restjava/RestJavaProperties.java @@ -17,6 +17,7 @@ package com.hedera.mirror.restjava; import jakarta.annotation.PostConstruct; +import jakarta.validation.Valid; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotNull; import java.util.HashMap; @@ -35,6 +36,7 @@ public class RestJavaProperties { @NotNull + @Valid private ResponseConfig response = new ResponseConfig(); @Min(0) @@ -63,6 +65,7 @@ void mergeHeaders() { @Validated public static class ResponseConfig { @NotNull + @Valid private ResponseHeadersConfig headers = new ResponseHeadersConfig(); } diff --git a/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/client/TokenClient.java b/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/client/TokenClient.java index 79abd804049..695886e9be8 100644 --- a/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/client/TokenClient.java +++ b/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/client/TokenClient.java @@ -499,7 +499,7 @@ public NetworkTransactionResponse transferNonFungibleToken( public NetworkTransactionResponse updateToken(TokenId tokenId, ExpandedAccountId expandedAccountId) { PublicKey publicKey = expandedAccountId.getPublicKey(); - String newSymbol = RandomStringUtils.randomAlphabetic(4).toUpperCase(); + String newSymbol = RandomStringUtils.secure().nextAlphabetic(4).toUpperCase(); String memo = getMemo("Update token"); TokenUpdateTransaction tokenUpdateTransaction = new TokenUpdateTransaction() .setAdminKey(publicKey) diff --git a/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/config/AcceptanceTestProperties.java b/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/config/AcceptanceTestProperties.java index f3777c3ceda..a2d56547982 100644 --- a/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/config/AcceptanceTestProperties.java +++ b/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/config/AcceptanceTestProperties.java @@ -20,6 +20,7 @@ import com.hedera.mirror.test.e2e.acceptance.client.ContractClient.NodeNameEnum; import com.hedera.mirror.test.e2e.acceptance.props.NodeProperties; import jakarta.inject.Named; +import jakarta.validation.Valid; import jakarta.validation.constraints.DecimalMax; import jakarta.validation.constraints.DecimalMin; import jakarta.validation.constraints.Max; @@ -76,6 +77,7 @@ public class AcceptanceTestProperties { private HederaNetwork network = HederaNetwork.TESTNET; @NotNull + @Valid private Set nodes = new LinkedHashSet<>(); @NotNull diff --git a/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/config/ClientConfiguration.java b/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/config/ClientConfiguration.java index 63c23d54026..fecc2680efb 100644 --- a/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/config/ClientConfiguration.java +++ b/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/config/ClientConfiguration.java @@ -23,8 +23,8 @@ import java.util.concurrent.TimeoutException; import lombok.RequiredArgsConstructor; import org.slf4j.LoggerFactory; -import org.springframework.boot.web.client.ClientHttpRequestFactories; -import org.springframework.boot.web.client.ClientHttpRequestFactorySettings; +import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder; +import org.springframework.boot.http.client.ClientHttpRequestFactorySettings; import org.springframework.boot.web.client.RestClientCustomizer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -45,7 +45,7 @@ class ClientConfiguration { RestClientCustomizer restClientCustomizer() { var baseUrl = acceptanceTestProperties.getRestProperties().getBaseUrl(); var clientProperties = acceptanceTestProperties.getWebClientProperties(); - var factorySettings = ClientHttpRequestFactorySettings.DEFAULTS + var factorySettings = ClientHttpRequestFactorySettings.defaults() .withConnectTimeout(clientProperties.getConnectionTimeout()) .withReadTimeout(clientProperties.getReadTimeout()); var logger = LoggerFactory.getLogger(MirrorNodeClient.class); @@ -56,7 +56,7 @@ RestClientCustomizer restClientCustomizer() { httpHeaders.setContentType(MediaType.APPLICATION_JSON); httpHeaders.setCacheControl(CacheControl.noStore()); }) - .requestFactory(ClientHttpRequestFactories.get(factorySettings)) + .requestFactory(ClientHttpRequestFactoryBuilder.detect().build(factorySettings)) .requestInterceptor((request, body, execution) -> { var response = execution.execute(request, body); var statusCode = response.getStatusCode(); diff --git a/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/steps/EstimateFeature.java b/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/steps/EstimateFeature.java index a19f4d379c2..a507329fb26 100644 --- a/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/steps/EstimateFeature.java +++ b/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/steps/EstimateFeature.java @@ -89,12 +89,12 @@ @CustomLog @RequiredArgsConstructor public class EstimateFeature extends AbstractEstimateFeature { + private static final String HEX_DIGITS = "0123456789abcdef"; - private static final String RANDOM_ADDRESS = to32BytesString(RandomStringUtils.random(40, HEX_DIGITS)); + private static final String RANDOM_ADDRESS = + to32BytesString(RandomStringUtils.secure().next(40, HEX_DIGITS)); private final TokenClient tokenClient; private final AccountClient accountClient; - private static final int BASE_GAS_FEE = 21_000; - private static final int ADDITIONAL_FEE_FOR_CREATE = 32_000; private DeployedContract deployedContract; private DeployedContract deployedPrecompileContract; private String contractSolidityAddress; diff --git a/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/steps/EstimatePrecompileFeature.java b/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/steps/EstimatePrecompileFeature.java index 3fec88978d3..94dd50be83d 100644 --- a/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/steps/EstimatePrecompileFeature.java +++ b/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/steps/EstimatePrecompileFeature.java @@ -78,7 +78,8 @@ public class EstimatePrecompileFeature extends AbstractEstimateFeature { private static final String HEX_DIGITS = "0123456789abcdef"; private static final Tuple[] EMPTY_TUPLE_ARRAY = new Tuple[] {}; - private static final String RANDOM_ADDRESS = to32BytesString(RandomStringUtils.random(40, HEX_DIGITS)); + private static final String RANDOM_ADDRESS = + to32BytesString(RandomStringUtils.secure().next(40, HEX_DIGITS)); private static final long FIRST_NFT_SERIAL_NUMBER = 1; private final TokenClient tokenClient; private final AccountClient accountClient; diff --git a/hedera-mirror-web3/build.gradle.kts b/hedera-mirror-web3/build.gradle.kts index 1a205b43d92..38fa8e41a63 100644 --- a/hedera-mirror-web3/build.gradle.kts +++ b/hedera-mirror-web3/build.gradle.kts @@ -126,7 +126,7 @@ val extractOpenZeppelin = tasks.bootRun { jvmArgs = listOf("--enable-preview") } -tasks.compileJava { options.compilerArgs.add("--enable-preview") } +tasks.withType { options.compilerArgs.add("--enable-preview") } tasks.test { jvmArgs = listOf("--enable-preview") } @@ -201,7 +201,7 @@ tasks.register("moveAndCleanTestHistoricalFiles") { afterEvaluate { tasks.named("extractSolidityImports") { dependsOn("extractContracts") } } tasks.compileTestJava { - options.compilerArgs.add("--enable-preview") + options.compilerArgs.add("-Xlint:-unchecked") // Web3j generates code with unchecked options.compilerArgs.removeIf { it == "-Werror" } dependsOn("moveAndCleanTestHistoricalFiles") } diff --git a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/evm/config/ServicesConfiguration.java b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/evm/config/ServicesConfiguration.java index 985c0ebf7e3..7ac7f02e51a 100644 --- a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/evm/config/ServicesConfiguration.java +++ b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/evm/config/ServicesConfiguration.java @@ -129,6 +129,7 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.evm.frame.MessageFrame; import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -770,7 +771,7 @@ HTSPrecompiledContract htsPrecompiledContract( HederaExtCodeHashOperationV038 hederaExtCodeHashOperationV038( final GasCalculator gasCalculator, final Predicate
strictSystemAccountDetector, - BiPredicate addressValidator, + @Qualifier("addressValidator") BiPredicate addressValidator, final MirrorNodeEvmProperties mirrorNodeEvmProperties) { return new HederaExtCodeHashOperationV038( gasCalculator, addressValidator, strictSystemAccountDetector, mirrorNodeEvmProperties); @@ -778,7 +779,8 @@ HederaExtCodeHashOperationV038 hederaExtCodeHashOperationV038( @Bean HederaExtCodeHashOperation hederaExtCodeHashOperation( - final GasCalculator gasCalculator, BiPredicate preV38AddressValidator) { + final GasCalculator gasCalculator, + @Qualifier("preV38AddressValidator") BiPredicate preV38AddressValidator) { return new HederaExtCodeHashOperation(gasCalculator, preV38AddressValidator); } diff --git a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/Web3IntegrationTest.java b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/Web3IntegrationTest.java index c9b9323a75a..6e5e1b005e2 100644 --- a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/Web3IntegrationTest.java +++ b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/Web3IntegrationTest.java @@ -21,12 +21,12 @@ import com.hedera.mirror.web3.evm.store.Store; import jakarta.annotation.Resource; import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.boot.test.mock.mockito.SpyBean; +import org.springframework.test.context.bean.override.mockito.MockitoSpyBean; @ExtendWith(ContextExtension.class) public abstract class Web3IntegrationTest extends CommonIntegrationTest { - @SpyBean + @MockitoSpyBean protected MirrorEvmTxProcessor processor; @Resource diff --git a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/config/LoggingFilterTest.java b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/config/LoggingFilterTest.java index 8fa92f1931a..f2be635c535 100644 --- a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/config/LoggingFilterTest.java +++ b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/config/LoggingFilterTest.java @@ -140,7 +140,7 @@ void postMultiLine(CapturedOutput output) { @SneakyThrows void postLargeContent(CapturedOutput output) { int maxSize = web3Properties.getMaxPayloadLogSize(); - var content = RandomStringUtils.random(maxSize + 1, "abcdef0123456789"); + var content = RandomStringUtils.secure().next(maxSize + 1, "abcdef0123456789"); var request = new MockHttpServletRequest("POST", "/"); request.setContent(content.getBytes(StandardCharsets.UTF_8)); response.setStatus(HttpStatus.OK.value()); diff --git a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/controller/ContractControllerTest.java b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/controller/ContractControllerTest.java index d3e10c01e8c..45ab0dd755f 100644 --- a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/controller/ContractControllerTest.java +++ b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/controller/ContractControllerTest.java @@ -73,12 +73,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.OutputCaptureExtension; import org.springframework.context.annotation.Bean; import org.springframework.dao.QueryTimeoutException; import org.springframework.http.MediaType; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.ResultActions; @@ -98,19 +98,19 @@ class ContractControllerTest { @Resource private ObjectMapper objectMapper; - @MockBean + @MockitoBean private ContractExecutionService service; - @MockBean(name = "rateLimitBucket") + @MockitoBean(name = "rateLimitBucket") private Bucket rateLimitBucket; - @MockBean(name = "gasLimitBucket") + @MockitoBean(name = "gasLimitBucket") private Bucket gasLimitBucket; @Autowired private MirrorNodeEvmProperties evmProperties; - @MockBean + @MockitoBean private ThrottleProperties throttleProperties; @BeforeEach diff --git a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/controller/OpcodesControllerTest.java b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/controller/OpcodesControllerTest.java index 815413c79f2..c879bd11e96 100644 --- a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/controller/OpcodesControllerTest.java +++ b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/controller/OpcodesControllerTest.java @@ -101,9 +101,9 @@ import org.mockito.Captor; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Bean; import org.springframework.http.MediaType; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.ResultMatcher; @@ -126,31 +126,31 @@ class OpcodesControllerTest { @Resource private ObjectMapper objectMapper; - @MockBean + @MockitoBean private ContractDebugService contractDebugService; - @MockBean(name = "rateLimitBucket") + @MockitoBean(name = "rateLimitBucket") private Bucket rateLimitBucket; - @MockBean + @MockitoBean private TransactionRepository transactionRepository; - @MockBean + @MockitoBean private EthereumTransactionRepository ethereumTransactionRepository; - @MockBean + @MockitoBean private ContractTransactionHashRepository contractTransactionHashRepository; - @MockBean + @MockitoBean private ContractResultRepository contractResultRepository; - @MockBean + @MockitoBean private RecordFileRepository recordFileRepository; - @MockBean + @MockitoBean private EntityDatabaseAccessor entityDatabaseAccessor; - @MockBean + @MockitoBean private Web3Properties web3Properties; @Captor diff --git a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/service/AbstractContractCallServiceOpcodeTracerTest.java b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/service/AbstractContractCallServiceOpcodeTracerTest.java index 335145071a1..9dd44a3e1de 100644 --- a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/service/AbstractContractCallServiceOpcodeTracerTest.java +++ b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/service/AbstractContractCallServiceOpcodeTracerTest.java @@ -48,7 +48,7 @@ import org.junit.jupiter.api.BeforeEach; import org.mockito.ArgumentCaptor; import org.mockito.Captor; -import org.springframework.boot.test.mock.mockito.SpyBean; +import org.springframework.test.context.bean.override.mockito.MockitoSpyBean; import org.web3j.tx.Contract; abstract class AbstractContractCallServiceOpcodeTracerTest extends AbstractContractCallServiceHistoricalTest { @@ -56,7 +56,7 @@ abstract class AbstractContractCallServiceOpcodeTracerTest extends AbstractContr @Resource protected ContractDebugService contractDebugService; - @SpyBean + @MockitoSpyBean protected TransactionExecutionService transactionExecutionService; @Captor diff --git a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/service/ContractCallAddressThisTest.java b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/service/ContractCallAddressThisTest.java index 8c9a1c03969..7f687369382 100644 --- a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/service/ContractCallAddressThisTest.java +++ b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/service/ContractCallAddressThisTest.java @@ -44,8 +44,8 @@ import org.hyperledger.besu.datatypes.Address; import org.junit.jupiter.api.Test; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.mock.mockito.SpyBean; import org.springframework.http.MediaType; +import org.springframework.test.context.bean.override.mockito.MockitoSpyBean; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.ResultActions; import org.testcontainers.shaded.org.apache.commons.lang3.StringUtils; @@ -64,7 +64,7 @@ class ContractCallAddressThisTest extends AbstractContractCallServiceTest { @Resource private ObjectMapper objectMapper; - @SpyBean + @MockitoSpyBean private ContractExecutionService contractExecutionService; @SneakyThrows diff --git a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/service/ContractCallEvmCodesTest.java b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/service/ContractCallEvmCodesTest.java index 5fb3a8f245d..d46df952639 100644 --- a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/service/ContractCallEvmCodesTest.java +++ b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/service/ContractCallEvmCodesTest.java @@ -51,7 +51,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; -import org.springframework.boot.test.mock.mockito.SpyBean; +import org.springframework.test.context.bean.override.mockito.MockitoSpyBean; import org.web3j.abi.FunctionReturnDecoder; import org.web3j.abi.TypeReference; import org.web3j.abi.datatypes.AbiTypes; @@ -65,7 +65,7 @@ class ContractCallEvmCodesTest extends AbstractContractCallServiceTest { private final MirrorNodeEvmProperties mirrorNodeEvmProperties; - @SpyBean + @MockitoSpyBean private ContractExecutionService contractExecutionService; @Test