Skip to content

Commit

Permalink
tests: Remove the unit-tests directory.
Browse files Browse the repository at this point in the history
This code doesn't work and hasn't been touched in several years.  There
are other ways to test booth that do work, and the fact that no one has
fixed these tests means that no one thinks they are important enough to
get working.  So, remove them.

Signed-off-by: Chris Lumens <[email protected]>
  • Loading branch information
clumens committed Apr 23, 2024
1 parent f3fe313 commit abbc467
Show file tree
Hide file tree
Showing 17 changed files with 2 additions and 1,225 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ conf/booth*.service
docs/*.8
docs/*.8.html
script/service-runnable
script/unit-test.py
src/b_config.h.in
src/b_config.h
src/booth_config.h
Expand Down
3 changes: 1 addition & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@ TARFILE = $(PACKAGE_NAME)-$(VERSION).tar.gz

EXTRA_DIST = autogen.sh conf/booth.conf.example \
script/booth-keygen script/lsb script/ocf script/service-runnable.in \
script/unit-test.py.in script/wireshark-dissector.lua \
script/wireshark-dissector.lua \
test/arbtests.py test/assertions.py test/booth_path test/boothrunner.py \
test/boothtestenv.py.in test/clientenv.py test/clienttests.py test/live_test.sh \
test/runtests.py.in test/serverenv.py test/servertests.py test/sitetests.py \
test/utils.py \
unit-tests \
contrib \
icons \
$(SPEC).in booth-rpmlintrc \
Expand Down
87 changes: 0 additions & 87 deletions README-testing
Original file line number Diff line number Diff line change
Expand Up @@ -141,91 +141,4 @@ BOOTH_RUNTESTS_SINGLE_INSTANCE environment variable to make tests use
only single port (9929), but parallel instances will fail.



=== Unit tests

These use gdb and pexpect to set boothd state to some configured value,
injecting some input and looking at the output.

# python script/unit-test.py src/boothd unit-tests/

Or, if using the 'booth-test' RPM,

# python unit-test.py src/boothd unit-tests/

This must (currently?) be run as a non-root user; another optional argument is
the test to start from, eg. '003'.


Basically, boothd is started with the config file `unit-tests/booth.conf`, and
gdb gets attached to it.

Then, some ticket state is set, incoming messages are delivered, and outgoing
messages and the state is compared to expected values.

`unit-tests/_defaults.txt` has default values for the initial state and
message data.


Each test file consists of headers and key/value pairs:

--------------------
ticket:
state ST_STABLE
message0: # optional comment for the log file
header.cmd OP_ACCEPTING
ticket.id "asdga"
outgoing0:
header.cmd OP_PREPARING
last_ack_ballot 42
finally:
new_ballot 1234
--------------------


A few details to the the above example:

* Ticket states in RAM (`ticket`, `finally`) are written in host-endianness.

* Message data (`messageN`, `outgoingN`) are automatically converted via `htonl` resp. `ntohl`. They are delivered/checked in the order defined by the integer `N` component.

* Strings are done via `strcpy()`

* `ticket` and `messageN` are assignment chunks

* `finally` and `outgoingN` are compare chunks

* In `outgoingN` you can check _both_ message data (keys with a `.` in them) and ticket state

* Symbolic names are useable, GDB translates them for us

* The test scripts in `unit-tests/` need to be named with 3 digits, an underscore, some text, and `.txt`

* The "fake" `crm_ticket` script gets the current test via `UNIT_TEST`; test scripts can pass additional information via `UNIT_TEST_AUX`.



==== Tips and Hints

There's another special header: `gdb__N__`. These lines are sent to GDB after
injecting a message, but before waiting for an outgoing line. Values that
contain `§` are sent as multiple lines to GDB.

This means that a stanza like

--------------------
gdb0:
watch booth_conf->ticket[0].owner § commands § bt § c § end
--------------------

will cause a watchpoint to be set, and when it is triggered a backtrace (`bt`)
is written to the log file.

This makes it easy to ask for additional data or check for a call-chain when
hitting bugs that can be reproduced via such a unit-test.


# vim: set ft=asciidoc :
2 changes: 1 addition & 1 deletion booth.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ ln -s ../../%{_initddir}/booth-arbitrator %{buildroot}%{_sbindir}/rcbooth-arbitr
#install test-parts

mkdir -p %{buildroot}/%{test_path}/conf
cp -a unit-tests/ script/unit-test.py test %{buildroot}/%{test_path}/
cp -a test %{buildroot}/%{test_path}/
cp -a conf/booth.conf.example %{buildroot}/%{test_path}/conf/
chmod +x %{buildroot}/%{test_path}/test/booth_path
chmod +x %{buildroot}/%{test_path}/test/live_test.sh
Expand Down
1 change: 0 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ AC_CONFIG_FILES([Makefile
docs/Makefile
conf/Makefile])
AC_CONFIG_FILES([conf/booth-arbitrator.service conf/[email protected]])
AC_CONFIG_FILES([script/unit-test.py])
AC_CONFIG_FILES([script/service-runnable], [chmod +x script/service-runnable])

# ===============================================
Expand Down
Loading

0 comments on commit abbc467

Please sign in to comment.