~brendan-donegan/maas/qa-lab-tests_boot_resources_2.0

« back to all changes in this revision

Viewing changes to maas-integration.py

  • Committer: Brendan Donegan
  • Date: 2016-07-15 19:35:12 UTC
  • mfrom: (438.2.6 reserve_bmc_ip_range)
  • Revision ID: brendan.donegan@canonical.com-20160715193512-10mvi1oiamfvzkll
Merge reserve_bmc_ip_range

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
from config import (
97
97
    ADMIN_USER,
98
98
    ARM_LAB,
 
99
    BMC_START_IP,
 
100
    BMC_END_IP,
99
101
    CLUSTER_CONTROLLER_IP,
100
102
    DO_NOT_USE_ARM_NODES,
101
103
    DO_NOT_TEST_JUJU,
186
188
    # From this point on, we can connect to the external world.
187
189
    "test_import_boot_resources", # Start importing now, check later.
188
190
    "test_create_dynamic_range",
 
191
    "test_reserve_bmc_range",
189
192
    "test_set_up_dhcp_vlan",
190
193
    "test_check_dhcp_service_systemctl",
191
194
    "test_update_dns_config_systemctl",
222
225
    "test_juju_deploy_postgresql",
223
226
    "test_machines_deployed",
224
227
    "test_ip_addresses_not_in_dynamic_range",
 
228
    "test_ip_addresses_not_in_bmc_range",
225
229
]
226
230
 
227
231
def sorting_method(ignored, first_test, second_test):
853
857
        self.assertNotIn('test-vlan', [v['name'] for v in out])
854
858
        self.assertEqual(1, len(out), 'Fabric should have only one VLAN now.')
855
859
 
 
860
    def test_reserve_bmc_range(self):
 
861
        _, err = self._run_maas_cli(
 
862
            ['ipranges', 'create', 'type=reserved',
 
863
             'start_ip=' + BMC_START_IP, 'end_ip=' + BMC_END_IP,
 
864
             'comment=BMCs']
 
865
        )
 
866
        output, err = self._run_maas_cli(
 
867
            ['ipranges', 'read']
 
868
        )
 
869
        out = loads(output)
 
870
        # TODO: assert that newly created range is there
 
871
        bmc_range = None
 
872
        for range in out:
 
873
            if range['comment'] == 'BMCs':
 
874
                bmc_range = range
 
875
        self.assertIsNotNone(bmc_range, 'BMC range not found')
 
876
        self.assertThat(bmc_range['start_ip'], Equals(BMC_START_IP))
 
877
        self.assertThat(bmc_range['end_ip'], Equals(BMC_END_IP))
 
878
        self.assertThat(bmc_range['type'], Equals('reserved'))
 
879
 
856
880
    @skipIf(
857
881
        StrictVersion(get_maas_version()[:3]) < StrictVersion('1.9'),
858
882
        "Fabric feature only available after 1.9")
1084
1108
            for ip in ips:
1085
1109
                self.assertThat(ip_range, Not(Contains(ip)))
1086
1110
 
 
1111
    @timeout(10*60)
 
1112
    @skipIf(DO_NOT_TEST_JUJU, "Not testing juju")
 
1113
    def test_ip_addresses_not_in_bmc_range(self):
 
1114
        # Make sure that the deployed machines do not have addresses
 
1115
        # in the range reserved for the BMCs
 
1116
        deployed_machines = self._wait_machines(
 
1117
            NODE_STATUS.DEPLOYED, num_expected=self.nb_of_deployed_machines)
 
1118
        for deployed_machine in deployed_machines:
 
1119
            ips = [IPAddress(ip) for ip in deployed_machine['ip_addresses']]
 
1120
            ip_range = IPRange(BMC_START_IP, BMC_END_IP)
 
1121
            for ip in ips:
 
1122
                self.assertThat(ip_range, Not(Contains(ip)))
 
1123
 
 
1124
 
1087
1125
    @classmethod
1088
1126
    def dump_database(cls):
1089
1127
        """Dump the Django DB to /var/log/maas."""