fix(core): 코어 업데이트 격리 디렉토리 잔존·root 소유권·완료 안내문 수정
7.0.9 → 7.0.10 sudo 업데이트 실측 후 점검에서 드러난 3건.
- 정리 단계가 소스 경로(core_{ts}/extracted/{루트}) 안쪽만 지워 껍데기가
업데이트마다 남던 것을 격리 디렉토리 루트째 삭제로 바꾼다. 부모는 구버전
클래스로 돌아 다음 업데이트부터 효력이 있으므로, 신버전 코드로 도는 두 자식
(execute-upgrade-steps / execute-bundled-updates)이 파일이 없는 core_* 만
골라 치운다 — 구버전 부모에서 올라오는 업데이트도 껍데기 없이 끝난다.
- 항목별 소유권 스냅샷이 격리 디렉토리 생성 뒤에 찍혀 root 가 만든 추출본을
원본으로 기록하고 복원이 다시 root 로 되돌리던 것을, 이번 실행의 격리
디렉토리를 스냅샷에서 제외해 닫는다.
- 완료 안내문이 성공 경로에서는 동작하지 않는 hotfix:rollback-stale-files 를
가리키던 것을 --prune 재실행 안내만 남기도록 정정한다(ko/en/ja).
부수: ExecuteUpgradeStepsStandaloneTest 가 앞선 core:update 실행이 남긴
프로세스 env 플래그에 따라 결과가 갈리던 순서 의존을 setUp/tearDown 에서 제거.
This commit is contained in:
1 parent
24f9df9de4
commit
033d2e6d9b
15 files changed
+527
-14
No files matched your search
@@ -30,10 +30,23 @@ class ExecuteUpgradeStepsStandaloneTest extends TestCase
|
||||
{
|
||||
private array $createdPaths = [];
|
||||
|
||||
/**
|
||||
* 테스트 진입 전의 spawn 플래그 상태 (없으면 false) — tearDown 에서 되돌린다.
|
||||
*/
|
||||
private string|false $originalSpawnFlag = false;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
// 이 클래스의 절반은 "spawn 플래그가 없는 단독 실행" 을 전제한다. 그런데 같은 프로세스에서
|
||||
// 앞서 돈 테스트가 `core:update`(CoreUpdateCommand::handle) 를 한 번이라도 거치면 그 플래그가
|
||||
// 프로세스 env 에 남아 여기 도착한다 — 부모 커맨드는 "프로세스 종료와 함께 소멸" 을 전제로
|
||||
// 정리하지 않기 때문이다. 실행 순서에 따라 결과가 갈리지 않도록 진입 시 비우고 종료 시 되돌린다.
|
||||
$this->originalSpawnFlag = getenv('G7_UPDATE_IN_PROGRESS');
|
||||
putenv('G7_UPDATE_IN_PROGRESS');
|
||||
unset($_ENV['G7_UPDATE_IN_PROGRESS'], $_SERVER['G7_UPDATE_IN_PROGRESS']);
|
||||
|
||||
// 빈 upgrade step 디렉토리 보장 — 본 테스트는 step 자체가 아닌 사전/사후 단계만 검증.
|
||||
// 임시 dummy step 파일을 작성해 from < to 비교가 ">=" 조건을 통과하도록 한다.
|
||||
$this->writeNoopStep('0.9.1', 'standalone_noop');
|
||||
@@ -50,6 +63,15 @@ class ExecuteUpgradeStepsStandaloneTest extends TestCase
|
||||
|
||||
Mockery::close();
|
||||
|
||||
if ($this->originalSpawnFlag === false) {
|
||||
putenv('G7_UPDATE_IN_PROGRESS');
|
||||
unset($_ENV['G7_UPDATE_IN_PROGRESS'], $_SERVER['G7_UPDATE_IN_PROGRESS']);
|
||||
} else {
|
||||
putenv('G7_UPDATE_IN_PROGRESS='.$this->originalSpawnFlag);
|
||||
$_ENV['G7_UPDATE_IN_PROGRESS'] = $this->originalSpawnFlag;
|
||||
$_SERVER['G7_UPDATE_IN_PROGRESS'] = $this->originalSpawnFlag;
|
||||
}
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
@@ -183,6 +205,34 @@ class ExecuteUpgradeStepsStandaloneTest extends TestCase
|
||||
$this->assertSame(0, $exitCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 부모(구버전 코드)의 정리 단계가 남긴 빈 격리 디렉토리(`core_{ts}/extracted` 껍데기)는
|
||||
* 신버전 코드로 도는 이 자식이 치운다. spawn 자식 모드에서도, 단독 실행에서도 호출된다 —
|
||||
* 구버전 부모에서 올라오는 업데이트(7.0.9→7.0.10)를 덮는 유일한 자리이기 때문이다.
|
||||
*
|
||||
* @effects ExecuteUpgradeStepsCommand_sweeps_empty_staging_directories_left_by_parent
|
||||
*/
|
||||
public function test_스텝_완료_후_빈_격리_디렉토리를_청소한다(): void
|
||||
{
|
||||
[$service, $module, $plugin, $template, $langPack] = $this->bindMocks();
|
||||
|
||||
$service->shouldReceive('runUpgradeSteps')->once();
|
||||
$service->shouldReceive('sweepEmptyStagingDirectories')->once()->andReturn(1);
|
||||
|
||||
putenv('G7_UPDATE_IN_PROGRESS=1');
|
||||
$_ENV['G7_UPDATE_IN_PROGRESS'] = '1';
|
||||
$_SERVER['G7_UPDATE_IN_PROGRESS'] = '1';
|
||||
|
||||
try {
|
||||
$exitCode = $this->runCommand([]);
|
||||
} finally {
|
||||
putenv('G7_UPDATE_IN_PROGRESS');
|
||||
unset($_ENV['G7_UPDATE_IN_PROGRESS'], $_SERVER['G7_UPDATE_IN_PROGRESS']);
|
||||
}
|
||||
|
||||
$this->assertSame(0, $exitCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 자식이 이전 버전 config 캐시로 부팅했으면(구버전 부모는 spawn 전에 캐시를 비우지 않는다)
|
||||
* `config('app.update.restore_ownership_group_writable')` 은 옛 목록이다. 이때는 디스크의
|
||||
@@ -404,6 +454,9 @@ class ExecuteUpgradeStepsStandaloneTest extends TestCase
|
||||
// 종료부의 root 산출물 소유권 정상화(#615 도입)는 모든 경로에서 호출되며 본 테스트의 관심사가
|
||||
// 아니다 — 기본 허용으로 두어 각 케이스가 자기 단계만 단언하게 한다.
|
||||
$service->shouldReceive('normalizeRuntimeOwnershipAfterRootRun')->andReturnNull()->byDefault();
|
||||
// 종료부의 빈 격리 디렉토리 청소(7.0.10 도입)도 모든 경로에서 호출된다 — 전용 케이스가
|
||||
// once() 로 단언하고, 나머지 케이스는 기본 허용.
|
||||
$service->shouldReceive('sweepEmptyStagingDirectories')->andReturn(0)->byDefault();
|
||||
$module = Mockery::mock(ModuleManager::class);
|
||||
$plugin = Mockery::mock(PluginManager::class);
|
||||
$template = Mockery::mock(TemplateManager::class);
|
||||
|
||||
@@ -85,4 +85,36 @@ class ExecuteBundledUpdatesCommandTest extends TestCase
|
||||
$this->assertStringContainsString('"success":0', $output);
|
||||
$this->assertStringContainsString('"failed":0', $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* 이 자식은 부모의 정리 단계가 끝난 **뒤에** 돈다. 구버전 부모(7.0.0~7.0.9)의 정리는
|
||||
* 소스 경로 안쪽만 지워 `core_{ts}/extracted` 껍데기를 남기므로, 그 껍데기를 여기서
|
||||
* 치워야 구버전에서 올라오는 업데이트도 잔존물 없이 끝난다. 파일이 있는 격리
|
||||
* 디렉토리는 건드리지 않는다.
|
||||
*
|
||||
* @effects execute_bundled_updates_child_sweeps_empty_staging_directories_left_by_parent
|
||||
*/
|
||||
public function test_빈_매니페스트_처리_후_부모가_남긴_빈_격리_디렉토리를_치운다(): void
|
||||
{
|
||||
$base = storage_path('framework/testing/bundled-sweep-'.uniqid());
|
||||
File::ensureDirectoryExists($base.DIRECTORY_SEPARATOR.'core_20260906_095309'.DIRECTORY_SEPARATOR.'extracted');
|
||||
$live = $base.DIRECTORY_SEPARATOR.'core_20260906_120000'.DIRECTORY_SEPARATOR.'extracted';
|
||||
File::ensureDirectoryExists($live);
|
||||
File::put($live.DIRECTORY_SEPARATOR.'composer.json', '{}');
|
||||
config(['app.update.pending_path' => $base]);
|
||||
|
||||
$path = storage_path('app/test_bundled_manifest_'.uniqid().'.json');
|
||||
File::put($path, json_encode(['modules' => [], 'plugins' => [], 'templates' => [], 'lang_packs' => []]));
|
||||
$this->tempFiles[] = $path;
|
||||
|
||||
try {
|
||||
$exit = Artisan::call('core:execute-bundled-updates', ['--manifest' => $path]);
|
||||
|
||||
$this->assertSame(0, $exit);
|
||||
$this->assertDirectoryDoesNotExist($base.DIRECTORY_SEPARATOR.'core_20260906_095309', '빈 껍데기는 치운다');
|
||||
$this->assertFileExists($live.DIRECTORY_SEPARATOR.'composer.json', '파일이 있는 격리 디렉토리는 남긴다');
|
||||
} finally {
|
||||
File::deleteDirectory($base);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user