Exemple #1
0
 public RemotePool(string remoteServerUri, string username, string password)
 {
     Service          = new RemoteExecutionService(remoteServerUri, username, password);
     PendingJobs      = new ConcurrentDictionary <string, Job>();
     ShutdownPool     = new ManualResetEvent(false);
     JobMonitorThread = new Thread(MonitorJobs);
     JobMonitorThread.Start();
 }
Exemple #2
0
        public void TestArtifactUpload()
        {
            var service = new RemoteExecutionService("http://localhost:8080", "test", "test");

            var hash = "";

            using (var uploadedFileStream = new MemoryStream(Resources.test_run_dir))
            {
                hash = service.UploadArtifact(uploadedFileStream);
            }

            Assert.Equal(hash, "4a0c2b277e4451d5ac59ccd57edf786c79455c99");
        }
Exemple #3
0
        public void TestRunJobToCompletion()
        {
            var service = new RemoteExecutionService("http://localhost:8080", "test", "test");

            var hash = "";

            using (var uploadedFileStream = new MemoryStream(Resources.test_run_dir))
            {
                hash = service.UploadArtifact(uploadedFileStream);
            }

            Assert.Equal(hash, "4a0c2b277e4451d5ac59ccd57edf786c79455c99");

            var jobId = service.CreateJob("dir", ".", hash, "");

            Assert.NotNull(jobId);

            var jobComplete = false;
            var timer       = 0;

            do
            {
                var jobStatus = service.GetJobInfo(jobId);

                if (jobStatus.Status == RemoteExecutionService.RemoteJobState.Succeeded ||
                    jobStatus.Status == RemoteExecutionService.RemoteJobState.Cancelled ||
                    jobStatus.Status == RemoteExecutionService.RemoteJobState.Failed)
                {
                    jobComplete = true;
                }
                else
                {
                    Thread.Sleep(1000);
                    timer += 1000;
                }
            } while (!jobComplete && timer <= (20 * 1000));

            var finalStatus = service.GetJobInfo(jobId);

            Assert.Equal(RemoteExecutionService.RemoteJobState.Succeeded, finalStatus.Status);
            Assert.NotNull(finalStatus.ResultZipId);

            Assert.Equal(hash, "4a0c2b277e4451d5ac59ccd57edf786c79455c99");

            using (var downloadedFileStream = new MemoryStream())
            {
                service.DownloadArtifact(finalStatus.ResultZipId, downloadedFileStream);

                Assert.NotEqual(0, downloadedFileStream.Length);
            }
        }
Exemple #4
0
        public void VerifyServer(string password)
        {
            Verifying = true;
            var verifyServerTask = new Task <Exception>(() =>
            {
                var remoteService = new RemoteExecutionService(ServerName, Username, password);

                try
                {
                    remoteService.PingServer(); //TODO: validate that we received the response we expected
                    return(null);
                }
                catch (Exception e)
                {
                    return(e);
                }
            });

            verifyServerTask.ContinueWith(task =>
            {
                if (task.Result == null)
                {
                    // Verification completed successfully
                    if (ServerVerified != null)
                    {
                        ServerVerified(this, EventArgs.Empty);
                    }
                }
                else
                {
                    Verifying = false;

                    if (ServerVerificationFailed != null)
                    {
                        ServerVerificationFailed(this, new ServerVerificationFailedEventArgs(task.Result));
                    }
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());

            verifyServerTask.Start();
        }
Exemple #5
0
        public void GetJobGetsJob()
        {
            var service = new RemoteExecutionService("http://localhost:8080", "test", "test");

            var hash = "";

            using (var uploadedFileStream = new MemoryStream(Resources.test_run_dir))
            {
                hash = service.UploadArtifact(uploadedFileStream);
            }

            Assert.Equal(hash, "4a0c2b277e4451d5ac59ccd57edf786c79455c99");

            var jobId = service.CreateJob("dir", ".", hash, "");

            Assert.NotNull(jobId);

            var job = service.GetJobInfo(jobId);

            Assert.NotNull(job);
            Assert.Equal(job.Uid, jobId);
        }
Exemple #6
0
        public void GetNonexistentJobThrows()
        {
            var service = new RemoteExecutionService("http://localhost:8080", "test", "test");

            Assert.Throws <RemoteExecutionService.ObjectNotFoundException>(() => service.GetJobInfo("not_a_job_id"));
        }