2
0

EbsTest.php 23 KB

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