Skip to content

Commit

Permalink
github workflows: testing cmdtests
Browse files Browse the repository at this point in the history
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
  • Loading branch information
kvalo committed Feb 24, 2024
1 parent 5575c37 commit 53c30f7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/tests-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: sudo apt update
- run: sudo apt install pycodestyle pyflakes3
- run: ./run_tests checks
- run: sudo apt install python3-mock
- run: ./run_tests unittests
- run: sudo apt install cmdtest figlet python3-flask-restful python3-pexpect python3-aiosmtpd
- run: ./run_tests stubs smtpd
22 changes: 17 additions & 5 deletions stubs/cmdtests/smtpd.script
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

import os
import os.path
import sys
import subprocess
import time

Expand All @@ -43,22 +42,35 @@ def main():
stubdir = os.path.join(srcdir, 'stubs')
smtpddir = os.path.join(datadir, 'smtpddir')

port = 4433
delay = 5

os.chdir(datadir)

os.mkdir(smtpddir)

env = os.environ.copy()
env['STUB_SMTPD_DATADIR'] = smtpddir

smtpd = subprocess.Popen([os.path.join(stubdir, 'smtpd'), '--port=4321'],
print('Starting smtpd on port %d' % (port))
smtpd = subprocess.Popen([os.path.join(stubdir, 'smtpd'), '--port=%d' % (port)],
env=env)

time.sleep(1)
(stdout, stderr) = smtpd.communicate()
print('smtpd.returncode:' % (smtpd.returncode))
print(stdout)
print(stderr)

print('Sleeping %ds' % (delay))
time.sleep(delay)

subprocess.call([os.path.join(stubdir, 'smtpclient'), '--port=4321'])
print('Starting smtpclient on port %d' % (port))
subprocess.call([os.path.join(stubdir, 'smtpclient'), '--port=%d' % (port)])

time.sleep(1)
print('Sleeping %ds' % (delay))
time.sleep(delay)

print('Killing smtpd')
smtpd.kill()

# print all the files to make sure there are no extra mails
Expand Down
5 changes: 5 additions & 0 deletions stubs/cmdtests/smtpd.stdout
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Starting smtpd on port 4433
Sleeping 5s
Starting smtpclient on port 4433
Sleeping 5s
Killing smtpd
files: ['0']
test@example.com -> foo@example.com, bar@example.com
Content-Type: text/plain; charset="us-ascii"
Expand Down
2 changes: 1 addition & 1 deletion stubs/smtpclient
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def run(args):
msg['From'] = from_address

try:
server = smtplib.SMTP('localhost', args.port)
server = smtplib.SMTP('127.0.0.1', args.port)
server.sendmail(from_address, to, msg.as_string())
server.quit()
except Exception as e:
Expand Down

0 comments on commit 53c30f7

Please sign in to comment.