CI migration/automation + new test to ease iTop release management

- new Jenkinsfile and .jenkins removal to launch phpunit/behat tests
triggered on both iTop build and push.
 - N°3053 - Check XML conversion methods
 - N°3057 - New build recipe
 - N°3059 - Automatically set the documentation URLs
 - N°3052 - Check community modules XML version against latest version
 - N°3054 - Check community modules version against major version
 - N°3062 - setup.css file integrity test
 - N°3060 - Check consistency between the list of modules and installation.xml
 - Add exclusion group for CI
 - N°3061 - Automatically check the installation.xml consistency
This commit is contained in:
odain
2020-07-13 10:53:15 +02:00
parent 07bd6b8539
commit 8902d6e532
34 changed files with 890 additions and 945 deletions

View File

@@ -20,47 +20,47 @@ class StatusTest extends ItopTestCase {
*
*/
public function testStatusWrongUrl() {
$sPath = APPROOT . 'status_wrong.php';
$sPath = __DIR__ . '/status_wrong.php';
exec("php $sPath", $aOutput, $iRet);
$this->assertNotEquals(0, $iRet, "Problem executing status page: $sPath, $iRet, aOutput:\n" . var_export($aOutput, true));
$this->assertNotEquals(0, $iRet, "Problem executing status page: $sPath, $iRet");
}
/**
*
*/
public function testStatusGood() {
$sPath = APPROOT . 'status.php';
$sPath = __DIR__ . '/status.php';
exec("php $sPath", $aOutput, $iRet);
$this->assertEquals(0, $iRet, "Problem executing status page: $sPath, $iRet");
$this->assertEquals(0, $iRet, "Problem executing status page: $sPath, $iRet, aOutput:\n" . var_export($aOutput, true));
}
/**
*
*/
public function testStatusGoodWithJson() {
$sPath = APPROOT . 'status.php';
$sPath = __DIR__ . '/status.php';
exec("php $sPath", $aOutput, $iRet);
$sAdditionnalInfo = "aOutput:\n" . var_export($aOutput, true);
//Check response
$this->assertNotEmpty($aOutput[0], 'Empty response');
$this->assertJson($aOutput[0], 'Not a JSON');
$this->assertNotEmpty($aOutput[0], 'Empty response. ' . $sAdditionnalInfo);
$this->assertJson($aOutput[0], 'Not a JSON. ' . $sAdditionnalInfo);
$aResponseDecoded = json_decode($aOutput[0], true);
//Check status
$this->assertArrayHasKey('status', $aResponseDecoded, 'JSON does not have a status\' field');
$this->assertEquals('RUNNING', $aResponseDecoded['status'], 'Status is not \'RUNNING\'');
$this->assertArrayHasKey('status', $aResponseDecoded, 'JSON does not have a status\' field. ' . $sAdditionnalInfo);
$this->assertEquals('RUNNING', $aResponseDecoded['status'], 'Status is not \'RUNNING\'. ' . $sAdditionnalInfo);
//Check code
$this->assertArrayHasKey('code', $aResponseDecoded, 'JSON does not have a code\' field');
$this->assertEquals(0, $aResponseDecoded['code'], 'Code is not 0');
$this->assertArrayHasKey('code', $aResponseDecoded, 'JSON does not have a code\' field. ' . $sAdditionnalInfo);
$this->assertEquals(0, $aResponseDecoded['code'], 'Code is not 0. ' . $sAdditionnalInfo);
//Check message
$this->assertArrayHasKey('message', $aResponseDecoded, 'JSON does not have a message\' field');
$this->assertEmpty($aResponseDecoded['message'], 'Message is not empty');
$this->assertArrayHasKey('message', $aResponseDecoded, 'JSON does not have a message\' field. ' . $sAdditionnalInfo);
$this->assertEmpty($aResponseDecoded['message'], 'Message is not empty. ' . $sAdditionnalInfo);
}
}

25
test/status/status.php Normal file
View File

@@ -0,0 +1,25 @@
<?php
//Include status functions
require_once(__DIR__.'/../../sources/application/status/status.inc.php');
//Do check Status
try
{
\Combodo\iTop\Application\Status\StatusStartup();
$aResult = array('status' => STATUS_RUNNING, 'code' => \RestResult::OK, 'message' => '');
}
catch (\Exception $e)
{
$iCode = (defined('\RestResult::INTERNAL_ERROR')) ? \RestResult::INTERNAL_ERROR : 100;
$aResult = array('status' => STATUS_ERROR, 'code' => $iCode, 'message' => $e->getMessage());
http_response_code(500);
}
//Set headers, based on webservices/rest.php
$sContentType = 'application/json';
header('Content-type: ' . $sContentType);
header('Access-Control-Allow-Origin: *');
//Output result
$sResponse = json_encode($aResult);
echo $sResponse;