forked from aws/aws-sdk-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConcurrencyTest.php
42 lines (34 loc) · 1.12 KB
/
ConcurrencyTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace Aws\Test\Integ;
use Aws\CommandPool;
use GuzzleHttp\Promise;
class ConcurrencyTest extends \PHPUnit_Framework_TestCase
{
use IntegUtils;
public function testSendsRequestsAsynchronously()
{
/** @var \Aws\S3\S3Client $s3 */
$s3 = $this->getSdk()->createS3();
$promise = Promise\all([
$s3->listBucketsAsync(),
$s3->listBucketsAsync(),
$s3->listBucketsAsync()
]);
$results = $promise->wait();
$this->assertCount(3, $results);
$this->assertCount(1, array_unique(\JmesPath\search('[*].Owner.ID', $results)));
}
public function testSendsRequestsConcurrentlyWithPool()
{
/** @var \Aws\S3\S3Client $s3 */
$s3 = $this->getSdk()->createS3();
$commands = [
$s3->getCommand('ListBuckets'),
$s3->getCommand('ListBuckets'),
$s3->getCommand('ListBuckets')
];
$results = CommandPool::batch($s3, $commands);
$this->assertCount(3, $results);
$this->assertCount(1, array_unique(\JmesPath\search('[*].Owner.ID', $results)));
}
}