Skip to content

Commit 85bb2c2

Browse files
committed
Integration test for network port
1 parent 7216a8c commit 85bb2c2

File tree

3 files changed

+67
-3
lines changed

3 files changed

+67
-3
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
require 'vendor/autoload.php';
4+
5+
$openstack = new OpenStack\OpenStack([
6+
'authUrl' => '{authUrl}',
7+
'region' => '{region}',
8+
'user' => ['id' => '{userId}', 'password' => '{password}'],
9+
'scope' => ['project' => ['id' => '{projectId}']]
10+
]);
11+
12+
$networking = $openstack->networkingV2();
13+
14+
$port = $networking->createPort([
15+
'name' => 'portName',
16+
'networkId' => '{networkId}',
17+
'adminStateUp' => true,
18+
'fixedIps' => [
19+
[
20+
'ipAddress' => '192.168.199.100'
21+
],
22+
[
23+
'ipAddress' => '192.168.199.200'
24+
]
25+
]
26+
]);

tests/integration/Networking/v2/CoreTest.php

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ private function deleteSubnet($subnetId)
273273

274274
public function ports()
275275
{
276+
$this->logStep('Test port');
277+
276278
$replacements = ['{newName}' => $this->randomStr()];
277279

278280
/** @var $network \OpenStack\Networking\v2\Models\Network */
@@ -284,7 +286,6 @@ public function ports()
284286
/** @var $port \OpenStack\Networking\v2\Models\Port */
285287
$path = $this->sampleFile($replacements, 'ports/create.php');
286288
require_once $path;
287-
$this->assertInstanceOf(Port::class, $port);
288289

289290
$replacements['{portId}'] = $port->id;
290291
$port->networkId = $network->id;
@@ -316,5 +317,43 @@ public function ports()
316317

317318
$path = $this->sampleFile($replacements, 'networks/delete.php');
318319
require_once $path;
320+
321+
$this->createPortWithFixedIps();
322+
}
323+
324+
private function createPortWithFixedIps()
325+
{
326+
$this->logStep('Test port with fixed IP');
327+
328+
/** @var $network \OpenStack\Networking\v2\Models\Network */
329+
$path = $this->sampleFile(['{networkName}' => $this->randomStr()], 'networks/create.php');
330+
require_once $path;
331+
$this->logStep('Created network {id}', ['{id}' => $network->id]);
332+
333+
334+
/** @var $subnet \OpenStack\Networking\v2\Models\Subnet */
335+
$path = $this->sampleFile(['{subnetName}' => $this->randomStr(), '{networkId}' => $network->id], 'subnets/create.php');
336+
require_once $path;
337+
$this->logStep('Created subnet {id}', ['{id}' => $subnet->id]);
338+
339+
/** @var $port \OpenStack\Networking\v2\Models\Port */
340+
$path = $this->sampleFile(['{networkId}' => $network->id], 'ports/create_with_fixed_ips.php');
341+
require_once $path;
342+
$this->logStep('Created port {id}', ['{id}' => $port->id]);
343+
344+
$path = $this->sampleFile(['{portId}' => $port->id], 'ports/delete.php');
345+
require_once $path;
346+
347+
$this->logStep('Deleted port {id}', ['{id}' => $port->id]);
348+
349+
/** @var $subnet \OpenStack\Networking\v2\Models\Subnet */
350+
$path = $this->sampleFile(['{subnetId}' => $subnet->id], 'subnets/delete.php');
351+
require_once $path;
352+
$this->logStep('Deleted subnet {id}', ['{id}' => $subnet->id]);
353+
354+
/** @var $network \OpenStack\Networking\v2\Models\Network */
355+
$path = $this->sampleFile(['{networkId}' => $network->id], 'networks/delete.php');
356+
require_once $path;
357+
$this->logStep('Deleted network {id}', ['{id}' => $network->id]);
319358
}
320359
}

tests/unit/Networking/v2/Models/PortTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function test_it_creates()
6767
'networkId' => self::NETWORK_ID,
6868
'fixedIps' => [
6969
[
70-
'ipAdress' => '192.168.254.20',
70+
'ipAddress' => '192.168.254.20',
7171
'subnetId' => 'd8e52c33-b301-4feb-9856-a71b71f06c1d'
7272
]
7373
]
@@ -82,7 +82,6 @@ public function test_it_creates()
8282
]
8383
];
8484

85-
8685
$this->setupMock('POST', 'v2.0/ports', $expectedJson, [], 'port_post');
8786

8887
$this->port->create($opts);

0 commit comments

Comments
 (0)