Skip to content

Commit dcd7aa9

Browse files
committed
smoketests for Cloud DNS
1 parent 9b66a89 commit dcd7aa9

File tree

1 file changed

+56
-9
lines changed

1 file changed

+56
-9
lines changed

smoketest.php

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,6 @@ function info($msg,$p1=NULL,$p2=NULL,$p3=NULL,$p4=NULL,$p5=NULL) {
4646
}
4747
define('TIMEFORMAT', 'r');
4848

49-
/**
50-
* START THE TESTS!
51-
*/
52-
printf("SmokeTest started at %s\n", date(TIMEFORMAT, $start));
53-
printf("Using endpoint [%s]\n", $_ENV['NOVA_URL']);
54-
printf("Using region [%s]\n", MYREGION);
55-
5649
// parse command-line arguments
5750
if ($argc > 1) {
5851
foreach($argv as $arg) {
@@ -79,6 +72,13 @@ function info($msg,$p1=NULL,$p2=NULL,$p3=NULL,$p4=NULL,$p5=NULL) {
7972
}
8073
}
8174

75+
/**
76+
* START THE TESTS!
77+
*/
78+
printf("SmokeTest started at %s\n", date(TIMEFORMAT, $start));
79+
printf("Using endpoint [%s]\n", $_ENV['NOVA_URL']);
80+
printf("Using region [%s]\n", MYREGION);
81+
8282
step('Authenticate');
8383
$rackspace = new OpenCloud\Rackspace(AUTHURL,
8484
array( 'username' => USERNAME,
@@ -106,6 +106,53 @@ function info($msg,$p1=NULL,$p2=NULL,$p3=NULL,$p4=NULL,$p5=NULL) {
106106
$rackspace->ImportCredentials(unserialize($str));
107107
}
108108

109+
/**
110+
* Cloud DNS
111+
*/
112+
step('Connect to Cloud DNS');
113+
$dns = $rackspace->DNS();
114+
115+
step('Try to add a domain raxdrg.info');
116+
$domain = $dns->Domain();
117+
$aresp = $domain->Create(array(
118+
'name' => 'raxdrg.info',
119+
'emailAddress' => '[email protected]',
120+
'ttl' => 3600));
121+
$aresp->WaitFor('COMPLETED', 300, 'dotter', 1);
122+
if ($aresp->Status() == 'ERROR') {
123+
info('Error condition (this may be valid if the domain exists');
124+
info('[%d] %s - %s',
125+
$aresp->error->code, $aresp->error->message, $aresp->error->details);
126+
}
127+
128+
step('Adding a CNAME record www.raxdrg.info');
129+
$dlist = $dns->DomainList(array('name'=>'raxdrg.info'));
130+
$domain = $dlist->Next();
131+
$record = $domain->Record();
132+
$aresp = $record->Create(array(
133+
'type' => 'CNAME', 'ttl' => 600, 'name' => 'www.raxdrg.info',
134+
'data' => 'developer.rackspace.com'));
135+
$aresp->WaitFor('COMPLETED', 300, 'dotter', 1);
136+
if ($aresp->Status() == 'ERROR') {
137+
info('Error status:');
138+
info('[%d] $s - %s', $aresp->error->code, $aresp->error->message,
139+
$aresp->error->details);
140+
}
141+
142+
step('List domains and records');
143+
$dlist = $dns->DomainList();
144+
while($domain = $dlist->Next()) {
145+
info('%s [%s]',
146+
$domain->Name(), $domain->emailAddress);
147+
// list records
148+
info('Domain Records:');
149+
$rlist = $domain->RecordList();
150+
while($rec = $rlist->Next()) {
151+
info('- %s %d %s %s',
152+
$rec->type, $rec->ttl, $rec->Name(), $rec->data);
153+
}
154+
}
155+
109156
/**
110157
* Cloud Files
111158
*/
@@ -481,8 +528,8 @@ function info($msg,$p1=NULL,$p2=NULL,$p3=NULL,$p4=NULL,$p5=NULL) {
481528
* Callback for the WaitFor() method
482529
*/
483530
function dotter($obj) {
484-
info('...waiting on %s/%-12s %3d%%',
531+
info('...waiting on %s/%-12s %4s',
485532
$obj->Name(),
486533
$obj->Status(),
487-
isset($obj->progress) ? $obj->progress : 0);
534+
isset($obj->progress) ? $obj->progress.'%' : 0);
488535
}

0 commit comments

Comments
 (0)