Skip to content

Commit 047a14a

Browse files
authored
Bugfix/health checks (#616)
* 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
1 parent 87f599b commit 047a14a

File tree

7 files changed

+99
-24
lines changed

7 files changed

+99
-24
lines changed

CMAF/impl/checkCMAFTracks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
$xml = get_DOM($xmlRepresentation, 'atomlist');
2626

2727
if (!$xml) {
28-
fwrite(STDERR, "NO xml in $xmlRepresentation\n");
28+
fwrite(STDERR, "Invalid xml in $xmlRepresentation\n");
2929
return;
3030
}
3131

CTAWAVE/impl/CTACheckPresentation.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,10 @@
176176
$presentationProfile = "";
177177
}
178178

179-
$logger->test(
180-
"CTAWAVE",
181-
"Informative",
182-
"Wave set conformance to CMAF Presentation Profile",
183-
$presentationProfile != "",
184-
"PASS",
185-
"Conformance to $presentationProfile",
186-
"No conformance found"
187-
);
179+
180+
if ($presentationProfile != ""){
181+
182+
}
183+
184+
$logger->message("Stream found to conform to a CMAF Presentation Profile: $presentationProfile");
185+

DASH/processMPD.php

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function process_MPD($parseSegments = false)
5353
## If only MPD validation is requested or inferred, stop
5454
## If any error is found in the MPD validation process, stop
5555
## If no error is found, then proceed with segment validation below
56-
//$valid_mpd = validate_MPD();
56+
// $valid_mpd = validate_MPD();
5757

5858

5959

@@ -64,14 +64,14 @@ function process_MPD($parseSegments = false)
6464
}
6565

6666
if (!$parseSegments) {
67-
fwrite(STDERR,($parseSegments ? "DO " : "DO NOT ") . "parse segments\n");
67+
fwrite(STDERR, ($parseSegments ? "DO " : "DO NOT ") . "parse segments\n");
6868
return;
6969
}
7070

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

109109
global $modules;
110110

111+
global $logger;
111112

112113
$adaptation_sets = $period['AdaptationSet'];
113114
while ($current_adaptation_set < sizeof($adaptation_sets)) {
115+
if ($logger->getModuleVerdict("HEALTH") == "FAIL") {
116+
break;
117+
}
114118
$adaptation_set = $adaptation_sets[$current_adaptation_set];
115119
$representations = $adaptation_set['Representation'];
116120

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

119123

120124
while ($current_representation < sizeof($representations)) {
125+
if ($logger->getModuleVerdict("HEALTH") == "FAIL") {
126+
break;
127+
}
121128
$representation = $representations[$current_representation];
122129
$segment_url = $segment_urls[$current_adaptation_set][$current_representation];
123130

@@ -131,7 +138,12 @@ function processAdaptationSetOfCurrentPeriod($period, $ResultXML, $segment_urls)
131138
}
132139
}
133140

141+
$logger->setModule("HEALTH");
134142
validate_segment($adaptationDirectory, $representationDirectory, $period, $adaptation_set, $representation, $segment_url, $is_subtitle_rep);
143+
$logger->write();
144+
if ($logger->getModuleVerdict("HEALTH") == "FAIL") {
145+
break;
146+
}
135147

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

142154
$current_representation++;
143155
}
156+
if ($logger->getModuleVerdict("HEALTH") == "FAIL") {
157+
break;
158+
}
144159

145160
## Representations in current Adaptation Set finished
146161
crossRepresentationProcess();
@@ -155,10 +170,12 @@ function processAdaptationSetOfCurrentPeriod($period, $ResultXML, $segment_urls)
155170
$current_adaptation_set++;
156171
}
157172

173+
if ($logger->getModuleVerdict("HEALTH") != "FAIL") {
158174
## Adaptation Sets in current Period finished
159-
foreach ($modules as $module) {
160-
if ($module->isEnabled()) {
161-
$module->hookAdaptationSet();
175+
foreach ($modules as $module) {
176+
if ($module->isEnabled()) {
177+
$module->hookAdaptationSet();
178+
}
162179
}
163180
}
164181
//err_file_op(2);

Utils/Process_cli.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
include __DIR__ . '/sessionHandler.php';
2929
require __DIR__ . '/moduleInterface.php';
3030
include __DIR__ . '/moduleLogger.php';
31-
include __DIR__ . '/MPDHandler.php';
3231

3332
include __DIR__ . '/Session.php'; //#Session Functions, No Direct Executable Code
3433
//#Document loading functions, mostly xml. Some assertion options and error initialization

Utils/moduleLogger.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ public function setModule($moduleName)
6969
$this->currentHook = '';
7070
}
7171

72+
public function getModuleVerdict($moduleName){
73+
if (!array_key_exists($moduleName, $this->entries)) {
74+
return "PASS";
75+
}
76+
return $this->entries[$moduleName]['verdict'];
77+
}
78+
7279
public function setHook($hookName)
7380
{
7481
$this->currentHook = $hookName;
@@ -243,7 +250,7 @@ public function hasFeature($feature)
243250
return false;
244251
}
245252

246-
private function write()
253+
public function write()
247254
{
248255
$this->entries['Stats']['LastWritten'] = date("Y-m-d h:i:s");
249256
file_put_contents($this->logfile, \json_encode($this->asArray()));

Utils/segment_validation.php

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,10 @@ function analyze_results($returncode, $curr_adapt_dir, $representationDirectory)
175175
function run_backend($configFile, $representationDirectory = "")
176176
{
177177
global $session;
178+
global $logger;
178179

179180
$sessionDirectory = $session->getDir();
180181

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

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

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

197-
if ($representationDirectory != "") {
198-
rename("$sessionDirectory/atominfo.xml", "$representationDirectory/atomInfo.xml");
196+
197+
$t = time();
198+
exec($command, $output, $returncode);
199+
$et = time();
200+
201+
$moveAtom = true;
202+
203+
$moveAtom &= $logger->test(
204+
"Health Checks",
205+
"Segment Validation",
206+
"ISOSegmentValidator runs successful",
207+
$returncode == 0,
208+
"FAIL",
209+
"Ran succesful on $configFile; took ". ($et - $t) . "seconds",
210+
"Issues with $configFile; Returncode $returncode; took " . ($et - $t) . " seconds"
211+
);
212+
213+
$moveAtom &= $logger->test(
214+
"Health Checks",
215+
"Segment Validation",
216+
"AtomInfo written",
217+
file_exists("$sessionDirectory/atominfo.xml"),
218+
"FAIL",
219+
"Atominfo for $representationDirectory exists",
220+
"Atominfo for $representationDirectory missing"
221+
);
222+
223+
$xml = get_DOM("$sessionDirectory/atominfo.xml", 'atomlist');
224+
$moveAtom &= $logger->test(
225+
"Health Checks",
226+
"Segment Validation",
227+
"AtomInfo contains valid xml",
228+
$xml !== false,
229+
"FAIL",
230+
"Atominfo for $representationDirectory has valid xml",
231+
"Atominfo for $representationDirectory has invalid xml"
232+
);
233+
234+
$moveAtom &= $logger->test(
235+
"Health Checks",
236+
"Segment Validation",
237+
"AtomInfo < 100Mb",
238+
filesize("$sessionDirectory/atominfo.xml") < (100 * 1024 * 1024),
239+
"FAIL",
240+
"Atominfo for $representationDirectory < 100Mb",
241+
"Atominfo for $representationDirectory is ". filesize("$sessionDirectory/atominfo.xml")
242+
);
243+
244+
245+
if (!$moveAtom){
246+
fwrite(STDERR, "Ignoring atomfile for $representationDirectory\n");
247+
unlink("$sessionDirectory/atominfo.xml");
248+
}else{
249+
fwrite(STDERR, "Using atomfile for $representationDirectory\n");
250+
if ($representationDirectory != "") {
251+
rename("$sessionDirectory/atominfo.xml", "$representationDirectory/atomInfo.xml");
252+
}
199253
}
200254

201255
return $returncode;

validation-tests/cta/validationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function streamProvider()
116116
"https://dash.akamaized.net/WAVE/vectors/avc_sets/15_30_60/t3/2022-01-17/stream.mpd"
117117
];
118118
$content = file_get_contents(
119-
"validations-tests/cta/wave.json");
119+
"validation-tests/cta/wave.json");
120120
$dbJson = json_decode($content);
121121
$streamsToTest = array();
122122
foreach ($dbJson as $item) {

0 commit comments

Comments
 (0)