Skip to content

Commit

Permalink
Bugfix/health checks (#616)
Browse files Browse the repository at this point in the history
* Add timeouts and some basic "HEALTH" checks on segment validator.

* Improvement for issue #614

* Less ambiguous message for issue #612

* Fix typo in validation test script for CTA WAVE

* Removed MPD handler as it is not part of this bugfix release

* Use global logger where needed
  • Loading branch information
Phencys authored Nov 30, 2022
1 parent 87f599b commit 047a14a
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 24 deletions.
2 changes: 1 addition & 1 deletion CMAF/impl/checkCMAFTracks.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
$xml = get_DOM($xmlRepresentation, 'atomlist');

if (!$xml) {
fwrite(STDERR, "NO xml in $xmlRepresentation\n");
fwrite(STDERR, "Invalid xml in $xmlRepresentation\n");
return;
}

Expand Down
16 changes: 7 additions & 9 deletions CTAWAVE/impl/CTACheckPresentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,10 @@
$presentationProfile = "";
}

$logger->test(
"CTAWAVE",
"Informative",
"Wave set conformance to CMAF Presentation Profile",
$presentationProfile != "",
"PASS",
"Conformance to $presentationProfile",
"No conformance found"
);

if ($presentationProfile != ""){

}

$logger->message("Stream found to conform to a CMAF Presentation Profile: $presentationProfile");

29 changes: 23 additions & 6 deletions DASH/processMPD.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function process_MPD($parseSegments = false)
## If only MPD validation is requested or inferred, stop
## If any error is found in the MPD validation process, stop
## If no error is found, then proceed with segment validation below
//$valid_mpd = validate_MPD();
// $valid_mpd = validate_MPD();



Expand All @@ -64,14 +64,14 @@ function process_MPD($parseSegments = false)
}

if (!$parseSegments) {
fwrite(STDERR,($parseSegments ? "DO " : "DO NOT ") . "parse segments\n");
fwrite(STDERR, ($parseSegments ? "DO " : "DO NOT ") . "parse segments\n");
return;
}

//------------------------------------------------------------------------//
## Perform Segment Validation for each representation in each adaptation set within the current period
if (!checkBeforeSegmentValidation()) {
return;
return;
}
if ($mpd_features['type'] !== 'dynamic') {
$current_period = 0;
Expand Down Expand Up @@ -108,16 +108,23 @@ function processAdaptationSetOfCurrentPeriod($period, $ResultXML, $segment_urls)

global $modules;

global $logger;

$adaptation_sets = $period['AdaptationSet'];
while ($current_adaptation_set < sizeof($adaptation_sets)) {
if ($logger->getModuleVerdict("HEALTH") == "FAIL") {
break;
}
$adaptation_set = $adaptation_sets[$current_adaptation_set];
$representations = $adaptation_set['Representation'];

$adaptationDirectory = $session->getAdaptationDir($current_period, $current_adaptation_set);


while ($current_representation < sizeof($representations)) {
if ($logger->getModuleVerdict("HEALTH") == "FAIL") {
break;
}
$representation = $representations[$current_representation];
$segment_url = $segment_urls[$current_adaptation_set][$current_representation];

Expand All @@ -131,7 +138,12 @@ function processAdaptationSetOfCurrentPeriod($period, $ResultXML, $segment_urls)
}
}

$logger->setModule("HEALTH");
validate_segment($adaptationDirectory, $representationDirectory, $period, $adaptation_set, $representation, $segment_url, $is_subtitle_rep);
$logger->write();
if ($logger->getModuleVerdict("HEALTH") == "FAIL") {
break;
}

foreach ($modules as $module) {
if ($module->isEnabled()) {
Expand All @@ -141,6 +153,9 @@ function processAdaptationSetOfCurrentPeriod($period, $ResultXML, $segment_urls)

$current_representation++;
}
if ($logger->getModuleVerdict("HEALTH") == "FAIL") {
break;
}

## Representations in current Adaptation Set finished
crossRepresentationProcess();
Expand All @@ -155,10 +170,12 @@ function processAdaptationSetOfCurrentPeriod($period, $ResultXML, $segment_urls)
$current_adaptation_set++;
}

if ($logger->getModuleVerdict("HEALTH") != "FAIL") {
## Adaptation Sets in current Period finished
foreach ($modules as $module) {
if ($module->isEnabled()) {
$module->hookAdaptationSet();
foreach ($modules as $module) {
if ($module->isEnabled()) {
$module->hookAdaptationSet();
}
}
}
//err_file_op(2);
Expand Down
1 change: 0 additions & 1 deletion Utils/Process_cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
include __DIR__ . '/sessionHandler.php';
require __DIR__ . '/moduleInterface.php';
include __DIR__ . '/moduleLogger.php';
include __DIR__ . '/MPDHandler.php';

include __DIR__ . '/Session.php'; //#Session Functions, No Direct Executable Code
//#Document loading functions, mostly xml. Some assertion options and error initialization
Expand Down
9 changes: 8 additions & 1 deletion Utils/moduleLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ public function setModule($moduleName)
$this->currentHook = '';
}

public function getModuleVerdict($moduleName){
if (!array_key_exists($moduleName, $this->entries)) {
return "PASS";
}
return $this->entries[$moduleName]['verdict'];
}

public function setHook($hookName)
{
$this->currentHook = $hookName;
Expand Down Expand Up @@ -243,7 +250,7 @@ public function hasFeature($feature)
return false;
}

private function write()
public function write()
{
$this->entries['Stats']['LastWritten'] = date("Y-m-d h:i:s");
file_put_contents($this->logfile, \json_encode($this->asArray()));
Expand Down
64 changes: 59 additions & 5 deletions Utils/segment_validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ function analyze_results($returncode, $curr_adapt_dir, $representationDirectory)
function run_backend($configFile, $representationDirectory = "")
{
global $session;
global $logger;

$sessionDirectory = $session->getDir();

fwrite(STDERR, "Going to run segment validator with config file $configFile\n");

## Select the executable version
## Copy segment validation tool to session folder
Expand All @@ -188,14 +188,68 @@ function run_backend($configFile, $representationDirectory = "")
chmod("$sessionDirectory/$validatemp4", 0777);

## Execute backend conformance software
$command = "$sessionDirectory/$validatemp4 -logconsole -atomxml -configfile " . $configFile;
$command = "timeout -k 30s 30s $sessionDirectory/$validatemp4 -logconsole -atomxml -configfile " . $configFile;
$output = [];
$returncode = 0;
chdir($sessionDirectory);
exec($command, $output, $returncode);

if ($representationDirectory != "") {
rename("$sessionDirectory/atominfo.xml", "$representationDirectory/atomInfo.xml");

$t = time();
exec($command, $output, $returncode);
$et = time();

$moveAtom = true;

$moveAtom &= $logger->test(
"Health Checks",
"Segment Validation",
"ISOSegmentValidator runs successful",
$returncode == 0,
"FAIL",
"Ran succesful on $configFile; took ". ($et - $t) . "seconds",
"Issues with $configFile; Returncode $returncode; took " . ($et - $t) . " seconds"
);

$moveAtom &= $logger->test(
"Health Checks",
"Segment Validation",
"AtomInfo written",
file_exists("$sessionDirectory/atominfo.xml"),
"FAIL",
"Atominfo for $representationDirectory exists",
"Atominfo for $representationDirectory missing"
);

$xml = get_DOM("$sessionDirectory/atominfo.xml", 'atomlist');
$moveAtom &= $logger->test(
"Health Checks",
"Segment Validation",
"AtomInfo contains valid xml",
$xml !== false,
"FAIL",
"Atominfo for $representationDirectory has valid xml",
"Atominfo for $representationDirectory has invalid xml"
);

$moveAtom &= $logger->test(
"Health Checks",
"Segment Validation",
"AtomInfo < 100Mb",
filesize("$sessionDirectory/atominfo.xml") < (100 * 1024 * 1024),
"FAIL",
"Atominfo for $representationDirectory < 100Mb",
"Atominfo for $representationDirectory is ". filesize("$sessionDirectory/atominfo.xml")
);


if (!$moveAtom){
fwrite(STDERR, "Ignoring atomfile for $representationDirectory\n");
unlink("$sessionDirectory/atominfo.xml");
}else{
fwrite(STDERR, "Using atomfile for $representationDirectory\n");
if ($representationDirectory != "") {
rename("$sessionDirectory/atominfo.xml", "$representationDirectory/atomInfo.xml");
}
}

return $returncode;
Expand Down
2 changes: 1 addition & 1 deletion validation-tests/cta/validationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function streamProvider()
"https://dash.akamaized.net/WAVE/vectors/avc_sets/15_30_60/t3/2022-01-17/stream.mpd"
];
$content = file_get_contents(
"validations-tests/cta/wave.json");
"validation-tests/cta/wave.json");
$dbJson = json_decode($content);
$streamsToTest = array();
foreach ($dbJson as $item) {
Expand Down

0 comments on commit 047a14a

Please sign in to comment.