Skip to content

Commit

Permalink
[IT-2471] Simplified result validation, removed deprecated code
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Burnicki committed Nov 13, 2018
1 parent d214db3 commit a517543
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 37 deletions.
Expand Up @@ -84,19 +84,18 @@ class JobResultPersisterService {
if (wptStatus.isFailed()) {
return JobResultStatus.FAILED
} else if (wptStatus.isSuccess() && resultXml.hasRuns()) {
int numValidResults = 0
int numExpectedResults = 1
JobResult jobResult = JobResult.findByJobAndTestId(job, testId)
if (jobResult) {
numValidResults = resultXml.countValidResults(jobResult.jobConfigRuns, jobResult.expectedSteps, jobResult.firstViewOnly)
numExpectedResults = jobResult.jobConfigRuns * jobResult.expectedSteps * (jobResult.firstViewOnly ? 1 : 2)
if (!jobResult) {
log.error("There is no job result for finished job id ${job.id} and test id ${testId}!")
return JobResultStatus.FAILED
}
int numValidResults = resultXml.countValidResults(jobResult.jobConfigRuns, jobResult.expectedSteps, jobResult.firstViewOnly)
int numExpectedResults = jobResult.jobConfigRuns * jobResult.expectedSteps * (jobResult.firstViewOnly ? 1 : 2)
if (numValidResults < 1) {
return JobResultStatus.FAILED
}
return numValidResults < numExpectedResults ? JobResultStatus.INCOMPLETE : JobResultStatus.SUCCESS
}
// TODO(sbr): Check for timeout
if (wptStatus == WptStatus.IN_PROGRESS) {
return JobResultStatus.RUNNING
}
Expand Down
Expand Up @@ -139,22 +139,15 @@ class ResultPersisterService implements iResultListener {

void persistResultsForAllTeststeps(WptResultXml resultXml, long jobId) {
Integer testStepCount = resultXml.getTestStepCount()

log.debug("starting persistance of ${testStepCount} event results for test steps")
//TODO: possible to catch non median results at this position and check if they should persist or not

for (int zeroBasedTeststepIndex = 0; zeroBasedTeststepIndex < testStepCount; zeroBasedTeststepIndex++) {
if (resultXml.getStepNode(zeroBasedTeststepIndex)) {
try {
if (!persistResultsOfOneTeststep(zeroBasedTeststepIndex, resultXml, jobId)) {
break
}
} catch (Exception e) {
log.error("an error occurred while persisting EventResults of testId ${resultXml.getTestId()} of teststep ${zeroBasedTeststepIndex}", e)
try {
if (!persistResultsOfOneTeststep(zeroBasedTeststepIndex, resultXml, jobId)) {
break
}

} else {
log.error("there is no testStep ${zeroBasedTeststepIndex + 1} for testId ${resultXml.getTestId()}")
} catch (Exception e) {
log.error("an error occurred while persisting EventResults of testId ${resultXml.getTestId()} of teststep ${zeroBasedTeststepIndex}", e)
}
}
}
Expand All @@ -173,10 +166,12 @@ class ResultPersisterService implements iResultListener {

log.debug('getting event name from xml result ...')
String measuredEventName = resultXml.getEventName(job, testStepZeroBasedIndex)
log.debug('getting event name from xml result ... DONE')
if (!measuredEventName) {
log.error("there is no testStep ${testStepZeroBasedIndex + 1} for testId ${resultXml.getTestId()}")
return false
}
log.debug("getting MeasuredEvent from eventname '${measuredEventName}' ...")
MeasuredEvent event = getMeasuredEvent(measuredEventName);
log.debug("getting MeasuredEvent from eventname '${measuredEventName}' ... DONE")

log.debug("persisting result for step=${event}")
int runCount = resultXml.getRunCount()
Expand Down Expand Up @@ -324,7 +319,7 @@ class ResultPersisterService implements iResultListener {
try {
result.testDetailsWaterfallURL = result.buildTestDetailsURL(jobRun, waterfallAnchor);
} catch (MalformedURLException mue) {
log.error("Failed to build test's detail url for result: ${result}!")
log.error("Failed to build test's detail url for result: ${result} and jobResult: ${jobRun}!", mue)
} catch (Exception e) {
log.error("An unexpected error occurred while trying to build test's detail url (result=${result})!", e)
}
Expand Down
Expand Up @@ -118,9 +118,9 @@ class WptResultXml {
case WptXmlResultVersion.BEFORE_MULTISTEP:
return job.getEventNameIfUnknown() ?: job.getLabel()
case WptXmlResultVersion.MULTISTEP_FORK_ITERATEC:
return responseNode.data.median.firstView.testStep.getAt(testStepZeroBasedIndex).eventName.toString();
return responseNode.data.median.firstView.testStep.getAt(testStepZeroBasedIndex)?.eventName?.toString()
case WptXmlResultVersion.MULTISTEP:
return responseNode.data.run.getAt(0).firstView.step.getAt(testStepZeroBasedIndex).eventName.toString();
return responseNode.data.run.getAt(0).firstView.step.getAt(testStepZeroBasedIndex)?.eventName?.toString()
default:
throw new IllegalStateException("Version of result xml isn't specified!")

Expand All @@ -131,20 +131,6 @@ class WptResultXml {
return responseNode.data.run
}

//TODO(sbr): Remove
def getStepNode(int stepZeroBasedIndex) {
switch (version) {
case WptXmlResultVersion.BEFORE_MULTISTEP:
return responseNode.data.median?.firstView
case WptXmlResultVersion.MULTISTEP_FORK_ITERATEC:
return responseNode.data.median.firstView.testStep.getAt(stepZeroBasedIndex)
case WptXmlResultVersion.MULTISTEP:
return responseNode.data.run.getAt(0).firstView.step.getAt(stepZeroBasedIndex)?.results
default:
throw new IllegalStateException("Version of result xml isn't specified or result is no multistep result!")
}
}

GPathResult getResultNodeForRunAndView(runZeroBasedIndex, cachedView) {
GPathResult runNode = getRunNodes()[runZeroBasedIndex]
if (cachedView == CachedView.UNCACHED) {
Expand Down

0 comments on commit a517543

Please sign in to comment.