{"id":23925,"date":"2016-10-10T05:52:40","date_gmt":"2016-10-10T09:52:40","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/visualstudioalm\/?p=23925"},"modified":"2019-02-14T15:56:14","modified_gmt":"2019-02-14T23:56:14","slug":"tracking-branch-health-and-identifying-flaky-tests-in-rm-driven-test-automation","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/devops\/tracking-branch-health-and-identifying-flaky-tests-in-rm-driven-test-automation\/","title":{"rendered":"Tracking branch health and identifying flaky tests in RM driven test automation"},"content":{"rendered":"<p>In my previous blog post, I had written about how we have a <a href=\"https:\/\/blogs.msdn.microsoft.com\/visualstudioalm\/2016\/03\/23\/using-parallel-environments-and-release-promotion-in-test-automation\/\">single Release Definition for our team which runs all the test environments in parallel<\/a>.&nbsp; Now that Release Management supports branch based filters while listing releases, it is very easy to track the health of a particular branch.&nbsp; Further, with the work the test team has done around making test case history branch and environment aware, it has become significantly easier to pinpoint the checkin which caused a particular test to start failing, and to identify flaky tests.&nbsp; <\/p>\n<h2>Branch filters<\/h2>\n<p>The \u201cReleases\u201d view of our team\u2019s Release Definition (named RM.CDP \u2013 which runs a bunch of test automation per checkin) tells a pretty sordid story regarding the test pass rate (see screenshot below).&nbsp; There are lots of reds, and I have no idea whether we can deploy to prod or not.<\/p>\n<p>However, note the \u201cBranch: All\u201d control in the upper right corner (highlighted) which was added recently.&nbsp; This view lists releases across all branches, and I have highlighted a few of the branches that are being worked on).<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/6\/2019\/05\/image373.png\"><img decoding=\"async\" title=\"image\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2016\/10\/image_thumb344.png\" width=\"820\" height=\"463\"><\/a><\/p>\n<p>I want to check the health of the release branch for the previous sprint i.e. releases\/M106 to see whether we can deploy it to prod or not.&nbsp; I can do this by selecting this value from the dropdown:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/6\/2019\/05\/image374.png\"><img decoding=\"async\" title=\"image\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2016\/10\/image_thumb345.png\" width=\"818\" height=\"540\"><\/a><\/p>\n<p>This branch looks much healthier, with a lot more greens.&nbsp; I dig deeper into the latest build from this branch:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/6\/2019\/05\/image375.png\"><img decoding=\"async\" title=\"image\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2016\/10\/image_thumb346.png\" width=\"805\" height=\"645\"><\/a><\/p>\n<p>I find that the compat tests are broken (i.e. when the version of RM is greater than that of TFS, or less than that of TFS, then we have issues).&nbsp; Once we rationalize\/fix up these compat tests in releases\/M106, we can deploy releases\/M106 to prod.<\/p>\n<p>Thus the branch filter feature can be used to easily find the health of a particular branch.<\/p>\n<h2>Analyzing test failures and identifying flaky tests<\/h2>\n<p>There are usually 3 kinds of test failures that we see in our automation:<\/p>\n<p>(1) A dev checkin caused the test to start failing<\/p>\n<p>(2) There is an infrastructure issue which is causing the test to fail e.g. the machine is out of disk space<\/p>\n<p>(3) The test is flaky<\/p>\n<p>Here, I will walk you through how to identify each of these scenarios using the cool \u201cView History\u201d feature that the Test team added, which is now Branch aware as well as Environment aware.<\/p>\n<h2>How to find which checkin caused a test to start failing?<\/h2>\n<p>Lets look at the health of the features\/rmmaster branch (which is our team\u2019s working branch), and dig into the latest release by double-clicking on it.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/6\/2019\/05\/image376.png\"><img decoding=\"async\" title=\"image\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2016\/10\/image_thumb347.png\" width=\"772\" height=\"384\"><\/a><\/p>\n<p>I focus on the TfsOnPrem environment to start with (which runs the tests on an on-prem TFS installation), and notice that 96.55% of the tests passed.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/6\/2019\/05\/image391.png\"><img decoding=\"async\" title=\"image\" style=\"border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2016\/10\/image_thumb360.png\" width=\"776\" height=\"512\"><\/a><\/p>\n<p>I click on this number (96.55%) to see which tests failed.&nbsp; I note that there is one failing test.&nbsp; Check out the \u201cView History\u201d link on the right.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/6\/2019\/05\/image378.png\"><img decoding=\"async\" title=\"image\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2016\/10\/image_thumb349.png\" width=\"716\" height=\"463\"><\/a><\/p>\n<p>I now click on the \u201cView History\u201d button to see when it began failing.&nbsp; In this view, I first filter by Environment, then by my branch of interest (features\/rmmaster).&nbsp; Finally, I click on the first red bar in the TfsOnPrem environment to see when it began failing.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/6\/2019\/05\/image379.png\"><img decoding=\"async\" title=\"image\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2016\/10\/image_thumb350.png\" width=\"746\" height=\"317\"><\/a><\/p>\n<p>This gives me the build that caused the problem.&nbsp; <\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/6\/2019\/05\/image380.png\"><img decoding=\"async\" title=\"image\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2016\/10\/image_thumb351.png\" width=\"752\" height=\"419\"><\/a><\/p>\n<p>If I click on the build, I can see the commit that caused the failure.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/6\/2019\/05\/image390.png\"><img decoding=\"async\" title=\"image\" style=\"border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2016\/10\/image_thumb359.png\" width=\"756\" height=\"575\"><\/a><\/p>\n<h2>Is it an infrastructure issue?<\/h2>\n<p>If the commit seems unrelated, then you need to check if there is an infra issue.&nbsp; If the test began failing across multiple branches at the same time, then it is likely an infra issue (assuming that the same checkin isn\u2019t made into multiple branches simultaneously).<\/p>\n<p>In the above example, it turned out that the test actually began failing across other branches (features\/rmmaster and releases\/M106) at around the same time:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/6\/2019\/05\/image383.png\"><img decoding=\"async\" title=\"image\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2016\/10\/image_thumb354.png\" width=\"812\" height=\"388\"><\/a><\/p>\n<p>It was indeed an infrastructure issue (where the PAT token for the External TFS server had expired, and therefore all tests that were trying to access this TFS server were failing).&nbsp; This test in fact caused the tests in the releases\/M106 branch to also go red after we deployed M106 to prod.<\/p>\n<h2>Is it a flaky test?<\/h2>\n<p>If the test has reds and green interspersed for the same branch, and same environment, then it is likely a flaky test:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/6\/2019\/05\/image382.png\"><img decoding=\"async\" title=\"image\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2016\/10\/image_thumb353.png\" width=\"774\" height=\"388\"><\/a><\/p>\n<h2>Conclusion<\/h2>\n<p>Hopefully this blog has helped explain how we use Release Management\u2019s branch-awareness features to keep our working branch healthy (or at least as healthy as we can <img decoding=\"async\" class=\"wlEmoticon wlEmoticon-smile\" style=\"border-top-style: none;border-left-style: none;border-bottom-style: none;border-right-style: none\" alt=\"Smile\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2016\/10\/wlEmoticon-smile1.png\">).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my previous blog post, I had written about how we have a single Release Definition for our team which runs all the test environments in parallel.&nbsp; Now that Release Management supports branch based filters while listing releases, it is very easy to track the health of a particular branch.&nbsp; Further, with the work the [&hellip;]<\/p>\n","protected":false},"author":123,"featured_media":45953,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[253,226,1,252],"tags":[],"class_list":["post-23925","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-devops-server","category-ci","category-devops","category-testing"],"acf":[],"blog_post_summary":"<p>In my previous blog post, I had written about how we have a single Release Definition for our team which runs all the test environments in parallel.&nbsp; Now that Release Management supports branch based filters while listing releases, it is very easy to track the health of a particular branch.&nbsp; Further, with the work the [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/23925","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/users\/123"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/comments?post=23925"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/23925\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media\/45953"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media?parent=23925"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/categories?post=23925"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/tags?post=23925"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}