Coyote is a library and tool for testing concurrent C# code and deterministically reproducing bugs.
Перейти к файлу
Akash Lal 53a9cbcda9
match assembly simple name before loading (#508)
2024-07-20 05:31:12 -07:00
.config increased version to 1.7.11 (#499) 2024-03-15 21:17:56 -07:00
.github/workflows dropping unsupported netcore 3.1 target and fixing JSON dependency (#507) 2024-07-16 02:01:13 -07:00
Common dropping unsupported netcore 3.1 target and fixing JSON dependency (#507) 2024-07-16 02:01:13 -07:00
Samples update the project to net8.0 (#497) 2024-03-04 12:17:18 -08:00
Scripts dropping unsupported netcore 3.1 target and fixing JSON dependency (#507) 2024-07-16 02:01:13 -07:00
Source match assembly simple name before loading (#508) 2024-07-20 05:31:12 -07:00
Tests dropping unsupported netcore 3.1 target and fixing JSON dependency (#507) 2024-07-16 02:01:13 -07:00
Tools dropping unsupported netcore 3.1 target and fixing JSON dependency (#507) 2024-07-16 02:01:13 -07:00
docs dropping unsupported netcore 3.1 target and fixing JSON dependency (#507) 2024-07-16 02:01:13 -07:00
.gitattributes enable disabled test (#312) 2022-03-17 11:04:32 -07:00
.gitignore assembly analysis pass that diffs IL contents for debugging (#249) 2021-10-31 23:34:42 -07:00
.travis.yml remove deployment step (#31) 2020-05-23 11:53:14 -07:00
CITATION.cff increased version to 1.7.11 (#499) 2024-03-15 21:17:56 -07:00
Coyote.sln support for running xunit systematic tests from cli (#481) 2023-06-05 18:04:17 -07:00
History.md dropping unsupported netcore 3.1 target and fixing JSON dependency (#507) 2024-07-16 02:01:13 -07:00
LICENSE Initial commit 2020-02-28 19:32:20 -08:00
NuGet.config updates to nuget package testing for samples (#322) 2022-03-28 16:32:57 -07:00
README.md update readme (#494) 2024-02-01 09:51:10 -08:00
SECURITY.md updated security readme to latest version 2020-04-03 10:09:25 -07:00
global.json dropping unsupported netcore 3.1 target and fixing JSON dependency (#507) 2024-07-16 02:01:13 -07:00
mkdocs-local.yml fixed actor halting when calling raise event (#483) 2023-06-09 12:54:04 -07:00
mkdocs.yml fixed actor halting when calling raise event (#483) 2023-06-09 12:54:04 -07:00

README.md

Coyote

NuGet Nuget Build and Test CI CodeQL

Coyote is a cross-platform library and tool for testing concurrent C# code and deterministically reproducing bugs.

Using Coyote, you can easily test the concurrency and other nondeterminism in your C# code, by writing what we call a concurrency unit test. These look like your regular unit tests, but can reliably test concurrent workloads (such as actors, tasks, or concurrent requests to ASP.NET controllers). In regular unit tests, you would typically avoid concurrency due to flakiness, but with Coyote you are encouraged to embrace concurrency in your tests to find bugs.

Coyote is used by many teams in Azure to test their distributed systems and services, and has found hundreds of concurrency-related bugs before deploying code in production and affecting users. In the words of an Azure service architect:

Coyote found several issues early in the dev process, this sort of issues that would usually bleed through into production and become very expensive to fix later.

Coyote is made with ❤️ by Microsoft Research.

How it works

Consider the following simple test:

[Fact]
public async Task TestTask()
{
  int value = 0;
  Task task = Task.Run(() =>
  {
    value = 1;
  });

  Assert.Equal(0, value);
  await task;
}

This test will pass most of the time because the assertion will typically execute before the task starts, but there is one schedule where the task starts fast enough to set value to 1 causing the assertion to fail. Of course, this is a very naive example and the bug is obvious, but you could imagine much more complicated race conditions that are hidden in complex execution paths.

The way Coyote works, is that you first convert the above test to a concurrency unit test using the Coyote TestingEngine API:

using Microsoft.Coyote.SystematicTesting;

[Fact]
public async Task CoyoteTestTask()
{
  var configuration = Configuration.Create().WithTestingIterations(10);
  var engine = TestingEngine.Create(configuration, TestTask);
  engine.Run();
}

Next, you run the coyote rewrite command from the CLI (typically as a post-build task) to automatically rewrite the IL of your test and production binaries. This allows Coyote to inject hooks that take control of the concurrent execution during testing.

You can then run the concurrent unit test from your favorite unit testing framework (such as xUnit). Coyote will take over and repeatedly execute the test from beginning to the end for N iterations (in the above example N was configured to 10). Under the hood, Coyote uses intelligent search strategies to explore all kinds of execution paths that might hide a bug in each iteration.

The awesome thing is that once a bug is found, Coyote gives you a trace through the engine.TestReport API that you can use to reliably reproduce the bug as many times as you want, making debugging and fixing the issue significantly easier.

Get started

Getting started with Coyote is easy! First, follow this guide to install the coyote command-line tool from NuGet. You are now ready to check out the Coyote website for tutorials, documentation, how-tos, samples and more information about the project. Enjoy!

Upgrading your coyote dependencies? Check the changelog here.

Support

Note that Coyote is an open-source project that is provided "as-is". We are not able to provide any formal support. For Microsoft employees we have the Friends of Coyote Teams channel, which is an internal community that can help answer questions and learn from each other.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.