[TESTS] Speed up test runs
This commit is contained in:
parent
46fcab2e94
commit
daec26f2d8
|
@ -1,4 +1,8 @@
|
|||
parameters:
|
||||
test_token: 1
|
||||
|
||||
doctrine:
|
||||
dbal:
|
||||
override_url: true
|
||||
dbname: test
|
||||
dbname: 'test_%env(default:test_token:TEST_TOKEN)%'
|
||||
logging: false
|
||||
|
|
6
config/packages/test/security.yaml
Normal file
6
config/packages/test/security.yaml
Normal file
|
@ -0,0 +1,6 @@
|
|||
security:
|
||||
password_hashers:
|
||||
App\Entity\LocalUser:
|
||||
algorithm: md5
|
||||
encode_as_base64: false
|
||||
iterations: 0
|
|
@ -3,15 +3,15 @@
|
|||
cd /var/www/social || exit 1
|
||||
|
||||
printf "Cleaning Redis cache: " && echo "FLUSHALL" | nc redis 6379
|
||||
bin/console doctrine:database:drop --force || exit 1
|
||||
bin/console doctrine:database:drop --force --if-exists || exit 1
|
||||
bin/console doctrine:database:create || exit 1
|
||||
bin/console doctrine:schema:update --force || exit 1
|
||||
yes yes | bin/console doctrine:fixtures:load || exit 1
|
||||
|
||||
if [ "$#" -eq 0 ] || [ -z "$*" ]; then
|
||||
XDEBUG_MODE=coverage vendor/bin/phpunit --verbose --debug --configuration=phpunit.xml.dist
|
||||
# XDEBUG_MODE=off vendor/bin/paratest --verbose --debug --processes=32 --functional --configuration=phpunit.xml.dist $*
|
||||
php -dpcov.enabled=1 -dpcov.directory=. -dpcov.exclude="~vendor~" vendor/bin/phpunit --configuration=phpunit.xml.dist $*
|
||||
else
|
||||
echo "Running with filter"
|
||||
XDEBUG_MODE=coverage vendor/bin/phpunit --verbose --debug --configuration=phpunit.xml.dist $*
|
||||
# XDEBUG_MODE=coverage vendor/bin/paratest --processes=32 --functional --configuration=phpunit.xml.dist
|
||||
XDEBUG_MODE=off vendor/bin/paratest --processes=32 --functional --configuration=phpunit.xml.dist $*
|
||||
fi
|
||||
|
|
|
@ -4,7 +4,7 @@ WORKDIR /var/www/social
|
|||
|
||||
RUN apk update \
|
||||
&& apk add --no-cache $PHPIZE_DEPS runuser \
|
||||
&& pecl install xdebug \
|
||||
&& docker-php-ext-enable xdebug
|
||||
&& pecl install pcov \
|
||||
&& docker-php-ext-enable pcov
|
||||
|
||||
RUN apk add --no-cache openssh sshpass
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
<php>
|
||||
<ini name="error_reporting" value="-1"/>
|
||||
<server name="APP_ENV" value="test" force="true"/>
|
||||
<server name="APP_DEBUG" value="false" />
|
||||
<server name="SHELL_VERBOSITY" value="-1"/>
|
||||
<server name="SYMFONY_PHPUNIT_REMOVE" value=""/>
|
||||
<server name="SYMFONY_PHPUNIT_VERSION" value="9.5"/>
|
||||
|
|
|
@ -45,10 +45,7 @@ declare(strict_types = 1);
|
|||
|
||||
namespace App\Core;
|
||||
|
||||
use App\Core\DB;
|
||||
use App\Core\I18n\I18n;
|
||||
use App\Core\Queue;
|
||||
use App\Core\Router;
|
||||
use App\Kernel;
|
||||
use App\Util\Common;
|
||||
use App\Util\Exception\ConfigurationException;
|
||||
|
@ -156,31 +153,27 @@ class GNUsocial implements EventSubscriberInterface
|
|||
*/
|
||||
public function initialize(): void
|
||||
{
|
||||
if (!$this->initialized) {
|
||||
Common::setupConfig($this->config);
|
||||
if (!\is_null($this->request)) {
|
||||
Common::setRequest($this->request);
|
||||
}
|
||||
Log::setLogger($this->logger);
|
||||
Event::setDispatcher($this->event_dispatcher);
|
||||
I18n::setTranslator($this->translator);
|
||||
DB::setManager($this->entity_manager);
|
||||
Form::setFactory($this->form_factory);
|
||||
Queue::setMessageBus($this->message_bus);
|
||||
Security::setHelper($this->security);
|
||||
HTML::setSanitizer($this->sanitizer);
|
||||
Router::setRouter($this->router);
|
||||
HTTPClient::setClient($this->client);
|
||||
Formatting::setTwig($this->twig);
|
||||
Cache::setupCache();
|
||||
|
||||
DB::initTableMap();
|
||||
|
||||
// Events are preloaded on compilation, but set at runtime, along with configuration
|
||||
$this->module_manager->loadModules();
|
||||
|
||||
$this->initialized = true;
|
||||
Common::setupConfig($this->config);
|
||||
if (!\is_null($this->request)) {
|
||||
Common::setRequest($this->request);
|
||||
}
|
||||
Log::setLogger($this->logger);
|
||||
Event::setDispatcher($this->event_dispatcher);
|
||||
I18n::setTranslator($this->translator);
|
||||
DB::setManager($this->entity_manager);
|
||||
Form::setFactory($this->form_factory);
|
||||
Queue::setMessageBus($this->message_bus);
|
||||
Security::setHelper($this->security);
|
||||
HTML::setSanitizer($this->sanitizer);
|
||||
Router::setRouter($this->router);
|
||||
HTTPClient::setClient($this->client);
|
||||
Formatting::setTwig($this->twig);
|
||||
Cache::setupCache();
|
||||
|
||||
DB::initTableMap();
|
||||
|
||||
// Events are preloaded on compilation, but set at runtime, along with configuration
|
||||
$this->module_manager->loadModules();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,7 +44,6 @@ class GNUsocialTestCase extends WebTestCase
|
|||
{
|
||||
public static GNUsocial $social;
|
||||
protected static TestContainer|null $container = null;
|
||||
private static bool $initialized = false;
|
||||
|
||||
/**
|
||||
* Provide our own initialization for testing
|
||||
|
@ -64,25 +63,6 @@ class GNUsocialTestCase extends WebTestCase
|
|||
}
|
||||
|
||||
private static function do_setup()
|
||||
{
|
||||
if (!self::$initialized) {
|
||||
// We utilize the filesystem as shared mutable state to coordinate between processes
|
||||
touch('/tmp/test-initialization-lock-file');
|
||||
$lockFile = fopen('/tmp/test-initialization-lock-file', 'r');
|
||||
|
||||
// Attempt to get an exclusive lock - first process wins
|
||||
if (flock($lockFile, \LOCK_EX | \LOCK_NB)) {
|
||||
// Since we are the single process that has an exclusive lock, we run the initialization
|
||||
self::initialize();
|
||||
} else {
|
||||
// If no exclusive lock is available, block until the first process is done with initialization
|
||||
flock($lockFile, \LOCK_SH);
|
||||
}
|
||||
self::$initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static function initialize()
|
||||
{
|
||||
static::$container = self::$kernel->getContainer()->get('test.service_container');
|
||||
$services = F\map(
|
||||
|
|
Loading…
Reference in New Issue
Block a user