|
| 1 | + |
| 2 | +# Copyright 2017 F5 Networks Inc. |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +# |
| 16 | + |
| 17 | + |
| 18 | +def set_sflow_http_settings_test(request, mgmt_root): |
| 19 | + def teardown(): |
| 20 | + sf_http.pollInterval = sf_http_int |
| 21 | + sf_http.update() |
| 22 | + request.addfinalizer(teardown) |
| 23 | + sf_http = mgmt_root.tm.sys.sflow.global_settings.http.load() |
| 24 | + sf_http_int = sf_http.pollInterval |
| 25 | + return sf_http |
| 26 | + |
| 27 | + |
| 28 | +def set_sflow_interface_settings_test(request, mgmt_root): |
| 29 | + def teardown(): |
| 30 | + sf_interface.pollInterval = sf_interface_int |
| 31 | + sf_interface.update() |
| 32 | + request.addfinalizer(teardown) |
| 33 | + sf_interface = mgmt_root.tm.sys.sflow.global_settings.interface.load() |
| 34 | + sf_interface_int = sf_interface.pollInterval |
| 35 | + return sf_interface |
| 36 | + |
| 37 | + |
| 38 | +def set_sflow_system_settings_test(request, mgmt_root): |
| 39 | + def teardown(): |
| 40 | + sf_system.pollInterval = sf_system_int |
| 41 | + sf_system.update() |
| 42 | + request.addfinalizer(teardown) |
| 43 | + sf_system = mgmt_root.tm.sys.sflow.global_settings.system.load() |
| 44 | + sf_system_int = sf_system.pollInterval |
| 45 | + return sf_system |
| 46 | + |
| 47 | + |
| 48 | +def set_sflow_vlan_settings_test(request, mgmt_root): |
| 49 | + def teardown(): |
| 50 | + sf_vlan.pollInterval = sf_vlan_int |
| 51 | + sf_vlan.update() |
| 52 | + request.addfinalizer(teardown) |
| 53 | + sf_vlan = mgmt_root.tm.sys.sflow.global_settings.vlan.load() |
| 54 | + sf_vlan_int = sf_vlan.pollInterval |
| 55 | + return sf_vlan |
| 56 | + |
| 57 | + |
| 58 | +def set_sflow_receiver_test(request, mgmt_root): |
| 59 | + def teardown(): |
| 60 | + sflow_receiver.delete() |
| 61 | + request.addfinalizer(teardown) |
| 62 | + |
| 63 | + sflow_receiver = mgmt_root.tm.sys.sflow.receivers.receiver.create( |
| 64 | + name='sr1', address='172.16.44.20' |
| 65 | + ) |
| 66 | + return sflow_receiver |
| 67 | + |
| 68 | + |
| 69 | +class TestSflowHttp_Setting(object): |
| 70 | + def test_RUL(self, request, mgmt_root): |
| 71 | + # Load |
| 72 | + h1 = set_sflow_http_settings_test(request, mgmt_root) |
| 73 | + h2 = mgmt_root.tm.sys.sflow.global_settings.http.load() |
| 74 | + assert h1.pollInterval == 10 |
| 75 | + assert h1.pollInterval == h2.pollInterval |
| 76 | + |
| 77 | + # Update |
| 78 | + h1.pollInterval = 20 |
| 79 | + h1.update() |
| 80 | + assert h1.pollInterval == 20 |
| 81 | + assert h2.pollInterval == 10 |
| 82 | + |
| 83 | + # Refresh |
| 84 | + h2.refresh() |
| 85 | + assert h2.pollInterval == h1.pollInterval |
| 86 | + |
| 87 | + |
| 88 | +class TestSflowInterface_Setting(object): |
| 89 | + def test_RUL(self, request, mgmt_root): |
| 90 | + # Load |
| 91 | + h1 = set_sflow_interface_settings_test(request, mgmt_root) |
| 92 | + h2 = mgmt_root.tm.sys.sflow.global_settings.interface.load() |
| 93 | + assert h1.pollInterval == 10 |
| 94 | + assert h1.pollInterval == h2.pollInterval |
| 95 | + |
| 96 | + # Update |
| 97 | + h1.pollInterval = 20 |
| 98 | + h1.update() |
| 99 | + assert h1.pollInterval == 20 |
| 100 | + assert h2.pollInterval == 10 |
| 101 | + |
| 102 | + # Refresh |
| 103 | + h2.refresh() |
| 104 | + assert h2.pollInterval == h1.pollInterval |
| 105 | + |
| 106 | + |
| 107 | +class TestSflowSystem_Setting(object): |
| 108 | + def test_RUL(self, request, mgmt_root): |
| 109 | + # Load |
| 110 | + h1 = set_sflow_system_settings_test(request, mgmt_root) |
| 111 | + h2 = mgmt_root.tm.sys.sflow.global_settings.system.load() |
| 112 | + assert h1.pollInterval == 10 |
| 113 | + assert h1.pollInterval == h2.pollInterval |
| 114 | + |
| 115 | + # Update |
| 116 | + h1.pollInterval = 20 |
| 117 | + h1.update() |
| 118 | + assert h1.pollInterval == 20 |
| 119 | + assert h2.pollInterval == 10 |
| 120 | + |
| 121 | + # Refresh |
| 122 | + h2.refresh() |
| 123 | + assert h2.pollInterval == h1.pollInterval |
| 124 | + |
| 125 | + |
| 126 | +class TestSflowVlan_Setting(object): |
| 127 | + def test_RUL(self, request, mgmt_root): |
| 128 | + # Load |
| 129 | + h1 = set_sflow_vlan_settings_test(request, mgmt_root) |
| 130 | + h2 = mgmt_root.tm.sys.sflow.global_settings.vlan.load() |
| 131 | + assert h1.pollInterval == 10 |
| 132 | + assert h1.pollInterval == h2.pollInterval |
| 133 | + |
| 134 | + # Update |
| 135 | + h1.pollInterval = 20 |
| 136 | + h1.update() |
| 137 | + assert h1.pollInterval == 20 |
| 138 | + assert h2.pollInterval == 10 |
| 139 | + |
| 140 | + # Refresh |
| 141 | + h2.refresh() |
| 142 | + assert h2.pollInterval == h1.pollInterval |
| 143 | + |
| 144 | + |
| 145 | +class TestSflowReceiver(object): |
| 146 | + def test_CURDLE(self, request, mgmt_root): |
| 147 | + # Assume create/delete tested by setup/teardown |
| 148 | + r1 = set_sflow_receiver_test(request, mgmt_root) |
| 149 | + |
| 150 | + # Exists |
| 151 | + assert mgmt_root.tm.sys.sflow.receivers.receiver.exists(name='sr1') |
| 152 | + |
| 153 | + # Load |
| 154 | + r2 = mgmt_root.tm.sys.sflow.receivers.receiver.load(name='sr1') |
| 155 | + assert r1.name == r2.name |
| 156 | + |
| 157 | + # Update |
| 158 | + r1.address = '172.16.44.21' |
| 159 | + r1.update() |
| 160 | + assert r1.address != r2.address |
| 161 | + |
| 162 | + # Refresh |
| 163 | + r2.refresh() |
| 164 | + assert r1.address == r2.address |
0 commit comments