Skip to content

Commit 70c07d4

Browse files
committed
[ticket/17543] Optimize functional tests running time
PHPBB-17543
1 parent 2baac73 commit 70c07d4

11 files changed

Lines changed: 69 additions & 29 deletions

tests/functional/extension_controller_test.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static public function tearDownAfterClass(): void
3939

4040
protected static function setup_extensions()
4141
{
42-
return ['foo/bar', 'foo/foo'];
42+
return self::$tests_count == self::$tests_number ? ['foo/bar', 'foo/foo'] : [];
4343
}
4444

4545
protected function setUp(): void
@@ -51,8 +51,11 @@ protected function setUp(): void
5151

5252
protected function tearDown(): void
5353
{
54-
$this->uninstall_ext('foo/bar');
55-
$this->uninstall_ext('foo/foo');
54+
if (self::$tests_count == 1)
55+
{
56+
$this->uninstall_ext('foo/bar');
57+
$this->uninstall_ext('foo/foo');
58+
}
5659

5760
parent::tearDown();
5861
}

tests/functional/extension_module_test.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,17 @@ static public function tearDownAfterClass(): void
4040

4141
protected function tearDown(): void
4242
{
43-
$this->uninstall_ext('foo/bar');
43+
if (self::$tests_count == 1)
44+
{
45+
$this->uninstall_ext('foo/bar');
46+
}
4447

4548
parent::tearDown();
4649
}
4750

4851
protected static function setup_extensions()
4952
{
50-
return ['foo/bar'];
53+
return self::$tests_count == self::$tests_number ? ['foo/bar'] : [];
5154
}
5255

5356
public function test_acp()

tests/functional/extension_template_event_order_test.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,18 @@ protected function setUp(): void
4646

4747
protected function tearDown(): void
4848
{
49-
$this->uninstall_ext('foo/bar');
50-
$this->uninstall_ext('foo/foo');
49+
if (self::$tests_count == 1)
50+
{
51+
$this->uninstall_ext('foo/bar');
52+
$this->uninstall_ext('foo/foo');
53+
}
5154

5255
parent::tearDown();
5356
}
5457

5558
protected static function setup_extensions()
5659
{
57-
return ['foo/bar', 'foo/foo'];
60+
return self::$tests_count == self::$tests_number ? ['foo/bar', 'foo/foo'] : [];
5861
}
5962

6063
/**
@@ -84,7 +87,7 @@ public function test_different_template_event_priority()
8487
$crawler = self::request('GET', 'index.php');
8588
$quick_links_menu = $crawler->filter('ul[role="menu"]')->eq(0);
8689
$quick_links_menu_nodes_count = (int) $quick_links_menu->filter('li')->count();
87-
// Ensure foo/foo template event goes before foo/bar one
90+
// Ensure foo/bar template event goes before foo/foo one
8891
$this->assertStringContainsString('FOO_BAR_QUICK_LINK', $quick_links_menu->filter('li')->eq($quick_links_menu_nodes_count - 4)->filter('span')->text());
8992
$this->assertStringContainsString('FOO_FOO_QUICK_LINK', $quick_links_menu->filter('li')->eq($quick_links_menu_nodes_count - 3)->filter('span')->text());
9093
}

tests/functional/mcp/mcp_main_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public function test_create_topic_with_replies()
208208
// Create replies. Flood control was disabled above
209209
for ($i = 1; $i <= 15; $i++)
210210
{
211-
sleep(1);
211+
usleep(100000);
212212
$post_text = "This is reply number $i to the Test Topic 4 to test moderation actions from MCP/View topic page.";
213213
$post[$i] = $this->create_post(2, $post[0]['topic_id'], 'Re: Test Topic 4', $post_text);
214214
$crawler = self::request('GET', "viewtopic.php?p={$post[$i]['post_id']}&sid={$this->sid}#p{$post[$i]['post_id']}");

tests/functional/metadata_manager_test.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case
2424

2525
protected function tearDown(): void
2626
{
27-
$this->uninstall_ext('foo/bar');
27+
if (self::$tests_count == 1)
28+
{
29+
$this->uninstall_ext('foo/bar');
30+
}
2831

2932
parent::tearDown();
3033
}
@@ -55,7 +58,7 @@ protected function setUp(): void
5558

5659
protected static function setup_extensions()
5760
{
58-
return ['foo/bar'];
61+
return self::$tests_count == self::$tests_number ? ['foo/bar'] : [];
5962
}
6063

6164
public function test_extensions_list()

tests/functional/prune_shadow_topic_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function test_move_topic()
133133
self::request('GET', "app.php/cron/cron.task.core.prune_shadow_topics?f={$this->data['forums']['Prune Shadow']}&sid={$this->sid}", array(), false);
134134

135135
// Try to ensure that the cron can actually run before we start to wait for it
136-
sleep(1);
136+
usleep(100000);
137137
$cron_lock = new \phpbb\lock\db('cron_lock', new \phpbb\config\db($this->db, new \phpbb\cache\driver\dummy(), 'phpbb_config'), $this->db);
138138
while (!$cron_lock->acquire())
139139
{

tests/functional/search/base.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ public function test_search_backend()
137137
$this->login();
138138
$this->admin_login();
139139

140-
$this->create_search_index('phpbb\\search\\backend\\fulltext_native');
141-
142140
$post = $this->create_topic(2, 'Test Topic 1 foosubject', 'This is a test topic posted by the barsearch testing framework.');
143141
$topic_multiple_results_count1 = $this->create_topic(2, 'Test Topic for multiple search results', 'This is a test topic posted to test multiple results count.');
144142
$this->create_post(2, $topic_multiple_results_count1['topic_id'], 'Re: Test Topic for multiple search results', 'This is a test post 2 posted to test multiple results count.');

tests/functional/search/mysql_test.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ class phpbb_functional_search_mysql_test extends phpbb_functional_search_base
2020
{
2121
protected $search_backend = 'phpbb\search\backend\fulltext_mysql';
2222

23+
protected function setUp(): void
24+
{
25+
$sql_layer = substr(self::$config['dbms'], strlen('phpbb\\db\\driver\\'));
26+
if ($sql_layer !== 'mysqli') // MySQL search backend runs on MySQL/MariaDB only
27+
{
28+
$this->markTestSkipped($sql_layer . ': MySQL search is not supported');
29+
}
30+
31+
parent::setUp();
32+
}
33+
2334
protected function create_search_index($backend = null)
2435
{
2536
parent::create_search_index($backend);

tests/functional/search/postgres_test.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,14 @@ class phpbb_functional_search_postgres_test extends phpbb_functional_search_base
2020
{
2121
protected $search_backend = 'phpbb\search\backend\fulltext_postgres';
2222

23+
protected function setUp(): void
24+
{
25+
$sql_layer = substr(self::$config['dbms'], strlen('phpbb\\db\\driver\\'));
26+
if ($sql_layer !== 'postgres') // PostgreSQL search backend runs on PostgreSQL only
27+
{
28+
$this->markTestSkipped($sql_layer . ': PostgreSQL search is not supported');
29+
}
30+
31+
parent::setUp();
32+
}
2333
}

tests/functional/search/sphinx_test.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ class phpbb_functional_search_sphinx_test extends phpbb_functional_search_base
2020
{
2121
protected $search_backend = 'phpbb\search\backend\fulltext_sphinx';
2222

23+
protected function setUp(): void
24+
{
25+
$sql_layer = substr(self::$config['dbms'], strlen('phpbb\\db\\driver\\'));
26+
if ($sql_layer !== 'mysqli') // Sphinx search backend runs on MySQL/MariaDB only so far
27+
{
28+
$this->markTestSkipped($sql_layer . ': Sphinx search is not supported');
29+
}
30+
31+
parent::setUp();
32+
}
33+
2334
protected function create_search_index($backend = null)
2435
{
2536
parent::create_search_index($backend);
@@ -35,16 +46,4 @@ protected function create_search_index($backend = null)
3546
exec('sudo -S service sphinxsearch start', $output, $retval); // Attempt to start sphinxsearch service again
3647
}
3748
}
38-
39-
public function test_search_backend()
40-
{
41-
if ($this->db->sql_layer != 'mysqli') // Sphinx test runs on MySQL/MariaDB only so far
42-
{
43-
$this->markTestIncomplete('Sphinx Tests are not supported');
44-
}
45-
else
46-
{
47-
parent::test_search_backend();
48-
}
49-
}
5049
}

0 commit comments

Comments
 (0)