Skip to content

Commit

Permalink
Add plugin support
Browse files Browse the repository at this point in the history
bootstrap.sh will now download plugins given in the env var PLUGIN
The format is <repo>/<plugin> and only github is support for now.
They get downloaded into /sytest/plugins by default.
Multiple plugins can be given, devided by : (similar to PATH)

SyTest will now look for plugins in /sytest/plugins (overridable by $SYTEST_PLUGINS)
ServerImplementations and Output plugins are supported for now.
The dir structure of plugins follows the structure of sytest itself.

See http://github.com/valkum/sytest_conduit for an example plugin
  • Loading branch information
valkum committed Sep 17, 2020
1 parent 77c9724 commit e61a412
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
30 changes: 25 additions & 5 deletions docker/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,32 @@ else
# Dendrite uses master as its main branch. If the branch is master, we probably want sytest develop
branch_name="develop"
fi
if [ "$SYTEST_TARGET" == "conduit" ]; then
# Dendrite uses master as its main branch. If the branch is master, we probably want sytest develop
branch_name="develop"
fi

# Try and fetch the branch
wget -q https://github.com/matrix-org/sytest/archive/$branch_name.tar.gz -O sytest.tar.gz || {
wget -q https://github.com/valkum/sytest/archive/$branch_name.tar.gz -O sytest.tar.gz || {
# Probably a 404, fall back to develop
echo "Using develop instead..."
wget -q https://github.com/matrix-org/sytest/archive/develop.tar.gz -O sytest.tar.gz
wget -q https://github.com/valkum/sytest/archive/develop.tar.gz -O sytest.tar.gz
}

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

if [ -n "$PLUGIN" ]; then
mkdir /sytest/plugins
echo "--- Downloading plugins for sytest"
IFS=':'; for plugin in $PLUGIN; do
wget -q https://github.com/$plugin/archive/master.tar.gz -O plugin.tar.gz || {
echo "Failed to download plugin: $plugin"
}
mkdir -p /sytest/plugins/$plugin
tar -C /sytest/plugins/$plugin --strip-components=1 -xf plugin.tar.gz
done
fi
fi

echo "--- Preparing sytest for ${SYTEST_TARGET}"
Expand All @@ -49,8 +65,12 @@ if [ -x "/sytest/scripts/${SYTEST_TARGET}_sytest.sh" ]; then
elif [ -x "/sytest/docker/${SYTEST_TARGET}_sytest.sh" ]; then
# old branches of sytest used to put the sytest running script in the "/docker" directory
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 -exec test -x {} \; -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
my @plugins = grep { -d } glob(catdir($plugin_dir, "*", "*")); # Read all plugins/<author>/<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

0 comments on commit e61a412

Please sign in to comment.