Skip to the content.

RCA: Test Points, Test Results and Timestamps

Over the last month or so we have been receiving a lot of customer tickets related to mismatch in test point counts in Progress Report, or the test result timestamp being in the future(!) or the test result chart showing incorrect data etc.

Here are some developer community tickets related to this issue,
Difference between Test Plan Outcome and Progress Report outcome
TestPoint Analytics Data showing incorrect ChangedDateSK
Test Point API is returning incorrect completion test date

Before we delve into what caused this issue and how we fixed it, let’s spend some time in understanding the issue and what scenarios users saw broken.

Root Cause

This problem was caused by a seemingly innocuous change that was made for the automated test results scenario. Unfortunately, the code path was also used for Manual tests and that broke our scenario.

The bug in automated scenario was that the test results’ duration was being set to 0 even though the client was passing the duration value when updating the test result data. The fix was simple, use the duration value to compute the results’ CompletedDate. Here’s the snippet of code that fixed this issue:

if (context.IsFeatureEnabled(DurationPriorityWhenPresent) && 
      resultModel.DurationInMs > 0)
{
    resultUpdateRequest.TestCaseResult.DateCompleted =
      resultUpdateRequest.TestCaseResult.DateStarted.AddTimeSpan(
        TimeSpan.FromMilliseconds(resultModel.DurationInMs));
}

Now, due to unknown historical reasons (a.k.a legacy code), Manual Testing scenario had a weird logic when it came to computing the duration of the test result. Manual testing always used the startDate and completedDate fields separately and both these fields would be sent from the client side code.

The duration field on the other hand was being multiplied by 10,000 on the client side and sent to server. I’m assuming whoever did this wanted to convert the value from milliseconds to ticks maybe. And when the client wanted to render the duration on a web page it would divide the value from server by 10,000 and then treat the resultant value in milliseconds and show it appropriately. Things were all working fine until the above change went in. When the above change went live, this is what happened for manual testing scenario.

The code change mentioned above went live around 14th Jan, 2020 and the fix for the issue went live on 24th Feb, 2020. All manual test runs that were done within this window all had issues with duration timestamps.

Snowball effect

What further amplified and made this problem worse,

Fix

The fix was simple once we knew what the issue was. We added a conditional check in the above code so that it would update the date only if the run was for automated tests.

Mitigation

For Manual test customers who performed a test run between the impact period, we had to go and fix up the timestamp enteries in the TCM and TFS database.

Prevention

We’ve since added tests for this scenario so that in future we can catch this before it can impact customers on production.