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

Add plugin support. #941

Merged
merged 6 commits into from
Nov 27, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ synapse) and place it within the homeserver configuration directory

.. _dictConfig: https://docs.python.org/2/library/logging.config.html#logging.config.dictConfig

Sytest supports plugins. Plugins follow the same project structure as sytest and can be placed
valkum marked this conversation as resolved.
Show resolved Hide resolved
in the `plugins` directory.
To override the path of the plugins directory set the env var `SYTEST_PLUGINS` to another directory.
valkum marked this conversation as resolved.
Show resolved Hide resolved

Currently only Homeserver and Output Implementations are supported in plugins.
valkum marked this conversation as resolved.
Show resolved Hide resolved

Developing
----------

Expand Down
22 changes: 20 additions & 2 deletions docker/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ else

mkdir -p /sytest
tar -C /sytest --strip-components=1 -xf sytest.tar.gz

if [ -n "$PLUGINS" ]; then
valkum marked this conversation as resolved.
Show resolved Hide resolved
mkdir /sytest/plugins
echo "--- Downloading plugins for sytest"
IFS=' '; for plugin in $PLUGINS; do
plugindir=$(mktemp -d --tmpdir=/sytest/plugins)
wget -q $plugin -O plugin.tar.gz || {
echo "Failed to download plugin: $plugin" >&2
exit 1
}
tar -C $plugindir --strip-components=1 -xf plugin.tar.gz
done
fi
fi

echo "--- Preparing sytest for ${SYTEST_TARGET}"
Expand All @@ -51,6 +64,11 @@ elif [ -x "/sytest/docker/${SYTEST_TARGET}_sytest.sh" ]; then
exec "/sytest/docker/${SYTEST_TARGET}_sytest.sh" "$@"

else
echo "sytest runner script for ${SYTEST_TARGET} not found" >&2
exit 1
PLUGIN_RUNNER=$(find /sytest/plugins/ -type f -name "${SYTEST_TARGET}_sytest.sh" -print)
if [ -n PLUGIN_RUNNER ]; then
exec ${PLUGIN_RUNNER} "$@"
else
echo "sytest runner script for ${SYTEST_TARGET} not found" >&2
exit 1
fi
fi
8 changes: 7 additions & 1 deletion run-tests.pl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

use Data::Dump qw( pp );
use File::Basename qw( basename );
use File::Spec::Functions qw( catdir );
use Getopt::Long qw( :config no_ignore_case gnu_getopt );
use IO::Socket::SSL;
use List::Util 1.33 qw( first all any maxstr max );
Expand All @@ -34,17 +35,22 @@
: undef;
});

my $plugin_dir = $ENV{"SYTEST_PLUGINS"} || "plugins"; # Read plugin dir from env var SYTEST_PLUGINS or fallback to plugins
richvdh marked this conversation as resolved.
Show resolved Hide resolved
my @plugins = grep { -d } glob(catdir($plugin_dir, "*")); # Read all plugins/<plugin>
my @lib_dirs = map { catdir($_, "lib") } @plugins;

use Module::Pluggable
sub_name => "output_formats",
search_path => [ "SyTest::Output" ],
search_dirs => \@lib_dirs,
require => 1;

use Module::Pluggable
sub_name => "homeserver_factories",
search_path => [ "SyTest::HomeserverFactory" ],
search_dirs => \@lib_dirs,
require => 1;


binmode(STDOUT, ":utf8");

our $WANT_TLS = 1; # This is shared with the test scripts
Expand Down