예제 #1
0
        private string prepareHistoricBatches(int batchesCount)
        {
            DateTime startDate = ClockUtil.CurrentTime;

            ClockUtil.CurrentTime = DateUtils.addDays(startDate, daysInThePast);

            IList <Batch> list = new List <Batch>();

            for (int i = 0; i < batchesCount; i++)
            {
                list.Add(helper.migrateProcessInstancesAsync(1));
            }

            Batch  batch1    = list[0];
            string batchType = batch1.Type;

            helper.executeSeedJob(batch1);
            helper.executeJobs(batch1);
            ClockUtil.CurrentTime = DateUtils.addDays(startDate, batch1EndTime);
            helper.executeMonitorJob(batch1);

            Batch batch2 = list[1];

            helper.executeSeedJob(batch2);
            helper.executeJobs(batch2);
            ClockUtil.CurrentTime = DateUtils.addDays(startDate, batch2EndTime);
            helper.executeMonitorJob(batch2);

            ClockUtil.CurrentTime = DateTime.Now;

            return(batchType);
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testBatchQueryResult()
        public virtual void testBatchQueryResult()
        {
            DateTime startDate = new DateTime(10000L);
            DateTime endDate   = new DateTime(40000L);

            // given
            ClockUtil.CurrentTime = startDate;
            Batch batch = helper.migrateProcessInstancesAsync(1);

            helper.executeSeedJob(batch);
            helper.executeJobs(batch);

            ClockUtil.CurrentTime = endDate;
            helper.executeMonitorJob(batch);

            // when
            HistoricBatch resultBatch = historyService.createHistoricBatchQuery().singleResult();

            // then
            Assert.assertNotNull(resultBatch);

            assertEquals(batch.Id, resultBatch.Id);
            assertEquals(batch.BatchJobDefinitionId, resultBatch.BatchJobDefinitionId);
            assertEquals(batch.MonitorJobDefinitionId, resultBatch.MonitorJobDefinitionId);
            assertEquals(batch.SeedJobDefinitionId, resultBatch.SeedJobDefinitionId);
            assertEquals(batch.TenantId, resultBatch.TenantId);
            assertEquals(batch.Type, resultBatch.Type);
            assertEquals(batch.BatchJobsPerSeed, resultBatch.BatchJobsPerSeed);
            assertEquals(batch.InvocationsPerBatchJob, resultBatch.InvocationsPerBatchJob);
            assertEquals(batch.TotalJobs, resultBatch.TotalJobs);
            assertEquals(startDate, resultBatch.StartTime);
            assertEquals(endDate, resultBatch.EndTime);
        }
예제 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testDeleteHistoricIncidentByBatchId()
        public virtual void testDeleteHistoricIncidentByBatchId()
        {
            // given
            initBatchOperationHistoryTimeToLive();
            ClockUtil.CurrentTime = DateUtils.addDays(DateTime.Now, -11);

            BatchEntity batch = (BatchEntity)createFailingMigrationBatch();

            migrationHelper.executeSeedJob(batch);

            IList <Job> list = managementService.createJobQuery().list();

            foreach (Job job in list)
            {
                if (((JobEntity)job).JobHandlerType.Equals("instance-migration"))
                {
                    managementService.setJobRetries(job.Id, 1);
                }
            }
            migrationHelper.executeJobs(batch);

            ClockUtil.CurrentTime = DateUtils.addDays(DateTime.Now, -10);
            managementService.deleteBatch(batch.Id, false);
            ClockUtil.CurrentTime = DateTime.Now;

            // assume
            if (eventTypes != null)
            {
                HistoricIncident historicIncident = historyService.createHistoricIncidentQuery().singleResult();
                assertNotNull(historicIncident);
            }

            // when
            historyService.cleanUpHistoryAsync(true);
            foreach (Job job in historyService.findHistoryCleanupJobs())
            {
                managementService.executeJob(job.Id);
            }

            // then
            IList <HistoricIncident> incidents = historyService.createHistoricIncidentQuery().list();

            assertEquals(0, incidents.Count);
        }
예제 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testCleanupHistoricIncident()
        public virtual void testCleanupHistoricIncident()
        {
            initBatchOperationHistoryTimeToLive(DEFAULT_TTL_DAYS);
            ClockUtil.CurrentTime = DateUtils.addDays(DateTime.Now, -11);

            BatchEntity batch = (BatchEntity)createFailingMigrationBatch();

            migrationHelper.executeSeedJob(batch);

            IList <Job> list = managementService.createJobQuery().list();

            foreach (Job job in list)
            {
                if (((JobEntity)job).JobHandlerType.Equals("instance-migration"))
                {
                    managementService.setJobRetries(job.Id, 1);
                }
            }
            migrationHelper.executeJobs(batch);

            IList <string> byteArrayIds = findExceptionByteArrayIds();

            ClockUtil.CurrentTime = DateUtils.addDays(DateTime.Now, -10);
            managementService.deleteBatch(batch.Id, false);
            ClockUtil.CurrentTime = DateTime.Now;

            // given
            HistoricBatch historicBatch = historyService.createHistoricBatchQuery().singleResult();
            string        batchId       = historicBatch.Id;

            // when
            runHistoryCleanup();

            assertEquals(0, historyService.createHistoricBatchQuery().count());
            assertEquals(0, historyService.createHistoricJobLogQuery().jobDefinitionConfiguration(batchId).count());
            assertEquals(0, historyService.createHistoricIncidentQuery().count());
            verifyByteArraysWereRemoved(byteArrayIds.ToArray());
        }