Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Flaky" attribute for tests that are flaky in various environments #8237

Closed
4 tasks done
analogrelay opened this issue Mar 6, 2019 · 11 comments
Closed
4 tasks done
Labels
area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework

Comments

@analogrelay
Copy link
Contributor

analogrelay commented Mar 6, 2019

Tracking work:

public static class HelixQueues
{
    // Must be const because they are used in attributes!
    public const string All = "All";
    public const string Debian8 = "...";
    // ...
}

public sealed class FlakyAttribute
{
    // Required for code inspection analytics (verifying that the issue remains open, etc.)
    public string GitHubIssueLink { get; }

    // Specific helix queues on which this test is deemed "flaky"
    // If not specified or 'all', implies all queues
    // If 'none', implies that test runs on all queues
    // Otherwise, this is a semi-colon-delimited list of queues
    public string OnHelixQueues { get; set; } = "all";

    // Indicates if this test is flaky in AzDO
    public bool OnAzDO { get; set; } = true;

    public FlakyAttribute(string gitHubIssueLink) { ... }
}

Usage examples:

  • [Flaky("...")] - This test is always flaky
  • [Flaky("...", OnHelixQueues = "none")] - This test is flaky on AzDO but never on Helix
  • [Flaky("...", OnAzDO = false)] - This test is flaky on Helix but never on AzDO
  • [Flaky("...", OnHelixQueues = "Debian8.whatchamajigger...;Ubuntu.CromulantCrux...")] - This test is flaky on AzDO and specific Helix queues but never on the other Helix queues
  • [Flaky("...", OnHelixQueues = "Debian8.whatchamajigger...;Ubuntu.CromulantCrux...", OnAzDO = false)] - This test is only on specific helix queues and never flaky on the other queues and AzDO

The idea being that the attribute defines the environments in which the test is flaky and the tooling for those builds will sequester the test as necessary.

Discussions are open on making sure these properties are clear and understandable :). My goal was to say that by default Flaky indicates the entire test is flaky in all environments and then the other attributes can be used to "loosen" the requirements.

The implementation is still somewhat TBD (I'll be playing with this today) but the idea is this:

  • The properties of the attribute determine if the flaky xunit trait will be applied
  • The build script will run two passes for each project:
    • One excluding the flaky trait
    • One including the flaky trait which will ignore the exit code, but still record the results.

This all depends on the infrastructure supporting what I want to do here, but I think we can get away with not having a separate AspNetCore-flaky-ci run :).

I think this can live in https://github.com/aspnet/Extensions/tree/master/src/TestingUtils/Microsoft.AspNetCore.Testing and be accessible to everyone.. or we can use a shared-source file like we do with SkipOnHelixAttribute today.

@Eilon @muratg @mkArtakMSFT @ajcvickers @HaoK @ryanbrandenburg @dougbu (maybe we need an aspnet/engineering GitHub team ;))

@Eilon Eilon added the area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework label Mar 6, 2019
@analogrelay
Copy link
Contributor Author

@analogrelay
Copy link
Contributor Author

One thing to think about is how this attribute affects dev builds. My feeling is that it has no effect and we still run flaky tests on dev builds. That's the easiest pattern right now, but I'm open to discussion :).

@Eilon
Copy link
Member

Eilon commented Mar 6, 2019

Hmm I suppose we could try that, but why bother?

@ryanbrandenburg
Copy link
Contributor

AzDO seems about as likely to have queue-specific flakiness as Helix, may as well allow it to be list the queue's it hates too.

@analogrelay
Copy link
Contributor Author

Can do!

@analogrelay
Copy link
Contributor Author

analogrelay commented Mar 6, 2019

Hmm I suppose we could try that, but why bother?

Mostly because of how the traits work. By default, VS doesn't apply any trait filters, nor does dotnet test (with no additional filters). The only place we could reliably add flaky test filtering for local dev builds is in build.cmd -test and if they decide to run dotnet test --filter "Flaky:Local=true" or something like that.

@Eilon
Copy link
Member

Eilon commented Mar 6, 2019

Ah OK

@analogrelay
Copy link
Contributor Author

Plus the goal here is clean CI builds. Right now, I'm not too worried if engineers who are running tests in the projects containing flakiness see flakiness :). It's likely their responsibility anyway 😈.

analogrelay added a commit to dotnet/extensions that referenced this issue Mar 6, 2019
@HaoK
Copy link
Member

HaoK commented Mar 6, 2019

Maybe this is getting too far ahead, but it seems like we also need some kind of automated good behavior/parole for falsely accused 'innocent' tests that might be jailed for things unrelated to them, i.e. will we be able to easily do something like parole any tests that haven't failed in a week/month? Seems important to have a reasonably lax parole system if its 1 strike and its off to flake island...

@analogrelay
Copy link
Contributor Author

Yeah, that's the kind of analysis we can do by scraping the TRX/xUnit reports from the flaky test runs. That's one major reason I want to keep running and reporting them :).

@Eilon
Copy link
Member

Eilon commented Mar 21, 2019

This is done.

@Eilon Eilon closed this as completed Mar 21, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework
Projects
None yet
Development

No branches or pull requests

4 participants