EbsTest.php 24 KB

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