THE SELFTEST SUITE Testing Samba May 21th, 2015 Andreas Schneider - - PowerPoint PPT Presentation

the selftest suite
SMART_READER_LITE
LIVE PREVIEW

THE SELFTEST SUITE Testing Samba May 21th, 2015 Andreas Schneider - - PowerPoint PPT Presentation

THE SELFTEST SUITE Testing Samba May 21th, 2015 Andreas Schneider Red Hat Inc. Samba Team Who am I? The Selftest Suite Running tests Writing tests ABOUT ME I'm a Free and Open Source Software developer working on: Samba - The domain


slide-1
SLIDE 1

THE SELFTEST SUITE

Testing Samba

May 21th, 2015

Andreas Schneider

Red Hat Inc. Samba Team

slide-2
SLIDE 2

Who am I?

slide-3
SLIDE 3

The Selftest Suite Running tests Writing tests

ABOUT ME

I'm a Free and Open Source Software developer working on: → Samba - The domain controller and file server → cmocka - a unit testing framework for C → cwrap - Full network server/client testing made easy → libssh - The SSH Library → FreeIPA - An integrated security information management solution for Linux

Twitter: @cryptomilk Blog: http://blog.cryptomilk.org/ Git: http://git.cryptomilk.org/

3

slide-4
SLIDE 4

Are you Pastafarian?

slide-5
SLIDE 5

The Selftest Suite Running tests Writing tests

YOU NEED TO BELIEVE!

If you work on this code you need to believe ...

5

slide-6
SLIDE 6

The Selftest Suite Running tests Writing tests

FLYING SPAGETTHI MONSTER

in the Flying Spaghetti Monster!

6

slide-7
SLIDE 7

The Selftest Suite Running tests Writing tests

WE SUCCESSFULLY MIX ...

C, Perl, Python and Bash!

7

slide-8
SLIDE 8

The Selftest Suite Running tests Writing tests

YOU WILL LEARN ABOUT

→ torture test planning → setting up Samba environments → running tests → how to use testenv. → something about pirates

8

slide-9
SLIDE 9

THE SELFTEST SUITE

slide-10
SLIDE 10

The Selftest Suite Running tests Writing tests

SELFTEST SUITE

Samba Selftest

Test Environment Setup AD DC PDC AD Member File Server (Perl)

Subunit

Testsuite planning Spoolss SMB3 Winbind DSDB (Python)

10

slide-11
SLIDE 11

The Selftest Suite Running tests Writing tests

SUBUNIT

→ the subunit protocol is a report format for unit tests → provides tools to parse unit test output → Samba has special non-comptabile extensions → https://github.com/testing-cabal/subunit

11

slide-12
SLIDE 12

The Selftest Suite Running tests Writing tests

SELFTEST SUITE

Samba Selftest

Test Environment Setup AD DC PDC AD Member File Server (Perl)

Subunit

Testsuite planning Spoolss SMB3 Winbind DSDB (Python)

12

slide-13
SLIDE 13

The Selftest Suite Running tests Writing tests

SELFTEST TARGETS Target environment setup

→ Creates a harness for Samba with artificial users and groups, and complete local fake network (using cwrap.org project). → Setup an AD DC, PDC, File Server, etc. → Join members servers to DCs or setup several DCs → Create different configurations

13

slide-14
SLIDE 14

The Selftest Suite Running tests Writing tests

CWRAP

→ socket_wrapper - Network address emulation (IPv4 and IPv6) → nss_wrapper - Artificial users, groups and hostnames resolving → uid_wrapper - Fakes privilege separation (user switching) → resolv_wrapper - Fakes DNS resolving (SRV records) Visit https://cwrap.org

14

slide-15
SLIDE 15

The Selftest Suite Running tests Writing tests

SELFTEST TEST EXECUTION Test planning

→ A test (smbtorture, bash script, vfstest) is planned → A test specifies a target → The target is set up if it isn't already running → The test is executed, output parsed with subunit and reported

15

slide-16
SLIDE 16

The Selftest Suite Running tests Writing tests

INTEGRATION TESTS

SMBTORTURE → Huge test application for integration tests → Tests for all SMB flavors (SMB3, SMB2, ...) → Tests for all RPC services → Some other strange tests ;)

16

slide-17
SLIDE 17

RUNNING TESTS

slide-18
SLIDE 18

The Selftest Suite Running tests Writing tests

SELFTEST SUITE Running tests

→ make test → make test TESTS="spoolss" → make test TESTS="spoolss" SMBD_OPTIONS=-d10 → make test TESTS="spoolss" SUBUNIT_FORMATTER=cat → make test TESTS="spoolss" VALGRIND="1" → Test specifiation is a regex, tests are separated by spaces Speedup tests: source selftest/devel_env.sh

18

slide-19
SLIDE 19

I TYPE FUNNY COMMANDS AND YOU WATCH COMMANDLINE OUTPUT (aka DEMO)

slide-20
SLIDE 20

The Selftest Suite Running tests Writing tests

SELFTEST SUITE Entering a testenv

→ make testenv → make testenv SELFTEST_TESTENV=nt4_dc → Test environments: ad_dc, nt4_dc, ad _member, nt4_member, ... Speedup tests: source selftest/devel_env.sh

20

slide-21
SLIDE 21

The Selftest Suite Running tests Writing tests

SELFTEST SUITE Packet capturing

→ export SOCKET_WRAPPER_PCAP_FILE=debug.pcap Note that for each test, data will be appended to that file!

21

slide-22
SLIDE 22

WRITING TESTS

slide-23
SLIDE 23

The Selftest Suite Running tests Writing tests

WRITING A NEW TEST

→ Check if there is a target which suites your need or create one. → Write a smbtorture test or add a new bash script for testing a tool. → Plan the test at e.g. source3/selftest/tests.py https://git.samba.org/?p=asn/samba.git;a=shortlog;h=refs/heads/ master-selftest

23

slide-24
SLIDE 24

The Selftest Suite Running tests Writing tests

LINKS

→ Writing and running tests: https://wiki.samba.org/index.php/Writing_Torture_Tests

24

slide-25
SLIDE 25

Questions & Answers Take a look at my testing related projects! http://cwrap.org/ http://cmocka.org/