xmppmirror/test/test.sh

37 lines
997 B
Bash
Raw Normal View History

2022-06-13 17:33:08 +00:00
#!/bin/bash
# Run ejabberd docker as a daemon
docker run --name xmppbot-test -d -p 25222:5222 ejabberd/ecs
# Wait few seconds for ejabberd to boot
sleep 5
# Create acounts for admin and xmppbot
docker exec -it xmppbot-test bin/ejabberdctl register admin localhost admintestpassword
docker exec -it xmppbot-test bin/ejabberdctl register xmppbot localhost bottestpassword
# Create MUC rooms for testing
docker exec -it xmppbot-test bin/ejabberdctl create_room testroom1 conference.localhost localhost
docker exec -it xmppbot-test bin/ejabberdctl create_room testroom2 conference.localhost localhost
# Run xmpp mirror bot
2022-06-13 20:24:07 +00:00
python3 ../xmppmirror & XMPPMIRRORPID=$!
2022-06-13 17:33:08 +00:00
# Run xmpp test bot
2022-06-13 20:24:07 +00:00
python3 testbot & TESTBOTPID=$!
# Wait for bots to connect
sleep 10
# Wait certain amount of time for every test message in the file
2022-06-13 20:29:53 +00:00
for i in $(cat testmsgs.txt); do sleep 5; done
2022-06-13 20:24:07 +00:00
# Kill bots
2022-06-13 20:29:53 +00:00
kill $XMPPMIRRORPID
kill $TESTBOTPID
2022-06-13 17:33:08 +00:00
# Stop and remove containter
docker stop xmppbot-test
docker rm xmppbot-test