Skip to content

Conversation

@barton2526
Copy link
Member

This adds a test case for the scheduler from upstream. The goal of this PR was initially to port bitcoin/bitcoin#18285, which adds a test case to catch bugs like this one #1887. While working I discovered we didn't test the scheduler at all, so let's get more coverage.

Ref: bitcoin/bitcoin@fa6bad2

Optional other tests include:

BOOST_AUTO_TEST_CASE(manythreads)

    // Stress test: hundreds of microsecond-scheduled tasks,
    // serviced by 10 threads.
    //
    // So... ten shared counters, which if all the tasks execute
    // properly will sum to the number of tasks done.
    // Each task adds or subtracts a random amount from one of the
    // counters, and then schedules another task 0-1000
    // microseconds in the future to subtract or add from
    // the counter -random_amount+1, so in the end the shared
    // counters should sum to the number of initial tasks performed.
...


 BOOST_AUTO_TEST_CASE(singlethreadedscheduler_ordered)

    // each queue should be well ordered with respect to itself but not other queues
    SingleThreadedSchedulerClient queue1(&scheduler);
    SingleThreadedSchedulerClient queue2(&scheduler);

    // create more threads than queues
    // if the queues only permit execution of one task at once then
    // the extra threads should effectively be doing nothing
    // if they don't we'll get out of order behaviour
...

@barton2526
Copy link
Member Author

barton2526 commented Sep 11, 2021

The PR compiles, but the new test case is failing in an obscure way.

   Running 413 test cases...
  unknown location(0): fatal error: in "scheduler_tests/wait_until_past": Throw location unknown (consider using BOOST_THROW_EXCEPTION)
  Dynamic exception type: boost::wrapexcept<boost::condition_error>
  std::exception::what: boost::condition_variable::do_wait_until failed in pthread_cond_timedwait: Invalid argument
  
  test/scheduler_tests.cpp(38): last checkpoint
  
  *** 1 failure is detected in the test module "Gridcoin Test Suite"
  FAIL test/test_gridcoin (exit status: 201)

It also appears to have passed on Windows 32 bit...?

Perhaps it would be better to take boost out of the scheduler?
bitcoin/bitcoin@d0ebd93

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants