Esempio n. 1
0
        public void JobShell_Can_Start()
        {
            var queueName = QueueNameHelper.CreateQueueName();
            var jobStore  = new InMemoryTestStore();
            var executor  = new HardInjectedJobExecutorShell <JobQueueLayerActor, JobWorkerActor, JobQueueCoordinator>(() => new JobQueueLayerActor(jobStore),
                                                                                                                       () => new JobWorkerActor(new MockJobSuccessExecutor()),
                                                                                                                       () => new JobQueueCoordinator(), null);

            executor.StartJobQueue(queueName, 5, 1);
        }
Esempio n. 2
0
        public void JobExecutorShell_Will_Execute_Jobs()
        {
            var queueName = QueueNameHelper.CreateQueueName();
            var jobStore  = new InMemoryTestStore();
            var executor  = new HardInjectedJobExecutorShell <JobQueueLayerActor, JobWorkerActor, JobQueueCoordinator>(() => new JobQueueLayerActor(jobStore),
                                                                                                                       () => new JobWorkerActor(new DefaultJobExecutor(new DefaultContainerFactory())),
                                                                                                                       () => new JobQueueCoordinator(), null);

            executor.StartJobQueue(queueName, 5, 1, 1);
            jobStore.AddJob((ShellMockJob m) => m.DoThing(0), null, null, queueName);
            SpinWait.SpinUntil(() => false, TimeSpan.FromSeconds(8));
            Xunit.Assert.Equal(1, ShellMockJob.MyCounter);
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            var store    = new InMemoryTestStore();
            var jobQueue = new HardInjectedJobExecutorShell <JobQueueLayerActor, JobWorkerActor, JobQueueCoordinator>(() => new JobQueueLayerActor(store),
                                                                                                                      () => new JobWorkerActor(new DefaultJobExecutor(new DefaultContainerFactory())),
                                                                                                                      () => new JobQueueCoordinator(),
                                                                                                                      loggerConfig: new StandardConsoleEngineLoggerConfig("DEBUG"));

            jobQueue.StartJobQueue("sample", 5, 5);


            var timer = StartSampleJobTimer(store);

            System.Console.WriteLine("Press ENTER to quit...");
            System.Console.ReadLine();
        }
Esempio n. 4
0
        public void JobExecutorShell_Will_Shutdown()
        {
            var queueName = QueueNameHelper.CreateQueueName();
            //Warning: this test is a bit racy, due to the nature of JobExecutor and the scheduler.
            //Lowering the timeouts may cause false failures on the test, as the timer may fire before the shutdown is even called.
            var jobStore = new InMemoryTestStore();
            var executor = new HardInjectedJobExecutorShell <JobQueueLayerActor, JobWorkerActor, JobQueueCoordinator>(() => new JobQueueLayerActor(jobStore),
                                                                                                                      () => new JobWorkerActor(new DefaultJobExecutor(new DefaultContainerFactory())),
                                                                                                                      () => new JobQueueCoordinator(), null);

            jobStore.AddJob((ShellShutdownMockJob1 m) => m.DoThing(0), null, null, queueName);
            executor.StartJobQueue(queueName, 5, 5, 5);
            executor.ShutDownQueue(queueName);
            SpinWait.SpinUntil(() => false, TimeSpan.FromSeconds(5));
            Xunit.Assert.True(ShellShutdownMockJob1.MyCounter.ContainsKey(0) == false);
        }