/** * Test failure at the snapshot step */ public function testSnapshotFailure() { $pipeline = $this->getDummyPipeline(); // Start failure $pipeline->markFailed(); $step = $pipeline->RollbackStep1(); // Assert not error at startup $this->assertEquals('Started', $step->Status); $this->assertEquals('Deployment', $step->Doing); // Mark the service as completed and check result $deployment = $step->RollbackDeployment(); $deployment->markFinished(); // Re-enter step as if called from checkPipelineStatus PipelineTest_MockLog::clear(); $step->start(); $this->assertEquals('Started', $step->Status); $this->assertEquals('Snapshot', $step->Doing); // Mark the snapshot as completed and check result $snapshot = $step->RollbackDatabase(); $snapshot->markFailed(); // Re-enter step as if called from checkPipelineStatus PipelineTest_MockLog::clear(); $step->start(); $this->assertEquals('Failed', $step->Status); }
public function testTimeout() { $step = $this->getDummyDeployment(); $step->start(); // Assert not error at startup $this->assertEquals('Started', $step->Status); $this->assertTrue(PipelineTest_MockLog::has_message('TestDeployStep:Snapshot creating snapshot of database')); // Go to two hours into the future SS_Datetime::set_mock_now(date('Y-m-d H:i:s', strtotime('+2 hours'))); // Retry step PipelineTest_MockLog::clear(); $step->start(); $this->assertEquals('Failed', $step->Status); $this->assertTrue($step->isTimedOut()); $this->assertTrue(PipelineTest_MockLog::has_message('Checking status of TestDeployStep:Snapshot...')); $this->assertTrue(PipelineTest_MockLog::has_message('TestDeployStep:Snapshot took longer than 3600 seconds to run and has timed out')); }
/** * Test the rollback step */ public function testRollback() { $step = $this->getDummyRollback(); // First run, start revert code $step->start(); $this->assertHasLog('RollbackStep:Deployment starting revert deployment'); $this->assertHasLog('[Skipped] Create DNDeployment'); // Second run, finish deployment and start database restoration PipelineTest_MockLog::clear(); $step->start(); $this->assertHasLog('Checking status of RollbackStep:Deployment...'); $this->assertHasLog('[Skipped] Checking progress of deployment'); $this->assertHasLog('RollbackStep:Snapshot reverting database from snapshot'); $this->assertHasLog('[Skipped] Create DNDataTransfer restore'); // Third run, complete snapshot restore PipelineTest_MockLog::clear(); $step->start(); $this->assertHasLog('Checking status of RollbackStep:Snapshot...'); $this->assertHasLog('[Skipped] Checking progress of snapshot restore'); $this->assertHasLog('Step finished successfully!'); }
/** * Reset logs of scaffolded services */ protected function clearLog() { PipelineTest_MockLog::clear(); PipelineTest_RecordingMessageSender::clear(); }