comparison UnitTestsSources/MultiThreadingTests.cpp @ 2950:dc18d5804746

support of JobsHistorySize set to zero
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 30 Nov 2018 17:19:57 +0100
parents 22524fd06225
children 10c610e80b15
comparison
equal deleted inserted replaced
2949:e6204cd21443 2950:dc18d5804746
327 } 327 }
328 328
329 329
330 TEST(JobsRegistry, Priority) 330 TEST(JobsRegistry, Priority)
331 { 331 {
332 JobsRegistry registry; 332 JobsRegistry registry(10);
333 333
334 std::string i1, i2, i3, i4; 334 std::string i1, i2, i3, i4;
335 registry.Submit(i1, new DummyJob(), 10); 335 registry.Submit(i1, new DummyJob(), 10);
336 registry.Submit(i2, new DummyJob(), 30); 336 registry.Submit(i2, new DummyJob(), 30);
337 registry.Submit(i3, new DummyJob(), 20); 337 registry.Submit(i3, new DummyJob(), 20);
406 } 406 }
407 407
408 408
409 TEST(JobsRegistry, Simultaneous) 409 TEST(JobsRegistry, Simultaneous)
410 { 410 {
411 JobsRegistry registry; 411 JobsRegistry registry(10);
412 412
413 std::string i1, i2; 413 std::string i1, i2;
414 registry.Submit(i1, new DummyJob(), 20); 414 registry.Submit(i1, new DummyJob(), 20);
415 registry.Submit(i2, new DummyJob(), 10); 415 registry.Submit(i2, new DummyJob(), 10);
416 416
436 } 436 }
437 437
438 438
439 TEST(JobsRegistry, Resubmit) 439 TEST(JobsRegistry, Resubmit)
440 { 440 {
441 JobsRegistry registry; 441 JobsRegistry registry(10);
442 442
443 std::string id; 443 std::string id;
444 registry.Submit(id, new DummyJob(), 10); 444 registry.Submit(id, new DummyJob(), 10);
445 445
446 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); 446 ASSERT_TRUE(CheckState(registry, id, JobState_Pending));
480 } 480 }
481 481
482 482
483 TEST(JobsRegistry, Retry) 483 TEST(JobsRegistry, Retry)
484 { 484 {
485 JobsRegistry registry; 485 JobsRegistry registry(10);
486 486
487 std::string id; 487 std::string id;
488 registry.Submit(id, new DummyJob(), 10); 488 registry.Submit(id, new DummyJob(), 10);
489 489
490 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); 490 ASSERT_TRUE(CheckState(registry, id, JobState_Pending));
517 } 517 }
518 518
519 519
520 TEST(JobsRegistry, PausePending) 520 TEST(JobsRegistry, PausePending)
521 { 521 {
522 JobsRegistry registry; 522 JobsRegistry registry(10);
523 523
524 std::string id; 524 std::string id;
525 registry.Submit(id, new DummyJob(), 10); 525 registry.Submit(id, new DummyJob(), 10);
526 526
527 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); 527 ASSERT_TRUE(CheckState(registry, id, JobState_Pending));
540 } 540 }
541 541
542 542
543 TEST(JobsRegistry, PauseRunning) 543 TEST(JobsRegistry, PauseRunning)
544 { 544 {
545 JobsRegistry registry; 545 JobsRegistry registry(10);
546 546
547 std::string id; 547 std::string id;
548 registry.Submit(id, new DummyJob(), 10); 548 registry.Submit(id, new DummyJob(), 10);
549 549
550 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); 550 ASSERT_TRUE(CheckState(registry, id, JobState_Pending));
578 } 578 }
579 579
580 580
581 TEST(JobsRegistry, PauseRetry) 581 TEST(JobsRegistry, PauseRetry)
582 { 582 {
583 JobsRegistry registry; 583 JobsRegistry registry(10);
584 584
585 std::string id; 585 std::string id;
586 registry.Submit(id, new DummyJob(), 10); 586 registry.Submit(id, new DummyJob(), 10);
587 587
588 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); 588 ASSERT_TRUE(CheckState(registry, id, JobState_Pending));
615 } 615 }
616 616
617 617
618 TEST(JobsRegistry, Cancel) 618 TEST(JobsRegistry, Cancel)
619 { 619 {
620 JobsRegistry registry; 620 JobsRegistry registry(10);
621 621
622 std::string id; 622 std::string id;
623 registry.Submit(id, new DummyJob(), 10); 623 registry.Submit(id, new DummyJob(), 10);
624 624
625 ASSERT_FALSE(registry.Cancel("nope")); 625 ASSERT_FALSE(registry.Cancel("nope"));
709 709
710 710
711 711
712 TEST(JobsEngine, SubmitAndWait) 712 TEST(JobsEngine, SubmitAndWait)
713 { 713 {
714 JobsEngine engine; 714 JobsEngine engine(10);
715 engine.SetThreadSleep(10); 715 engine.SetThreadSleep(10);
716 engine.SetWorkersCount(3); 716 engine.SetWorkersCount(3);
717 engine.Start(); 717 engine.Start();
718 718
719 Json::Value content = Json::nullValue; 719 Json::Value content = Json::nullValue;
729 } 729 }
730 730
731 731
732 TEST(JobsEngine, DISABLED_SequenceOfOperationsJob) 732 TEST(JobsEngine, DISABLED_SequenceOfOperationsJob)
733 { 733 {
734 JobsEngine engine; 734 JobsEngine engine(10);
735 engine.SetThreadSleep(10); 735 engine.SetThreadSleep(10);
736 engine.SetWorkersCount(3); 736 engine.SetWorkersCount(3);
737 engine.Start(); 737 engine.Start();
738 738
739 std::string id; 739 std::string id;
769 } 769 }
770 770
771 771
772 TEST(JobsEngine, DISABLED_Lua) 772 TEST(JobsEngine, DISABLED_Lua)
773 { 773 {
774 JobsEngine engine; 774 JobsEngine engine(10);
775 engine.SetThreadSleep(10); 775 engine.SetThreadSleep(10);
776 engine.SetWorkersCount(2); 776 engine.SetWorkersCount(2);
777 engine.Start(); 777 engine.Start();
778 778
779 LuaJobManager lua; 779 LuaJobManager lua;
1280 1280
1281 public: 1281 public:
1282 OrthancJobsSerialization() 1282 OrthancJobsSerialization()
1283 { 1283 {
1284 db_.Open(); 1284 db_.Open();
1285 context_.reset(new ServerContext(db_, storage_, true /* running unit tests */)); 1285 context_.reset(new ServerContext(db_, storage_, true /* running unit tests */, 10));
1286 context_->SetupJobsEngine(true, false); 1286 context_->SetupJobsEngine(true, false);
1287 } 1287 }
1288 1288
1289 virtual ~OrthancJobsSerialization() ORTHANC_OVERRIDE 1289 virtual ~OrthancJobsSerialization() ORTHANC_OVERRIDE
1290 { 1290 {
1702 { 1702 {
1703 Json::Value s; 1703 Json::Value s;
1704 std::string i1, i2; 1704 std::string i1, i2;
1705 1705
1706 { 1706 {
1707 JobsRegistry registry; 1707 JobsRegistry registry(10);
1708 registry.Submit(i1, new DummyJob(), 10); 1708 registry.Submit(i1, new DummyJob(), 10);
1709 registry.Submit(i2, new SequenceOfOperationsJob(), 30); 1709 registry.Submit(i2, new SequenceOfOperationsJob(), 30);
1710 registry.Serialize(s); 1710 registry.Serialize(s);
1711 } 1711 }
1712 1712
1713 { 1713 {
1714 DummyUnserializer unserializer; 1714 DummyUnserializer unserializer;
1715 JobsRegistry registry(unserializer, s); 1715 JobsRegistry registry(unserializer, s, 10);
1716 1716
1717 Json::Value t; 1717 Json::Value t;
1718 registry.Serialize(t); 1718 registry.Serialize(t);
1719 ASSERT_TRUE(CheckSameJson(s, t)); 1719 ASSERT_TRUE(CheckSameJson(s, t));
1720 } 1720 }