Skip to content

Commit

Permalink
Fix/stderr (#631)
Browse files Browse the repository at this point in the history
* Initial fixes to handle stderr.txt file

* Fix typo

* Add segment validation output to JSON output

* Log a warning for each line of output, as not everything has to be an error.
  • Loading branch information
dsilhavy authored Feb 6, 2023
1 parent 2541940 commit dbf3877
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 6 deletions.
4 changes: 2 additions & 2 deletions CTAWAVE/impl/checkCMFHDBaselineConstraints.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"CMFHD profile",
count(array_unique($presentationProfileArray)) === 1 && array_unique($presentationProfileArray)[0] == "CMFHD",
"FAIL",
"All CMAF Swithcing sets are CMFHD conformant",
"Not all CMAF Swithcing sets are CMFHD conformant"
"All CMAF Switching sets are CMFHD conformant",
"Not all CMAF Switching sets are CMFHD conformant"
);
2 changes: 0 additions & 2 deletions DASH/processMPD.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ function processAdaptationSetOfCurrentPeriod()
}
}


$logger->setModule("HEALTH");
validate_segment(
$adaptationDirectory,
$representationDirectory,
Expand Down
8 changes: 8 additions & 0 deletions Utils/moduleLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ public function setModule($moduleName)
$this->currentHook = '';
}

public function getCurrentModule() {
return $this->currentModule;
}

public function getCurrentHook() {
return $this->currentHook;
}

public function getModuleVerdict($moduleName)
{
if (!array_key_exists($moduleName, $this->entries)) {
Expand Down
71 changes: 69 additions & 2 deletions Utils/segment_validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ function validate_segment(
$file_location[] = 'notexist';
}

// Save content of stderr
saveStdErrOutput($representationDirectory);

return $file_location;
}

Expand Down Expand Up @@ -158,12 +161,13 @@ function analyze_results($returncode, $curr_adapt_dir, $representationDirectory)

$adaptation_set = $mpdHandler->getFeatures()['Period'][$selectedPeriod]['AdaptationSet'][$selectedAdaptation];
$representation = $adaptation_set['Representation'][$selectedRepresentation];
$stdErrPath = $session->getDir()."/stderr.txt";
if (!$hls_manifest) {
$logger->test(
"Segment Validations",
"analyze_results()",
"stderr filled??",
filesize("$representationDirectory/stderr.txt") !== 0,
filesize($stdErrPath) !== 0 && filesize($stdErrPath) !== false,
"FAIL",
"Contents in stderr.txt found",
"Failed to process adaptationset $selectedAdaptation, " .
Expand All @@ -174,7 +178,7 @@ function analyze_results($returncode, $curr_adapt_dir, $representationDirectory)
"Segment Validations",
"analyze_results()",
"stderr filled??",
filesize("$representationDirectory/stderr.txt") !== 0,
filesize($stdErrPath) !== 0 && filesize($stdErrPath) !== false,
"FAIL",
"Contents in stderr.txt found",
"Failed to process HLS $tag_array[0] index $tag_array[1]"
Expand Down Expand Up @@ -208,6 +212,10 @@ function analyze_results($returncode, $curr_adapt_dir, $representationDirectory)

rename($session->getDir() . "/leafinfo.txt", "$representationDirectory/leafInfo.txt");

if (file_exists($stdErrPath)) {
rename($stdErrPath, "$representationDirectory/stderr.txt");
}

if (!$hls_manifest) {
## Check segment duration and start times against MPD times.
loadAndCheckSegmentDuration();
Expand Down Expand Up @@ -245,6 +253,10 @@ function run_backend($configFile, $representationDirectory = "")

$moveAtom = true;

$currentModule = $logger->getCurrentModule();
$currentHook = $logger->getCurrentHook();

$logger->setModule("HEALTH");
$moveAtom &= $logger->test(
"Health Checks",
"Segment Validation",
Expand Down Expand Up @@ -317,6 +329,10 @@ function run_backend($configFile, $representationDirectory = "")
}
}

// Restore module information since health checks are over
$logger->setModule($currentModule);
$logger->setHook($currentHook);

return $returncode;
}

Expand Down Expand Up @@ -515,3 +531,54 @@ function checkSegmentDurationWithMPD($segmentsTime, $PTO, $duration, $representa
);
}
}

function saveStdErrOutput($representationDirectory) {
global $logger;

$currentModule = $logger->getCurrentModule();
$currentHook = $logger->getCurrentHook();
$logger->setModule("SEGMENT_VALIDATION");

$content = file_get_contents("$representationDirectory/stderr.txt");
$contentArray = explode("\n", $content);

if (!$contentArray->length ){
$logger->test(
"Segment Validation",
"Segment Validation",
"std error output",
true,
"PASS",
"Segment validation did not produce any output",
$content
);
} else {
foreach ($contentArray as $i => $msg){
$severity = "PASS";
//Catch both warn and warning
if (stripos($msg, "warn") !== FALSE){
$severity = "WARN";
}
//Catch errors
if (stripos($msg, "error") !== FALSE){
$severity = "FAIL";
}

$logger->test(
"Segment Validation",
"Segment Validation",
"std error output",
$severity == "PASS",
$severity,
$msg,
$msg
);

}
}


// Restore module information since health checks are over
$logger->setModule($currentModule);
$logger->setHook($currentHook);
}

0 comments on commit dbf3877

Please sign in to comment.