Beispiel #1
0
    def host_config(self):
        """
        configuer the host :
        1.ZONE = American/New_York;
        2.check cpuinfo;
        3.add ntp server ip;
        4.start ntpd service
        """
        # Set the time zone to New_York
        cmd = ('echo \'ZONE = "America/New_York"\' > /etc/sysconfig/clock;')
        try:
            process.run(cmd, ignore_status=False, shell=True)
        except process.CmdError as detail:
            self.test.fail("set Zone on host failed.%s" % detail)
        cmd_ln = 'ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime'
        process.run(cmd_ln, ignore_status=True, shell=True)

        # Check the cpu info of constant_tsc
        cmd = "cat /proc/cpuinfo | grep constant_tsc"
        result = process.run(cmd, shell=True)
        if not result.stdout.strip():
            self.test.fail("constant_tsc not available in this system!!")

        # Stop ntpd to use ntpdate
        host_ntpd = service.Factory.create_service("ntpd")
        host_ntpd.stop()

        # Timing by ntpdate
        utils_test.ntpdate(self.server_ip)

        # Test the ntpdate result
        server_date = utils_test.get_date(self.server_session)
        host_date = utils_test.get_date()
        logging.info("server time: %s", server_date)
        logging.info("host time: %s", host_date)
        if not abs(int(server_date) - int(host_date)) < 2:
            self.test.fail("timing by ntpdate on host failed!!")

        # Delete server of local clock
        result = process.run("grep '^server %s' /etc/ntp.conf" %
                             self.local_clock,
                             ignore_status=True,
                             shell=True)
        if result.stdout.strip():
            process.run("sed -i '/%s/d' /etc/ntp.conf" % self.local_clock,
                        shell=True)
        # Check the ntp.conf and add server ip into it
        cmd = "grep '^server %s' /etc/ntp.conf" % self.server_ip
        result = process.run(cmd, ignore_status=True, shell=True)
        if not result.stdout.strip():
            cmd = "echo 'server %s' >> /etc/ntp.conf" % self.server_ip
            try:
                process.run(cmd, ignore_status=False, shell=True)
            except process.CmdError as detail:
                self.test.fail("config /etc/ntp.conf on host failed!!")

        # Start ntpd service
        host_ntpd.start()
Beispiel #2
0
    def host_config(self):
        """
        configuer the host :
        1.ZONE = American/New_York;
        2.check cpuinfo;
        3.add ntp server ip;
        4.start ntpd service
        """
        # Set the time zone to New_York
        cmd = ('echo \'ZONE = "America/New_York"\' > /etc/sysconfig/clock;')
        try:
            process.run(cmd, ignore_status=False, shell=True)
        except process.CmdError as detail:
            self.test.fail("set Zone on host failed.%s" % detail)
        cmd_ln = 'ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime'
        process.run(cmd_ln, ignore_status=True, shell=True)

        # Check the cpu info of constant_tsc
        cmd = "cat /proc/cpuinfo | grep constant_tsc"
        result = process.run(cmd, shell=True)
        if not result.stdout.strip():
            self.test.fail("constant_tsc not available in this system!!")

        # Stop ntpd to use ntpdate
        host_ntpd = service.Factory.create_service("ntpd")
        host_ntpd.stop()

        # Timing by ntpdate
        utils_test.ntpdate(self.server_ip)

        # Test the ntpdate result
        server_date = utils_test.get_date(self.server_session)
        host_date = utils_test.get_date()
        logging.info("server time: %s" % server_date)
        logging.info("host time: %s" % host_date)
        if not abs(int(server_date) - int(host_date)) < 2:
            self.test.fail("timing by ntpdate on host failed!!")

        # Delete server of local clock
        result = process.run("grep '^server %s' /etc/ntp.conf" %
                             self.local_clock, ignore_status=True, shell=True)
        if result.stdout.strip():
            process.run("sed -i '/%s/d' /etc/ntp.conf" % self.local_clock,
                        shell=True)
        # Check the ntp.conf and add server ip into it
        cmd = "grep '^server %s' /etc/ntp.conf" % self.server_ip
        result = process.run(cmd, ignore_status=True, shell=True)
        if not result.stdout.strip():
            cmd = "echo 'server %s' >> /etc/ntp.conf" % self.server_ip
            try:
                process.run(cmd, ignore_status=False, shell=True)
            except process.CmdError as detail:
                self.test.fail("config /etc/ntp.conf on host failed!!")

        # Start ntpd service
        host_ntpd.start()
Beispiel #3
0
 def long_time_test(self):
     """
     test on guest ntpd after 24h
     """
     logging.info("waiting for long time test : %s s" % self.long_sleep)
     time.sleep(self.long_sleep)
     server_date = utils_test.get_date(self.server_session)
     guest_date = utils_test.get_date(self.session)
     logging.info("server time is %s" % server_date)
     logging.info("guest time is %s" % guest_date)
     if not abs(int(server_date) - int(guest_date)) < 2:
         self.test.fail("timing by ntpd on guest failed")
Beispiel #4
0
 def long_time_test(self):
     """
     test on guest ntpd after 24h
     """
     logging.info("waiting for long time test : %s s", self.long_sleep)
     time.sleep(self.long_sleep)
     server_date = utils_test.get_date(self.server_session)
     guest_date = utils_test.get_date(self.session)
     logging.info("server time is %s", server_date)
     logging.info("guest time is %s", guest_date)
     if not abs(int(server_date) - int(guest_date)) < 2:
         self.test.fail("timing by ntpd on guest failed")
Beispiel #5
0
    def guest_config(self):
        """
        configure the guest:
        1.ZONE = American/New_York;
        2.test the ntpdate;
        3.configur the ntp.conf;
        4.restart ntpd service
        """
        # Set the time zone to american new york
        cmd = ('echo \'ZONE = "America/New_York"\' > /etc/sysconfig/clock;')
        self.session.cmd(cmd)
        cmd_ln = 'ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime'
        self.session.cmd(cmd_ln)

        # Timing by ntpdate
        guest_run = remote.RemoteRunner(session=self.session)
        guest_ntpd = service.Factory.create_service("ntpd", run=guest_run.run)
        guest_ntpd.stop()

        # ntpdate
        utils_test.ntpdate(self.server_ip, self.session)

        # Check the result of ntpdate
        server_date = utils_test.get_date(self.server_session)
        guest_date = utils_test.get_date(self.session)
        logging.info("server time is : %s" % server_date)
        logging.info("guest time is : %s " % guest_date)
        if not abs(int(server_date) - int(guest_date)) < 2:
            self.test.fail("timing by ntpdate on guest failed!!")

        # Delete server of local clock
        output = self.session.cmd_output("grep '%s' /etc/ntp.conf"
                                         % self.local_clock).strip()
        if not output:
            self.session.cmd("sed -i '/%s/d' /etc/ntp.conf" % self.local_clock)
        # Check the ntp.conf and add server ip into it
        output = self.session.cmd_output("grep '^server %s' /etc/ntp.conf"
                                         % self.server_ip)
        if not output:
            cmd = "echo 'server %s' >> /etc/ntp.conf" % self.server_ip
            status = self.session.cmd_status(cmd)
            if status:
                self.test.fail("config /etc/ntp.conf on server failed!!")

        # Start the ntpd service
        guest_ntpd.start()
Beispiel #6
0
    def guest_config(self):
        """
        configure the guest:
        1.ZONE = American/New_York;
        2.test the ntpdate;
        3.configur the ntp.conf;
        4.restart ntpd service
        """
        # Set the time zone to american new york
        cmd = ('echo \'ZONE = "America/New_York"\' > /etc/sysconfig/clock;')
        self.session.cmd(cmd)
        cmd_ln = 'ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime'
        self.session.cmd(cmd_ln)

        # Timing by ntpdate
        guest_run = remote.RemoteRunner(session=self.session)
        guest_ntpd = service.Factory.create_service("ntpd", run=guest_run.run)
        guest_ntpd.stop()

        # ntpdate
        utils_test.ntpdate(self.server_ip, self.session)

        # Check the result of ntpdate
        server_date = utils_test.get_date(self.server_session)
        guest_date = utils_test.get_date(self.session)
        logging.info("server time is : %s", server_date)
        logging.info("guest time is : %s ", guest_date)
        if not abs(int(server_date) - int(guest_date)) < 2:
            self.test.fail("timing by ntpdate on guest failed!!")

        # Delete server of local clock
        output = self.session.cmd_output("grep '%s' /etc/ntp.conf" %
                                         self.local_clock).strip()
        if not output:
            self.session.cmd("sed -i '/%s/d' /etc/ntp.conf" % self.local_clock)
        # Check the ntp.conf and add server ip into it
        output = self.session.cmd_output("grep '^server %s' /etc/ntp.conf" %
                                         self.server_ip)
        if not output:
            cmd = "echo 'server %s' >> /etc/ntp.conf" % self.server_ip
            status = self.session.cmd_status(cmd)
            if status:
                self.test.fail("config /etc/ntp.conf on server failed!!")

        # Start the ntpd service
        guest_ntpd.start()
Beispiel #7
0
        # Check the cpu info of constant_tsc
        cmd = "cat /proc/cpuinfo | grep constant_tsc"
        result = utils.run(cmd)
        if not result.stdout.strip():
            raise error.TestFail("constant_tsc not available in this system!!")

        # Stop ntpd to use ntpdate
        host_ntpd = service.Factory.create_service("ntpd")
        host_ntpd.stop()

        # Timing by ntpdate
        utils_test.ntpdate(self.server_ip)

        # Test the ntpdate result
        server_date = utils_test.get_date(self.server_session)
        host_date = utils_test.get_date()
        logging.info("server time: %s" % server_date)
        logging.info("host time: %s" % host_date)
        if not abs(int(server_date) - int(host_date)) < 2:
            raise error.TestFail("timing by ntpdate on host failed!!")

        # Delete server of local clock
        result = utils.run("grep '^server %s' /etc/ntp.conf" % self.local_clock,
                           ignore_status=True)
        if result.stdout.strip():
            utils.run("sed -i '/%s/d' /etc/ntp.conf" % self.local_clock)
        # Check the ntp.conf and add server ip into it
        cmd = "grep '^server %s' /etc/ntp.conf" % self.server_ip
        result = utils.run(cmd, ignore_status=True)
        if not result.stdout.strip():