saurabhnanda / odd-jobs

Haskell job queue with admin UI and loads of other features.
https://www.haskelltutorials.com/odd-jobs/
BSD 3-Clause "New" or "Revised" License
75 stars 29 forks source link

Proper test suite #4

Open saurabhnanda opened 4 years ago

mrputty commented 3 years ago

As a prelude to working on issue #38, I just tried to build the current test-suite (via cabal configure --enable-tests; cabal build tests), and it fails with lots of errors like this:

test/Test.hs:163:38: error:
    Not in scope: ‘Job.monitorJobRunner’
    Module ‘OddJobs.Job’ does not export ‘monitorJobRunner’.
    |
163 |   let jobMonitorSettings = defaults{ Job.monitorJobRunner = jobRunner
    |                                      ^^^^^^^^^^^^^^^^^^^^

It looks like these undefined symbols are from an earlier version of odd-jobs. Is the jobrunner test-suite intended to work with the current version?

There are several other code files in this test-suite that are empty or all commented out. Also, the devel executable seems to have been used for ad hoc testing as some point, but it is also no longer working.

@saurabhnanda, could you describe the current testing process (prior to the implementation of a proper test suite)?

saurabhnanda commented 3 years ago

could you describe the current testing process (prior to the implementation of a proper test suite)?

there were simple "example based" tests primarily to ensure that the underlying raw SQL for things like createJob, scheduleJob were working.

There was one massive property-based test which first scheduled many randomly created jobs, and then run them, and then assert a bunch of properties.

I'll get the test suite back to working condition and then we can collaborate on it iteratively along with developing the feature and the benchmarks.

saurabhnanda commented 3 years ago

@mrputty I've got the tests to compile again in the fix/tests branch. Although the tests themselves are still failing. I'll spend some time now in getting the tests up-to-speed.

saurabhnanda commented 3 years ago

@mrputty the "example based" tests are passing now. The property-based test is still commented-out. I'll take a look at it over the weekend.

mrputty commented 3 years ago

@saurabhnanda , thanks for looking at this. I've started thinking about how to write some behavioral tests for #38, but I'd like to get your comments on my draft #55 before I put any real work into that.

mrputty commented 3 years ago

@saurabhnanda, I'm soon going to start working on unit test for #38. I normally do Haskell development in Docker containers, and I typically run things like a database for unit testing in a separate container from the one running GHC. The upshot of this is that I'd like to make a change in the test/Test.sh to facilitate this.

Specifically, I'd like to introduce an environment variable that would, if set, override the hard coded connInfo that's currently defined in main. I'd also do a little bit of refactoring around pool creation, but otherwise I don't think anything would have to change, and things would continue to work as they do today when the environment variable is not set.

Let me know if you have any concerns about this.