|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class SmokeTestPipelineStepTest extends PipelineTest { |
|
|
|
|
|
|
4
|
|
|
|
|
5
|
|
|
protected static $fixture_file = 'PipelineTest.yml'; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Make the dummy deployment step |
|
9
|
|
|
* |
|
10
|
|
|
* @return SmokeTestPipelineStep |
|
11
|
|
|
*/ |
|
12
|
|
View Code Duplication |
public function getDummySmokeTestStep($name) { |
|
|
|
|
|
|
13
|
|
|
// Load data inte step and pipeline |
|
14
|
|
|
$data = $this->getPipelineConfig(); |
|
15
|
|
|
$smokeStep = $this->objFromFixture('SmokeTestPipelineStep', 'testsmoketest'); |
|
16
|
|
|
$pipeline = $smokeStep->Pipeline(); |
|
17
|
|
|
$pipeline->Config = serialize($data); |
|
18
|
|
|
$pipeline->write(); |
|
19
|
|
|
$smokeStep->Config = serialize($pipeline->getConfigSetting('Steps', $name)); |
|
20
|
|
|
$smokeStep->write(); |
|
21
|
|
|
return $smokeStep; |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Test successful smoke test |
|
26
|
|
|
*/ |
|
27
|
|
View Code Duplication |
public function testSmokeTestPass() { |
|
|
|
|
|
|
28
|
|
|
$this->markTestSkipped("Failing sporadically"); |
|
|
|
|
|
|
29
|
|
|
return; |
|
30
|
|
|
|
|
31
|
|
|
$step = $this->getDummySmokeTestStep('SmokeTest'); |
|
|
|
|
|
|
32
|
|
|
$this->assertTrue($step->start()); |
|
33
|
|
|
$this->assertHasLog('Starting smoke test "Videos" to URL http://www.youtube.com/'); |
|
34
|
|
|
$this->assertHasLog('Smoke test "Videos" to URL http://www.youtube.com/ successful'); |
|
35
|
|
|
$this->assertHasLog('Starting smoke test "Home" to URL https://github.com/'); |
|
36
|
|
|
$this->assertHasLog('Smoke test "Home" to URL https://github.com/ successful'); |
|
37
|
|
|
$this->assertEquals('Finished', $step->Status); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Test failed smoke test |
|
42
|
|
|
*/ |
|
43
|
|
View Code Duplication |
public function testSmokeTestFail() { |
|
|
|
|
|
|
44
|
|
|
// the testsmokefaile yml config contains a invalid smoketest url |
|
45
|
|
|
// which is how it fails |
|
46
|
|
|
$step = $this->getDummySmokeTestStep('FailTest'); |
|
47
|
|
|
$this->assertFalse($step->start()); |
|
|
|
|
|
|
48
|
|
|
$this->assertHasLog('Starting smoke test "BrokenPage" to URL http://bob.bob.bob.bob/'); |
|
49
|
|
|
$this->assertHasLog('Curl error: '); |
|
50
|
|
|
$this->assertHasLog('Starting smoke test "Home" to URL https://github.com/'); |
|
51
|
|
|
$this->assertHasLog('Smoke test "Home" to URL https://github.com/ successful'); |
|
52
|
|
|
$this->assertEquals('Failed', $step->Status); |
|
|
|
|
|
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function testReattempts() { |
|
56
|
|
|
// the testsmokefaile yml config contains a invalid smoketest url which is how it fails |
|
57
|
|
|
$step = $this->getDummySmokeTestStep('RepeatTest'); |
|
58
|
|
|
$this->assertFalse($step->start()); |
|
|
|
|
|
|
59
|
|
|
$this->assertHasLog('Starting smoke test "BrokenPage" to URL http://bob.bob.bob.bob/'); |
|
60
|
|
|
$this->assertHasLog('Curl error: '); |
|
61
|
|
|
$this->assertHasLog('Starting smoke test "Home" to URL https://github.com/'); |
|
62
|
|
|
$this->assertHasLog('Smoke test "Home" to URL https://github.com/ successful'); |
|
63
|
|
|
$this->assertHasLog('Request failed, performing reattempt (#1)'); |
|
64
|
|
|
$this->assertHasLog('Request failed, performing reattempt (#2)'); |
|
65
|
|
|
$this->assertHasLog('Failed after 3 attempts'); |
|
66
|
|
|
$this->assertEquals('Failed', $step->Status); |
|
|
|
|
|
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.