Snapshot tests are now passing.

This commit is contained in:
Technosophos
2012-05-30 11:34:07 -05:00
parent 56cdcf09d1
commit a1bdb7ca11
4 changed files with 34 additions and 18 deletions

View File

@@ -50,6 +50,7 @@ class DBaaSSnapshot extends DBaaSTestCase {
$this->assertNotEmpty($dbname);
$this->destroyDatabase();
//$this->destroySnapshots();
$dbaas = $this->dbaas();
$inst = $dbaas->instance();
@@ -64,20 +65,23 @@ class DBaaSSnapshot extends DBaaSTestCase {
$snap = $dbaas->snapshot();
$this->assertInstanceOf('\HPCloud\Services\DBaaS\Snapshot', $snap);
$name = $id . '-SNAPSHOT';
$name = $id . self::SNAPSHOT_SUFFIX;
$snap->listSnapshots();
$details = $snap->create($id, $name);
$this->assertInstanceOf('\HPCloud\Services\DBaaS\SnapshotDetails', $details);
$this->waitUntilSnapshotReady($snap, $details, TRUE);
//$this->waitUntilSnapshotReady($snap, $details, TRUE);
$this->assertNotEmpty($details->id());
$this->assertNotEmpty($details->instanceId());
$this->assertNotEmpty($details->status());
//$this->assertNotEmpty($details->status());
$this->assertNotEmpty($details->createdOn());
$this->assertIsArray($details->links());
$this->assertNotEmpty($details->links());
$links = $details->links();
$this->assertEquals('self', $links[0]['rel']);
$this->assertNotEmpty($links[0]['href']);
return $details;
}
@@ -106,7 +110,6 @@ class DBaaSSnapshot extends DBaaSTestCase {
/**
* @depends testCreate
*/
/*
public function testDescribe($info) {
$snap = $this->dbaas()->snapshot();
@@ -115,7 +118,6 @@ class DBaaSSnapshot extends DBaaSTestCase {
$this->assertEquals($info->id(), $details->id());
$this->assertEquals($info->instanceId(), $details->instanceId());
}
*/
/**
* @depends testCreate
@@ -124,7 +126,7 @@ class DBaaSSnapshot extends DBaaSTestCase {
$snap = $this->dbaas()->snapshot();
// Test listing all
$all = $snap->listSnapshpts();
$all = $snap->listSnapshots();
$this->assertNotEmpty($all);
$found;
@@ -138,7 +140,7 @@ class DBaaSSnapshot extends DBaaSTestCase {
// Test listing just for specific instance ID.
$all = $snap->listSnapshpts($info->instanceId());
$all = $snap->listSnapshots($info->instanceId());
$this->assertEquals(1, count($all));
$found = NULL;
@@ -149,7 +151,7 @@ class DBaaSSnapshot extends DBaaSTestCase {
}
$this->assertInstanceOf('\HPCloud\Services\DBaaS\SnapshotDetails', $found);
$this->assertEqual($item->id(), $found->id());
$this->assertEquals($item->id(), $found->id());
}
/**

View File

@@ -16,6 +16,8 @@ use \HPCloud\Services\DBaaS\Snapshot;
* @group dbaas
*/
abstract class DBaaSTestCase extends \HPCloud\Tests\TestCase {
const SNAPSHOT_SUFFIX = '-SNAPSHOT';
public function dbaas() {
$ident = $this->identity();
$dbaas = DBaaS::newFromIdentity($ident);
@@ -40,7 +42,21 @@ abstract class DBaaSTestCase extends \HPCloud\Tests\TestCase {
}
}
}
}
public function destroySnapshots() {
$dbaas = $this->dbaas();
$snap = $dbaas->snapshot();
$list = $snap->listSnapshots();
if (!empty($list)) {
foreach ($list as $item) {
//if (strrpos($item->name(), self::SNAPSHOT_SUFFIX) !== FALSE) {
fprintf(STDOUT, "Deleteing snapshot %s\n", $item->id());
$snap->delete($item->id());
//}
}
}
}
public function waitUntilRunning($inst, &$details, $verbose = FALSE, $max = 15, $sleep = 5) {