smartcommunitylab / smartcampus.gamification

8 stars 10 forks source link

Classification rules are not triggered #67

Open nyhobbit opened 8 years ago

nyhobbit commented 8 years ago

by the leaderboard definition - likely a race condition because it works when debugger is on.

nyhobbit commented 8 years ago

here is a test file that makes the problem evident. https://github.com/nyhobbit/smartcampus.gamification/blob/long-game/game-engine.test/src/test/java/eu/trentorise/LongGameTest.java

mirkoperillo commented 8 years ago

It's correct, there is a race condition and so we have a bug.

The issue happens when in test environment game defines some classification tasks and test simulates some game execution.

The bug affected only the test environment and not the runtime execution. This is because in test environment task execution is emulated invoking directly the execute method sequentially on the main thread, meanwhile game executions are queued on another thread.

In real situation the cronjob executes the task using the GameContext so the task calls to engine are queued on the same thread executor.