Skip to content

Commit 2cbfc51

Browse files
committed
Improved integration tests for Compute
1 parent 4c4a10a commit 2cbfc51

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

tests/integration/BlockStorage/v2/CoreTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public function runTests()
4141
public function volumes()
4242
{
4343
$this->logStep('-> Volumes tests');
44-
$this->logStep('Creating volume type');
4544
$volumeType = $this->getService()->createVolumeType(['name' => $this->randomStr()]);
4645

4746
$replacements = [
@@ -92,8 +91,6 @@ public function volumes()
9291

9392
public function volumeTypes()
9493
{
95-
$this->logStep('-> Volumes Types tests');
96-
9794
$replacements = [
9895
'{name}' => $this->randomStr(),
9996
];
@@ -128,8 +125,6 @@ public function volumeTypes()
128125

129126
public function snapshots()
130127
{
131-
$this->logStep('-> Snapshot tests');
132-
133128
$this->logStep('Creating volume');
134129
$volume = $this->getService()->createVolume(['name' => $this->randomStr(), 'size' => 1]);
135130
$volume->waitUntil('available', 60);

tests/integration/Compute/v2/CoreTest.php

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
use OpenStack\Compute\v2\Models\Server;
1313
use OpenStack\Integration\TestCase;
1414
use OpenStack\Integration\Utils;
15+
use OpenStack\Networking\v2\Extensions\SecurityGroups\Models\SecurityGroup;
1516
use OpenStack\Networking\v2\Models\Network;
1617
use OpenStack\Networking\v2\Models\Subnet;
1718
use OpenStack\Networking\v2\Service as NetworkService;
1819
use OpenStack\BlockStorage\v2\Service as BlockStorageService;
20+
use OpenStack\Networking\v2\Extensions\SecurityGroups\Service as SecurityGroupService;
1921

2022
class CoreTest extends TestCase
2123
{
@@ -24,6 +26,8 @@ class CoreTest extends TestCase
2426
const SUBNET = 'phptest_subnet';
2527
const VOLUME = 'phptest_volume';
2628

29+
const SECGROUP = 'phptest_secgroup';
30+
2731
const IMAGE = 'cirros';
2832

2933
/** @var NetworkService */
@@ -32,6 +36,9 @@ class CoreTest extends TestCase
3236
/** @var BlockStorageService */
3337
private $blockStorageService;
3438

39+
/** @var SecurityGroupService */
40+
private $secgroupService;
41+
3542
/** @var Network */
3643
private $network;
3744

@@ -41,6 +48,9 @@ class CoreTest extends TestCase
4148
/** @var Volume */
4249
private $volume;
4350

51+
/** @var SecurityGroup */
52+
private $secgroup;
53+
4454
// Core test
4555
private $service;
4656
private $serverId;
@@ -68,6 +78,12 @@ private function getNetworkService()
6878
return $this->networkService;
6979
}
7080

81+
private function getSecurityGroupService(): SecurityGroupService
82+
{
83+
$this->secgroupService = $this->secgroupService ?? Utils::getOpenStack()->networkingV2ExtSecGroups();
84+
return $this->secgroupService;
85+
}
86+
7187
private function getBlockStorageService()
7288
{
7389
if (!$this->blockStorageService) {
@@ -100,7 +116,7 @@ protected function setUp()
100116
]
101117
);
102118

103-
$this->logStep('Created network {name} with id {id}', ['name' => $this->network->name, 'id' => $this->network->id]);
119+
$this->logStep('Created network {name} with {id}', ['name' => $this->network->name, 'id' => $this->network->id]);
104120

105121
$this->subnet = $this->getNetworkService()->createSubnet(
106122
[
@@ -111,7 +127,7 @@ protected function setUp()
111127
]
112128
);
113129

114-
$this->logStep('Created subnet {name} with id {id}', ['name' => $this->subnet->name, 'id' => $this->subnet->id]);
130+
$this->logStep('Created subnet {name} with {id}', ['name' => $this->subnet->name, 'id' => $this->subnet->id]);
115131

116132
$this->volume = $this->getBlockStorageService()->createVolume(
117133
[
@@ -121,7 +137,11 @@ protected function setUp()
121137
]
122138
);
123139

124-
$this->logStep('Created volume {name} with id {id}', ['name' => $this->volume->name, 'id' => $this->volume->id]);
140+
$this->logStep('Created volume {name} with {id}', ['name' => $this->volume->name, 'id' => $this->volume->id]);
141+
142+
$this->getSecurityGroupService()->createSecurityGroup(['name' => self::SECGROUP]);
143+
144+
$this->logStep('Created security group {secgroup}', ['secgroup' => self::SECGROUP]);
125145
}
126146

127147
public function runTests()
@@ -193,12 +213,14 @@ public function runTests()
193213
// Interface attachments
194214
$this->createInterfaceAttachment();
195215
} finally {
216+
$this->logger->info('Tearing down');
196217
// Teardown
197218
$this->deleteServer();
198219
$this->deleteFlavor();
199220
$this->subnet->delete();
200221
$this->network->delete();
201222
$this->volume->delete();
223+
$this->secgroup->delete();
202224
}
203225

204226
$this->outputTimeTaken();
@@ -341,6 +363,7 @@ private function resizeServer()
341363

342364
private function confirmServerResize()
343365
{
366+
$this->logger->info('Waiting for status VERIFY_RESIZE');
344367
$replacements = ['{serverId}' => $this->serverId];
345368

346369
/** @var $server \OpenStack\Compute\v2\Models\Server */
@@ -623,8 +646,8 @@ private function getLimits()
623646
private function addSecurityGroupToServer()
624647
{
625648
$replacements = [
626-
'{serverId}' => $this->serverId,
627-
'{secGroupName}' => 'default'
649+
'{serverId}' => $this->serverId,
650+
'{secGroupName}' => self::SECGROUP,
628651
];
629652

630653
require_once $this->sampleFile($replacements, 'servers/add_security_group.php');
@@ -650,8 +673,8 @@ private function listServerSecurityGroups()
650673
private function removeServerSecurityGroup()
651674
{
652675
$replacements = [
653-
'{serverId}' => $this->serverId,
654-
'{secGroupName}' => 'default'
676+
'{serverId}' => $this->serverId,
677+
'{secGroupName}' => self::SECGROUP,
655678
];
656679

657680
require_once $this->sampleFile($replacements, 'servers/remove_security_group.php');

0 commit comments

Comments
 (0)