public function testFactoryInitializesClient() { $client = DataPipelineClient::factory(array(ClientOptions::KEY => 'foo', ClientOptions::SECRET => 'bar', ClientOptions::REGION => 'us-east-1')); $this->assertInstanceOf('Aws\\Common\\Signature\\SignatureV4', $client->getSignature()); $this->assertInstanceOf('Aws\\Common\\Credentials\\Credentials', $client->getCredentials()); $this->assertEquals('https://datapipeline.us-east-1.amazonaws.com', $client->getBaseUrl()); }
public function testLongPollingEnabledForPollForWorkOperation() { $client = DataPipelineClient::factory(array(ClientOptions::KEY => 'foo', ClientOptions::SECRET => 'bar', ClientOptions::REGION => 'us-east-1')); $command = $client->getCommand('PollForTask'); $curlopts = $command->get('curl.options') ?: array(); $this->assertArrayHasKey('CURLOPT_TIMEOUT', $curlopts); $this->assertEquals($curlopts['CURLOPT_TIMEOUT'], 90); }
public function testCrudOperationsForPipelines() { self::log('Create 3 pipelines.'); $pipelineIds = array(); foreach (range(1, 3) as $index) { $name = "php-test-pipeline-{$index}"; $result = $this->dataPipeline->getCommand('CreatePipeline', array('name' => $name, 'uniqueId' => $name))->getResult(); $pipelineIds[] = $result['pipelineId']; } self::log('List the pipelines and make sure the ones we added are there.'); foreach ($this->dataPipeline->getIterator('ListPipelines') as $pipeline) { if (strpos($pipeline['name'], 'php-test-pipeline') === 0) { $this->assertContains($pipeline['id'], $pipelineIds); } } self::log('Describe the pipelines and make sure the ones we added are still there.'); $result = $this->dataPipeline->getCommand('DescribePipelines', array('pipelineIds' => $pipelineIds))->getResult(); $this->assertCount(3, $result['pipelineDescriptionList']); foreach ($result['pipelineDescriptionList'] as $pipeline) { $this->assertContains($pipeline['pipelineId'], $pipelineIds); } self::log('Test putting a pipeline definition.'); $definition = array('pipelineId' => $pipelineIds[0], 'pipelineObjects' => array(array('id' => 'Default', 'name' => 'Default', 'fields' => array(array('key' => 'workerGroup', 'stringValue' => 'workerGroup'))), array('id' => 'Schedule', 'name' => 'Schedule', 'fields' => array(array('key' => 'startDateTime', 'stringValue' => '2012-12-12T00:00:00'), array('key' => 'type', 'stringValue' => 'Schedule'), array('key' => 'period', 'stringValue' => '1 hour'), array('key' => 'endDateTime', 'stringValue' => '2012-12-21T18:00:00'))), array('id' => 'SayHello', 'name' => 'SayHello', 'fields' => array(array('key' => 'type', 'stringValue' => 'ShellCommandActivity'), array('key' => 'command', 'stringValue' => 'echo hello'), array('key' => 'parent', 'refValue' => 'Default'), array('key' => 'schedule', 'refValue' => 'Schedule'))))); $result = $this->dataPipeline->getCommand('ValidatePipelineDefinition', $definition)->getResult(); $this->assertFalse($result->get('errored')); $result = $this->dataPipeline->getCommand('PutPipelineDefinition', $definition)->getResult(); $this->assertFalse($result->get('errored')); self::log('Get a pipeline definition.'); $response = $this->dataPipeline->getCommand('GetPipelineDefinition', array('pipelineId' => $pipelineIds[0]))->getResponse(); $this->assertEquals(200, $response->getStatusCode()); self::log('Delete the pipelines we created.'); foreach ($pipelineIds as $pipelineId) { $response = $this->dataPipeline->getCommand('DeletePipeline', array('pipelineId' => $pipelineId))->getResponse(); $this->assertEquals(200, $response->getStatusCode()); } self::log('Sleep to let delete calls propagate.'); sleep(5); self::log('List the pipelines and make sure the ones we deleted are gone.'); foreach ($this->dataPipeline->getIterator('ListPipelines') as $pipeline) { if (strpos($pipeline['name'], 'php-test-pipeline') === 0) { $this->fail("The pipeline {$pipeline['name']} was not deleted."); } } }