the selftest suite
play

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


  1. THE SELFTEST SUITE Testing Samba May 21th, 2015 Andreas Schneider Red Hat Inc. Samba Team

  2. Who am I?

  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

  4. Are you Pastafarian?

  5. The Selftest Suite Running tests Writing tests YOU NEED TO BELIEVE! If you work on this code you need to believe ... 5

  6. The Selftest Suite Running tests Writing tests FLYING SPAGETTHI MONSTER in the Flying Spaghetti Monster! 6

  7. The Selftest Suite Running tests Writing tests WE SUCCESSFULLY MIX ... C, Perl, Python and Bash! 7

  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

  9. THE SELFTEST SUITE

  10. The Selftest Suite Running tests Writing tests SELFTEST SUITE Samba Selftest Subunit Test Environment Setup Testsuite planning AD DC Spoolss PDC SMB3 AD Member Winbind File Server DSDB (Perl) (Python) 10

  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

  12. The Selftest Suite Running tests Writing tests SELFTEST SUITE Samba Selftest Subunit Test Environment Setup Testsuite planning AD DC Spoolss PDC SMB3 AD Member Winbind File Server DSDB (Perl) (Python) 12

  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

  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

  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

  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

  17. RUNNING TESTS

  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

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

  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

  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

  22. WRITING TESTS

  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

  24. The Selftest Suite Running tests Writing tests LINKS → Writing and running tests: https://wiki.samba.org/index.php/Writing_Torture_Tests 24

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

Recommend


More recommend