Skip to content

Commit

Permalink
Add dependsOn in some test config
Browse files Browse the repository at this point in the history
  • Loading branch information
kalaiyarasiganeshalingam committed Mar 25, 2021
1 parent 68fd2d9 commit 68d7b03
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
6 changes: 4 additions & 2 deletions task-ballerina/tests/schedulerTest.bal
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ class Job6 {
}

@test:Config {
groups: ["FrequencyJob"]
groups: ["FrequencyJob"],
dependsOn: [testLogIgnore]
}
function testIgnoreTrigger() returns error? {
JobId id = check scheduleJobRecurByFrequency(new Job6(), 5, maxCount = 10, taskPolicy = { waitingPolicy: IGNORE });
Expand Down Expand Up @@ -555,7 +556,8 @@ isolated function testMaxCountValidation() {
}

@test:Config {
groups: ["FrequencyJob"]
groups: ["FrequencyJob"],
dependsOn: [testLogIgnore]
}
isolated function testEmptyRunningJobs() returns error? {
JobId[] ids = getRunningJobs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@
import org.ballerinalang.stdlib.task.exceptions.SchedulingException;
import org.ballerinalang.stdlib.task.objects.TaskManager;
import org.ballerinalang.stdlib.task.utils.TaskConstants;
import org.ballerinalang.stdlib.task.utils.TaskListener;
import org.ballerinalang.stdlib.task.utils.Utils;
import org.quartz.JobDataMap;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;
import java.util.Random;
Expand All @@ -51,7 +48,6 @@ public class TaskActions {

private static int bound = 1000000;
private static String value = "1000";
private static final Logger LOG = LoggerFactory.getLogger(TaskListener.class);

public static Object configureThread(Environment env, long workerCount, long waitingTimeInMillis) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public static TaskManager getInstance() {
public void initializeScheduler(Properties properties, Environment env) throws SchedulingException,
SchedulerException {
getAllRunningJobs();
if (this.scheduler != null) {
this.scheduler.shutdown();
}
if (!triggerInfoMap.isEmpty()) {
configureScheduler(properties, env);
} else {
Expand All @@ -79,11 +82,13 @@ public Scheduler getScheduler(Properties properties, Environment env) throws Sch
if (isConfiguredSchFactory) {
this.scheduler = Utils.initializeScheduler(this.properties);
isConfiguredSchFactory = false;
setRuntime(env.getRuntime());
} else {
if (this.scheduler == null || this.scheduler.isShutdown()) {
this.scheduler = Utils.initializeScheduler(properties);
setRuntime(env.getRuntime());
}
}
if (this.scheduler == null || this.scheduler.isShutdown()) {
this.scheduler = Utils.initializeScheduler(properties);
}
setRuntime(env.getRuntime());
return this.scheduler;
}

Expand Down Expand Up @@ -164,9 +169,6 @@ private boolean isTriggerCompleted(Trigger.TriggerState triggerState) {

private void configureScheduler(Properties properties, Environment env) throws SchedulerException,
SchedulingException {
if (this.scheduler != null) {
this.scheduler.shutdown();
}
this.scheduler = Utils.initializeScheduler(properties);
setRuntime(env.getRuntime());
if (!triggerInfoMap.isEmpty()) {
Expand Down

0 comments on commit 68d7b03

Please sign in to comment.