Skip to content

Commit

Permalink
Added Schedule test for boot3 application. (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
cppwfs authored Aug 3, 2023
1 parent 42b29c4 commit 96ad9ac
Showing 1 changed file with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2022 the original author or authors.
* Copyright 2020-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -90,7 +90,7 @@ public void after() {

while (scheduleInfoResourceIterator.hasNext()) {
scheduleInfoResource = scheduleInfoResourceIterator.next();
logger.info("Test unchedule:" + scheduleInfoResource.getScheduleName());
logger.info("Test unschedule:" + scheduleInfoResource.getScheduleName());
dataFlowOperations.schedulerOperations().unschedule(scheduleInfoResource.getScheduleName());
}
}
Expand Down Expand Up @@ -198,6 +198,42 @@ public void scheduleLifeCycle() {
}
}

@Test
@Tag("group4")
@Tag("smoke")
public void scheduleLifeCycleBoot3() {
logger.info("schedule-lifecycle-test-boot3");
if (!supportBoot3Jobs()) {
logger.warn("skipping boot3 workload for " + runtimeApps.getDataflowServerVersion());
return;
}

try (Task task = Task.builder(dataFlowOperations).name(randomName("task")).definition("testtimestamp3").build();
TaskSchedule taskSchedule = TaskSchedule.builder(dataFlowOperations).scheduleName(randomName("schedule")).task(task).build()) {

assertThat(taskSchedule.isScheduled()).isFalse();

logger.info("schedule-lifecycle-test: SCHEDULE");
taskSchedule.schedule(DEFAULT_CRON_EXPRESSION, Collections.emptyMap());

assertThat(taskSchedule.isScheduled()).isTrue();

TaskSchedule retrievedSchedule = TaskSchedule.builder(dataFlowOperations).findByScheduleName(taskSchedule.getScheduleName()).get();
assertThat(retrievedSchedule.getScheduleName()).isEqualTo(taskSchedule.getScheduleName());
assertThat(retrievedSchedule.getScheduleProperties().containsKey(SchedulerPropertyKeys.CRON_EXPRESSION)).isTrue();
assertThat(retrievedSchedule.getScheduleProperties().get(SchedulerPropertyKeys.CRON_EXPRESSION)).isEqualTo(DEFAULT_CRON_EXPRESSION);

logger.info("schedule-lifecycle-test-boot3: UNSCHEDULE");
taskSchedule.unschedule();

assertThat(taskSchedule.isScheduled()).isFalse();
}
}

private boolean supportBoot3Jobs() {
return !runtimeApps.dataflowServerVersionLowerThan("2.11.0-SNAPSHOT");
}

private static String randomName(String prefix) {
return prefix + "-" + UUID.randomUUID().toString().substring(0, 10);
}
Expand Down

0 comments on commit 96ad9ac

Please sign in to comment.