add more info to test.sh
This commit is contained in:
parent
6e40fba236
commit
405e7c21c3
@ -4,3 +4,5 @@ PASSWORD = bottestpassword
|
|||||||
NICK = xmppbot
|
NICK = xmppbot
|
||||||
ROOM1 = testroom1@conference.localhost
|
ROOM1 = testroom1@conference.localhost
|
||||||
ROOM2 = testroom2@conference.localhost
|
ROOM2 = testroom2@conference.localhost
|
||||||
|
HOST = 127.0.0.1
|
||||||
|
PORT = 25222
|
||||||
|
27
test/test.sh
27
test/test.sh
@ -1,5 +1,16 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# Check if docker is installed
|
||||||
|
if ! command -v docker run &> /dev/null
|
||||||
|
then
|
||||||
|
echo "No docker detected. If you are running debian based system, you can install docker with"
|
||||||
|
echo "sudo apt install docker.io
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Docker detected"
|
||||||
|
|
||||||
# Run ejabberd docker as a daemon
|
# Run ejabberd docker as a daemon
|
||||||
|
echo "Starting ejabberd docker container"
|
||||||
docker run --name xmppbot-test -d -p 25222:5222 ejabberd/ecs
|
docker run --name xmppbot-test -d -p 25222:5222 ejabberd/ecs
|
||||||
|
|
||||||
# Wait few seconds for ejabberd to boot
|
# Wait few seconds for ejabberd to boot
|
||||||
@ -15,9 +26,11 @@ docker exec -it xmppbot-test bin/ejabberdctl create_room testroom1 conference.lo
|
|||||||
docker exec -it xmppbot-test bin/ejabberdctl create_room testroom2 conference.localhost localhost
|
docker exec -it xmppbot-test bin/ejabberdctl create_room testroom2 conference.localhost localhost
|
||||||
|
|
||||||
# Run xmpp mirror bot
|
# Run xmpp mirror bot
|
||||||
|
echo "Running xmpp mirror bot"
|
||||||
python3 ../xmppmirror & XMPPMIRRORPID=$!
|
python3 ../xmppmirror & XMPPMIRRORPID=$!
|
||||||
|
|
||||||
# Run xmpp test bot
|
# Run xmpp test bot
|
||||||
|
echo "Running test bot"
|
||||||
python3 testbot & TESTBOTPID=$!
|
python3 testbot & TESTBOTPID=$!
|
||||||
|
|
||||||
# Wait for bots to connect
|
# Wait for bots to connect
|
||||||
@ -27,10 +40,20 @@ sleep 10
|
|||||||
for i in $(cat testmsgs.txt); do sleep 5; done
|
for i in $(cat testmsgs.txt); do sleep 5; done
|
||||||
|
|
||||||
# Kill bots
|
# Kill bots
|
||||||
kill $XMPPMIRRORPID
|
if ps -p $XMPPMIRRORPID > /dev/null
|
||||||
kill $TESTBOTPID
|
then
|
||||||
|
echo "Killing xmpp mirror bot"
|
||||||
|
kill $XMPPMIRRORPID
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ps -p $TESTBOTPID > /dev/null
|
||||||
|
then
|
||||||
|
echo "Killing test bot"
|
||||||
|
kill $TESTBOTPID
|
||||||
|
fi
|
||||||
|
|
||||||
# Stop and remove containter
|
# Stop and remove containter
|
||||||
|
echo "Stopping and removing docker container"
|
||||||
docker stop xmppbot-test
|
docker stop xmppbot-test
|
||||||
docker rm xmppbot-test
|
docker rm xmppbot-test
|
||||||
|
|
||||||
|
@ -4,3 +4,5 @@ PASSWORD = admintestpassword
|
|||||||
NICK = admin
|
NICK = admin
|
||||||
ROOM1 = testroom1@conference.localhost
|
ROOM1 = testroom1@conference.localhost
|
||||||
ROOM2 = testroom2@conference.localhost
|
ROOM2 = testroom2@conference.localhost
|
||||||
|
HOST = 127.0.0.1
|
||||||
|
PORT = 25222
|
||||||
|
@ -59,6 +59,12 @@ if __name__ == '__main__':
|
|||||||
NICK = config.get('credentials', 'NICK')
|
NICK = config.get('credentials', 'NICK')
|
||||||
ROOM1 = config.get('credentials', 'ROOM1')
|
ROOM1 = config.get('credentials', 'ROOM1')
|
||||||
ROOM2 = config.get('credentials', 'ROOM2')
|
ROOM2 = config.get('credentials', 'ROOM2')
|
||||||
|
HOST = None
|
||||||
|
PORT = 5222
|
||||||
|
if "host" in config.options('credentials'):
|
||||||
|
HOST = config.get('credentials', 'HOST')
|
||||||
|
if "port" in config.options('credentials'):
|
||||||
|
PORT = config.get('credentials', 'PORT')
|
||||||
|
|
||||||
|
|
||||||
xmpp = MUCBot(JID, PASSWORD, NICK, ROOM1, ROOM2)
|
xmpp = MUCBot(JID, PASSWORD, NICK, ROOM1, ROOM2)
|
||||||
@ -67,6 +73,9 @@ if __name__ == '__main__':
|
|||||||
xmpp.register_plugin('xep_0199') # XMPP Ping
|
xmpp.register_plugin('xep_0199') # XMPP Ping
|
||||||
|
|
||||||
# Connect to the XMPP server and start processing XMPP stanzas.
|
# Connect to the XMPP server and start processing XMPP stanzas.
|
||||||
|
if HOST != None:
|
||||||
|
xmpp.connect(address=(HOST,int(PORT)))
|
||||||
|
else:
|
||||||
xmpp.connect()
|
xmpp.connect()
|
||||||
xmpp.process()
|
xmpp.process()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user