mirror of
https://github.com/chatmail/relay.git
synced 2026-05-10 16:04:37 +00:00
cmdeploy: fix status cmd after sshexec rework (#723)
* cmdeploy: fix status cmd after sshexec rework * tests: test cmdeploy status * tests: move test to online tests * tests: require chatmail_config for status test
This commit is contained in:
@@ -171,10 +171,15 @@ def dns_cmd(args, out):
|
|||||||
return retcode
|
return retcode
|
||||||
|
|
||||||
|
|
||||||
|
def status_cmd_options(parser):
|
||||||
|
add_ssh_host_option(parser)
|
||||||
|
|
||||||
|
|
||||||
def status_cmd(args, out):
|
def status_cmd(args, out):
|
||||||
"""Display status for online chatmail instance."""
|
"""Display status for online chatmail instance."""
|
||||||
|
|
||||||
sshexec = args.get_sshexec()
|
ssh_host = args.ssh_host if args.ssh_host else args.config.mail_domain
|
||||||
|
sshexec = get_sshexec(ssh_host, verbose=args.verbose)
|
||||||
|
|
||||||
out.green(f"chatmail domain: {args.config.mail_domain}")
|
out.green(f"chatmail domain: {args.config.mail_domain}")
|
||||||
if args.config.privacy_mail:
|
if args.config.privacy_mail:
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
import os
|
||||||
import smtplib
|
import smtplib
|
||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
@@ -7,6 +8,7 @@ import time
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from cmdeploy import remote
|
from cmdeploy import remote
|
||||||
|
from cmdeploy.cmdeploy import main
|
||||||
from cmdeploy.sshexec import SSHExec
|
from cmdeploy.sshexec import SSHExec
|
||||||
|
|
||||||
|
|
||||||
@@ -68,6 +70,47 @@ class TestSSHExecutor:
|
|||||||
assert (now - since_date).total_seconds() < 60 * 60 * 51
|
assert (now - since_date).total_seconds() < 60 * 60 * 51
|
||||||
|
|
||||||
|
|
||||||
|
def test_status_cmd(chatmail_config, capsys, request):
|
||||||
|
os.chdir(request.config.invocation_params.dir)
|
||||||
|
assert main(["status"]) == 0
|
||||||
|
status_out = capsys.readouterr()
|
||||||
|
print(status_out.out)
|
||||||
|
|
||||||
|
services = [
|
||||||
|
"acmetool-redirector",
|
||||||
|
"chatmail-metadata",
|
||||||
|
"doveauth",
|
||||||
|
"dovecot",
|
||||||
|
"echobot",
|
||||||
|
"fcgiwrap",
|
||||||
|
"filtermail-incoming",
|
||||||
|
"filtermail",
|
||||||
|
"lastlogin",
|
||||||
|
"nginx",
|
||||||
|
"opendkim",
|
||||||
|
"postfix@-",
|
||||||
|
"systemd-journald",
|
||||||
|
"turnserver",
|
||||||
|
"unbound",
|
||||||
|
]
|
||||||
|
not_running = []
|
||||||
|
for service in services:
|
||||||
|
active = False
|
||||||
|
for line in status_out:
|
||||||
|
if service in line:
|
||||||
|
active = True
|
||||||
|
if not "loaded" in line:
|
||||||
|
active = False
|
||||||
|
if not "active" in line:
|
||||||
|
active = False
|
||||||
|
if not "running" in line:
|
||||||
|
active = False
|
||||||
|
break
|
||||||
|
if not active:
|
||||||
|
not_running.append(service)
|
||||||
|
assert not_running == []
|
||||||
|
|
||||||
|
|
||||||
def test_timezone_env(remote):
|
def test_timezone_env(remote):
|
||||||
for line in remote.iter_output("env"):
|
for line in remote.iter_output("env"):
|
||||||
print(line)
|
print(line)
|
||||||
|
|||||||
Reference in New Issue
Block a user