mirror of https://github.com/dapr/java-sdk.git
chore: Use 1.16.0 rc 2 (#1463)
* chore: Use 1.16.0 rc Signed-off-by: Javier Aliaga <javier@diagrid.io> * chore: Use dapr:1.16-rc.2 Signed-off-by: Javier Aliaga <javier@diagrid.io> * chore: Add overwrite flag to jobs Signed-off-by: Javier Aliaga <javier@diagrid.io> --------- Signed-off-by: Javier Aliaga <javier@diagrid.io> Signed-off-by: sirivarma <siri.varma@outlook.com>
This commit is contained in:
parent
9b94509cf9
commit
48ad25e334
|
|
@ -39,7 +39,7 @@ jobs:
|
||||||
GOPROXY: https://proxy.golang.org
|
GOPROXY: https://proxy.golang.org
|
||||||
JDK_VER: ${{ matrix.java }}
|
JDK_VER: ${{ matrix.java }}
|
||||||
DAPR_CLI_VER: 1.15.0
|
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_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.15.0/install/install.sh
|
||||||
DAPR_CLI_REF:
|
DAPR_CLI_REF:
|
||||||
DAPR_REF:
|
DAPR_REF:
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ jobs:
|
||||||
GOPROXY: https://proxy.golang.org
|
GOPROXY: https://proxy.golang.org
|
||||||
JDK_VER: ${{ matrix.java }}
|
JDK_VER: ${{ matrix.java }}
|
||||||
DAPR_CLI_VER: 1.15.0
|
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_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.15.0/install/install.sh
|
||||||
DAPR_CLI_REF:
|
DAPR_CLI_REF:
|
||||||
DAPR_REF:
|
DAPR_REF:
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ public class DaprTestContainersConfig {
|
||||||
@ServiceConnection
|
@ServiceConnection
|
||||||
public DaprContainer daprContainer(Network daprNetwork, PostgreSQLContainer<?> postgreSQLContainer){
|
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")
|
.withAppName("producer-app")
|
||||||
.withNetwork(daprNetwork)
|
.withNetwork(daprNetwork)
|
||||||
.withComponent(new Component("kvstore", "state.postgresql", "v1", STATE_STORE_PROPERTIES))
|
.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
|
@ServiceConnection
|
||||||
public DaprContainer daprContainer(Network daprNetwork, PostgreSQLContainer<?> postgreSQLContainer, RabbitMQContainer rabbitMQContainer){
|
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")
|
.withAppName("producer-app")
|
||||||
.withNetwork(daprNetwork)
|
.withNetwork(daprNetwork)
|
||||||
.withComponent(new Component("kvstore", "state.postgresql", "v1", STATE_STORE_PROPERTIES))
|
.withComponent(new Component("kvstore", "state.postgresql", "v1", STATE_STORE_PROPERTIES))
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ public class DaprJobsIT {
|
||||||
.withZone(ZoneOffset.UTC);
|
.withZone(ZoneOffset.UTC);
|
||||||
|
|
||||||
Instant currentTime = Instant.now();
|
Instant currentTime = Instant.now();
|
||||||
daprPreviewClient.scheduleJob(new ScheduleJobRequest("Job", currentTime)).block();
|
daprPreviewClient.scheduleJob(new ScheduleJobRequest("Job", currentTime).setOverwrite(true)).block();
|
||||||
|
|
||||||
GetJobResponse getJobResponse =
|
GetJobResponse getJobResponse =
|
||||||
daprPreviewClient.getJob(new GetJobRequest("Job")).block();
|
daprPreviewClient.getJob(new GetJobRequest("Job")).block();
|
||||||
|
|
@ -108,7 +108,7 @@ public class DaprJobsIT {
|
||||||
|
|
||||||
Instant currentTime = Instant.now();
|
Instant currentTime = Instant.now();
|
||||||
daprPreviewClient.scheduleJob(new ScheduleJobRequest("Job", JobSchedule.hourly())
|
daprPreviewClient.scheduleJob(new ScheduleJobRequest("Job", JobSchedule.hourly())
|
||||||
.setDueTime(currentTime)).block();
|
.setDueTime(currentTime).setOverwrite(true)).block();
|
||||||
|
|
||||||
GetJobResponse getJobResponse =
|
GetJobResponse getJobResponse =
|
||||||
daprPreviewClient.getJob(new GetJobRequest("Job")).block();
|
daprPreviewClient.getJob(new GetJobRequest("Job")).block();
|
||||||
|
|
@ -129,6 +129,7 @@ public class DaprJobsIT {
|
||||||
.setTtl(currentTime.plus(2, ChronoUnit.HOURS))
|
.setTtl(currentTime.plus(2, ChronoUnit.HOURS))
|
||||||
.setData("Job data".getBytes())
|
.setData("Job data".getBytes())
|
||||||
.setRepeat(3)
|
.setRepeat(3)
|
||||||
|
.setOverwrite(true)
|
||||||
.setSchedule(JobSchedule.fromString(cronExpression))).block();
|
.setSchedule(JobSchedule.fromString(cronExpression))).block();
|
||||||
|
|
||||||
GetJobResponse getJobResponse =
|
GetJobResponse getJobResponse =
|
||||||
|
|
@ -152,6 +153,7 @@ public class DaprJobsIT {
|
||||||
.setTtl(currentTime.plus(2, ChronoUnit.HOURS))
|
.setTtl(currentTime.plus(2, ChronoUnit.HOURS))
|
||||||
.setData("Job data".getBytes())
|
.setData("Job data".getBytes())
|
||||||
.setRepeat(3)
|
.setRepeat(3)
|
||||||
|
.setOverwrite(true)
|
||||||
.setSchedule(JobSchedule.fromString(cronExpression))).block();
|
.setSchedule(JobSchedule.fromString(cronExpression))).block();
|
||||||
|
|
||||||
daprPreviewClient.deleteJob(new DeleteJobRequest("Job")).block();
|
daprPreviewClient.deleteJob(new DeleteJobRequest("Job")).block();
|
||||||
|
|
|
||||||
|
|
@ -1353,6 +1353,8 @@ public class DaprClientImpl extends AbstractDaprClient {
|
||||||
scheduleJobRequestBuilder.setDueTime(iso8601Formatter.format(scheduleJobRequest.getDueTime()));
|
scheduleJobRequestBuilder.setDueTime(iso8601Formatter.format(scheduleJobRequest.getDueTime()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scheduleJobRequestBuilder.setOverwrite(scheduleJobRequest.getOverwrite());
|
||||||
|
|
||||||
Mono<DaprProtos.ScheduleJobResponse> scheduleJobResponseMono =
|
Mono<DaprProtos.ScheduleJobResponse> scheduleJobResponseMono =
|
||||||
Mono.deferContextual(context -> this.createMono(
|
Mono.deferContextual(context -> this.createMono(
|
||||||
it -> intercept(context, asyncStub)
|
it -> intercept(context, asyncStub)
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ public class ScheduleJobRequest {
|
||||||
private Instant dueTime;
|
private Instant dueTime;
|
||||||
private Integer repeats;
|
private Integer repeats;
|
||||||
private Instant ttl;
|
private Instant ttl;
|
||||||
|
private boolean overwrite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor to create ScheduleJobRequest.
|
* Constructor to create ScheduleJobRequest.
|
||||||
|
|
@ -165,4 +166,24 @@ public class ScheduleJobRequest {
|
||||||
public Instant getTtl() {
|
public Instant getTtl() {
|
||||||
return ttl;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -833,6 +833,84 @@ public class DaprPreviewClientGrpcTest {
|
||||||
assertEquals("Name in the request cannot be null or empty", exception.getMessage());
|
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
|
@Test
|
||||||
public void getJobShouldReturnResponseWhenAllFieldsArePresentInRequest() {
|
public void getJobShouldReturnResponseWhenAllFieldsArePresentInRequest() {
|
||||||
DateTimeFormatter iso8601Formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
|
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 add dapr https://dapr.github.io/helm-charts/
|
||||||
helm repo update
|
helm repo update
|
||||||
helm upgrade --install dapr dapr/dapr \
|
helm upgrade --install dapr dapr/dapr \
|
||||||
--version=1.15.7 \
|
--version=1.16.0-rc.2 \
|
||||||
--namespace dapr-system \
|
--namespace dapr-system \
|
||||||
--create-namespace \
|
--create-namespace \
|
||||||
--wait
|
--wait
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ limitations under the License.
|
||||||
package io.dapr.testcontainers;
|
package io.dapr.testcontainers;
|
||||||
|
|
||||||
public interface DaprContainerConstants {
|
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_RUNTIME_IMAGE_TAG = "daprio/daprd:" + DAPR_VERSION;
|
||||||
String DAPR_PLACEMENT_IMAGE_TAG = "daprio/placement:" + DAPR_VERSION;
|
String DAPR_PLACEMENT_IMAGE_TAG = "daprio/placement:" + DAPR_VERSION;
|
||||||
String DAPR_SCHEDULER_IMAGE_TAG = "daprio/scheduler:" + DAPR_VERSION;
|
String DAPR_SCHEDULER_IMAGE_TAG = "daprio/scheduler:" + DAPR_VERSION;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue