def test_checkserver_withps_success(self): PSLINES = """UID PID PPID C STIME TTY TIME CMD\ncustomer 555 1 0 05:20 ? 00:00:00 /usr/bin/python /home/customer/LAFS_source/support/bin/tahoe restart introducer\ncustomer 564 1 0 05:20 ? 00:00:00 /usr/bin/python /home/customer/LAFS_source/support/bin/tahoe restart storageserver""" def call_run(remotecommand): self.failUnlessEqual(remotecommand, 'ps -fC tahoe || true') return PSLINES self.patch(monitor, 'run', call_run) def call_crun(remotecommand, **kwargs): self.failUnlessEqual(remotecommand, 'whoami') return 'monitor' self.patch(server, 'run', call_crun) def call_set_host_and_key(publichost, monitor_privkey_path, username=None): self.failUnlessEqual(publichost, self.PUBLICHOST) self.failUnlessEqual(monitor_privkey_path, self.MONPRVKEYPATH) self.failUnlessEqual(username, 'monitor') self.patch(monitor, 'set_host_and_key', call_set_host_and_key) check_server(self.PUBLICHOST, self.MONPRVKEYPATH, self.STDOUT, self.STDERR)
def test_checkserver_failonUID(self): PSLINES = """FAILID""" def call_run(remotecommand): self.failUnlessEqual(remotecommand, 'ps -fC tahoe || true') return PSLINES self.patch(monitor, 'run', call_run) def call_crun(remotecommand, **kwargs): self.failUnlessEqual(remotecommand, 'whoami') return 'monitor' self.patch(server, 'run', call_crun) def call_set_host_and_key(publichost, monitor_privkey_path, username=None): self.failUnlessEqual(publichost, self.PUBLICHOST) self.failUnlessEqual(monitor_privkey_path, self.MONPRVKEYPATH) self.failUnlessEqual(username, 'monitor') self.patch(monitor, 'set_host_and_key', call_set_host_and_key) check_server(self.PUBLICHOST, self.MONPRVKEYPATH, self.STDOUT, self.STDERR)