Skip to content
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

Move integration tests out of source #443

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 16 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,25 @@ name: CI
on:
pull_request:
push:
branches: master
branches: [master]

jobs:
linux-glibc:
runs-on: ubuntu-latest
services:
ircd:
image: linuxserver/ngircd
ports:
- 6667:6667
xmppd:
image: cr.spectrum.im/spectrumim/prosody:master
ports:
- 5222:5222
- 5347:5347
env:
LOCAL: admin
DOMAIN: localhost
PASSWORD: secret

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -39,7 +53,7 @@ jobs:
- name: Run tests
run: docker run -tt --env LANG=en_US.UTF-8 spectrum:tests-musl
macos:
runs-on: macOS-12
runs-on: macos-12
steps:
- uses: actions/checkout@v2
- name: Install MacPorts
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ ARG APT_LISTCHANGES_FRONTEND=none

WORKDIR /spectrum2

RUN apt-get install --no-install-recommends -y prosody ngircd python3-sleekxmpp python3-dateutil python3-dnspython libcppunit-dev purple-xmpp-carbons libglib2.0-dev psmisc
RUN apt-get install --no-install-recommends -y python3-sleekxmpp python3-dateutil python3-dnspython libcppunit-dev purple-xmpp-carbons libglib2.0-dev psmisc

RUN cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_TESTS=ON -DENABLE_QT4=OFF -DCMAKE_UNITY_BUILD=ON . && make -j4

ENTRYPOINT ["make", "extended_test"]
ENTRYPOINT ["make", "test"]

FROM base as test-clang

Expand Down
7 changes: 0 additions & 7 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,5 @@ if(ENABLE_TESTS)
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/libtransport/libtransport_test
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests_output
)

add_custom_target(extended_test
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/libtransport/libtransport_test
COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/start.py
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests_output
)

endif()

81 changes: 4 additions & 77 deletions tests/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ def start(self, TestCaseFile):
return ret

def pre_test(self):
os.system("../../spectrum/src/spectrum2 -n ./" + self.config + " > spectrum2.log &")
pass

def post_test(self):
os.system("killall -w spectrum2")
pass

class LibcommuniServerModeSingleServerConf(BaseTest):
def __init__(self):
Expand All @@ -191,29 +191,11 @@ def skip_test(self, test):
return True
return False

def pre_test(self):
BaseTest.pre_test(self)
os.system("/usr/sbin/ngircd -f ../libcommuni/ngircd.conf &")

def post_test(self):
os.system("killall -w ngircd 2>/dev/null")
os.system("killall -w spectrum2_libcommuni_backend 2>/dev/null")
BaseTest.post_test(self)

class LibcommuniServerModeConf(BaseTest):
def __init__(self):
BaseTest.__init__(self, "../libcommuni/irc_test2.cfg", True, "#channel%localhost@localhost")
self.directory = "../libcommuni/"

def pre_test(self):
BaseTest.pre_test(self)
os.system("/usr/sbin/ngircd -f ../libcommuni/ngircd.conf &")

def post_test(self):
os.system("killall -w ngircd 2>/dev/null")
os.system("killall -w spectrum2_libcommuni_backend 2>/dev/null")
BaseTest.post_test(self)

class JabberServerModeConf(BaseTest):
def __init__(self):
BaseTest.__init__(self, "../libpurple_jabber/jabber_test.cfg", True, "room%conference.localhost@localhostxmpp")
Expand All @@ -233,68 +215,13 @@ def skip_test(self, test):
def pre_test(self):
os.system("cp ../libpurple_jabber/prefs.xml ./ -f >/dev/null")
BaseTest.pre_test(self)
os.system("prosody --config ../libpurple_jabber/prosody.cfg.lua >prosody.log &")
time.sleep(3)
os.system("../../spectrum_manager/src/spectrum2_manager -c ../libpurple_jabber/manager.conf localhostxmpp register client%localhost@localhostxmpp client@localhost password 2>/dev/null >/dev/null")
os.system("../../spectrum_manager/src/spectrum2_manager -c ../libpurple_jabber/manager.conf localhostxmpp register responder%localhost@localhostxmpp responder@localhost password 2>/dev/null >/dev/null")

def post_test(self):
os.system("killall -w -r lua.* 2>/dev/null")
os.system("killall -w spectrum2_libpurple_backend 2>/dev/null")
BaseTest.post_test(self)

class JabberSlackServerModeConf(BaseTest):
def __init__(self):
BaseTest.__init__(self, "../slack_jabber/jabber_slack_test.cfg", True, "room%conference.localhost@localhostxmpp")
self.directory = "../slack_jabber/"
self.client_jid = "client@localhost"
self.client_room = "[email protected]"
# Implicitly forces responder to connect to slack.com instead of localhost
# by passing a nonstandard responder_roompassword
self.responder_jid = "[email protected]"
self.responder_password = "spectrum2tests.e2zJwtKjLhLmt14VsMKq"
self.responder_room = "[email protected]"
self.responder_nick = "owner"
self.responder_roompassword = "spectrum2tests.e2zJwtKjLhLmt14VsMKq"

def skip_test(self, test):
os.system("cp ../slack_jabber/slack.sql .")
if test.find("bad_password") != -1:
print("Changing password to 'badpassword'")
os.system("sqlite3 slack.sql \"UPDATE users SET password='badpassword' WHERE id=1\"")
return False

def pre_test(self):
BaseTest.pre_test(self)
os.system("prosody --config ../slack_jabber/prosody.cfg.lua > prosody.log &")

def post_test(self):
os.system("killall -w -r lua.* 2>/dev/null")
os.system("killall -w spectrum2_libpurple_backend 2>/dev/null")
BaseTest.post_test(self)

class TwitterServerModeConf(BaseTest):
def __init__(self):
BaseTest.__init__(self, "../twitter/twitter_test.cfg", True, "")
self.directory = "../twitter/"
self.client_password = "testpass123"

def skip_test(self, test):
os.system("cp ../twitter/twitter.sql .")

def pre_test(self):
BaseTest.pre_test(self)

def post_test(self):
os.system("killall -w spectrum2_twitter_backend 2>/dev/null")
BaseTest.post_test(self)
os.system("spectrum2_manager localhostxmpp register client%localhost@localhostxmpp client@localhost password")
os.system("spectrum2_manager localhostxmpp register responder%localhost@localhostxmpp responder@localhost password")

configurations = []
configurations.append(LibcommuniServerModeSingleServerConf())
configurations.append(LibcommuniServerModeConf())
configurations.append(JabberServerModeConf())
#configurations.append(JabberSlackServerModeConf())
#configurations.append(TwitterServerModeConf())

exitcode = 0

Expand Down