2
0

EbsTest.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Service_Amazon
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * Test helper
  24. */
  25. require_once dirname(__FILE__) . '/../../../../TestHelper.php';
  26. require_once 'PHPUnit/Framework/TestCase.php';
  27. require_once 'Zend/Http/Client.php';
  28. require_once 'Zend/Http/Client/Adapter/Test.php';
  29. require_once 'Zend/Service/Amazon/Ec2/Ebs.php';
  30. /**
  31. * Zend_Service_Amazon_Ec2_Ebs test case.
  32. *
  33. * @category Zend
  34. * @package Zend_Service_Amazon
  35. * @subpackage UnitTests
  36. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  37. * @license http://framework.zend.com/license/new-bsd New BSD License
  38. * @group Zend_Service
  39. * @group Zend_Service_Amazon
  40. * @group Zend_Service_Amazon_Ec2
  41. */
  42. class Zend_Service_Amazon_Ec2_EbsTest extends PHPUnit_Framework_TestCase
  43. {
  44. /**
  45. * @var Zend_Service_Amazon_Ec2_Ebs
  46. */
  47. private $Zend_Service_Amazon_Ec2_Ebs;
  48. /**
  49. * Prepares the environment before running a test.
  50. */
  51. protected function setUp()
  52. {
  53. parent::setUp();
  54. $this->Zend_Service_Amazon_Ec2_Ebs = new Zend_Service_Amazon_Ec2_Ebs('access_key', 'secret_access_key');
  55. $adapter = new Zend_Http_Client_Adapter_Test();
  56. $client = new Zend_Http_Client(null, array(
  57. 'adapter' => $adapter
  58. ));
  59. $this->adapter = $adapter;
  60. Zend_Service_Amazon_Ec2_Ebs::setHttpClient($client);
  61. }
  62. /**
  63. * Cleans up the environment after running a test.
  64. */
  65. protected function tearDown()
  66. {
  67. unset($this->adapter);
  68. $this->Zend_Service_Amazon_Ec2_Ebs = null;
  69. parent::tearDown();
  70. }
  71. public function testAttachVolume()
  72. {
  73. $rawHttpResponse = "HTTP/1.1 200 OK\r\n"
  74. . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
  75. . "Server: hi\r\n"
  76. . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
  77. . "Status: 200 OK\r\n"
  78. . "Content-type: application/xml; charset=utf-8\r\n"
  79. . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
  80. . "Connection: close\r\n"
  81. . "\r\n"
  82. . "<AttachVolumeResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
  83. . " <volumeId>vol-4d826724</volumeId>\r\n"
  84. . " <instanceId>i-6058a509</instanceId>\r\n"
  85. . " <device>/dev/sdh</device>\r\n"
  86. . " <status>attaching</status>\r\n"
  87. . " <attachTime>2008-05-07T11:51:50.000Z</attachTime>\r\n"
  88. . "</AttachVolumeResponse >";
  89. $this->adapter->setResponse($rawHttpResponse);
  90. $return = $this->Zend_Service_Amazon_Ec2_Ebs->attachVolume('vol-4d826724', 'i-6058a509', '/dev/sdh');
  91. $arrAttach = array(
  92. 'volumeId' => 'vol-4d826724',
  93. 'instanceId' => 'i-6058a509',
  94. 'device' => '/dev/sdh',
  95. 'status' => 'attaching',
  96. 'attachTime' => '2008-05-07T11:51:50.000Z'
  97. );
  98. $this->assertSame($arrAttach, $return);
  99. }
  100. public function testCreateSnapshot()
  101. {
  102. $rawHttpResponse = "HTTP/1.1 200 OK\r\n"
  103. . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
  104. . "Server: hi\r\n"
  105. . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
  106. . "Status: 200 OK\r\n"
  107. . "Content-type: application/xml; charset=utf-8\r\n"
  108. . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
  109. . "Connection: close\r\n"
  110. . "\r\n"
  111. . "<CreateSnapshotResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
  112. . " <snapshotId>snap-78a54011</snapshotId>\r\n"
  113. . " <volumeId>vol-4d826724</volumeId>\r\n"
  114. . " <status>pending</status>\r\n"
  115. . " <startTime>2008-05-07T11:51:50.000Z</startTime>\r\n"
  116. . " <progress></progress>\r\n"
  117. . "</CreateSnapshotResponse>";
  118. $this->adapter->setResponse($rawHttpResponse);
  119. $return = $this->Zend_Service_Amazon_Ec2_Ebs->createSnapshot('vol-4d826724');
  120. $arrCreateSnapShot = array(
  121. 'snapshotId' => 'snap-78a54011',
  122. 'volumeId' => 'vol-4d826724',
  123. 'status' => 'pending',
  124. 'startTime' => '2008-05-07T11:51:50.000Z',
  125. 'progress' => ''
  126. );
  127. $this->assertSame($arrCreateSnapShot, $return);
  128. }
  129. public function testCreateNewVolume()
  130. {
  131. $rawHttpResponse = "HTTP/1.1 200 OK\r\n"
  132. . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
  133. . "Server: hi\r\n"
  134. . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
  135. . "Status: 200 OK\r\n"
  136. . "Content-type: application/xml; charset=utf-8\r\n"
  137. . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
  138. . "Connection: close\r\n"
  139. . "\r\n"
  140. . "<CreateVolumeResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
  141. . " <volumeId>vol-4d826724</volumeId>\r\n"
  142. . " <size>400</size>\r\n"
  143. . " <status>creating</status>\r\n"
  144. . " <createTime>2008-05-07T11:51:50.000Z</createTime>\r\n"
  145. . " <availabilityZone>us-east-1a</availabilityZone>\r\n"
  146. . " <snapshotId></snapshotId>\r\n"
  147. . "</CreateVolumeResponse>";
  148. $this->adapter->setResponse($rawHttpResponse);
  149. $return = $this->Zend_Service_Amazon_Ec2_Ebs->createNewVolume(400, 'us-east-1a');
  150. $arrCreateNewVolume = array(
  151. 'volumeId' => 'vol-4d826724',
  152. 'size' => '400',
  153. 'status' => 'creating',
  154. 'createTime' => '2008-05-07T11:51:50.000Z',
  155. 'availabilityZone' => 'us-east-1a'
  156. );
  157. $this->assertSame($arrCreateNewVolume, $return);
  158. }
  159. public function testCreateVolumeFromSnapshot()
  160. {
  161. $rawHttpResponse = "HTTP/1.1 200 OK\r\n"
  162. . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
  163. . "Server: hi\r\n"
  164. . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
  165. . "Status: 200 OK\r\n"
  166. . "Content-type: application/xml; charset=utf-8\r\n"
  167. . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
  168. . "Connection: close\r\n"
  169. . "\r\n"
  170. . "<CreateVolumeResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
  171. . " <volumeId>vol-4d826724</volumeId>\r\n"
  172. . " <size>400</size>\r\n"
  173. . " <status>creating</status>\r\n"
  174. . " <createTime>2008-05-07T11:51:50.000Z</createTime>\r\n"
  175. . " <availabilityZone>us-east-1a</availabilityZone>\r\n"
  176. . " <snapshotId>snap-78a54011</snapshotId>\r\n"
  177. . "</CreateVolumeResponse>";
  178. $this->adapter->setResponse($rawHttpResponse);
  179. $return = $this->Zend_Service_Amazon_Ec2_Ebs->createVolumeFromSnapshot('snap-78a54011', 'us-east-1a');
  180. $arrCreateNewVolume = array(
  181. 'volumeId' => 'vol-4d826724',
  182. 'size' => '400',
  183. 'status' => 'creating',
  184. 'createTime' => '2008-05-07T11:51:50.000Z',
  185. 'availabilityZone' => 'us-east-1a',
  186. 'snapshotId' => 'snap-78a54011'
  187. );
  188. $this->assertSame($arrCreateNewVolume, $return);
  189. }
  190. public function testDeleteSnapshot()
  191. {
  192. $rawHttpResponse = "HTTP/1.1 200 OK\r\n"
  193. . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
  194. . "Server: hi\r\n"
  195. . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
  196. . "Status: 200 OK\r\n"
  197. . "Content-type: application/xml; charset=utf-8\r\n"
  198. . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
  199. . "Connection: close\r\n"
  200. . "\r\n"
  201. . "<DeleteSnapshotResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
  202. . " <return>true</return>\r\n"
  203. . "</DeleteSnapshotResponse>";
  204. $this->adapter->setResponse($rawHttpResponse);
  205. $return = $this->Zend_Service_Amazon_Ec2_Ebs->deleteSnapshot('snap-78a54011');
  206. $this->assertTrue($return);
  207. }
  208. public function testDeleteVolume()
  209. {
  210. $rawHttpResponse = "HTTP/1.1 200 OK\r\n"
  211. . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
  212. . "Server: hi\r\n"
  213. . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
  214. . "Status: 200 OK\r\n"
  215. . "Content-type: application/xml; charset=utf-8\r\n"
  216. . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
  217. . "Connection: close\r\n"
  218. . "\r\n"
  219. . "<DeleteVolumeResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
  220. . " <return>true</return>\r\n"
  221. . "</DeleteVolumeResponse>";
  222. $this->adapter->setResponse($rawHttpResponse);
  223. $return = $this->Zend_Service_Amazon_Ec2_Ebs->deleteVolume('vol-4d826724');
  224. $this->assertTrue($return);
  225. }
  226. /**
  227. * Tests Zend_Service_Amazon_Ec2_Ebs->describeSnapshot()
  228. */
  229. public function testDescribeSingleSnapshot()
  230. {
  231. $rawHttpResponse = "HTTP/1.1 200 OK\r\n"
  232. . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
  233. . "Server: hi\r\n"
  234. . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
  235. . "Status: 200 OK\r\n"
  236. . "Content-type: application/xml; charset=utf-8\r\n"
  237. . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
  238. . "Connection: close\r\n"
  239. . "\r\n"
  240. . "<DescribeSnapshotsResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
  241. . " <snapshotSet>\r\n"
  242. . " <item>\r\n"
  243. . " <snapshotId>snap-78a54011</snapshotId>\r\n"
  244. . " <volumeId>vol-4d826724</volumeId>\r\n"
  245. . " <status>pending</status>\r\n"
  246. . " <startTime>2008-05-07T12:51:50.000Z</startTime>\r\n"
  247. . " <progress>80%</progress>\r\n"
  248. . " </item>\r\n"
  249. . " </snapshotSet>\r\n"
  250. . "</DescribeSnapshotsResponse>";
  251. $this->adapter->setResponse($rawHttpResponse);
  252. $return = $this->Zend_Service_Amazon_Ec2_Ebs->describeSnapshot('snap-78a54011');
  253. $arrSnapshot = array(array(
  254. 'snapshotId' => 'snap-78a54011',
  255. 'volumeId' => 'vol-4d826724',
  256. 'status' => 'pending',
  257. 'startTime' => '2008-05-07T12:51:50.000Z',
  258. 'progress' => '80%'
  259. ));
  260. $this->assertSame($arrSnapshot, $return);
  261. }
  262. public function testDescribeMultipleSnapshots()
  263. {
  264. $rawHttpResponse = "HTTP/1.1 200 OK\r\n"
  265. . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
  266. . "Server: hi\r\n"
  267. . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
  268. . "Status: 200 OK\r\n"
  269. . "Content-type: application/xml; charset=utf-8\r\n"
  270. . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
  271. . "Connection: close\r\n"
  272. . "\r\n"
  273. . "<DescribeSnapshotsResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
  274. . " <snapshotSet>\r\n"
  275. . " <item>\r\n"
  276. . " <snapshotId>snap-78a54011</snapshotId>\r\n"
  277. . " <volumeId>vol-4d826724</volumeId>\r\n"
  278. . " <status>pending</status>\r\n"
  279. . " <startTime>2008-05-07T12:51:50.000Z</startTime>\r\n"
  280. . " <progress>80%</progress>\r\n"
  281. . " </item>\r\n"
  282. . " <item>\r\n"
  283. . " <snapshotId>snap-78a54012</snapshotId>\r\n"
  284. . " <volumeId>vol-4d826725</volumeId>\r\n"
  285. . " <status>pending</status>\r\n"
  286. . " <startTime>2008-08-07T12:51:50.000Z</startTime>\r\n"
  287. . " <progress>65%</progress>\r\n"
  288. . " </item>\r\n"
  289. . " </snapshotSet>\r\n"
  290. . "</DescribeSnapshotsResponse>";
  291. $this->adapter->setResponse($rawHttpResponse);
  292. $return = $this->Zend_Service_Amazon_Ec2_Ebs->describeSnapshot(array('snap-78a54011', 'snap-78a54012'));
  293. $arrSnapshots = array(
  294. array(
  295. 'snapshotId' => 'snap-78a54011',
  296. 'volumeId' => 'vol-4d826724',
  297. 'status' => 'pending',
  298. 'startTime' => '2008-05-07T12:51:50.000Z',
  299. 'progress' => '80%',
  300. ),
  301. array(
  302. 'snapshotId' => 'snap-78a54012',
  303. 'volumeId' => 'vol-4d826725',
  304. 'status' => 'pending',
  305. 'startTime' => '2008-08-07T12:51:50.000Z',
  306. 'progress' => '65%',
  307. )
  308. );
  309. $this->assertSame($arrSnapshots, $return);
  310. }
  311. /**
  312. * Tests Zend_Service_Amazon_Ec2_Ebs->describeVolume()
  313. */
  314. public function testDescribeSingleVolume()
  315. {
  316. $rawHttpResponse = "HTTP/1.1 200 OK\r\n"
  317. . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
  318. . "Server: hi\r\n"
  319. . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
  320. . "Status: 200 OK\r\n"
  321. . "Content-type: application/xml; charset=utf-8\r\n"
  322. . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
  323. . "Connection: close\r\n"
  324. . "\r\n"
  325. . "<DescribeVolumesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
  326. . "<volumeSet>\r\n"
  327. . " <item>\r\n"
  328. . " <volumeId>vol-4282672b</volumeId>\r\n"
  329. . " <size>800</size>\r\n"
  330. . " <status>in-use</status>\r\n"
  331. . " <createTime>2008-05-07T11:51:50.000Z</createTime>\r\n"
  332. . " <attachmentSet>\r\n"
  333. . " <item>\r\n"
  334. . " <volumeId>vol-4282672b</volumeId>\r\n"
  335. . " <instanceId>i-6058a509</instanceId>\r\n"
  336. . " <device>/dev/sdh</device>\r\n"
  337. . " <snapshotId>snap-12345678</snapshotId>\r\n"
  338. . " <availabilityZone>us-east-1a</availabilityZone>\r\n"
  339. . " <status>attached</status>\r\n"
  340. . " <attachTime>2008-05-07T12:51:50.000Z</attachTime>\r\n"
  341. . " </item>\r\n"
  342. . " </attachmentSet>\r\n"
  343. . " </item>\r\n"
  344. . "</volumeSet>\r\n"
  345. . "</DescribeVolumesResponse>";
  346. $this->adapter->setResponse($rawHttpResponse);
  347. $return = $this->Zend_Service_Amazon_Ec2_Ebs->describeVolume('vol-4282672b');
  348. $arrVolumes = array(
  349. array(
  350. 'volumeId' => 'vol-4282672b',
  351. 'size' => '800',
  352. 'status' => 'in-use',
  353. 'createTime' => '2008-05-07T11:51:50.000Z',
  354. 'attachmentSet' => array(
  355. 'volumeId' => 'vol-4282672b',
  356. 'instanceId' => 'i-6058a509',
  357. 'device' => '/dev/sdh',
  358. 'status' => 'attached',
  359. 'attachTime' => '2008-05-07T12:51:50.000Z',
  360. )
  361. )
  362. );
  363. $this->assertSame($arrVolumes, $return);
  364. }
  365. public function testDescribeMultipleVolume()
  366. {
  367. $rawHttpResponse = "HTTP/1.1 200 OK\r\n"
  368. . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
  369. . "Server: hi\r\n"
  370. . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
  371. . "Status: 200 OK\r\n"
  372. . "Content-type: application/xml; charset=utf-8\r\n"
  373. . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
  374. . "Connection: close\r\n"
  375. . "\r\n"
  376. . "<DescribeVolumesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
  377. . "<volumeSet>\r\n"
  378. . " <item>\r\n"
  379. . " <volumeId>vol-4282672b</volumeId>\r\n"
  380. . " <size>800</size>\r\n"
  381. . " <status>in-use</status>\r\n"
  382. . " <createTime>2008-05-07T11:51:50.000Z</createTime>\r\n"
  383. . " <attachmentSet>\r\n"
  384. . " <item>\r\n"
  385. . " <volumeId>vol-4282672b</volumeId>\r\n"
  386. . " <instanceId>i-6058a509</instanceId>\r\n"
  387. . " <device>/dev/sdh</device>\r\n"
  388. . " <snapshotId>snap-12345678</snapshotId>\r\n"
  389. . " <availabilityZone>us-east-1a</availabilityZone>\r\n"
  390. . " <status>attached</status>\r\n"
  391. . " <attachTime>2008-05-07T12:51:50.000Z</attachTime>\r\n"
  392. . " </item>\r\n"
  393. . " </attachmentSet>\r\n"
  394. . " </item>\r\n"
  395. . " <item>\r\n"
  396. . " <volumeId>vol-42826775</volumeId>\r\n"
  397. . " <size>40</size>\r\n"
  398. . " <status>available</status>\r\n"
  399. . " <createTime>2008-08-07T11:51:50.000Z</createTime>\r\n"
  400. . " </item>\r\n"
  401. . "</volumeSet>\r\n"
  402. . "</DescribeVolumesResponse>";
  403. $this->adapter->setResponse($rawHttpResponse);
  404. $return = $this->Zend_Service_Amazon_Ec2_Ebs->describeVolume(array('vol-4282672b', 'vol-42826775'));
  405. $arrVolumes = array(
  406. array(
  407. 'volumeId' => 'vol-4282672b',
  408. 'size' => '800',
  409. 'status' => 'in-use',
  410. 'createTime' => '2008-05-07T11:51:50.000Z',
  411. 'attachmentSet' => array(
  412. 'volumeId' => 'vol-4282672b',
  413. 'instanceId' => 'i-6058a509',
  414. 'device' => '/dev/sdh',
  415. 'status' => 'attached',
  416. 'attachTime' => '2008-05-07T12:51:50.000Z',
  417. )
  418. ),
  419. array(
  420. 'volumeId' => 'vol-42826775',
  421. 'size' => '40',
  422. 'status' => 'available',
  423. 'createTime' => '2008-08-07T11:51:50.000Z'
  424. )
  425. );
  426. $this->assertSame($arrVolumes, $return);
  427. }
  428. public function testDescribeAttachedVolumes()
  429. {
  430. $rawHttpResponse = "HTTP/1.1 200 OK\r\n"
  431. . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
  432. . "Server: hi\r\n"
  433. . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
  434. . "Status: 200 OK\r\n"
  435. . "Content-type: application/xml; charset=utf-8\r\n"
  436. . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
  437. . "Connection: close\r\n"
  438. . "\r\n"
  439. . "<DescribeVolumesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
  440. . "<volumeSet>\r\n"
  441. . " <item>\r\n"
  442. . " <volumeId>vol-4282672b</volumeId>\r\n"
  443. . " <size>800</size>\r\n"
  444. . " <status>in-use</status>\r\n"
  445. . " <createTime>2008-05-07T11:51:50.000Z</createTime>\r\n"
  446. . " <attachmentSet>\r\n"
  447. . " <item>\r\n"
  448. . " <volumeId>vol-4282672b</volumeId>\r\n"
  449. . " <instanceId>i-6058a509</instanceId>\r\n"
  450. . " <device>/dev/sdh</device>\r\n"
  451. . " <snapshotId>snap-12345678</snapshotId>\r\n"
  452. . " <availabilityZone>us-east-1a</availabilityZone>\r\n"
  453. . " <status>attached</status>\r\n"
  454. . " <attachTime>2008-05-07T12:51:50.000Z</attachTime>\r\n"
  455. . " </item>\r\n"
  456. . " </attachmentSet>\r\n"
  457. . " </item>\r\n"
  458. . " <item>\r\n"
  459. . " <volumeId>vol-42826775</volumeId>\r\n"
  460. . " <size>40</size>\r\n"
  461. . " <status>available</status>\r\n"
  462. . " <createTime>2008-08-07T11:51:50.000Z</createTime>\r\n"
  463. . " </item>\r\n"
  464. . "</volumeSet>\r\n"
  465. . "</DescribeVolumesResponse>";
  466. $this->adapter->setResponse($rawHttpResponse);
  467. $return = $this->Zend_Service_Amazon_Ec2_Ebs->describeAttachedVolumes('i-6058a509');
  468. $arrVolumes = array(
  469. array(
  470. 'volumeId' => 'vol-4282672b',
  471. 'size' => '800',
  472. 'status' => 'in-use',
  473. 'createTime' => '2008-05-07T11:51:50.000Z',
  474. 'attachmentSet' => array(
  475. 'volumeId' => 'vol-4282672b',
  476. 'instanceId' => 'i-6058a509',
  477. 'device' => '/dev/sdh',
  478. 'status' => 'attached',
  479. 'attachTime' => '2008-05-07T12:51:50.000Z',
  480. )
  481. )
  482. );
  483. $this->assertSame($arrVolumes, $return);
  484. }
  485. /**
  486. * Tests Zend_Service_Amazon_Ec2_Ebs->detachVolume()
  487. */
  488. public function testDetachVolume()
  489. {
  490. $rawHttpResponse = "HTTP/1.1 200 OK\r\n"
  491. . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
  492. . "Server: hi\r\n"
  493. . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
  494. . "Status: 200 OK\r\n"
  495. . "Content-type: application/xml; charset=utf-8\r\n"
  496. . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
  497. . "Connection: close\r\n"
  498. . "\r\n"
  499. . "<DetachVolumeResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
  500. . " <volumeId>vol-4d826724</volumeId>\r\n"
  501. . " <instanceId>i-6058a509</instanceId>\r\n"
  502. . " <device>/dev/sdh</device>\r\n"
  503. . " <status>detaching</status>\r\n"
  504. . " <attachTime>2008-05-08T11:51:50.000Z</attachTime>\r\n"
  505. . "</DetachVolumeResponse>";
  506. $this->adapter->setResponse($rawHttpResponse);
  507. $return = $this->Zend_Service_Amazon_Ec2_Ebs->detachVolume('vol-4d826724');
  508. $arrVolume = array(
  509. 'volumeId' => 'vol-4d826724',
  510. 'instanceId' => 'i-6058a509',
  511. 'device' => '/dev/sdh',
  512. 'status' => 'detaching',
  513. 'attachTime' => '2008-05-08T11:51:50.000Z'
  514. );
  515. $this->assertSame($arrVolume, $return);
  516. }
  517. }