Difference between revisions of "Selftest namespaces"

From SambaWiki
Line 39: Line 39:
<pre>git grep "USE_NAMESPACES\|selftest/ns"</pre>
<pre>git grep "USE_NAMESPACES\|selftest/ns"</pre>
[[Category:New Feature]]
[[Category:New Feature]] [[Category:Testing]]

Revision as of 04:41, 10 June 2019


Added in Samba version: v4.11

The use of namespaces in the selftest system is only really of interest to Samba developers, or users who want to utilize the customdc selftest environment.

Currently the Samba selftest framework uses cwrap socket-wrapper to 'fake' network connections between the Samba testenv DCs. Each DC has a 127.0.0.<id> IP address and socket wrapper uses the '<id>' to work out which DC to pass the packets to.

As an alternative to using cwrap, there is experimental selftest support to use the kernel Namespaces to isolate the testenvs. This uses a mix of network namespaces in the kernel, for isolation, and veth tunnel interfaces, to connect together the separate testenv namespaces. The Samba testenv DC becomes more like a containerized system.

For more details on what namespaces are and how selftest uses them, see selftest/ns/README.

How to configure it

To use namespaces instead of socket-wrapper, just add 'USE_NAMESPACES=1' to the make command, e.g.

  • To run the 'quick' test cases using namespaces:
USE_NAMESPACES=1 make test TESTS=quick
  • To setup an ad_dc testenv using namespaces:
You can then connect secondary shells to the namespace your testenv is running in. The command to do this is a little complicated, so a helper 'nsenter.sh' script gets autogenerated when the testenv is created. E.g. to connect to the testenv that the ad_dc is running in, use:

Known issues and limitations

Refer to selftest/ns/README.


You can use standard packet capture tools, such as wireshark and tcpdump, to debug the Samba traffic. However, you would have to attach to the testenv namespace first, i.e. run ./st/ad_dc/nsenter.sh.

For Developers

Where the code is located

The scripts to setup namespaces are in selftest/ns/. You can find the places that namespaces hook into the selftest framework by using:

git grep "USE_NAMESPACES\|selftest/ns"