public void TestPipelineOperations() { var inputBucket = S3TestUtils.CreateBucket(s3Client); var outputBucket = S3TestUtils.CreateBucket(s3Client); var pipelineName = "sdktest-pipeline" + DateTime.Now.Ticks; var roleName = "sdktest-ets-role" + DateTime.Now.Ticks; var policyName = "Access_Policy"; var pipelineId = string.Empty; var pipelineExists = false; try { // Create a role with trust policy var role = iamClient.CreateRole(new CreateRoleRequest { RoleName = roleName, AssumeRolePolicyDocument = TrustPolicy }).Role; // Set access policy iamClient.PutRolePolicy(new PutRolePolicyRequest { RoleName = roleName, PolicyDocument = AccessPolicy, PolicyName = policyName }); Client.ListPipelines(); // Create Pipeline var pipeline = Client.CreatePipeline( new CreatePipelineRequest { Name = pipelineName, InputBucket = inputBucket, OutputBucket = outputBucket, Notifications = new Notifications { }, Role = role.Arn, AwsKmsKeyArn = kmsKeyArn }).Pipeline; pipelineExists = true; Assert.IsNotNull(pipeline); Assert.AreEqual(pipeline.Name, pipelineName); Thread.Sleep(1000 * 5); pipelineId = pipeline.Id; // List Pipelines var pipelines = Client.ListPipelines().Pipelines; Assert.IsTrue(pipelines.Count > 0); pipelines.Contains(pipeline); // Get Pipeline var readPipelineResult = Client.ReadPipeline( new ReadPipelineRequest() { Id = pipelineId }); Assert.AreEqual(readPipelineResult.Pipeline.Id, pipelineId); // Update pipeline Client.UpdatePipelineStatus( new UpdatePipelineStatusRequest { Id = pipelineId, Status = "Paused" }); // Get pipeline readPipelineResult = Client.ReadPipeline( new ReadPipelineRequest { Id = pipelineId }); Assert.AreEqual("Paused".ToLower(), readPipelineResult.Pipeline.Status.ToLower()); // List jobs var jobs = Client.ListJobsByPipeline( new ListJobsByPipelineRequest { PipelineId = pipelineId, Ascending = "true" }).Jobs; // Remove pipeline Client.DeletePipeline( new DeletePipelineRequest { Id = pipelineId }); pipelineExists = false; AssertExtensions.ExpectException(() => { readPipelineResult = Client.ReadPipeline( new ReadPipelineRequest() { Id = pipelineId }); }, typeof(ResourceNotFoundException)); } finally { s3Client.DeleteBucket(new DeleteBucketRequest { BucketName = inputBucket }); s3Client.DeleteBucket(new DeleteBucketRequest { BucketName = outputBucket }); iamClient.DeleteRolePolicy(new DeleteRolePolicyRequest { RoleName = roleName, PolicyName = policyName }); iamClient.DeleteRole(new DeleteRoleRequest { RoleName = roleName }); if (pipelineExists) { // Remove pipeline Client.DeletePipeline(new DeletePipelineRequest { Id = pipelineId }); } } }
public void Init() { bucketName = S3TestUtils.CreateBucket(Client); }