~matsubara/maas/wait-to-configure-cluster

« back to all changes in this revision

Viewing changes to maas-integration.py

  • Committer: Tarmac
  • Author(s): Diogo Matsubara
  • Date: 2013-12-13 13:58:43 UTC
  • mfrom: (227.1.17 adt-update)
  • Revision ID: tarmac-20131213135843-tgtjwim6cw8sjkt5
[r=rvb][bug=][author=matsubara] Changes tests to work with a non-forked version of auto-package-testing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import os
 
2
from shutil import copytree
2
3
from simplejson import loads
3
4
import sys
4
5
from time import sleep
17
18
 
18
19
from utils import (
19
20
    assertCommandReturnCode, assertStartedUpstartService,
20
 
    is_juju_core, run_command, timeout, update_pxe_config,
21
 
    CLUSTER_CONTROLLER_IP, SQUID_DEB_PROXY_URL, HTTP_PROXY
 
21
    change_logs_permissions, is_juju_core, run_command, timeout,
 
22
    update_pxe_config, CLUSTER_CONTROLLER_IP, SQUID_DEB_PROXY_URL, HTTP_PROXY
22
23
    )
23
24
 
24
25
sys.path.insert(0, "/usr/share/maas")
193
194
    "test_create_admin",
194
195
    "test_restart_dbus_avahi",
195
196
    "test_update_maas_url",
 
197
    "test_restart_provisioning_server",
196
198
    "test_check_initial_services",
197
199
    "test_update_pxe_config",
198
200
    "test_import_pxe_files",
270
272
        maas_fd = open("/etc/maas/maas_local_settings.py" , "r+")
271
273
        maas_file = maas_fd.read()
272
274
        maas_file = maas_file.replace(
273
 
            'DEFAULT_MAAS_URL = "http://10.98.3.59/MAAS"',
 
275
            'DEFAULT_MAAS_URL = "http://10.0.2.15/MAAS"',
274
276
            'DEFAULT_MAAS_URL = "http://192.168.21.5/MAAS"')
275
277
        maas_fd.seek(0)
276
278
        maas_fd.write(maas_file)
279
281
        expected_output = ' * Restarting web server apache2'
280
282
        assertCommandReturnCode(self, cmd, expected_output)
281
283
 
 
284
    def test_restart_provisioning_server(self):
 
285
        # Restart the provisioning server as MAAS is installed before the
 
286
        # network is properly configured, which makes pserv listen only in
 
287
        # the 10.0.2.15 interface.
 
288
        cmd = ["service", "maas-pserv", "restart"]
 
289
        expected_output = 'maas-pserv start/running'
 
290
        assertCommandReturnCode(self, cmd, expected_output)
 
291
 
282
292
    def test_check_initial_services(self):
283
293
        assertStartedUpstartService(
284
294
            self, 'maas-cluster-celery',
694
704
        self._wait_units_started('mediawiki', 2)
695
705
 
696
706
    @classmethod
 
707
    def _collect_logs(cls, log_dirs, log_dest):
 
708
        """Collect logs from the test run.
 
709
 
 
710
        This method copies logs from the test run to a known location so
 
711
        auto-package-testing can copy them out of the testbed.
 
712
        """
 
713
        for log_dir in log_dirs:
 
714
            ignored, tail = os.path.split(log_dir)
 
715
            copytree(log_dir, os.path.join(log_dest, tail))
 
716
 
 
717
    @classmethod
697
718
    def tearDownClass(cls):
698
 
        """Signal to the cluster that the region controller tests finished."""
 
719
        """Collect logs and signal to the cluster tests finished."""
 
720
        log_dest = '/var/tmp/testresults/maas-logs/'
 
721
        log_dirs = [
 
722
            '/var/log/maas',
 
723
            '/var/log/upstart',
 
724
            '/var/log/apache2',
 
725
            '/var/lib/maas/dhcp']
 
726
        cls._collect_logs(log_dirs, log_dest)
 
727
        change_logs_permissions(log_dest)
 
728
 
 
729
        # Signal to the cluster that the region controller tests finished.
699
730
        if not USE_CC_NODES:
700
731
            raise SkipTest("Not testing Cluster controller")
701
732
        context = zmq.Context()