Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ class SpringSchedulingTest extends InstrumentationSpecification {
setup:
def context = new AnnotationConfigApplicationContext(TriggerTaskConfig, SchedulingConfig)
def task = context.getBean(TriggerTask)
def scheduledTaskEndpoint = context.getBean(ScheduledTasksEndpoint)

task.blockUntilExecute()
// Capture cron tasks before closing the context (endpoint is unavailable after close).
def cronTasks = scheduledTaskEndpoint.scheduledTasks().getCron()
// Close the context immediately after the first execution to prevent a second cron
// firing before assertions complete, which would produce extra traces and cause flakiness.
context.close()

expect:
assert task != null
Expand Down Expand Up @@ -54,13 +60,10 @@ class SpringSchedulingTest extends InstrumentationSpecification {
}
}
and:
def scheduledTaskEndpoint = context.getBean(ScheduledTasksEndpoint)
assert scheduledTaskEndpoint != null
scheduledTaskEndpoint.scheduledTasks().getCron().each {
cronTasks.each {
it.getRunnable().getTarget() == TriggerTask.getName()
}
cleanup:
context.close()
}

def "schedule interval test"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ class SpringSchedulingTest extends InstrumentationSpecification {
setup:
def context = new AnnotationConfigApplicationContext(TriggerTaskConfig, SchedulingConfig)
def task = context.getBean(TriggerTask)
def scheduledTaskEndpoint = context.getBean(ScheduledTasksEndpoint)

task.blockUntilExecute()
// Capture cron tasks before closing the context (endpoint is unavailable after close).
def cronTasks = scheduledTaskEndpoint.scheduledTasks().getCron()
// Close the context immediately after the first execution to prevent a second cron
// firing before assertions complete, which would produce extra traces and cause flakiness.
context.close()

expect:
assert task != null
Expand Down Expand Up @@ -54,13 +60,10 @@ class SpringSchedulingTest extends InstrumentationSpecification {
}
}
and:
def scheduledTaskEndpoint = context.getBean(ScheduledTasksEndpoint)
assert scheduledTaskEndpoint != null
scheduledTaskEndpoint.scheduledTasks().getCron().each {
cronTasks.each {
it.getRunnable().getTarget() == TriggerTask.getName()
}
cleanup:
context.close()
}

def "schedule interval test"() {
Expand Down
Loading