Skip to content

Commit 6d34971

Browse files
Try to fix paratest
1 parent 7c40216 commit 6d34971

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+52
-96
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ phpunit.xml
2222
/tests/cypress/downloads/
2323
/tests/cypress/videos/
2424
/tests/files/
25+
/tests/files-2/
26+
/tests/files-3/
27+
/tests/files-4/
2528
/tests/.env
2629
/nbproject
2730
.composer.hash

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,17 @@ test-db-update: ## Update testing's database
177177
--env=testing
178178
.PHONY: test-db-update
179179

180+
test-db-clone: ## Set up DBs for parallel test execution
181+
@$(DB) bash -c ' \
182+
for i in 2 3 4; do \
183+
mariadb -u root -pglpi -e "DROP DATABASE IF EXISTS glpi_test_$$i"; \
184+
mariadb -u root -pglpi -e "CREATE DATABASE glpi_test_$$i CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"; \
185+
mariadb-dump -u root -pglpi --single-transaction glpi_test | mariadb -u root -pglpi glpi_test_$$i; \
186+
echo "Database glpi_test_$$i created and populated"; \
187+
done \
188+
'
189+
.PHONY: test-db-clone
190+
180191
e2e-db-install: ## Install e2e testing's database
181192
@$(CONSOLE) database:install \
182193
-r -f \
@@ -216,6 +227,11 @@ phpunit: ## Run phpunits tests, example: make phpunit c='tests/functional/Glpi/M
216227
@$(PHP) php vendor/bin/phpunit $(c)
217228
.PHONY: phpunit
218229

230+
paratest: ## Run paratest with 4 workers
231+
@$(eval c ?=)
232+
@$(PHP) php vendor/bin/paratest -p 4 --exclude-group "single-thread" $(c)
233+
.PHONY: paratest
234+
219235
phpstan: ## Run phpstan
220236
@$(eval c ?=)
221237
@$(PHP) php vendor/bin/phpstan --memory-limit=1G $(c)

src/Glpi/Application/Environment.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,13 @@ public static function validate(): void
139139
*/
140140
public function getConstantsOverride(string $root_dir): array
141141
{
142+
$test_token = getenv('TEST_TOKEN');
143+
142144
return match ($this) {
143145
default => [],
144146
self::TESTING => [
145147
'GLPI_CONFIG_DIR' => $root_dir . '/tests/config',
146-
'GLPI_VAR_DIR' => $root_dir . '/tests/files',
148+
'GLPI_VAR_DIR' => $root_dir . '/tests/files' . (($test_token !== false && $test_token !== '' && $test_token > 1) ? "-$test_token" : ''),
147149
'GLPI_LOG_LVL' => LogLevel::DEBUG,
148150
'GLPI_STRICT_ENV' => true,
149151
'GLPI_SERVERSIDE_URL_ALLOWLIST' => [

src/RuleCollection.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,9 @@ public function moveRule($ID, $ref_ID, $type = self::MOVE_AFTER, $new_rule = fal
879879
$ruleDescription = new Rule();
880880

881881
// Get actual ranking of Rule to move
882-
$ruleDescription->getFromDB($ID);
882+
if (!$ruleDescription->getFromDB($ID)) {
883+
throw new RuntimeException("Failed to load rule");
884+
}
883885
$old_rank = $ruleDescription->fields["ranking"];
884886

885887
$max_ranking_criteria = [

tests/functional/Glpi/Api/HL/Controller/AdministrationControllerTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
use Glpi\Http\Request;
4040
use Glpi\Tests\HLAPITestCase;
4141
use PHPUnit\Framework\Attributes\DataProvider;
42-
use PHPUnit\Framework\Attributes\Group;
4342

4443
class AdministrationControllerTest extends HLAPITestCase
4544
{
@@ -305,7 +304,6 @@ private function addCustomUserPicture(int $user_id, string $picture_path)
305304
]);
306305
}
307306

308-
#[Group('single-thread')]
309307
public function testGetMyPicture()
310308
{
311309
$this->login();
@@ -338,7 +336,6 @@ public function testGetMyPicture()
338336
});
339337
}
340338

341-
#[Group('single-thread')]
342339
public function testGetUserPictureByID()
343340
{
344341
$this->login();
@@ -364,7 +361,6 @@ public function testGetUserPictureByID()
364361
});
365362
}
366363

367-
#[Group('single-thread')]
368364
public function testGetUserPictureByUsername()
369365
{
370366
$this->login();

tests/functional/Glpi/Form/Export/FormSerializerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,6 @@ public function testExportAndImportItemQuestionWithInvalidItemsId(): void
15741574
$this->assertEquals(0, (new QuestionTypeItem())->getDefaultValueItemId($question));
15751575
}
15761576

1577-
#[Group('single-thread')]
15781577
public function testExportAndImportWithCustomIcon(): void
15791578
{
15801579
// Arrange: create a form with a custom icon

tests/functional/Glpi/Form/Migration/FormMigrationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ public static function tearDownAfterClass(): void
144144
$DB->dropTable($table['TABLE_NAME']);
145145
}
146146

147+
$DB->clearSchemaCache();
147148
parent::tearDownAfterClass();
148149
}
149150

tests/functional/Glpi/Form/Migration/TargetsMigrationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ public static function tearDownAfterClass(): void
146146
$DB->dropTable($table['TABLE_NAME']);
147147
}
148148

149+
$DB->clearSchemaCache();
149150
parent::tearDownAfterClass();
150151
}
151152

tests/functional/Glpi/Inventory/Assets/AntivirusTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@
3838
use Glpi\Inventory\Converter;
3939
use Glpi\Tests\AbstractInventoryAsset;
4040
use PHPUnit\Framework\Attributes\DataProvider;
41-
use PHPUnit\Framework\Attributes\Group;
4241

43-
#[Group('single-thread')]
4442
class AntivirusTest extends AbstractInventoryAsset
4543
{
4644
public static function assetProvider(): array

tests/functional/Glpi/Inventory/Assets/BatteryTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@
3838
use Glpi\Inventory\Converter;
3939
use Glpi\Tests\AbstractInventoryAsset;
4040
use PHPUnit\Framework\Attributes\DataProvider;
41-
use PHPUnit\Framework\Attributes\Group;
4241

43-
#[Group('single-thread')]
4442
class BatteryTest extends AbstractInventoryAsset
4543
{
4644
public static function assetProvider(): array

0 commit comments

Comments
 (0)