Skip to content

Commit 95495a4

Browse files
author
Jamie Hannaford
committed
fixing integration tests
1 parent 33130c8 commit 95495a4

File tree

10 files changed

+61
-18
lines changed

10 files changed

+61
-18
lines changed

src/Common/Api/Operation.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ public static function toParamArray(array $data)
124124
*/
125125
public function validate(array $userValues)
126126
{
127-
$this->checkDisallowedKeys($userValues);
128-
129127
foreach ($this->params as $paramName => $param) {
130128
if (array_key_exists($paramName, $userValues)) {
131129
$param->validate($userValues[$paramName]);
@@ -136,13 +134,4 @@ public function validate(array $userValues)
136134

137135
return true;
138136
}
139-
140-
private function checkDisallowedKeys(array $userValues)
141-
{
142-
if (!empty($disallowedKeys = array_keys(array_diff_key($userValues, $this->params)))) {
143-
throw new \Exception(sprintf(
144-
'The following keys are not supported: %s', implode($disallowedKeys, ', ')
145-
));
146-
}
147-
}
148137
}

src/Common/Api/Parameter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ private function validateEnums($userValues)
211211
{
212212
if (!empty($this->enum) && $this->type == 'string' && !in_array($userValues, $this->enum)) {
213213
throw new \Exception(sprintf(
214-
'The only permitted values are %s. You provided %s', implode(', ', $this->enum), $userValues
214+
'The only permitted values are %s. You provided %s', implode(', ', $this->enum), print_r($userValues, true)
215215
));
216216
}
217217
}
@@ -220,8 +220,8 @@ private function validateType($userValues)
220220
{
221221
if (!$this->hasCorrectType($userValues)) {
222222
throw new \Exception(sprintf(
223-
'The key provided "%s" has the wrong value type. You provided %s but was expecting %s',
224-
$this->name, print_r($userValues, true), $this->type
223+
'The key provided "%s" has the wrong value type. You provided %s (%s) but was expecting %s',
224+
$this->name, print_r($userValues, true), gettype($userValues), $this->type
225225
));
226226
}
227227
}

src/Common/Resource/HasWaiterTrait.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
namespace OpenStack\Common\Resource;
4+
use OpenStack\Common\Error\BadResponseError;
45

56
/**
67
* Contains reusable functionality for resources that have long operations which require waiting in
@@ -97,4 +98,26 @@ public function waitUntilActive($timeout = 60)
9798
{
9899
$this->waitUntil('ACTIVE');
99100
}
101+
102+
public function waitUntilDeleted($timeout = 60, $sleepPeriod = 1)
103+
{
104+
$startTime = time();
105+
106+
while (true) {
107+
try {
108+
$this->retrieve();
109+
} catch (BadResponseError $e) {
110+
if ($e->getResponse()->getStatusCode() === 404) {
111+
break;
112+
}
113+
throw $e;
114+
}
115+
116+
if ($this->shouldHalt($timeout, $startTime)) {
117+
break;
118+
}
119+
120+
sleep($sleepPeriod);
121+
}
122+
}
100123
}

src/ObjectStore/v1/Params.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function metadata($type, $remove = false)
162162

163163
return [
164164
'location' => self::HEADER,
165-
'type' => self::OBJECT_TYPE,
165+
'type' => self::ARRAY_TYPE,
166166
'prefix' => sprintf("X-%s-Meta-", ucfirst($type)),
167167
'description' => <<<EOT
168168
Human-readable key/value pairs that help describe and determine what type of resource it is. You can specify whichever

tests/integration/BlockStorage/V2Test.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public function runTests()
3636
$this->volumes();
3737
$this->volumeTypes();
3838
$this->snapshots();
39+
40+
$this->outputTimeTaken();
3941
}
4042

4143
public function volumes()
@@ -45,7 +47,7 @@ public function volumes()
4547

4648
$replacements = [
4749
'{description}' => $this->randomStr(),
48-
'{size}' => 1,
50+
"'{size}'" => 1,
4951
'{name}' => $this->randomStr(),
5052
'{volumeType}' => $volumeType->id,
5153
'{key1}' => $this->randomStr(),
@@ -57,10 +59,11 @@ public function volumes()
5759
require_once $this->sampleFile($replacements, 'volumes/create.php');
5860
$this->assertInstanceOf(Volume::class, $volume);
5961
$this->assertEquals($replacements['{name}'], $volume->name);
60-
$this->assertEquals(5, $volume->size);
62+
$this->assertEquals(1, $volume->size);
6163
$this->assertEquals($volumeType->name, $volume->volumeTypeName);
6264

63-
$replacements = ['{volumeId}' => $volume->id];
65+
$volumeId = $volume->id;
66+
$replacements = ['{volumeId}' => $volumeId];
6467

6568
$this->logStep('Getting volume');
6669
/** @var Volume $volume */
@@ -81,6 +84,9 @@ public function volumes()
8184
$this->logStep('Deleting volume');
8285
require_once $this->sampleFile($replacements, 'volumes/delete.php');
8386

87+
$volume = $this->getService()->getVolume($volumeId);
88+
$volume->waitUntilDeleted();
89+
8490
$this->logStep('Deleting volume type');
8591
$volumeType->delete();
8692
}
@@ -174,6 +180,7 @@ public function snapshots()
174180

175181
$this->logStep('Deleting snapshot');
176182
require_once $this->sampleFile($replacements, 'snapshots/delete.php');
183+
$snapshot->waitUntilDeleted();
177184

178185
$this->logStep('Deleting volume');
179186
$volume->delete();

tests/integration/Identity/V2Test.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace OpenStack\Integration\Identity;
4+
5+
use OpenStack\Integration\TestCase;
6+
7+
class V2Test extends TestCase
8+
{
9+
public function getBasePath()
10+
{
11+
}
12+
13+
public function runTests()
14+
{
15+
}
16+
}

tests/integration/Identity/V3Test.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public function runTests()
3535

3636
$this->tokens();
3737
$this->domains();
38+
39+
$this->outputTimeTaken();
3840
}
3941

4042
public function tokens()

tests/integration/Images/V2Test.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public function runTests()
3434

3535
$this->images();
3636
$this->members();
37+
38+
$this->outputTimeTaken();
3739
}
3840

3941
public function images()

tests/integration/ObjectStore/V1Test.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public function runTests()
3535
$this->accountMetadata();
3636
$this->containers();
3737
$this->objects();
38+
39+
$this->outputTimeTaken();
3840
}
3941

4042
public function accountMetadata()

tests/integration/TestCase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public function __construct(LoggerInterface $logger, $verbosity)
2727

2828
abstract protected function getBasePath();
2929

30+
abstract protected function runTests();
31+
3032
protected function getAuthOptsV3()
3133
{
3234
return [

0 commit comments

Comments
 (0)