Skip to content

Commit f7ec558

Browse files
chore: Use 1.16.0 rc 2 (#1463)
* chore: Use 1.16.0 rc Signed-off-by: Javier Aliaga <[email protected]> * chore: Use dapr:1.16-rc.2 Signed-off-by: Javier Aliaga <[email protected]> * chore: Add overwrite flag to jobs Signed-off-by: Javier Aliaga <[email protected]> --------- Signed-off-by: Javier Aliaga <[email protected]>
1 parent dd4964f commit f7ec558

File tree

10 files changed

+112
-9
lines changed

10 files changed

+112
-9
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
GOPROXY: https://proxy.golang.org
4040
JDK_VER: ${{ matrix.java }}
4141
DAPR_CLI_VER: 1.15.0
42-
DAPR_RUNTIME_VER: 1.15.7
42+
DAPR_RUNTIME_VER: 1.16.0-rc.2
4343
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.15.0/install/install.sh
4444
DAPR_CLI_REF:
4545
DAPR_REF:

.github/workflows/validate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
GOPROXY: https://proxy.golang.org
3939
JDK_VER: ${{ matrix.java }}
4040
DAPR_CLI_VER: 1.15.0
41-
DAPR_RUNTIME_VER: 1.15.7
41+
DAPR_RUNTIME_VER: 1.16.0-rc.2
4242
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.15.0/install/install.sh
4343
DAPR_CLI_REF:
4444
DAPR_REF:

daprdocs/content/en/java-sdk-docs/spring-boot/_index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public class DaprTestContainersConfig {
9595
@ServiceConnection
9696
public DaprContainer daprContainer(Network daprNetwork, PostgreSQLContainer<?> postgreSQLContainer){
9797

98-
return new DaprContainer("daprio/daprd:1.15.7")
98+
return new DaprContainer("daprio/daprd:1.16.0-rc.2")
9999
.withAppName("producer-app")
100100
.withNetwork(daprNetwork)
101101
.withComponent(new Component("kvstore", "state.postgresql", "v1", STATE_STORE_PROPERTIES))
@@ -250,7 +250,7 @@ Finally, because Dapr PubSub requires a bidirectional connection between your ap
250250
@ServiceConnection
251251
public DaprContainer daprContainer(Network daprNetwork, PostgreSQLContainer<?> postgreSQLContainer, RabbitMQContainer rabbitMQContainer){
252252

253-
return new DaprContainer("daprio/daprd:1.15.7")
253+
return new DaprContainer("daprio/daprd:1.16.0-rc.2")
254254
.withAppName("producer-app")
255255
.withNetwork(daprNetwork)
256256
.withComponent(new Component("kvstore", "state.postgresql", "v1", STATE_STORE_PROPERTIES))

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<grpc.version>1.69.0</grpc.version>
1818
<protobuf.version>3.25.5</protobuf.version>
1919
<protocCommand>protoc</protocCommand>
20-
<dapr.proto.baseurl>https://raw.githubusercontent.com/dapr/dapr/v1.15.7/dapr/proto</dapr.proto.baseurl>
20+
<dapr.proto.baseurl>https://raw.githubusercontent.com/dapr/dapr/v1.16.0-rc.2/dapr/proto</dapr.proto.baseurl>
2121
<dapr.sdk.version>1.16.0-SNAPSHOT</dapr.sdk.version>
2222
<dapr.sdk.alpha.version>0.16.0-SNAPSHOT</dapr.sdk.alpha.version>
2323
<os-maven-plugin.version>1.7.1</os-maven-plugin.version>

sdk-tests/src/test/java/io/dapr/it/testcontainers/jobs/DaprJobsIT.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void testJobScheduleCreationWithDueTime() {
9393
.withZone(ZoneOffset.UTC);
9494

9595
Instant currentTime = Instant.now();
96-
daprPreviewClient.scheduleJob(new ScheduleJobRequest("Job", currentTime)).block();
96+
daprPreviewClient.scheduleJob(new ScheduleJobRequest("Job", currentTime).setOverwrite(true)).block();
9797

9898
GetJobResponse getJobResponse =
9999
daprPreviewClient.getJob(new GetJobRequest("Job")).block();
@@ -108,7 +108,7 @@ public void testJobScheduleCreationWithSchedule() {
108108

109109
Instant currentTime = Instant.now();
110110
daprPreviewClient.scheduleJob(new ScheduleJobRequest("Job", JobSchedule.hourly())
111-
.setDueTime(currentTime)).block();
111+
.setDueTime(currentTime).setOverwrite(true)).block();
112112

113113
GetJobResponse getJobResponse =
114114
daprPreviewClient.getJob(new GetJobRequest("Job")).block();
@@ -129,6 +129,7 @@ public void testJobScheduleCreationWithAllParameters() {
129129
.setTtl(currentTime.plus(2, ChronoUnit.HOURS))
130130
.setData("Job data".getBytes())
131131
.setRepeat(3)
132+
.setOverwrite(true)
132133
.setSchedule(JobSchedule.fromString(cronExpression))).block();
133134

134135
GetJobResponse getJobResponse =
@@ -152,6 +153,7 @@ public void testDeleteJobRequest() {
152153
.setTtl(currentTime.plus(2, ChronoUnit.HOURS))
153154
.setData("Job data".getBytes())
154155
.setRepeat(3)
156+
.setOverwrite(true)
155157
.setSchedule(JobSchedule.fromString(cronExpression))).block();
156158

157159
daprPreviewClient.deleteJob(new DeleteJobRequest("Job")).block();

sdk/src/main/java/io/dapr/client/DaprClientImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,8 @@ public Mono<Void> scheduleJob(ScheduleJobRequest scheduleJobRequest) {
13361336
scheduleJobRequestBuilder.setDueTime(iso8601Formatter.format(scheduleJobRequest.getDueTime()));
13371337
}
13381338

1339+
scheduleJobRequestBuilder.setOverwrite(scheduleJobRequest.getOverwrite());
1340+
13391341
Mono<DaprProtos.ScheduleJobResponse> scheduleJobResponseMono =
13401342
Mono.deferContextual(context -> this.createMono(
13411343
it -> intercept(context, asyncStub)

sdk/src/main/java/io/dapr/client/domain/ScheduleJobRequest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class ScheduleJobRequest {
2525
private Instant dueTime;
2626
private Integer repeats;
2727
private Instant ttl;
28+
private boolean overwrite;
2829

2930
/**
3031
* Constructor to create ScheduleJobRequest.
@@ -165,4 +166,24 @@ public Integer getRepeats() {
165166
public Instant getTtl() {
166167
return ttl;
167168
}
169+
170+
/**
171+
* Gets the overwrite flag.
172+
*
173+
* @return The overwrite flag.
174+
*/
175+
public boolean getOverwrite() {
176+
return overwrite;
177+
}
178+
179+
/**
180+
* Sets the overwrite flag.
181+
*
182+
* @param overwrite The overwrite flag.
183+
* @return This builder instance.
184+
*/
185+
public ScheduleJobRequest setOverwrite(boolean overwrite) {
186+
this.overwrite = overwrite;
187+
return this;
188+
}
168189
}

sdk/src/test/java/io/dapr/client/DaprPreviewClientGrpcTest.java

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,84 @@ public void scheduleJobShouldThrowWhenNameInRequestIsEmpty() {
817817
assertEquals("Name in the request cannot be null or empty", exception.getMessage());
818818
}
819819

820+
@Test
821+
public void scheduleJobShouldThrowWhenNameAlreadyExists() {
822+
AtomicInteger callCount = new AtomicInteger(0);
823+
824+
doAnswer(invocation -> {
825+
StreamObserver<DaprProtos.ScheduleJobResponse> observer = invocation.getArgument(1);
826+
if (callCount.incrementAndGet() == 1) {
827+
// First call succeeds
828+
observer.onCompleted();
829+
} else {
830+
// Second call fails with ALREADY_EXISTS
831+
observer.onError(newStatusRuntimeException("ALREADY_EXISTS", "Job with name 'testJob' already exists"));
832+
}
833+
return null;
834+
}).when(daprStub).scheduleJobAlpha1(any(DaprProtos.ScheduleJobRequest.class), any());
835+
836+
// First call should succeed
837+
ScheduleJobRequest firstRequest = new ScheduleJobRequest("testJob", Instant.now());
838+
assertDoesNotThrow(() -> previewClient.scheduleJob(firstRequest).block());
839+
840+
ArgumentCaptor<DaprProtos.ScheduleJobRequest> captor =
841+
ArgumentCaptor.forClass(DaprProtos.ScheduleJobRequest.class);
842+
843+
verify(daprStub, times(1)).scheduleJobAlpha1(captor.capture(), Mockito.any());
844+
DaprProtos.ScheduleJobRequest actualScheduleJobRequest = captor.getValue();
845+
DaprProtos.Job job = actualScheduleJobRequest.getJob();
846+
assertEquals("testJob", job.getName());
847+
assertFalse(job.hasData());
848+
assertEquals(0, job.getRepeats());
849+
assertFalse(job.hasTtl());
850+
851+
// Second call with same name should fail
852+
ScheduleJobRequest secondRequest = new ScheduleJobRequest("testJob", Instant.now());
853+
854+
assertThrowsDaprException(
855+
ExecutionException.class,
856+
"ALREADY_EXISTS",
857+
"ALREADY_EXISTS: Job with name 'testJob' already exists",
858+
() -> previewClient.scheduleJob(secondRequest).block());
859+
}
860+
861+
@Test
862+
public void scheduleJobShouldSucceedWhenNameAlreadyExistsWithOverwrite() {
863+
doAnswer(invocation -> {
864+
StreamObserver<DaprProtos.ScheduleJobResponse> observer = invocation.getArgument(1);
865+
observer.onCompleted(); // Simulate successful response for both calls
866+
return null;
867+
}).when(daprStub).scheduleJobAlpha1(any(DaprProtos.ScheduleJobRequest.class), any());
868+
869+
// First call should succeed
870+
ScheduleJobRequest firstRequest = new ScheduleJobRequest("testJob", Instant.now());
871+
assertDoesNotThrow(() -> previewClient.scheduleJob(firstRequest).block());
872+
873+
// Second call with same name but overwrite=true should also succeed
874+
ScheduleJobRequest secondRequest = new ScheduleJobRequest("testJob", Instant.now())
875+
.setOverwrite(true);
876+
assertDoesNotThrow(() -> previewClient.scheduleJob(secondRequest).block());
877+
878+
// Verify that both calls were made successfully
879+
ArgumentCaptor<DaprProtos.ScheduleJobRequest> captor =
880+
ArgumentCaptor.forClass(DaprProtos.ScheduleJobRequest.class);
881+
verify(daprStub, times(2)).scheduleJobAlpha1(captor.capture(), any());
882+
883+
// Verify the first call doesn't have overwrite set
884+
DaprProtos.ScheduleJobRequest firstActualRequest = captor.getAllValues().get(0);
885+
assertFalse(firstActualRequest.getJob().getOverwrite());
886+
assertEquals("testJob", firstActualRequest.getJob().getName());
887+
888+
// Verify the second call has overwrite set to true
889+
DaprProtos.ScheduleJobRequest secondActualRequest = captor.getAllValues().get(1);
890+
assertTrue(secondActualRequest.getJob().getOverwrite());
891+
assertEquals("testJob", secondActualRequest.getJob().getName());
892+
}
893+
894+
895+
896+
897+
820898
@Test
821899
public void getJobShouldReturnResponseWhenAllFieldsArePresentInRequest() {
822900
DateTimeFormatter iso8601Formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")

spring-boot-examples/kubernetes/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Once you have the cluster up and running you can install Dapr:
3030
helm repo add dapr https://dapr.github.io/helm-charts/
3131
helm repo update
3232
helm upgrade --install dapr dapr/dapr \
33-
--version=1.15.7 \
33+
--version=1.16.0-rc.2 \
3434
--namespace dapr-system \
3535
--create-namespace \
3636
--wait

testcontainers-dapr/src/main/java/io/dapr/testcontainers/DaprContainerConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
package io.dapr.testcontainers;
1515

1616
public interface DaprContainerConstants {
17-
String DAPR_VERSION = "1.15.7";
17+
String DAPR_VERSION = "1.16.0-rc.2";
1818
String DAPR_RUNTIME_IMAGE_TAG = "daprio/daprd:" + DAPR_VERSION;
1919
String DAPR_PLACEMENT_IMAGE_TAG = "daprio/placement:" + DAPR_VERSION;
2020
String DAPR_SCHEDULER_IMAGE_TAG = "daprio/scheduler:" + DAPR_VERSION;

0 commit comments

Comments
 (0)