コード例 #1
0
        public void RunDependentJob()
        {
            sut.EmulateServiceStart(null);
            DirectoryInfo tempDir = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "tempdll"));

            tempDir.Create();
            try
            {
                List <ExecutablePackage> packages = new List <ExecutablePackage>();
                ExecutablePackage        package  = new ExecutablePackage("mock.xml", tempDir.FullName, "TestJobManager.dll", "TestJobManager.MockJobRunner", new SerializableDictionary <string, string>(), new SerializableDictionary <string, string>());
                packages.Add(package);
                Job j1 = new Job("nobuildpath", "MockVMConfig1", new SerializableDictionary <string, string>(), packages, new SerializableDictionary <string, string>());
                Job j2 = new Job("nobuildpath", "MockVMConfig2", new SerializableDictionary <string, string>(), packages, new SerializableDictionary <string, string>());
                j2.DependsOnJobIds.Add(j1.JobID);
                MessageSendRecieve msr = new MessageSendRecieve(new DirectoryInfo(inboxPath), new DirectoryInfo(outboxPath));
                DateTime           queuedJobsDateTime = DateTime.Now;
                string             job2msgID          = msr.QueueJob(j2);
                string             job1msgID          = msr.QueueJob(j1);
                //wait for job 1 to start
                Assert.True(WaitForVMAction(vmHash["MockVMName1"], VMActionType.Start, queuedJobsDateTime, TimeSpan.FromSeconds(10)));
                //send request for job 1
                AutomationMessage m = new AutomationMessage(new SimpleRequest(SimpleRequests.JobRequest));
                m.From = "MockVMName1";
                Job j = msr.WaitForJob(msr.Send(m), DEFAULT_WAIT);
                Assert.That(j, Is.Not.Null);
                //send finished for job 1
                DateTime finishedSentDateTime = DateTime.Now;
                msr.ReportJobStatus(new JobCompleted(j1, new JobResult()));
                //wait for job 2 to start
                Assert.True(WaitForVMAction(vmHash["MockVMName2"], VMActionType.Start, finishedSentDateTime, TimeSpan.FromSeconds(10)));
                //send request for job 2
                m      = new AutomationMessage(new SimpleRequest(SimpleRequests.JobRequest));
                m.From = "MockVMName2";
                j      = msr.WaitForJob(msr.Send(m), DEFAULT_WAIT);
                Assert.That(j, Is.Not.Null);
                //send finished for job2
                msr.ReportJobStatus(new JobCompleted(j2, new JobResult()));

                Assert.That(msr.WaitForJobCompletion(job1msgID, DEFAULT_WAIT), Is.Not.Null);
                Assert.That(msr.WaitForJobCompletion(job2msgID, DEFAULT_WAIT), Is.Not.Null);

                sut.EmulateServiceStop();

                VerifyAppLogDoesNotContain(EventLogEntryType.Warning, testStart);
                VerifyAppLogDoesNotContain(EventLogEntryType.Error, testStart);

                VerifyMockVMActionInvoked(vmHash["MockVMName1"], VMActionType.RevertToNamedSnapshot, "Snapshot1");
                VerifyMockVMActionInvoked(vmHash["MockVMName2"], VMActionType.RevertToNamedSnapshot, "Snapshot2");
            }
            finally
            {
                tempDir.Delete(true);
            }
        }
コード例 #2
0
        public void TestNullDirPathInJob()
        {
            sut.EmulateServiceStart(null);
            List <ExecutablePackage> packages = new List <ExecutablePackage>();
            ExecutablePackage        package  = new ExecutablePackage("mock.xml", null, "TestJobManager.dll", "TestJobManager.MockJobRunner", new SerializableDictionary <string, string>(), new SerializableDictionary <string, string>());

            packages.Add(package);
            Job j1 = new Job("nobuildpath", "MockVMConfig1", new SerializableDictionary <string, string>(), packages, new SerializableDictionary <string, string>());
            MessageSendRecieve msr = new MessageSendRecieve(new DirectoryInfo(inboxPath), new DirectoryInfo(outboxPath));
            DateTime           queuedJobsDateTime = DateTime.Now;
            string             job1msgID          = msr.QueueJob(j1);

            //wait for job completion
            JobCompleted jobCompleted = msr.WaitForJobCompletion(job1msgID, DEFAULT_WAIT);

            sut.EmulateServiceStop();

            Assert.That(jobCompleted, Is.Not.Null);
            Assert.That(jobCompleted.Job, Is.Not.Null);
            Assert.That(jobCompleted.Result, Is.Not.Null);
            Assert.That(jobCompleted.Result.Errors, Is.Not.Empty);
            VerifyStringInList(jobCompleted.Result.Errors, "Exception: Value cannot be null.\nParameter name: path");

            VerifyAppLogDoesNotContain(EventLogEntryType.Warning, testStart);
            VerifyAppLogDoesNotContain(EventLogEntryType.Error, testStart);
        }
コード例 #3
0
        public void TestNullISOs()
        {
            sut.EmulateServiceStart(null);
            DirectoryInfo tempDir = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "tempdll"));

            tempDir.Create();
            try
            {
                List <ExecutablePackage> packages = new List <ExecutablePackage>();
                ExecutablePackage        package  = new ExecutablePackage("mock.xml", tempDir.FullName, "TestJobManager.dll", "TestJobManager.MockJobRunner", new SerializableDictionary <string, string>(), new SerializableDictionary <string, string>());
                packages.Add(package);

                Job j1 = new Job(null, "MockVMConfig1", null, packages, new SerializableDictionary <string, string>());
                MessageSendRecieve msr = new MessageSendRecieve(new DirectoryInfo(inboxPath), new DirectoryInfo(outboxPath));
                DateTime           queuedJobsDateTime = DateTime.Now;
                string             job1msgID          = msr.QueueJob(j1);

                //wait for job 1 to start
                Assert.True(WaitForVMAction(vmHash["MockVMName1"], VMActionType.Start, queuedJobsDateTime, TimeSpan.FromSeconds(5)));

                //send request for job 1
                AutomationMessage m = new AutomationMessage(new SimpleRequest(SimpleRequests.JobRequest));
                m.From = "MockVMName1";
                Job j = msr.WaitForJob(msr.Send(m), DEFAULT_WAIT);
                Assert.That(j, Is.Not.Null);
                Assert.That(j.JobID, Is.EqualTo(j1.JobID));

                //send finished for job 1
                DateTime  finishedSentDateTime = DateTime.Now;
                JobResult jr = new JobResult();
                jr.Completed = true;
                ExecutionResult er = new ExecutionResult();
                er.Success = true;
                jr.ExecutionResults.Add(er);
                msr.ReportJobStatus(new JobCompleted(j1, jr));

                //wait for job completion
                JobCompleted jobCompleted = msr.WaitForJobCompletion(job1msgID, DEFAULT_WAIT);

                sut.EmulateServiceStop();

                VerifyAppLogDoesNotContain(EventLogEntryType.Warning, testStart);
                VerifyAppLogDoesNotContain(EventLogEntryType.Error, testStart);

                Assert.That(jobCompleted, Is.Not.Null);
                Assert.That(jobCompleted.Job, Is.Not.Null);
                Assert.That(jobCompleted.Result, Is.Not.Null);
                Assert.That(jobCompleted.Result.Errors, Is.Empty);
                Assert.That(jobCompleted.Result.Success, Is.True);
                Assert.That(jobCompleted.Result.Completed, Is.True);
            }
            finally
            {
                tempDir.Delete(true);
            }
        }
コード例 #4
0
        public void TestNullConfiguration()
        {
            sut.EmulateServiceStart(null);
            Job j1 = new Job("abc", null, new SerializableDictionary <string, string>(), new List <ExecutablePackage>(), new SerializableDictionary <string, string>());
            MessageSendRecieve msr = new MessageSendRecieve(new DirectoryInfo(inboxPath), new DirectoryInfo(outboxPath));
            DateTime           queuedJobsDateTime = DateTime.Now;
            string             job1msgID          = msr.QueueJob(j1);

            //wait for job completion
            JobCompleted jobCompleted = msr.WaitForJobCompletion(job1msgID, DEFAULT_WAIT);

            sut.EmulateServiceStop();

            VerifyAppLogDoesNotContain(EventLogEntryType.Warning, testStart);
            VerifyAppLogDoesNotContain(EventLogEntryType.Error, testStart);

            Assert.That(jobCompleted, Is.Not.Null);
            Assert.That(jobCompleted.Job, Is.Not.Null);
            Assert.That(jobCompleted.Result, Is.Not.Null);
            Assert.That(jobCompleted.Result.Errors, Is.Not.Empty);
            VerifyStringInList(jobCompleted.Result.Errors, "Configuration cannot be null or empty");
        }
コード例 #5
0
        public void TestNullPackageList()
        {
            sut.EmulateServiceStart(null);
            Job j1 = new Job("nobuildpath", "MockVMConfig1", new SerializableDictionary <string, string>(), null, new SerializableDictionary <string, string>());
            MessageSendRecieve msr = new MessageSendRecieve(new DirectoryInfo(inboxPath), new DirectoryInfo(outboxPath));
            DateTime           queuedJobsDateTime = DateTime.Now;
            string             job1msgID          = msr.QueueJob(j1);

            //wait for job completion
            JobCompleted jobCompleted = msr.WaitForJobCompletion(job1msgID, DEFAULT_WAIT);

            sut.EmulateServiceStop();

            VerifyAppLogDoesNotContain(EventLogEntryType.Warning, testStart);
            VerifyAppLogDoesNotContain(EventLogEntryType.Error, testStart);

            Assert.That(jobCompleted, Is.Not.Null);
            Assert.That(jobCompleted.Job, Is.Not.Null);
            Assert.That(jobCompleted.Result, Is.Not.Null);
            Assert.That(jobCompleted.Result.Errors, Is.Not.Empty);
            VerifyStringInList(jobCompleted.Result.Errors, "Job does not have any packages defined");
        }