Skip to content

Commit 9e3d6fd

Browse files
committed
Add regression test for local_archive parallel deploy race
Refs #4232
1 parent d5fdaac commit 9e3d6fd

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

tests/spec/LocalArchiveTest.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace Deployer;
4+
5+
use spec\SpecTest;
6+
use Symfony\Component\Console\Output\Output;
7+
8+
class LocalArchiveTest extends SpecTest
9+
{
10+
public const RECIPE = __DIR__ . '/recipe/local_archive.php';
11+
12+
public static function setUpBeforeClass(): void
13+
{
14+
parent::setUpBeforeClass();
15+
putenv('DEPLOYER_LOCAL_WORKER=false');
16+
}
17+
18+
public static function tearDownAfterClass(): void
19+
{
20+
putenv('DEPLOYER_LOCAL_WORKER=true');
21+
parent::tearDownAfterClass();
22+
}
23+
24+
public function testParallelLocalArchiveDeploy()
25+
{
26+
$this->init(self::RECIPE);
27+
$this->tester->run([
28+
'deploy',
29+
'selector' => 'all',
30+
'-f' => self::RECIPE,
31+
], [
32+
'verbosity' => Output::VERBOSITY_VERBOSE,
33+
]);
34+
35+
$display = $this->tester->getDisplay();
36+
self::assertEquals(0, $this->tester->getStatusCode(), $display);
37+
38+
foreach ($this->deployer->hosts as $host) {
39+
$deployPath = $host->get('deploy_path');
40+
self::assertFileExists($deployPath . '/current/README.md', $display);
41+
}
42+
43+
$gitRoot = trim((string) shell_exec('git rev-parse --show-toplevel'));
44+
self::assertFileDoesNotExist($gitRoot . '/archive.tar');
45+
}
46+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Deployer;
4+
5+
require 'recipe/common.php';
6+
7+
set('update_code_strategy', 'local_archive');
8+
set('deploy_path', sys_get_temp_dir() . '/deployer/{{hostname}}');
9+
set('sub_directory', 'tests/fixtures/repository');
10+
set('keep_releases', 1);
11+
12+
localhost('alpha');
13+
localhost('beta');
14+
localhost('gamma');

0 commit comments

Comments
 (0)