예제 #1
0
        private async Task AssertPolicyDoesNotRetryOnValidationExceptions(IRetryPolicy policy)
        {
            int callCount = 0;

            using (BatchClient client = BatchClient.Open(this.credentials))
            {
                client.CustomBehaviors.Add(new RequestInterceptor(
                                               (req) =>
                {
                    var stronglyTypedRequest = (Microsoft.Azure.Batch.Protocol.BatchRequests.JobAddBatchRequest)req;

                    var originalServiceRequestFunc = stronglyTypedRequest.ServiceRequestFunc;

                    stronglyTypedRequest.ServiceRequestFunc = (token) =>
                    {
                        ++callCount;
                        return(originalServiceRequestFunc(token));
                    };
                }));

                client.CustomBehaviors.Add(new RetryPolicyProvider(policy));

                //This will throw an exception since a job has required parameters such as id which are not specified
                CloudJob job = client.JobOperations.CreateJob();
                await Assert.ThrowsAsync <Microsoft.Rest.ValidationException>(async() => await job.CommitAsync());

                Assert.Equal(1, callCount);
            }
        }
예제 #2
0
        public void CreateJobWithApplicationReferencesTest()
        {
            const string applicationId = "blender.exe";
            const string version       = "blender";
            const string jobId         = "mock-job";

            using (BatchClient client = ClientUnitTestCommon.CreateDummyClient())
            {
                Microsoft.Azure.Batch.PoolInformation autoPoolSpecification = new Microsoft.Azure.Batch.PoolInformation
                {
                    AutoPoolSpecification = new Microsoft.Azure.Batch.AutoPoolSpecification
                    {
                        KeepAlive         = false,
                        PoolSpecification = new Microsoft.Azure.Batch.PoolSpecification
                        {
                            ApplicationPackageReferences = new List <Microsoft.Azure.Batch.ApplicationPackageReference>
                            {
                                new Microsoft.Azure.Batch.ApplicationPackageReference
                                {
                                    ApplicationId = applicationId,
                                    Version       = version
                                }
                            },
                            AutoScaleEnabled = false
                        }
                    }
                };

                Microsoft.Azure.Batch.CloudJob cloudJob = client.JobOperations.CreateJob(jobId, autoPoolSpecification);

                Assert.Equal(cloudJob.PoolInformation.AutoPoolSpecification.PoolSpecification.ApplicationPackageReferences.First().ApplicationId, applicationId);
                Assert.Equal(cloudJob.PoolInformation.AutoPoolSpecification.PoolSpecification.ApplicationPackageReferences.First().Version, version);
            }
        }
        private async Task AssertPolicyDoesNotRetryOnValidationExceptions(IRetryPolicy policy)
        {
            int callCount = 0;

            using (BatchClient client = BatchClient.Open(this.credentials))
            {
                client.CustomBehaviors.Add(new RequestInterceptor(
                                               (req) =>
                {
                    var stronglyTypedRequest = (Microsoft.Azure.Batch.Protocol.BatchRequests.JobAddBatchRequest)req;

                    stronglyTypedRequest.ServiceRequestFunc = (token) =>
                    {
                        ++callCount;
                        throw new Microsoft.Rest.ValidationException();
                    };
                }));

                client.CustomBehaviors.Add(new RetryPolicyProvider(policy));

                CloudJob job = client.JobOperations.CreateJob();
                await Assert.ThrowsAsync <Microsoft.Rest.ValidationException>(async() => await job.CommitAsync());

                Assert.Equal(1, callCount);
            }
        }
예제 #4
0
 internal PSCloudJob(Microsoft.Azure.Batch.CloudJob omObject)
 {
     if ((omObject == null))
     {
         throw new System.ArgumentNullException("omObject");
     }
     this.omObject = omObject;
 }
예제 #5
0
 internal PSCloudJob(Microsoft.Azure.Batch.CloudJob omObject)
 {
     if ((omObject == null))
     {
         throw new System.ArgumentNullException("omObject");
     }
     this.omObject = omObject;
 }