如何使带有调度程序(Quartz)的应用程序可手动测试?

发布于 2024-11-14 20:08:30 字数 504 浏览 6 评论 0原文

我们正在构建一个具有大量预定处理的财务应用程序。我们希望使应用程序的手动测试变得容易,但由于大多数流程需要几个月才能完成,因此我们需要为测试人员提供将当前日期提前的选项。

对于我们所有的业务服务来说,伪造当前日期不是问题,因为它们都通过“TimeService”间接访问日期。我们遇到的问题是调度程序(Quartz)。不可能将调度程序的当前日期移至未来(也不能移至过去,但这没有多大意义)。我知道在调度程序运行时弄乱它的当前时间可能不是最好的主意,但是如果您可以使用相对于当前日期的偏移时间间隔启动调度程序,那么应该没有逻辑问题 - Quartz 应该找到所有错过的执行并根据配置的失火指令进行处理。

因此,要更具体地说明这个一般设计问题:

  1. 是否有可能伪造 Quartz 的当前日期?
  2. 如果没有,您如何设计这个“测试人员神奇的时间按钮”,将应用程序带向未来?特别是关于计划任务......

需要明确的是 - 我们的自动测试没有问题(不需要调度程序),并且我们并没有尝试测试调度程序本身。

We're building a financial application with quite a lot of scheduled processing. We want to make manual testing of the application easy, but because most of the processes take months to finish, we need to give testers an option to move the current date forward.

It's not a problem to fake current date for all of our business services, because all of them access date indirectly through a "TimeService". The problem we run into is with the scheduler (Quartz). It's not possible to move scheduler's current date into the future (nor past, but that just doesn't make much sense). I understand it's probably not the best idea to mess with Scheduler's current time when it's running, but if you could start the scheduler with an offset time interval relative to current date, there should be no logical problem with that - Quartz should just find all missed executions and handle them according to configured misfire instructions.

So to be a little more specific in this general design question:

  1. Is it possible to fake current date for Quartz?
  2. If not, what's the way you design this "magic time button for testers" that takes the application to the future? Especially regarding scheduled tasks...

Just to be clear - we're not having problems with our automatic tests (no need for scheduler there) and we're not trying to test the scheduler itself.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

靑春怀旧 2024-11-21 20:08:30

我将重点介绍我们最终为其他可能感兴趣的人实施的解决方案。最终我们在开发环境中根本没有使用Quartz。调度程序仅在生产配置中运行(显然不可能改变时间)。然后我们有一段特殊的代码,每天在转换时间时启动日常处理(仅存在于开发/测试环境中)。

我们的底线是:不要尝试将调度程序与调度程序结合起来。将时间转移到未来 - 使用特殊逻辑创建单独的配置,以替换无调度程序配置中的调度程序。

I'll just highlight the solution we ended up implementing for other people that might be interested. In the end, we did not use Quartz in the development environment at all. Scheduler is only running in the production configuration (where it's obviously not possible to shift time). Then we have a special piece of code that launches daily processing for every day when shifting time (which is only present in development / test environment).

The bottom line for us: don't try to combine scheduler & moving time into the future - create separate configuration with one XOR another with special logic to replace scheduler in the scheduler-less configuration.

时光暖心i 2024-11-21 20:08:30

您唯一真正的选择是在启动调度程序之前提前系统时间。

Your only real option is to advance the system's time before starting the scheduler.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文