Skip to content

Commit 48ad25e

Browse files
javier-aliagasiri-varma
authored andcommitted
chore: Use 1.16.0 rc 2 (dapr#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]> Signed-off-by: sirivarma <[email protected]>
1 parent 9b94509 commit 48ad25e

File tree

9 files changed

+111
-8
lines changed

9 files changed

+111
-8
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))

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
@@ -1353,6 +1353,8 @@ public Mono<Void> scheduleJob(ScheduleJobRequest scheduleJobRequest) {
13531353
scheduleJobRequestBuilder.setDueTime(iso8601Formatter.format(scheduleJobRequest.getDueTime()));
13541354
}
13551355

1356+
scheduleJobRequestBuilder.setOverwrite(scheduleJobRequest.getOverwrite());
1357+
13561358
Mono<DaprProtos.ScheduleJobResponse> scheduleJobResponseMono =
13571359
Mono.deferContextual(context -> this.createMono(
13581360
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
@@ -833,6 +833,84 @@ public void scheduleJobShouldThrowWhenNameInRequestIsEmpty() {
833833
assertEquals("Name in the request cannot be null or empty", exception.getMessage());
834834
}
835835

836+
@Test
837+
public void scheduleJobShouldThrowWhenNameAlreadyExists() {
838+
AtomicInteger callCount = new AtomicInteger(0);
839+
840+
doAnswer(invocation -> {
841+
StreamObserver<DaprProtos.ScheduleJobResponse> observer = invocation.getArgument(1);
842+
if (callCount.incrementAndGet() == 1) {
843+
// First call succeeds
844+
observer.onCompleted();
845+
} else {
846+
// Second call fails with ALREADY_EXISTS
847+
observer.onError(newStatusRuntimeException("ALREADY_EXISTS", "Job with name 'testJob' already exists"));
848+
}
849+
return null;
850+
}).when(daprStub).scheduleJobAlpha1(any(DaprProtos.ScheduleJobRequest.class), any());
851+
852+
// First call should succeed
853+
ScheduleJobRequest firstRequest = new ScheduleJobRequest("testJob", Instant.now());
854+
assertDoesNotThrow(() -> previewClient.scheduleJob(firstRequest).block());
855+
856+
ArgumentCaptor<DaprProtos.ScheduleJobRequest> captor =
857+
ArgumentCaptor.forClass(DaprProtos.ScheduleJobRequest.class);
858+
859+
verify(daprStub, times(1)).scheduleJobAlpha1(captor.capture(), Mockito.any());
860+
DaprProtos.ScheduleJobRequest actualScheduleJobRequest = captor.getValue();
861+
DaprProtos.Job job = actualScheduleJobRequest.getJob();
862+
assertEquals("testJob", job.getName());
863+
assertFalse(job.hasData());
864+
assertEquals(0, job.getRepeats());
865+
assertFalse(job.hasTtl());
866+
867+
// Second call with same name should fail
868+
ScheduleJobRequest secondRequest = new ScheduleJobRequest("testJob", Instant.now());
869+
870+
assertThrowsDaprException(
871+
ExecutionException.class,
872+
"ALREADY_EXISTS",
873+
"ALREADY_EXISTS: Job with name 'testJob' already exists",
874+
() -> previewClient.scheduleJob(secondRequest).block());
875+
}
876+
877+
@Test
878+
public void scheduleJobShouldSucceedWhenNameAlreadyExistsWithOverwrite() {
879+
doAnswer(invocation -> {
880+
StreamObserver<DaprProtos.ScheduleJobResponse> observer = invocation.getArgument(1);
881+
observer.onCompleted(); // Simulate successful response for both calls
882+
return null;
883+
}).when(daprStub).scheduleJobAlpha1(any(DaprProtos.ScheduleJobRequest.class), any());
884+
885+
// First call should succeed
886+
ScheduleJobRequest firstRequest = new ScheduleJobRequest("testJob", Instant.now());
887+
assertDoesNotThrow(() -> previewClient.scheduleJob(firstRequest).block());
888+
889+
// Second call with same name but overwrite=true should also succeed
890+
ScheduleJobRequest secondRequest = new ScheduleJobRequest("testJob", Instant.now())
891+
.setOverwrite(true);
892+
assertDoesNotThrow(() -> previewClient.scheduleJob(secondRequest).block());
893+
894+
// Verify that both calls were made successfully
895+
ArgumentCaptor<DaprProtos.ScheduleJobRequest> captor =
896+
ArgumentCaptor.forClass(DaprProtos.ScheduleJobRequest.class);
897+
verify(daprStub, times(2)).scheduleJobAlpha1(captor.capture(), any());
898+
899+
// Verify the first call doesn't have overwrite set
900+
DaprProtos.ScheduleJobRequest firstActualRequest = captor.getAllValues().get(0);
901+
assertFalse(firstActualRequest.getJob().getOverwrite());
902+
assertEquals("testJob", firstActualRequest.getJob().getName());
903+
904+
// Verify the second call has overwrite set to true
905+
DaprProtos.ScheduleJobRequest secondActualRequest = captor.getAllValues().get(1);
906+
assertTrue(secondActualRequest.getJob().getOverwrite());
907+
assertEquals("testJob", secondActualRequest.getJob().getName());
908+
}
909+
910+
911+
912+
913+
836914
@Test
837915
public void getJobShouldReturnResponseWhenAllFieldsArePresentInRequest() {
838916
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)