Skip to content

Functional tests #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 49 commits into
base: testing
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
69e6029
Rough start for functional tests
cdunklau Feb 3, 2020
6dfbda6
Add behavioral notes
cdunklau Feb 8, 2020
8197557
Start dockerized ircd + services experiment
cdunklau Feb 9, 2020
5e878e9
docker-compose, configuration, initial services db
cdunklau Feb 9, 2020
85e9759
Update gitignores
cdunklau Feb 10, 2020
8c432d8
Add a basic test client
cdunklau Feb 11, 2020
0ed3cec
Handle child process lifecycle a bit nicer
cdunklau Feb 11, 2020
d51e1c8
Don't let atheme expire accounts or channels
cdunklau Feb 11, 2020
ba18589
Register channels and accounts
cdunklau Feb 11, 2020
72216b3
Enable account extban module in charybdis
cdunklau Feb 11, 2020
143bc5d
functests config module, add logging
cdunklau Feb 11, 2020
b7526aa
Check functest registrations exist
cdunklau Feb 12, 2020
d96ddbe
Remove obsolete experimental test
cdunklau Feb 12, 2020
e820021
More composition, store protocol state with the protocol
cdunklau Feb 12, 2020
7fc5aa6
Simplify channel data structure, handle JOIN errors
cdunklau Feb 13, 2020
5c8b065
Add a bunch of generic accounts
cdunklau Feb 13, 2020
7bbd36c
Expand readme a lot
cdunklau Feb 13, 2020
de251d7
Fix example mistake in readme
cdunklau Feb 15, 2020
eef9891
Add a script to produce some chat messages
cdunklau Feb 15, 2020
e487b4b
Add a generic simulator, refactor config and runner
cdunklau Feb 15, 2020
6cf387d
Support JSON for web UI's bans endpoint
cdunklau Feb 15, 2020
0a3f572
Make infobob's IRCClient log unknown messages
cdunklau Feb 15, 2020
c66bc45
Detail simulate in readme
cdunklau Feb 16, 2020
9d4b134
Refactor a bit
cdunklau Feb 16, 2020
14a3cee
Add a channel operator for use in tests
cdunklau Feb 16, 2020
689327d
Log less verbosely
cdunklau Feb 16, 2020
94876dc
Add some Gherkin feature files for planning
cdunklau Feb 16, 2020
80f30ef
Make test IRCClient log with what nick it has
cdunklau Feb 16, 2020
c0a9d19
Separate tests
cdunklau Feb 16, 2020
05efe03
Add monitor client fixture
cdunklau Feb 23, 2020
69ec662
Expand pastebin rehosting feature description
cdunklau Feb 29, 2020
2c407ba
Fix pylint errors
cdunklau Feb 29, 2020
2c47d5c
More pylint fixes
cdunklau Feb 29, 2020
53f2bdf
Clean up unused imports and vars
cdunklau Feb 29, 2020
86334e8
Default to joining all channels
cdunklau Feb 29, 2020
9fe7d58
Add starting bits for redent test
cdunklau Feb 29, 2020
654dbf6
Rearrange clients.py a bit
cdunklau Feb 29, 2020
9bc9f27
Partially test redent, expand helper client
cdunklau Feb 29, 2020
7d5e6df
Separate channel state and from-test interaction
cdunklau Mar 1, 2020
f1c5ff3
Track bans
cdunklau Mar 1, 2020
c5ed62a
Expand client, add first ban workflow test
cdunklau Mar 1, 2020
c00f3e9
Ensure clear initial ban state
cdunklau Mar 1, 2020
f0fee08
Add PM support, test response to unset ban
cdunklau Mar 1, 2020
6f2bc87
Generalize _ActionsWrangler
cdunklau Mar 4, 2020
16ef71f
Comment BDD-style, supersedes Gherkin features
cdunklau Mar 4, 2020
31e753f
Give bot runner control over lifecycle and webui
cdunklau Mar 8, 2020
786d9b5
Allow for querying running bot's database
cdunklau Mar 8, 2020
b462eab
Support JSON for webui edit ban endpoint
cdunklau Mar 8, 2020
7d6cc51
Add test for auto-unset of expired bans
cdunklau Mar 8, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
/infobob.cfg
*.sqlite
*.py[co]
.tox
.coverage
dist/
build/
_trial_temp
twisted/plugins/dropin.cache
3 changes: 3 additions & 0 deletions functional-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
infobob-env/
tests-env/
cornell_movie_dialogs_corpus.*
125 changes: 125 additions & 0 deletions functional-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
Functional test suite for infobob
=================================

Uses charybdis (ircd) and atheme (services), configured to resemble Freenode.
Freenode uses modified versions of these, but so far I haven't been able to
find important differences, so hopefully it's close enough.

Requirements:

- Docker for the ircd and services
- Python 3.6+ for the tests
- Python 2.7 and virtualenv for infobob itself

The `features/` directory has some [Gherkin](https://cucumber.io/docs/gherkin/)
feature files. I don't intend to make these actually executable; they're
primarily intended to document test cases that haven't yet been implemented.


Setup and Running
-----------------

# tests env
python3 -m venv tests-env
tests-env/bin/pip install -r requirements.txt
# infobob env (with py2)
python2 -m virtualenv infobob-env
infobob-env/bin/pip install -e ..
export INFOBOB_PYTHON=infobob-env/bin/python

Run the ircd and services in another terminal:

export COMPOSE_PROJECT_NAME=infobob-functests
docker-compose build && docker-compose up

Wait for them to come up: atheme will output something like
`m_pong(): finished synching with uplink (465 ms)`.

Then run the tests:

tests-env/bin/pytest


Other Goodies
-------------

If you want to poke around, point your IRC client at localhost:6667
(plaintext). The superadmin is `god`, password `letmein` (for both
NickServ and full IRCops).

There's a `simulate.py` script you can use to run infobob with a fresh db,
along with a few chatty bots. The script takes a single optional argument,
a filename containing phrases to use.

You can use the `movie_lines.py` script to generate a better phrases file,
e.g. `./movie_lines.py lines -n m13` if you're a fan of "Airplane!". Don't
forget to initialize with `./movie_lines.py initdb` first.


Updating the initial services database
--------------------------------------

The NickServ account credentials and channel configurations (with their
associated ChanServ settings) in `config.py` are preloaded in a database file
which is written into the atheme container image on build. If you change the
tests to rely on different services data (e.g. additional accounts or
registered channels), you'll need to update apps/atheme/initial.db.

While it appears to be a flat text file, you should consider it opaque: it's
difficult to hand-edit accurately, and it's probably a bad idea to assume
atheme can gracefully deal with invalid data. Instead, follow this procedure
to start from a clean slate, change the things you need, and update the file:

1. Note which changes you need to make. If you don't remember exactly, you
can run this to persist the db for manual comparison:

docker run \
--mount type=volume,source=infobob-functests_atheme-db,dst=/athemedb,readonly \
debian:buster \
cat /athemedb/services.db \
> backup.db

2. Stop docker-compose, then delete the container and volume:

docker rm infobob-functests_atheme_1
docker volume rm infobob-functests_atheme-db

3. Spin it back up:

export COMPOSE_PROJECT_NAME=infobob-functests
docker-compose build && docker-compose up

4. Make the changes you need. The convention for account password is
`nickname + 'pass'` and email `nickname + '@infobobtest.local'`.
At least with irssi, you can oneline stuff with `/eval`, which makes
registering a bunch of users fairly easy:

/eval nick flubber; \
msg nickserv register flubberpass [email protected]; \
msg nickserv logout

5. Since atheme only writes its db every 5 minutes, you'll need to make sure
the services DB is updated: log in as `god`, make sure you're identified
with NickServ, use the `/oper` command to escalate, then
`/msg operserv update`. Make sure you got a notice from OperServ saying
`UPDATE completed`.

6. Stop docker-compose, then grab the DB:

docker run \
--rm \
--mount type=volume,source=infobob-functests_atheme-db,dst=/athemedb,readonly \
debian:buster \
cat /athemedb/services.db \
> apps/atheme/initial.db

7. Sanitize the DB by replacing your host username, which might show up:
edit apps/atheme/initial.db and look for MDU lines, e.g.

MDU somenick private:host:actual [email protected]
MDU somenick private:host:vhost [email protected]

Replace your username with `someone`, but be careful about it.

8. Finally, repeat steps 2 and 3, then double check that the changes persist
and the tests pass. You're ready to commit!
6 changes: 6 additions & 0 deletions functional-tests/apps/atheme/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Don't allow git to mess with the DB.
# diffs could still be interesting, so leave that set,
# but don't let it play with line endings, or try to
# merge two versions of it.
# Also ignore whitespace errors.
initial.db diff -text -merge -whitespace
14 changes: 14 additions & 0 deletions functional-tests/apps/atheme/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM debian:buster

RUN apt-get update \
&& apt-get install -y \
atheme-services

COPY atheme.conf /etc/atheme/atheme.conf
COPY initial.db /var/lib/atheme/services.db

# HTTP port for XMLRPC
EXPOSE 8080
# Volume for services database
VOLUME /var/lib/atheme
ENTRYPOINT ["atheme-services", "-n", "-p", "/var/run/atheme.pid"]
Loading