def test_init(self): ntp_chrony = ntp.NtpChronyd(self.remote_mock, 'node') assert ntp_chrony.remote is self.remote_mock assert ntp_chrony.node_name == 'node' assert repr(ntp_chrony) == \ "NtpChronyd(remote=<SSHClient()>, node_name='node')" ntp_chrony.start() ntp_chrony.stop()
def test_set_actual_time(self): ntp_chrony = ntp.NtpChronyd(self.remote_mock, 'node') ntp_chrony.set_actual_time() self.remote_mock.check_call.assert_has_calls(( mock.call('chronyc -a burst 3/5'), mock.call('chronyc -a makestep'), )) self.wait_mock.assert_called_once_with( ntp_chrony._get_burst_complete, timeout=600, timeout_msg="Failed to set actual time on node 'node'")
def test_get_burst_complete_false(self): self.remote_mock.check_call.return_value = \ self.make_exec_result("""200 OK 200 OK 3 sources online 0 sources offline 1 sources doing burst (return to online) 0 sources doing burst (return to offline) 0 sources with unknown address""") ntp_chrony = ntp.NtpChronyd(self.remote_mock, 'node') r = ntp_chrony._get_burst_complete() self.remote_mock.check_call.assert_called_once_with( 'chronyc -a activity') assert r is False
def test_wait_peer(self): ntp_chrony = ntp.NtpChronyd(self.remote_mock, 'node') ntp_chrony.wait_peer() self.remote_mock.check_call.assert_called_once_with( 'chronyc -a waitsync 10 0.01')