Skip to content

Commit

Permalink
chore: Temporal spring test termination status fix (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
antonioT90 authored Jan 30, 2025
1 parent d8d70bc commit 3846b09
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 38 deletions.
8 changes: 1 addition & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ repositories {
val springDocOpenApiVersion = "2.7.0"
val openApiToolsVersion = "0.2.6"
val micrometerVersion = "1.4.1"
val p4paActivitiesVersion = "1.45.1"
val postgresJdbcVersion = "42.7.4"
val p4paActivitiesVersion = "1.45.2"
val temporalVersion = "1.27.0"
val protobufJavaVersion = "3.25.5"
val bouncycastleVersion = "1.79"
Expand All @@ -50,7 +49,6 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-oauth2-resource-server")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("io.micrometer:micrometer-tracing-bridge-otel:$micrometerVersion")
implementation("io.micrometer:micrometer-registry-prometheus")
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:$springDocOpenApiVersion")
Expand All @@ -70,10 +68,6 @@ dependencies {
// updated for security reason
implementation("com.google.protobuf:protobuf-java:$protobufJavaVersion")


//postgres jdbc
implementation("org.postgresql:postgresql:$postgresJdbcVersion")

compileOnly("org.projectlombok:lombok")
annotationProcessor("org.projectlombok:lombok")

Expand Down
17 changes: 1 addition & 16 deletions gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ com.google.protobuf:protobuf-java-util:3.22.0=compileClasspath
com.google.protobuf:protobuf-java:3.25.5=compileClasspath
com.nimbusds:nimbus-jose-jwt:9.37.3=compileClasspath
com.uber.m3:tally-core:0.13.0=compileClasspath
com.zaxxer:HikariCP:5.1.0=compileClasspath
io.grpc:grpc-api:1.54.1=compileClasspath
io.grpc:grpc-bom:1.54.1=compileClasspath
io.grpc:grpc-context:1.54.1=compileClasspath
Expand Down Expand Up @@ -72,27 +71,21 @@ io.temporal:temporal-spring-boot-autoconfigure:1.27.0=compileClasspath
io.temporal:temporal-spring-boot-starter:1.27.0=compileClasspath
io.temporal:temporal-test-server:1.27.0=compileClasspath
io.temporal:temporal-testing:1.27.0=compileClasspath
it.gov.pagopa.payhub:p4pa-payhub-activities:1.45.1=compileClasspath
it.gov.pagopa.payhub:p4pa-payhub-activities:1.45.2=compileClasspath
jakarta.activation:jakarta.activation-api:2.1.3=compileClasspath
jakarta.annotation:jakarta.annotation-api:2.1.1=compileClasspath
jakarta.persistence:jakarta.persistence-api:3.1.0=compileClasspath
jakarta.transaction:jakarta.transaction-api:2.0.1=compileClasspath
jakarta.validation:jakarta.validation-api:3.0.2=compileClasspath
jakarta.xml.bind:jakarta.xml.bind-api:4.0.2=compileClasspath
org.antlr:antlr4-runtime:4.13.0=compileClasspath
org.apache.commons:commons-lang3:3.17.0=compileClasspath
org.apache.logging.log4j:log4j-api:2.24.3=compileClasspath
org.apache.logging.log4j:log4j-to-slf4j:2.24.3=compileClasspath
org.apache.tomcat.embed:tomcat-embed-core:10.1.34=compileClasspath
org.apache.tomcat.embed:tomcat-embed-el:10.1.34=compileClasspath
org.apache.tomcat.embed:tomcat-embed-websocket:10.1.34=compileClasspath
org.aspectj:aspectjweaver:1.9.22.1=compileClasspath
org.bouncycastle:bcprov-jdk18on:1.79=compileClasspath
org.checkerframework:checker-qual:3.43.0=compileClasspath
org.hibernate.orm:hibernate-core:6.6.4.Final=compileClasspath
org.jspecify:jspecify:1.0.0=compileClasspath
org.openapitools:jackson-databind-nullable:0.2.6=compileClasspath
org.postgresql:postgresql:42.7.4=compileClasspath
org.projectlombok:lombok:1.18.36=compileClasspath
org.slf4j:jul-to-slf4j:2.0.16=compileClasspath
org.slf4j:slf4j-api:2.0.16=compileClasspath
Expand All @@ -104,17 +97,13 @@ org.springframework.boot:spring-boot-actuator:3.4.1=compileClasspath
org.springframework.boot:spring-boot-autoconfigure:3.4.1=compileClasspath
org.springframework.boot:spring-boot-dependencies:2.7.18=compileClasspath
org.springframework.boot:spring-boot-starter-actuator:3.4.1=compileClasspath
org.springframework.boot:spring-boot-starter-data-jpa:3.4.1=compileClasspath
org.springframework.boot:spring-boot-starter-jdbc:3.4.1=compileClasspath
org.springframework.boot:spring-boot-starter-json:3.4.1=compileClasspath
org.springframework.boot:spring-boot-starter-logging:3.4.1=compileClasspath
org.springframework.boot:spring-boot-starter-oauth2-resource-server:3.4.1=compileClasspath
org.springframework.boot:spring-boot-starter-tomcat:3.4.1=compileClasspath
org.springframework.boot:spring-boot-starter-web:3.4.1=compileClasspath
org.springframework.boot:spring-boot-starter:3.4.1=compileClasspath
org.springframework.boot:spring-boot:3.4.1=compileClasspath
org.springframework.data:spring-data-commons:3.4.1=compileClasspath
org.springframework.data:spring-data-jpa:3.4.1=compileClasspath
org.springframework.security:spring-security-config:6.4.2=compileClasspath
org.springframework.security:spring-security-core:6.4.2=compileClasspath
org.springframework.security:spring-security-crypto:6.4.2=compileClasspath
Expand All @@ -123,15 +112,11 @@ org.springframework.security:spring-security-oauth2-jose:6.4.2=compileClasspath
org.springframework.security:spring-security-oauth2-resource-server:6.4.2=compileClasspath
org.springframework.security:spring-security-web:6.4.2=compileClasspath
org.springframework:spring-aop:6.2.1=compileClasspath
org.springframework:spring-aspects:6.2.1=compileClasspath
org.springframework:spring-beans:6.2.1=compileClasspath
org.springframework:spring-context:6.2.1=compileClasspath
org.springframework:spring-core:6.2.1=compileClasspath
org.springframework:spring-expression:6.2.1=compileClasspath
org.springframework:spring-jcl:6.2.1=compileClasspath
org.springframework:spring-jdbc:6.2.1=compileClasspath
org.springframework:spring-orm:6.2.1=compileClasspath
org.springframework:spring-tx:6.2.1=compileClasspath
org.springframework:spring-web:6.2.1=compileClasspath
org.springframework:spring-webmvc:6.2.1=compileClasspath
org.webjars:swagger-ui:5.18.2=compileClasspath
Expand Down
6 changes: 0 additions & 6 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ spring:
threads:
virtual:
enabled: "\${VIRTUAL_THREADS_ENABLED:true}"
data:
pu:
jdbc-url: "jdbc:postgresql://\${PU_DB_HOST}:\${PU_DB_PORT:5432}/\${PU_DB_NAME:dbname}"
username: "\${PU_DB_USER}"
password: "\${PU_DB_PASSWORD}"
driverClassName: "org.postgresql.Driver"
temporal:
connection:
enable-https: "\${TEMPORAL_SERVER_ENABLE_HTTPS:false}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,29 @@
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.context.bean.override.mockito.MockitoSpyBean;

import java.time.Duration;
import java.util.Set;
import java.util.function.Consumer;

@SpringBootTest(classes = WorkerApplication.class)
@EnableAutoConfiguration(exclude = {
DataSourceAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class,
HibernateJpaAutoConfiguration.class})
@TestPropertySource(properties = {
"spring.temporal.test-server.enabled: true",
"spring.temporal.workers-auto-discovery.packages: it.gov.pagopa.pu.worker",
"folders.shared: build"
})
class TemporalSpringBootIntegrationTest {
//region base test configuration code
private final Set<WorkflowExecutionStatus> wfTerminationStatuses = Set.of(
WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_COMPLETED,
WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_FAILED,
WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_TERMINATED,
WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_CANCELED
);

@Autowired
private WorkflowClient temporalClient;
Expand Down Expand Up @@ -86,7 +85,9 @@ protected void waitUntilWfCompletion(String workflowId) {
WorkflowExecutionInfo info;
do {
info = WorkflowClientHelper.describeWorkflowInstance(temporalClient.getWorkflowServiceStubs(), "default", WorkflowExecution.newBuilder().setWorkflowId(workflowId).build(), new NoopScope());
} while (!WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_COMPLETED.equals(info.getStatus()));
} while (!wfTerminationStatuses.contains(info.getStatus()));

Assertions.assertEquals(WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_COMPLETED, info.getStatus());
}
//endregion

Expand Down

0 comments on commit 3846b09

Please sign in to comment.