Generate randomness

Antithesis runs your tests in a deterministic simulation, so any random number generator (RNG) you consult will give the same sequence of answers in every test run.

Since we wish to explore many possibilities over the course of each test, Antithesis provides ways for your software – either your test template or your actual software – to request inputs that can be used in place of an RNG to make random decisions.

The most straightforward way to do this is from the system random devices, which we override and replace with our own source of entropy. But the SDKs offer an alternative source that is both more convenient and more structured.

Use of SDK random functions is usually more convenient than opening and reading from system random devices. The SDK also offers higher-level, more “structured” random methods, for example the equivalent of the Python standard library’s random.choice(). These are not provided only for convenience, they also make it easier for Antithesis to learn what sorts of inputs to provide.

Suppose you have a randomized test template that runs one of three tests, a(), b(), and c(). Suppose that test c() is ineffective, and rarely or never provokes interesting behavior in your system. If you use an SDK random function to decide which test to run, then over time Antithesis will learn that inputs which result in c() running are less fruitful, and will not provide them as often. But it is much easier to learn this if you tell Antithesis that you are making a choice between three options, as opposed to requesting a 64-bit number and computing its value modulo 3.

A corollary of this is that you should never take inputs returned by SDK random functions and use them to seed your own RNG, or store them to make a decision later. Either one of these anti-patterns makes it harder for Antithesis to learn to control your software, and defeats the purpose of using the SDK.

  • Introduction
  • How Antithesis works
  • Using Antithesis documentation with AI
  • Get started
  • Test an example system
  • With Docker Compose
  • Build and run an etcd cluster
  • Meet the Test Composer
  • With Kubernetes
  • Build and run an etcd cluster
  • Meet the Test Composer
  • Setup guide
  • For Docker Compose users
  • For Kubernetes users
  • Product
  • Test Composer
  • Test Composer basics
  • Test Composer commands
  • How to check test templates locally
  • How to port tests to Antithesis
  • Test launchers
  • Reports
  • The triage reports
  • Findings
  • Environment
  • Utilization
  • Properties
  • The bug reports
  • Context, Instance, & Logs
  • Bug likelihood over time
  • Logs Explorer & multiverse map
  • Multiverse debugging
  • Overview
  • The Antithesis multiverse
  • Querying with event sets
  • Environment utilities
  • Using the Antithesis Notebook
  • Cookbook
  • Tooling integrations
  • CI integration
  • Discord and Slack integrations
  • Issue tracker integration - BETA
  • Configuration
  • Access and authentication
  • The Antithesis environment
  • Optimizing for testing
  • Docker best practices
  • Kubernetes best practices
  • Concepts
  • Properties and Assertions
  • Properties in Antithesis
  • Assertions in Antithesis
  • Sometimes Assertions
  • Properties to test for
  • Fault injection
  • Reference
  • Webhooks
  • Launching a test
  • Launching a debugging session
  • Webhook parameters
  • SDK reference
  • Define test properties
  • Generate randomness
  • Manage test lifecycle
  • Assertion catalog
  • Coverage instrumentation
  • Go
  • Instrumentor
  • Tutorial
  • Assert (reference)
  • Lifecycle (reference)
  • Random (reference)
  • Java
  • Using the SDK
  • Building your software
  • Tutorial
  • Assert (reference)
  • Lifecycle (reference)
  • Random (reference)
  • C
  • C++
  • C/C++ Instrumentation
  • Tutorial
  • Assert (reference)
  • Lifecycle (reference)
  • Random (reference)
  • JavaScript
  • Python
  • Tutorial
  • Assert (reference)
  • Lifecycle (reference)
  • Random (reference)
  • Rust
  • Instrumentation
  • Tutorial
  • Assert (reference)
  • Lifecycle (reference)
  • Random (reference)
  • .NET
  • Instrumentation
  • Tutorial
  • Assert (reference)
  • Lifecycle (reference)
  • Random (reference)
  • Languages not listed above
  • Assert (reference)
  • Lifecycle (reference)
  • Assertion Schema
  • Handling external dependencies
  • FAQ
  • Product FAQs
  • About Antithesis POCs
  • Release notes
  • Release notes
  • General reliability resources
  • Reliability glossary
  • Techniques for better software testing
  • Autonomous testing
  • Deterministic simulation testing
  • Property-based testing
  • White paper — How much does an outage cost?
  • Catalog of reliability properties for key-value datastores
  • Catalog of reliability properties for blockchains
  • Test ACID compliance with a ring test