public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Hangbin Liu <liuhangbin@gmail.com>, netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	 Eric Dumazet <edumazet@google.com>,
	Shuah Khan <shuah@kernel.org>, David Ahern <dsahern@kernel.org>,
	 linux-kselftest@vger.kernel.org,
	Po-Hsu Lin <po-hsu.lin@canonical.com>,
	 Guillaume Nault <gnault@redhat.com>
Subject: Re: [Discuss] Seeking advice on net selftests netns naming method
Date: Tue, 14 Nov 2023 12:02:00 +0100	[thread overview]
Message-ID: <7b2d70645fecf83f30d71c44ae0071da1b3be67c.camel@redhat.com> (raw)
In-Reply-To: <ZVND+e6RKLFudYQA@Laptop-X1>

On Tue, 2023-11-14 at 17:55 +0800, Hangbin Liu wrote:
> Good day! Following Guillaume's suggestion, I've been working on updating all
> net self-tests to run in their respective netns. This modification allows us
> to execute all tests in parallel, potentially saving a significant amount of
> test time.
> 
> However, I've encountered a challenge while making these modifications. The
> net selftest folder contains around 80 tests (excluding the forwarding test),
> with some tests using common netns names and others using self-defined names.
> I've considered two methods to address this issue:
> 
> One approach is to retain the original names but append a unique suffix using
> $(mktemp -u XXXXXX). While this is a straightforward solution, it may not
> prevent future tests from using common names.
> 
> Another option is to establish a general netns lib. Similar to the NUM_NETIFS
> variable in the forwarding test, we could introduce a variable like NUM_NS.
> This variable would define the number of netns instances, and all tests would
> use the netns lib to set up and clean up netns accordingly. However, this
> approach might complicate test debugging, especially for tests like
> fib_nexthops.sh, which relies on clear and visually netns names
> (e.g., me/peer/remote).

I personally would like sort of both :) e.g. lib function(s) to
automatically create and dispose netns, and retain a script-
specific/related name prefix. 

The library function could optionally set  the newly created namespaces
name in global variables provided by the caller, e.g.:

# create 3 namespaces:
netns_init 3 

# create 3 namespaces and set the global variables:
# $remote, $local $me 
# to their respective names
netns_init 3 remote local me

The trick to do such assignment would be using the 'eval' statement,
something alike

netns_init()
{
	# create the netns

	shift
	while [ -n "$1" ]; do
		eval $1=$NETNS_NAMES[0]
		shift
	done
}

While at that, it would be useful to package some common helper e.g. to
wait for a (tcp) listener to be created (available) on a given port.

WDYT?

Thanks!

Paolo


  reply	other threads:[~2023-11-14 11:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-14  9:55 [Discuss] Seeking advice on net selftests netns naming method Hangbin Liu
2023-11-14 11:02 ` Paolo Abeni [this message]
2023-11-15  7:51   ` Hangbin Liu
2023-11-15  9:10     ` Paolo Abeni
2023-11-15  9:35       ` Hangbin Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7b2d70645fecf83f30d71c44ae0071da1b3be67c.camel@redhat.com \
    --to=pabeni@redhat.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=gnault@redhat.com \
    --cc=kuba@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=liuhangbin@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=po-hsu.lin@canonical.com \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox