-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introducing API and compliance tests for VARP (#234)
Also including all needed classes to build and run the compliance test
- Loading branch information
1 parent
3db61b9
commit 247fc0e
Showing
15 changed files
with
264 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
netman/api/doc_config/api_samples/post_switch_hostname_vlans_vlanid_varp_ips.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"address": "1.2.3.4", | ||
"mask": 25 | ||
} |
1 change: 1 addition & 0 deletions
1
netman/api/doc_config/api_samples/post_switch_hostname_vlans_vlanid_varp_ips.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.2.3.4/25 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
tests/adapters/compliance_tests/add_varp_ip_to_vlan_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright 2019 Internap. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from hamcrest import assert_that, is_ | ||
from netaddr import IPNetwork | ||
|
||
from netman.core.objects.exceptions import VarpAlreadyExistsForVlan | ||
from tests.adapters.compliance_test_case import ComplianceTestCase | ||
|
||
|
||
class AddVarpIpToVlanTest(ComplianceTestCase): | ||
_dev_sample = "arista_http" | ||
|
||
def setUp(self): | ||
super(AddVarpIpToVlanTest, self).setUp() | ||
self.client.add_vlan(1000, name="vlan_name") | ||
|
||
def tearDown(self): | ||
self.janitor.remove_vlan(1000) | ||
super(AddVarpIpToVlanTest, self).tearDown() | ||
|
||
def test_assigns_the_varp_ip(self): | ||
self.client.add_vlan_varp_ip(1000, IPNetwork("10.10.40.2/29")) | ||
assert_that(self.client.get_vlan(1000).varp_ips, is_([IPNetwork("10.10.40.2/29")])) | ||
|
||
def test_raises_if_ip_is_already_assigned_to_current_vlan(self): | ||
self.client.add_vlan_varp_ip(1000, IPNetwork("10.10.10.222/29")) | ||
|
||
with self.assertRaises(VarpAlreadyExistsForVlan): | ||
self.client.add_vlan_varp_ip(1000, IPNetwork("10.10.10.222/29")) |
43 changes: 43 additions & 0 deletions
43
tests/adapters/compliance_tests/remove_varp_ip_from_vlan_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Copyright 2019 Internap. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from hamcrest import assert_that, is_ | ||
from netaddr import IPNetwork | ||
|
||
from netman.core.objects.exceptions import VarpDoesNotExistForVlan | ||
from tests.adapters.compliance_test_case import ComplianceTestCase | ||
|
||
|
||
class RemoveVarpIpFromVlanTest(ComplianceTestCase): | ||
_dev_sample = "arista_http" | ||
|
||
def setUp(self): | ||
super(RemoveVarpIpFromVlanTest, self).setUp() | ||
self.client.add_vlan(1000, name="vlan_name") | ||
self.client.add_vlan_varp_ip(1000, IPNetwork("10.10.40.2/29")) | ||
self.client.add_vlan_varp_ip(1000, IPNetwork("10.10.30.2/29")) | ||
self.client.get_vlans() | ||
|
||
def tearDown(self): | ||
self.janitor.remove_vlan(1000) | ||
super(RemoveVarpIpFromVlanTest, self).tearDown() | ||
|
||
def test_removes_a_varp_ip(self): | ||
self.client.remove_vlan_varp_ip(1000, IPNetwork("10.10.40.2/29")) | ||
|
||
assert_that(self.client.get_vlan(1000).varp_ips, is_([IPNetwork("10.10.30.2/29")])) | ||
|
||
def test_raises_if_ip_is_not_on_current_vlan(self): | ||
with self.assertRaises(VarpDoesNotExistForVlan): | ||
self.client.remove_vlan_varp_ip(1000, IPNetwork("1.2.3.4/29")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.