mirror of https://github.com/dapr/java-sdk.git
Merge branch 'master' into issue-1466-camelcase
This commit is contained in:
commit
4f734c5733
|
|
@ -39,7 +39,7 @@ jobs:
|
|||
GOPROXY: https://proxy.golang.org
|
||||
JDK_VER: ${{ matrix.java }}
|
||||
DAPR_CLI_VER: 1.15.0
|
||||
DAPR_RUNTIME_VER: 1.15.7
|
||||
DAPR_RUNTIME_VER: 1.16.0-rc.2
|
||||
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.15.0/install/install.sh
|
||||
DAPR_CLI_REF:
|
||||
DAPR_REF:
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ jobs:
|
|||
GOPROXY: https://proxy.golang.org
|
||||
JDK_VER: ${{ matrix.java }}
|
||||
DAPR_CLI_VER: 1.15.0
|
||||
DAPR_RUNTIME_VER: 1.15.7
|
||||
DAPR_RUNTIME_VER: 1.16.0-rc.2
|
||||
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.15.0/install/install.sh
|
||||
DAPR_CLI_REF:
|
||||
DAPR_REF:
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public class DaprTestContainersConfig {
|
|||
@ServiceConnection
|
||||
public DaprContainer daprContainer(Network daprNetwork, PostgreSQLContainer<?> postgreSQLContainer){
|
||||
|
||||
return new DaprContainer("daprio/daprd:1.15.7")
|
||||
return new DaprContainer("daprio/daprd:1.16.0-rc.2")
|
||||
.withAppName("producer-app")
|
||||
.withNetwork(daprNetwork)
|
||||
.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
|
|||
@ServiceConnection
|
||||
public DaprContainer daprContainer(Network daprNetwork, PostgreSQLContainer<?> postgreSQLContainer, RabbitMQContainer rabbitMQContainer){
|
||||
|
||||
return new DaprContainer("daprio/daprd:1.15.7")
|
||||
return new DaprContainer("daprio/daprd:1.16.0-rc.2")
|
||||
.withAppName("producer-app")
|
||||
.withNetwork(daprNetwork)
|
||||
.withComponent(new Component("kvstore", "state.postgresql", "v1", STATE_STORE_PROPERTIES))
|
||||
|
|
|
|||
2
pom.xml
2
pom.xml
|
|
@ -17,7 +17,7 @@
|
|||
<grpc.version>1.69.0</grpc.version>
|
||||
<protobuf.version>3.25.5</protobuf.version>
|
||||
<protocCommand>protoc</protocCommand>
|
||||
<dapr.proto.baseurl>https://raw.githubusercontent.com/dapr/dapr/v1.15.7/dapr/proto</dapr.proto.baseurl>
|
||||
<dapr.proto.baseurl>https://raw.githubusercontent.com/dapr/dapr/v1.16.0-rc.2/dapr/proto</dapr.proto.baseurl>
|
||||
<dapr.sdk.version>1.16.0-SNAPSHOT</dapr.sdk.version>
|
||||
<dapr.sdk.alpha.version>0.16.0-SNAPSHOT</dapr.sdk.alpha.version>
|
||||
<os-maven-plugin.version>1.7.1</os-maven-plugin.version>
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ public class DaprJobsIT {
|
|||
.withZone(ZoneOffset.UTC);
|
||||
|
||||
Instant currentTime = Instant.now();
|
||||
daprPreviewClient.scheduleJob(new ScheduleJobRequest("Job", currentTime)).block();
|
||||
daprPreviewClient.scheduleJob(new ScheduleJobRequest("Job", currentTime).setOverwrite(true)).block();
|
||||
|
||||
GetJobResponse getJobResponse =
|
||||
daprPreviewClient.getJob(new GetJobRequest("Job")).block();
|
||||
|
|
@ -108,7 +108,7 @@ public class DaprJobsIT {
|
|||
|
||||
Instant currentTime = Instant.now();
|
||||
daprPreviewClient.scheduleJob(new ScheduleJobRequest("Job", JobSchedule.hourly())
|
||||
.setDueTime(currentTime)).block();
|
||||
.setDueTime(currentTime).setOverwrite(true)).block();
|
||||
|
||||
GetJobResponse getJobResponse =
|
||||
daprPreviewClient.getJob(new GetJobRequest("Job")).block();
|
||||
|
|
@ -129,6 +129,7 @@ public class DaprJobsIT {
|
|||
.setTtl(currentTime.plus(2, ChronoUnit.HOURS))
|
||||
.setData("Job data".getBytes())
|
||||
.setRepeat(3)
|
||||
.setOverwrite(true)
|
||||
.setSchedule(JobSchedule.fromString(cronExpression))).block();
|
||||
|
||||
GetJobResponse getJobResponse =
|
||||
|
|
@ -152,6 +153,7 @@ public class DaprJobsIT {
|
|||
.setTtl(currentTime.plus(2, ChronoUnit.HOURS))
|
||||
.setData("Job data".getBytes())
|
||||
.setRepeat(3)
|
||||
.setOverwrite(true)
|
||||
.setSchedule(JobSchedule.fromString(cronExpression))).block();
|
||||
|
||||
daprPreviewClient.deleteJob(new DeleteJobRequest("Job")).block();
|
||||
|
|
|
|||
|
|
@ -1336,6 +1336,8 @@ public class DaprClientImpl extends AbstractDaprClient {
|
|||
scheduleJobRequestBuilder.setDueTime(iso8601Formatter.format(scheduleJobRequest.getDueTime()));
|
||||
}
|
||||
|
||||
scheduleJobRequestBuilder.setOverwrite(scheduleJobRequest.getOverwrite());
|
||||
|
||||
Mono<DaprProtos.ScheduleJobResponse> scheduleJobResponseMono =
|
||||
Mono.deferContextual(context -> this.createMono(
|
||||
it -> intercept(context, asyncStub)
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ public class ScheduleJobRequest {
|
|||
private Instant dueTime;
|
||||
private Integer repeats;
|
||||
private Instant ttl;
|
||||
private boolean overwrite;
|
||||
|
||||
/**
|
||||
* Constructor to create ScheduleJobRequest.
|
||||
|
|
@ -165,4 +166,24 @@ public class ScheduleJobRequest {
|
|||
public Instant getTtl() {
|
||||
return ttl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the overwrite flag.
|
||||
*
|
||||
* @return The overwrite flag.
|
||||
*/
|
||||
public boolean getOverwrite() {
|
||||
return overwrite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the overwrite flag.
|
||||
*
|
||||
* @param overwrite The overwrite flag.
|
||||
* @return This builder instance.
|
||||
*/
|
||||
public ScheduleJobRequest setOverwrite(boolean overwrite) {
|
||||
this.overwrite = overwrite;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -817,6 +817,84 @@ public class DaprPreviewClientGrpcTest {
|
|||
assertEquals("Name in the request cannot be null or empty", exception.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void scheduleJobShouldThrowWhenNameAlreadyExists() {
|
||||
AtomicInteger callCount = new AtomicInteger(0);
|
||||
|
||||
doAnswer(invocation -> {
|
||||
StreamObserver<DaprProtos.ScheduleJobResponse> observer = invocation.getArgument(1);
|
||||
if (callCount.incrementAndGet() == 1) {
|
||||
// First call succeeds
|
||||
observer.onCompleted();
|
||||
} else {
|
||||
// Second call fails with ALREADY_EXISTS
|
||||
observer.onError(newStatusRuntimeException("ALREADY_EXISTS", "Job with name 'testJob' already exists"));
|
||||
}
|
||||
return null;
|
||||
}).when(daprStub).scheduleJobAlpha1(any(DaprProtos.ScheduleJobRequest.class), any());
|
||||
|
||||
// First call should succeed
|
||||
ScheduleJobRequest firstRequest = new ScheduleJobRequest("testJob", Instant.now());
|
||||
assertDoesNotThrow(() -> previewClient.scheduleJob(firstRequest).block());
|
||||
|
||||
ArgumentCaptor<DaprProtos.ScheduleJobRequest> captor =
|
||||
ArgumentCaptor.forClass(DaprProtos.ScheduleJobRequest.class);
|
||||
|
||||
verify(daprStub, times(1)).scheduleJobAlpha1(captor.capture(), Mockito.any());
|
||||
DaprProtos.ScheduleJobRequest actualScheduleJobRequest = captor.getValue();
|
||||
DaprProtos.Job job = actualScheduleJobRequest.getJob();
|
||||
assertEquals("testJob", job.getName());
|
||||
assertFalse(job.hasData());
|
||||
assertEquals(0, job.getRepeats());
|
||||
assertFalse(job.hasTtl());
|
||||
|
||||
// Second call with same name should fail
|
||||
ScheduleJobRequest secondRequest = new ScheduleJobRequest("testJob", Instant.now());
|
||||
|
||||
assertThrowsDaprException(
|
||||
ExecutionException.class,
|
||||
"ALREADY_EXISTS",
|
||||
"ALREADY_EXISTS: Job with name 'testJob' already exists",
|
||||
() -> previewClient.scheduleJob(secondRequest).block());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void scheduleJobShouldSucceedWhenNameAlreadyExistsWithOverwrite() {
|
||||
doAnswer(invocation -> {
|
||||
StreamObserver<DaprProtos.ScheduleJobResponse> observer = invocation.getArgument(1);
|
||||
observer.onCompleted(); // Simulate successful response for both calls
|
||||
return null;
|
||||
}).when(daprStub).scheduleJobAlpha1(any(DaprProtos.ScheduleJobRequest.class), any());
|
||||
|
||||
// First call should succeed
|
||||
ScheduleJobRequest firstRequest = new ScheduleJobRequest("testJob", Instant.now());
|
||||
assertDoesNotThrow(() -> previewClient.scheduleJob(firstRequest).block());
|
||||
|
||||
// Second call with same name but overwrite=true should also succeed
|
||||
ScheduleJobRequest secondRequest = new ScheduleJobRequest("testJob", Instant.now())
|
||||
.setOverwrite(true);
|
||||
assertDoesNotThrow(() -> previewClient.scheduleJob(secondRequest).block());
|
||||
|
||||
// Verify that both calls were made successfully
|
||||
ArgumentCaptor<DaprProtos.ScheduleJobRequest> captor =
|
||||
ArgumentCaptor.forClass(DaprProtos.ScheduleJobRequest.class);
|
||||
verify(daprStub, times(2)).scheduleJobAlpha1(captor.capture(), any());
|
||||
|
||||
// Verify the first call doesn't have overwrite set
|
||||
DaprProtos.ScheduleJobRequest firstActualRequest = captor.getAllValues().get(0);
|
||||
assertFalse(firstActualRequest.getJob().getOverwrite());
|
||||
assertEquals("testJob", firstActualRequest.getJob().getName());
|
||||
|
||||
// Verify the second call has overwrite set to true
|
||||
DaprProtos.ScheduleJobRequest secondActualRequest = captor.getAllValues().get(1);
|
||||
assertTrue(secondActualRequest.getJob().getOverwrite());
|
||||
assertEquals("testJob", secondActualRequest.getJob().getName());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void getJobShouldReturnResponseWhenAllFieldsArePresentInRequest() {
|
||||
DateTimeFormatter iso8601Formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ Once you have the cluster up and running you can install Dapr:
|
|||
helm repo add dapr https://dapr.github.io/helm-charts/
|
||||
helm repo update
|
||||
helm upgrade --install dapr dapr/dapr \
|
||||
--version=1.15.7 \
|
||||
--version=1.16.0-rc.2 \
|
||||
--namespace dapr-system \
|
||||
--create-namespace \
|
||||
--wait
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ limitations under the License.
|
|||
package io.dapr.testcontainers;
|
||||
|
||||
public interface DaprContainerConstants {
|
||||
String DAPR_VERSION = "1.15.7";
|
||||
String DAPR_VERSION = "1.16.0-rc.2";
|
||||
String DAPR_RUNTIME_IMAGE_TAG = "daprio/daprd:" + DAPR_VERSION;
|
||||
String DAPR_PLACEMENT_IMAGE_TAG = "daprio/placement:" + DAPR_VERSION;
|
||||
String DAPR_SCHEDULER_IMAGE_TAG = "daprio/scheduler:" + DAPR_VERSION;
|
||||
|
|
|
|||
Loading…
Reference in New Issue