Gitlab-Runner: Trying to open (and listen) on a port using MSTest/netcore for smtp

Timeout using dotnetcore3.1 opening a port

Describe your question in as much detail as possible:
I’m trying to write UnitTests using:

  • What are you seeing, and how does that differ from what you expect to see?
    I’d expect the gitlab-runner to behave like a “normal” environment and actually allow me to open and listen to a port i specify. However - what i’m seeing is nothing but a timeout as soon as i actually try to send/receive a mail within the command “dotnet test”.

  • What version are you on? Are you using self-managed or

    • GitLab (CE 12.9.0): selfhosted
    • Runner (12.9.0):
  • Add the CI configuration from .gitlab-ci.yml and other configuration if relevant (e.g. docker-compose.yml)

    - build
    - test

    srcDir: “src”
    projectName: “FluiTec.AppFx.Networking”

    - git submodule sync --recursive
    - git submodule update --init --recursive
    - “cd $srcDir”
    - “dotnet restore”

    stage: build
    - “dotnet build”

    stage: test
    - “dotnet test --filter $projectName”

  • What troubleshooting steps have you already taken? Can you link to any docs or other resources so we know where you have been?
    Honestly - i can’t seem to find any method of even finding a method where exactly the test is actually stuck. That doesnt mean i didnt try but actually getting output of myself using “dotnet test” when the test never even finishes seems completely impossible. To improve my chances of actually getting results i’ve been trying multiple smtp-implementations that all work locally including porting a working and threadsafe implementation to netcore. But i’m not getting any closer. Also i tried changing the port from 25 to 50.000 and other ports.

What i hope to get here are answers for the following questions:
a) Is it possible to open a port on the docker-executor and connect to it within the same process using “” or anything similar?
b) Apart from using such a selfmade form of unit-testing - can anybody offer advice for actually testing smtp and verify the results in the unittests?

If anybody actually want’s to try - the following C#-Class is enough for reproduction in a minimal test-project (works fine locally, leads to timeout in runner):
using MailKit.Net.Smtp;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MimeKit;
using MimeKit.Text;
using nDumbsterCore.smtp;

namespace FluiTec.AppFx.Networking.Mail.Tests
    public class MailTest
        public void DoMailTest()
            var server = SimpleSmtpServer.Start(25);

            using (var client = new SmtpClient())
                client.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true; // accepts all certs
                client.Connect("", 25, false);
                client.Send(new MimeMessage
                    From = { new MailboxAddress("Test", "") },
                    To = { new MailboxAddress("Test", "") },
                    Subject = "Subject",
                    Body = new TextPart(TextFormat.Plain)



As an update - i’ve found that adding the flag “-t” to dotnet test (that should only print discovered UnitTests to StdOut) actually fixes the test. I’m not entirely sure where to go next since that flag should not fix the problem at all - and i’m not sure which piece of software is at fault here.

If anybody could give me a tip on where to create an issue (Gitlab? Microsoft?) i would…

Thanks for reading this wall of text.