<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: LitmusChaos</title>
    <description>The latest articles on DEV Community by LitmusChaos (@litmus-chaos).</description>
    <link>https://dev.to/litmus-chaos</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F3775%2F088d3139-19f0-44be-863d-26f2d731731b.png</url>
      <title>DEV Community: LitmusChaos</title>
      <link>https://dev.to/litmus-chaos</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/litmus-chaos"/>
    <language>en</language>
    <item>
      <title>Making Chaos Conversational: A Beginner-Friendly Guide to the LitmusChaos MCP Server</title>
      <dc:creator>Pritesh Kiri</dc:creator>
      <pubDate>Thu, 20 Nov 2025 19:04:06 +0000</pubDate>
      <link>https://dev.to/litmus-chaos/making-chaos-conversational-a-beginner-friendly-guide-to-the-litmuschaos-mcp-server-2ia</link>
      <guid>https://dev.to/litmus-chaos/making-chaos-conversational-a-beginner-friendly-guide-to-the-litmuschaos-mcp-server-2ia</guid>
      <description>&lt;p&gt;Modern software systems are becoming more distributed, more complex, and more dependent on reliability than ever before. But reliability isn’t something you bolt on at the end, it’s something you test deliberately. That’s exactly where chaos engineering comes in: by intentionally injecting controlled failures, teams can understand how their systems behave under stress and make them more resilient.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://litmuschaos.io/" rel="noopener noreferrer"&gt;LitmusChaos&lt;/a&gt; has been one of the most widely adopted open-source frameworks for cloud-native chaos engineering. But even with its intuitive UI (ChaosCenter), CRDs, and CLI, we know that YAMLs and APIs can still feel intimidating, especially for teams just starting out.&lt;/p&gt;

&lt;p&gt;So, how do we make chaos engineering easier, faster, and more accessible?&lt;/p&gt;

&lt;p&gt;This is where the &lt;a href="https://docs.litmuschaos.io/docs/mcp-server/overview" rel="noopener noreferrer"&gt;LitmusChaos MCP Server&lt;/a&gt; comes in.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is MCP and Why Does It Matter?
&lt;/h2&gt;

&lt;p&gt;MCP (Model Context Protocol) is a new standard that allows AI assistants (like Claude or other LLM-powered tools) to communicate with external systems through structured, well-defined tools.&lt;/p&gt;

&lt;p&gt;Think of MCP as a bridge that lets your AI assistant:&lt;br&gt;
    • List chaos experiments&lt;br&gt;
    • Run experiments&lt;br&gt;
    • Stop them&lt;br&gt;
    • Check statuses&lt;br&gt;
    • Explore infrastructures&lt;br&gt;
    • Build probes&lt;/p&gt;

&lt;p&gt;Using just simple natural language.&lt;/p&gt;

&lt;p&gt;So instead of writing YAML or navigating multiple UI screens, you can simply ask:&lt;/p&gt;

&lt;p&gt;“Run a pod-delete experiment in my staging environment.”&lt;/p&gt;

&lt;p&gt;And the MCP Server will take care of it.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why Did LitmusChaos Build an MCP Server?
&lt;/h2&gt;

&lt;p&gt;Chaos engineering is powerful, but sometimes feels “too technical” or “too risky” for new practitioners. The LitmusChaos MCP Server solves this problem by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Lowering the barrier to chaos. Anyone on your team can run chaos with natural language — no CRDs required.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Improving speed and accessibility. Fast discovery, instant experiment triggers, quick monitoring — all via an AI assistant.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Integrating chaos into existing workflows. Teams already using AI agents can now tie chaos steps directly into operational workflows.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enforcing safe, scoped access. MCP tools only expose specific, controlled actions. Tokens and namespaces ensure safe execution.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Making chaos collaborative. Experiment reviews, run summaries, and probe outputs become conversational and easy to share.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ultimately, this brings chaos engineering closer to everyday development and reliability workflows.&lt;/p&gt;

&lt;p&gt;Check out our LitmusChaos MCP Server YouTube Playlist for a detailed guide.&lt;/p&gt;

&lt;p&gt;

  &lt;iframe src="https://www.youtube.com/embed/-d_5VLr5Hmo"&gt;
  &lt;/iframe&gt;


&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up the LitmusChaos MCP Server
&lt;/h2&gt;

&lt;p&gt;Below is a simple guide to getting the MCP Server running on your cloud desktop or local system.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;p&gt;You will need:&lt;br&gt;
    • Go 1.21 or newer&lt;br&gt;
    • Access to an existing LitmusChaos ChaosCenter&lt;br&gt;
    • A valid project and API token&lt;br&gt;
    • Any MCP-enabled AI client (e.g., Claude Desktop)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Clone the repository
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/litmuschaos/litmus-mcp-server.git
cd litmus-mcp-server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Build the binary
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;make build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Getting Your Credentials&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Chaos Center Endpoint: URL of your LitmusChaos installation&lt;/li&gt;
&lt;li&gt;Project ID: Found in Chaos Center project settings&lt;/li&gt;
&lt;li&gt;Access Token: Generate from Chaos Center → Settings → Access Tokens&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Connecting it with your MCP Client (Using Claude here)
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "mcpServers": {
    "litmuschaos": {
      "command": "/path/to/litmuschaos-mcp-server",
      "env": {
        "CHAOS_CENTER_ENDPOINT": "http://localhost:8080",
        "LITMUS_PROJECT_ID": "your-project-id",
        "LITMUS_ACCESS_TOKEN": "your-token"
      }
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Available Tools
&lt;/h2&gt;

&lt;p&gt;The server provides 17 comprehensive tools for chaos engineering operations:&lt;/p&gt;

&lt;h3&gt;
  
  
  Experiment Management
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;list_chaos_experiments&lt;/code&gt; - List all chaos experiments with filtering&lt;br&gt;
&lt;code&gt;get_chaos_experiment&lt;/code&gt; - Get detailed experiment information&lt;br&gt;
&lt;code&gt;run_chaos_experiment&lt;/code&gt; - Execute experiments immediately&lt;br&gt;
&lt;code&gt;stop_chaos_experiment&lt;/code&gt; - Stop running experiments&lt;/p&gt;

&lt;h3&gt;
  
  
  Execution Monitoring
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;list_experiment_runs&lt;/code&gt; - List experiment execution history&lt;br&gt;
&lt;code&gt;get_experiment_run_details&lt;/code&gt; - Get detailed run information with logs&lt;/p&gt;

&lt;h3&gt;
  
  
  Infrastructure Management
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;list_chaos_infrastructures&lt;/code&gt; - List all registered infrastructures&lt;br&gt;
&lt;code&gt;get_infrastructure_details&lt;/code&gt; - Get detailed infrastructure information&lt;br&gt;
&lt;code&gt;register_chaos_infrastructure&lt;/code&gt; - Register new Kubernetes infrastructures&lt;/p&gt;

&lt;h3&gt;
  
  
  Environment Organization
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;list_environments&lt;/code&gt; - List all environments&lt;br&gt;
&lt;code&gt;create_environment&lt;/code&gt; - Create new environments for the organization&lt;/p&gt;

&lt;h3&gt;
  
  
  Resilience Validation
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;list_resilience_probes&lt;/code&gt; - List all configured resilience probes&lt;br&gt;
&lt;code&gt;create_resilience_probe&lt;/code&gt; - Create HTTP, CMD, K8s, or Prometheus probes&lt;/p&gt;

&lt;h3&gt;
  
  
  Discovery &amp;amp; Analytics
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;list_chaos_hubs&lt;/code&gt; - List available ChaosHubs&lt;br&gt;
&lt;code&gt;get_chaos_faults&lt;/code&gt; - Browse available chaos faults&lt;br&gt;
&lt;code&gt;get_experiment_statistics&lt;/code&gt; - Get comprehensive platform statistics&lt;/p&gt;

&lt;h2&gt;
  
  
  Examples
&lt;/h2&gt;

&lt;p&gt;These are real-world prompts you can use once your MCP server is connected:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;List all experiments
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Show me all chaos experiments available in my staging environment.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Trigger an experiment
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Run the pod-delete-basic experiment and share the run ID.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Check experiment status
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Show me the timeline and probe results of run &amp;lt;RUN_ID&amp;gt;.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Stop running chaos
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Stop the currently running pod delete experiment.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Explore ChaosHub
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;List all Kubernetes pod-level faults from the ChaosHub.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Build a probe
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Create an HTTP probe that checks /health returns 200 within 2 seconds.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Add a new environment
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Create a new environment called chaos-lab.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why use MCP?
&lt;/h2&gt;

&lt;p&gt;As systems become more distributed and reliability becomes more critical, we need chaos engineering tools that integrate into everyday workflows.&lt;/p&gt;

&lt;p&gt;The LitmusChaos MCP Server delivers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ease of use → chaos through natural language&lt;/li&gt;
&lt;li&gt;Faster adoption → no need to learn CRDs or YAML&lt;/li&gt;
&lt;li&gt;Better collaboration → experiments become team-friendly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The LitmusChaos MCP Server is more than just a technical integration, it’s a new way of practicing chaos engineering. Making chaos accessible through natural language removes barriers and encourages teams to adopt reliability as a mindset, not a one-time activity.&lt;/p&gt;

</description>
      <category>testing</category>
      <category>mcp</category>
      <category>devops</category>
      <category>beginners</category>
    </item>
    <item>
      <title>LitmusChaos October Highlights - Hacktoberfest, Meetups &amp; More!</title>
      <dc:creator>Pritesh Kiri</dc:creator>
      <pubDate>Wed, 05 Nov 2025 04:14:40 +0000</pubDate>
      <link>https://dev.to/litmus-chaos/litmuschaos-october-highlights-hacktoberfest-meetups-more-51h6</link>
      <guid>https://dev.to/litmus-chaos/litmuschaos-october-highlights-hacktoberfest-meetups-more-51h6</guid>
      <description>&lt;p&gt;October has been one of the most exciting and eventful months for the &lt;a href="https://litmuschaos.io/" rel="noopener noreferrer"&gt;LitmusChaos&lt;/a&gt; community. With &lt;a href="https://hacktoberfest.com/" rel="noopener noreferrer"&gt;Hacktoberfest&lt;/a&gt; 2025 in full swing, we went all in, from hosting community-driven events to supporting contributors, shipping releases, and celebrating amazing open-source contributions. &lt;/p&gt;

&lt;h2&gt;
  
  
  Hacktoberfest 2025 (The Month of Open Source)
&lt;/h2&gt;

&lt;p&gt;Hacktoberfest has always been special for LitmusChaos, and this year, we made it even bigger. The community came together to contribute to LitmusChaos and Litmus Docs, improving the project’s security, user experience, and accessibility with Litmus 4.0.&lt;/p&gt;

&lt;p&gt;Here’s what we achieved together in October:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/litmuschaos/litmus" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; Stars: 112 new stars&lt;/li&gt;
&lt;li&gt;LitmusChaos Issues: 42 created → 27 closed (PRs merged), 15 in progress&lt;/li&gt;
&lt;li&gt;Litmus Docs Issues: 34 created → 31 closed (PRs merged), 3 in progress&lt;/li&gt;
&lt;li&gt;New Contributors

&lt;ul&gt;
&lt;li&gt;  23 new contributors to LitmusChaos&lt;/li&gt;
&lt;li&gt;  18 new contributors to Litmus Docs&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;These numbers reflect the incredible passion our contributors showed throughout Hacktoberfest. A big shoutout to everyone who helped strengthen LitmusChaos through code, docs, and discussions!&lt;/p&gt;

&lt;h2&gt;
  
  
  Release Spotlight: LitmusChaos MCP Server
&lt;/h2&gt;

&lt;p&gt;One of the biggest highlights of October was the release of the &lt;a href="https://docs.litmuschaos.io/docs/next/mcp-server/overview" rel="noopener noreferrer"&gt;LitmusChaos MCP&lt;/a&gt; (Model Context Protocol) Server, a major step toward making Chaos Engineering more accessible and intelligent.&lt;/p&gt;

&lt;p&gt;The Litmus MCP Server allows users to interact with chaos experiments using natural language, bridging the gap between developers and automation. Imagine simply asking, “Run a pod-delete experiment on the checkout service,” and seeing it happen seamlessly — that’s the power MCP brings to the Litmus ecosystem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adoption Continues to Grow
&lt;/h2&gt;

&lt;p&gt;LitmusChaos continues to see strong adoption within the cloud-native ecosystem.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi9r9fn1pq0yw918e1n1c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi9r9fn1pq0yw918e1n1c.png" alt="LitmusChaos Installion for October month"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;October Installation Trends:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mid-month spike: around 5.2K installations (Oct 6–7)&lt;/li&gt;
&lt;li&gt;End-of-month range: roughly 3.8K–4K installations&lt;/li&gt;
&lt;li&gt;Average daily installations: around 3.5K–4K&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’s heartening to see teams worldwide continue to adopt ChaosCenter to build more resilient systems.&lt;/p&gt;

&lt;h2&gt;
  
  
  New Blog of the Month
&lt;/h2&gt;

&lt;p&gt;We published a new blog this month:&lt;/p&gt;

&lt;p&gt;

&lt;/p&gt;
&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/litmus-chaos/making-chaos-engineering-accessible-introducing-the-litmuschaos-mcp-server-kif" class="crayons-story__hidden-navigation-link"&gt;Making Chaos Engineering Accessible: Introducing the LitmusChaos MCP Server&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;
          &lt;a class="crayons-logo crayons-logo--l" href="/litmus-chaos"&gt;
            &lt;img alt="LitmusChaos logo" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F3775%2F088d3139-19f0-44be-863d-26f2d731731b.png" class="crayons-logo__image"&gt;
          &lt;/a&gt;

          &lt;a href="/priteshkiri" class="crayons-avatar  crayons-avatar--s absolute -right-2 -bottom-2 border-solid border-2 border-base-inverted  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F990356%2F6e2d7880-79bb-4d19-a6e2-15a9b1b42a8b.jpeg" alt="priteshkiri profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/priteshkiri" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Pritesh Kiri
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Pritesh Kiri
                
              
              &lt;div id="story-author-preview-content-2965955" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/priteshkiri" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F990356%2F6e2d7880-79bb-4d19-a6e2-15a9b1b42a8b.jpeg" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Pritesh Kiri&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

            &lt;span&gt;
              &lt;span class="crayons-story__tertiary fw-normal"&gt; for &lt;/span&gt;&lt;a href="/litmus-chaos" class="crayons-story__secondary fw-medium"&gt;LitmusChaos&lt;/a&gt;
            &lt;/span&gt;
          &lt;/div&gt;
          &lt;a href="https://dev.to/litmus-chaos/making-chaos-engineering-accessible-introducing-the-litmuschaos-mcp-server-kif" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Oct 28 '25&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/litmus-chaos/making-chaos-engineering-accessible-introducing-the-litmuschaos-mcp-server-kif" id="article-link-2965955"&gt;
          Making Chaos Engineering Accessible: Introducing the LitmusChaos MCP Server
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/mcp"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;mcp&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/chaosengineering"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;chaosengineering&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/litmus"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;litmus&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/litmuschaos"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;litmuschaos&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/litmus-chaos/making-chaos-engineering-accessible-introducing-the-litmuschaos-mcp-server-kif" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/exploding-head-daceb38d627e6ae9b730f36a1e390fca556a4289d5a41abb2c35068ad3e2c4b5.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/multi-unicorn-b44d6f8c23cdd00964192bedc38af3e82463978aa611b4365bd33a0f1f4f3e97.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;6&lt;span class="hidden s:inline"&gt; reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/litmus-chaos/making-chaos-engineering-accessible-introducing-the-litmuschaos-mcp-server-kif#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              Comments


              &lt;span class="hidden s:inline"&gt;Add Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            3 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;




&lt;p&gt;The post dives into how the Model Context Protocol (MCP) is bringing natural language interfaces to chaos engineering, making it easier than ever to design and execute experiments using LitmusChaos.&lt;/p&gt;

&lt;h2&gt;
  
  
  Growing Our Content &amp;amp; Community Reach
&lt;/h2&gt;

&lt;p&gt;We’ve been consistent in sharing knowledge, updates, and community stories across our platforms.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://www.youtube.com/channel/UCa57PMqmz_j0wnteRa9nCaw" rel="noopener noreferrer"&gt;YouTube&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;13 new videos published:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Community &amp;amp; Contributor Calls&lt;/li&gt;
&lt;li&gt;Getting Started with Litmus” — a 10-part video series&lt;/li&gt;
&lt;li&gt;16 new subscribers joined our channel


  &lt;iframe src="https://www.youtube.com/embed/FSNS5cxqPzc"&gt;
  &lt;/iframe&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://x.com/LitmusChaos" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;+12 new followers and some great engagement on Hacktoberfest updates&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://www.linkedin.com/company/litmuschaos" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;+51 new followers — welcome to all the new faces joining the chaos community!&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://kubernetes.slack.com/?redir=%2Farchives%2FCNXNB0ZTN" rel="noopener noreferrer"&gt;Slack&lt;/a&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;42 new members joined our community Slack &lt;a href="https://kubernetes.slack.com/?redir=%2Farchives%2FCNXNB0ZTN" rel="noopener noreferrer"&gt;Community&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  October Offline Meetups
&lt;/h2&gt;

&lt;p&gt;We hosted two exciting in-person meetups in October to celebrate Hacktoberfest and connect with our amazing contributors!&lt;/p&gt;

&lt;p&gt;📍 LitmusChaos x Hacktoberfest Meetup — Bangalore (Oct 4)&lt;/p&gt;

&lt;p&gt;We kicked off October with a bang at the Harness Bangalore office, where 130+ attendees joined us to celebrate open source and learn about chaos engineering.&lt;/p&gt;

&lt;p&gt;

  &lt;iframe src="https://www.youtube.com/embed/RPXbq4pypns"&gt;
  &lt;/iframe&gt;


&lt;/p&gt;

&lt;p&gt;📍 Hacktoberfest Hyderabad Meetup — in Collaboration with DigitalOcean (Oct 11)&lt;/p&gt;

&lt;p&gt;Next up, we partnered with DigitalOcean for the Hyderabad Hacktoberfest meetup, proudly sponsored by Harness.&lt;/p&gt;

&lt;p&gt;

  &lt;iframe src="https://www.youtube.com/embed/NO_Vfaqnk7E"&gt;
  &lt;/iframe&gt;


&lt;/p&gt;

&lt;h2&gt;
  
  
  Community &amp;amp; Contributor Calls
&lt;/h2&gt;

&lt;p&gt;Our monthly calls were buzzing with energy and participation!&lt;/p&gt;

&lt;h3&gt;
  
  
  Community Call
&lt;/h3&gt;

&lt;p&gt;Topics we discussed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Release of Litmus v3.22.0&lt;/li&gt;
&lt;li&gt;Active Hacktoberfest activities and contributions&lt;/li&gt;
&lt;li&gt;Introduction to Litmus MCP&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;

  &lt;iframe src="https://www.youtube.com/embed/w0LeKaANqKQ"&gt;
  &lt;/iframe&gt;


&lt;/p&gt;

&lt;h3&gt;
  
  
  Contributor Call
&lt;/h3&gt;

&lt;p&gt;Highlights included:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Recap of community contributions during Hacktoberfest&lt;/li&gt;
&lt;li&gt;Open PRs discussion and shoutouts to active contributors&lt;/li&gt;
&lt;li&gt;Contributor best practices and guidelines&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;

  &lt;iframe src="https://www.youtube.com/embed/xwRqo1uXNCQ"&gt;
  &lt;/iframe&gt;


&lt;/p&gt;

&lt;p&gt;These calls continue to be a great space for collaboration, feedback, and celebrating progress together.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;October was nothing short of amazing — full of learning, contribution, and connection.&lt;br&gt;
From new contributors joining the fold to community-driven meetups and continuous adoption growth, LitmusChaos continues to thrive, powered by its community ❤️&lt;/p&gt;

&lt;p&gt;As we move into November, we’re excited to keep the momentum going. More releases, new experiments, and continued community engagement await!&lt;/p&gt;

&lt;p&gt;🔗 Join the conversation on &lt;a href="https://kubernetes.slack.com/?redir=%2Farchives%2FCNXNB0ZTN" rel="noopener noreferrer"&gt;Slack&lt;/a&gt; and follow us on &lt;a href="https://www.linkedin.com/company/litmuschaos" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;, &lt;a href="https://www.youtube.com/channel/UCa57PMqmz_j0wnteRa9nCaw" rel="noopener noreferrer"&gt;YouTube&lt;/a&gt;, and &lt;a href="https://x.com/LitmusChaos" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; for the latest updates.&lt;/p&gt;

</description>
      <category>hacktoberfest</category>
      <category>news</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Making Chaos Engineering Accessible: Introducing the LitmusChaos MCP Server</title>
      <dc:creator>Pritesh Kiri</dc:creator>
      <pubDate>Tue, 28 Oct 2025 03:56:16 +0000</pubDate>
      <link>https://dev.to/litmus-chaos/making-chaos-engineering-accessible-introducing-the-litmuschaos-mcp-server-kif</link>
      <guid>https://dev.to/litmus-chaos/making-chaos-engineering-accessible-introducing-the-litmuschaos-mcp-server-kif</guid>
      <description>&lt;p&gt;Chaos Engineering has always been about one thing: building resilient systems. But let’s be honest, while the idea sounds great, getting started with chaos experiments has never been easy.&lt;/p&gt;

&lt;p&gt;YAMLs, CLI commands, complex setups, and a fear of “what if I break something?” often stop developers and SREs before they even begin. Even with tools like &lt;a href="https://litmuschaos.io/" rel="noopener noreferrer"&gt;LitmusChaos&lt;/a&gt;, which simplify a lot of this, there’s still a learning curve, especially for those new to resilience testing.&lt;/p&gt;

&lt;p&gt;That’s exactly what the &lt;a href="https://github.com/litmuschaos/litmus-mcp-server" rel="noopener noreferrer"&gt;LitmusChaos MCP Server&lt;/a&gt; aims to change.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Challenge with Chaos Engineering
&lt;/h2&gt;

&lt;p&gt;Chaos Engineering helps you intentionally inject failures into your systems to test how they respond.&lt;/p&gt;

&lt;p&gt;But here’s the catch for many teams: it feels too technical, too complex, or too risky.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You need to understand multiple CRDs and YAML definitions.&lt;/li&gt;
&lt;li&gt;You have to set up and manage chaos infrastructures.&lt;/li&gt;
&lt;li&gt;You have to know how to interpret experimental results.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And if you’re a developer or DevOps engineer already juggling deployments, observability, and CI/CD,  adding “run chaos experiments” to that list can feel overwhelming.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where LitmusChaos Fits In
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/litmuschaos/litmus" rel="noopener noreferrer"&gt;LitmusChaos&lt;/a&gt; was built to solve exactly that. To make Chaos Engineering simpler, more organized, and more collaborative.&lt;br&gt;
With &lt;strong&gt;ChaosCenter&lt;/strong&gt;, you get a single pane of glass to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run and manage chaos experiments.&lt;/li&gt;
&lt;li&gt;Track resilience scores.&lt;/li&gt;
&lt;li&gt;Monitor chaos infrastructures (agents).&lt;/li&gt;
&lt;li&gt;Visualize experiment runs and results.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It has helped teams integrate chaos into their CI/CD pipelines and production workflows.&lt;/p&gt;

&lt;p&gt;But… even with all these features, there’s still one big barrier left: You still need to know how to use it.&lt;/p&gt;

&lt;p&gt;Now imagine if you could talk to your system and say:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Run a pod-delete experiment on the payment service in production.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And it just does it.&lt;/p&gt;

&lt;p&gt;That’s exactly what LitmusChaos MCP Server enables. It turns Chaos Engineering into a conversational experience.&lt;/p&gt;

&lt;p&gt;No YAMLs. No CLI. No UI clicks.&lt;/p&gt;

&lt;p&gt;Just natural language.&lt;/p&gt;
&lt;h2&gt;
  
  
  LitmusChaos MCP Server
&lt;/h2&gt;

&lt;p&gt;The LitmusChaos MCP Server is a Go-based Model Context Protocol (MCP) server that connects your AI assistant (like Claude) directly to your ChaosCenter.&lt;br&gt;
It provides a complete interface to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Manage experiments&lt;/li&gt;
&lt;li&gt;Control infrastructures&lt;/li&gt;
&lt;li&gt;Organize environments&lt;/li&gt;
&lt;li&gt;Run and monitor resilience probes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All through natural language interactions.&lt;/p&gt;

&lt;p&gt;In simple words, the MCP Server acts as a bridge between your AI assistant and your Chaos Engineering setup, letting anyone perform chaos operations just by asking.&lt;/p&gt;
&lt;h2&gt;
  
  
  What You Can Do With It?
&lt;/h2&gt;

&lt;p&gt;Here are some examples of what the MCP Server can handle through natural language:&lt;/p&gt;
&lt;h3&gt;
  
  
  1. Experiment Management
&lt;/h3&gt;

&lt;p&gt;“List all chaos experiments.”&lt;br&gt;
“Run the pod-delete experiment on the frontend pods.”&lt;br&gt;
“Stop the network latency experiment.”&lt;br&gt;
You can trigger, stop, or describe chaos experiments instantly.&lt;/p&gt;
&lt;h3&gt;
  
  
  2. Infrastructure Operations
&lt;/h3&gt;

&lt;p&gt;“List all active chaos infrastructures.”&lt;br&gt;
“Show me the status of the production infra.”&lt;br&gt;
You get a complete overview of all connected Litmus agents.&lt;/p&gt;
&lt;h3&gt;
  
  
  3. Environment Organization
&lt;/h3&gt;

&lt;p&gt;“Create a new environment called staging.”&lt;br&gt;
“Show me all experiments in the PROD environment.”&lt;br&gt;
Organize chaos operations by environments for better structure.&lt;/p&gt;
&lt;h3&gt;
  
  
  4. Resilience Probes
&lt;/h3&gt;

&lt;p&gt;“Create an HTTP probe that checks the payment API every 5 seconds.”&lt;br&gt;
“List all existing probes in my project.”&lt;br&gt;
You can validate steady-state conditions or system health with simple requests.&lt;/p&gt;
&lt;h3&gt;
  
  
  5. Analytics &amp;amp; Monitoring
&lt;/h3&gt;

&lt;p&gt;“Show me all failed experiments last week.”&lt;br&gt;
“What’s the resiliency score of my production environment?”&lt;br&gt;
It makes chaos data easy to access and interpret.&lt;/p&gt;
&lt;h2&gt;
  
  
  Getting Started with MCP Server
&lt;/h2&gt;

&lt;p&gt;You can get up and running in just a few minutes.&lt;br&gt;
Quick setup&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Clone and build
git clone https://github.com/litmuschaos/litmus-mcp-server.git
cd litmus-mcp-server
make build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, just add it to your Claude or any other MCP Host, and you’re ready to talk to your ChaosCenter through natural language.&lt;/p&gt;

&lt;p&gt;Follow &lt;a href="https://github.com/litmuschaos/litmus-mcp-server" rel="noopener noreferrer"&gt;this&lt;/a&gt; guide to learn more about setting up the Litmus MCP server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why It Matters
&lt;/h2&gt;

&lt;p&gt;The MCP Server is more than just a new integration; it’s a mindset shift for chaos engineering.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For Developers: No more YAML confusion. Learn chaos the easy way.&lt;/li&gt;
&lt;li&gt;For SREs: Run, monitor, and analyze chaos experiments faster.&lt;/li&gt;
&lt;li&gt;For DevOps Teams: Automate resilience testing with AI-driven workflows.&lt;/li&gt;
&lt;li&gt;For Organizations: Empower every engineer, not just chaos experts, to build resilient systems.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It lowers the barrier of entry so that anyone, regardless of chaos experience, can perform meaningful resilience testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Future of Accessible Chaos Engineering
&lt;/h2&gt;

&lt;p&gt;The LitmusChaos MCP Server marks a big step forward, where Chaos Engineering meets AI-driven accessibility.&lt;/p&gt;

&lt;p&gt;It makes resilience testing approachable, interactive, and intuitive.&lt;br&gt;
The future of chaos isn’t about running YAML files; it’s about asking the right questions, getting answers, and improving system resilience effortlessly.&lt;/p&gt;

&lt;p&gt;So go ahead,  try it out, connect your assistant, and let’s make Chaos Engineering something everyone can do.&lt;/p&gt;

</description>
      <category>mcp</category>
      <category>chaosengineering</category>
      <category>litmus</category>
      <category>litmuschaos</category>
    </item>
    <item>
      <title>LitmusChaos Community Highlights - September 2025 Recap</title>
      <dc:creator>Pritesh Kiri</dc:creator>
      <pubDate>Thu, 23 Oct 2025 11:00:52 +0000</pubDate>
      <link>https://dev.to/litmus-chaos/litmuschaos-community-highlights-september-2025-recap-e0c</link>
      <guid>https://dev.to/litmus-chaos/litmuschaos-community-highlights-september-2025-recap-e0c</guid>
      <description>&lt;p&gt;September was an exciting month for the &lt;a href="https://litmuschaos.io/" rel="noopener noreferrer"&gt;LitmusChaos&lt;/a&gt; community! &lt;/p&gt;

&lt;p&gt;From insightful discussions in our calls to strong GitHub activity and growing engagement on social platforms, the community continued to thrive as we geared up for Litmus 4.0 and Hacktoberfest. Here’s a look at what happened in September.&lt;/p&gt;

&lt;h2&gt;
  
  
  GitHub updates
&lt;/h2&gt;

&lt;p&gt;The community remained active on &lt;a href="https://github.com/litmuschaos/litmus" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; throughout September:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stars gained: 35 ⭐&lt;/li&gt;
&lt;li&gt;Issues: 9 total (6 open, 3 closed)&lt;/li&gt;
&lt;li&gt;Pull Requests: 7 total (4 open, 3 merged)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The activity shows steady engagement from contributors and continued momentum in maintaining and improving LitmusChaos.&lt;/p&gt;

&lt;h2&gt;
  
  
  Litmus Installations
&lt;/h2&gt;

&lt;p&gt;Here is the graph showing our installation chart for September:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1t6u55egtqcvajafmhq2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1t6u55egtqcvajafmhq2.png" alt="graph showing litmuschaos installation chart for September"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mid-month spike&lt;/strong&gt;: Around 1.2K installations&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;End-of-month jump&lt;/strong&gt;: Roughly 3.6K installations on Sep 30&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Average daily installations&lt;/strong&gt;: ~300–350&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This surge indicates growing interest in LitmusChaos as more users start experimenting and running chaos experiments.&lt;/p&gt;

&lt;h2&gt;
  
  
  New Videos &amp;amp; Resources
&lt;/h2&gt;

&lt;p&gt;We released 4 new videos in September to help the community stay informed and get started with LitmusChaos:&lt;/p&gt;

&lt;p&gt;1) “New Look of Litmus” – a fresh tour of Litmus features&lt;/p&gt;

&lt;p&gt;

  &lt;iframe src="https://www.youtube.com/embed/TfqmgtrnYL4"&gt;
  &lt;/iframe&gt;


&lt;/p&gt;

&lt;p&gt;2) Community Call – discussions on releases and upcoming events&lt;/p&gt;

&lt;p&gt;

  &lt;iframe src="https://www.youtube.com/embed/w0LeKaANqKQ"&gt;
  &lt;/iframe&gt;


&lt;/p&gt;

&lt;p&gt;3) “Learn Litmus in 20 Minutes” – a quick-start tutorial &lt;/p&gt;

&lt;p&gt;

  &lt;iframe src="https://www.youtube.com/embed/KIteEoZZmzQ"&gt;
  &lt;/iframe&gt;


&lt;/p&gt;

&lt;p&gt;4) Contributors Call – recap and guidance for contributors&lt;/p&gt;

&lt;p&gt;

  &lt;iframe src="https://www.youtube.com/embed/TOGzGdEDLc8"&gt;
  &lt;/iframe&gt;


&lt;/p&gt;

&lt;h2&gt;
  
  
  Community and Contributor Calls Recap
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Community Call Highlights
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Litmus v3.21.0 release updates&lt;/li&gt;
&lt;li&gt;Upcoming events: Hacktoberfest &amp;amp; meetups&lt;/li&gt;
&lt;li&gt;GitHub activities &amp;amp; contributions&lt;/li&gt;
&lt;li&gt;Sneak peek into Litmus 4.0 and Litmus MCP&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Watch the full video &lt;a href="https://www.youtube.com/watch?v=w0LeKaANqKQ" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Contributors Call Highlights
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Recap of community contributions so far&lt;/li&gt;
&lt;li&gt;Review of open PRs and recent contributions&lt;/li&gt;
&lt;li&gt;Best practices for contributing&lt;/li&gt;
&lt;li&gt;Hacktoberfest introduction and contribution planning&lt;/li&gt;
&lt;li&gt;How to start contributing to LitmusChaos and follow the contributor guidelines&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Watch the full video &lt;a href="https://www.youtube.com/watch?v=TOGzGdEDLc8" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Social &amp;amp; Community Growth
&lt;/h2&gt;

&lt;p&gt;September also saw engagement across our social platforms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;LinkedIn: 20+ new followers&lt;/li&gt;
&lt;li&gt;Slack: 15+ new members&lt;/li&gt;
&lt;li&gt;Twitter: 5+ new followers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We shared the new videos and key discussions across these channels, encouraging more people to join the community and participate in LitmusChaos.&lt;/p&gt;

&lt;h2&gt;
  
  
  Join the Litmus Community
&lt;/h2&gt;

&lt;p&gt;If you’re passionate about open source and want to help improve developer experience, we’d love to have you!&lt;br&gt;
Here’s how you can get involved:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Star the &lt;a href="https://github.com/litmuschaos/litmus" rel="noopener noreferrer"&gt;LitmusChaos GitHub repo&lt;/a&gt; — it really helps!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://kubernetes.slack.com/?redir=%2Farchives%2FCNXNB0ZTN" rel="noopener noreferrer"&gt;Join our Slack community&lt;/a&gt; to chat, ask questions, or collaborate. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Subscribe to our &lt;a href="https://www.youtube.com/channel/UCa57PMqmz_j0wnteRa9nCaw" rel="noopener noreferrer"&gt;YouTube&lt;/a&gt; channel for tutorials, community calls, and updates. Recently released the "&lt;a href="https://www.youtube.com/watch?v=FSNS5cxqPzc&amp;amp;list=PLmM1fgu30seVxW-Oobc7VOfPHbQAzICvS" rel="noopener noreferrer"&gt;Getting Started with LitmusChaos&lt;/a&gt;" Playlist.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What’s next?
&lt;/h2&gt;

&lt;p&gt;October is shaping up to be another exciting month:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hacktoberfest is around the corner. Get ready to contribute!&lt;/li&gt;
&lt;li&gt;More updates from Litmus 4.0 and Litmus MCP&lt;/li&gt;
&lt;li&gt;Continued growth in community engagement and learning resources&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Stay tuned, keep experimenting, and let’s continue building chaos together! ⚡&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>kubernetes</category>
      <category>litmus</category>
      <category>litmuschaos</category>
    </item>
    <item>
      <title>LitmusChaos is Heading to KubeCon + CloudNativeCon Europe 2025 – Join the Chaos!</title>
      <dc:creator>Sayan Mondal</dc:creator>
      <pubDate>Wed, 26 Mar 2025 05:39:15 +0000</pubDate>
      <link>https://dev.to/litmus-chaos/litmuschaos-is-heading-to-kubecon-cloudnativecon-europe-2025-join-the-chaos-g92</link>
      <guid>https://dev.to/litmus-chaos/litmuschaos-is-heading-to-kubecon-cloudnativecon-europe-2025-join-the-chaos-g92</guid>
      <description>&lt;p&gt;&lt;em&gt;March 26, 2025&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Project post by Sayan Mondal, Community Manager, LitmusChaos&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The cloud native community is gearing up for one of the most anticipated events of the year, &lt;a href="https://events.linuxfoundation.org/kubecon-cloudnativecon-europe/" rel="noopener noreferrer"&gt;KubeCon + CloudNativeCon Europe 2025&lt;/a&gt;, happening in the vibrant city of London from April 1 - 4, 2025. And guess what? LitmusChaos is back and thrilled to be part of the action once again!&lt;/p&gt;

&lt;p&gt;No matter if you’ve been doing chaos engineering for a while or you’re just starting to explore the world of reliability, we’re excited to connect with you. We’ve got some fun and insightful talks lined up, hands-on demos at our booth, and lots of conversations waiting to happen. Here’s a sneak peek at what LitmusChaos has planned for KubeCon EU 2025&lt;/p&gt;




&lt;h2&gt;
  
  
  🔥 Chaos Talks You Won’t Want to Miss
&lt;/h2&gt;

&lt;p&gt;We’re excited to be part of the conference schedule with &lt;strong&gt;two impactful sessions&lt;/strong&gt; that dive deep into chaos engineering and reliability practices in cloud native ecosystems.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Lightning Talk:&lt;/strong&gt;
&lt;a href="https://sched.co/1tcw9" rel="noopener noreferrer"&gt;Project Lightning Talk: Chaos Unleashed: LitmusChaos and Its Journey Towards CNCF Graduation - Vedant Shrotria, Maintainer&lt;/a&gt;
🗓 &lt;strong&gt;Tuesday April 1, 2025&lt;/strong&gt;
🕐 &lt;strong&gt;14:22 - 14:27 BST&lt;/strong&gt;
📍 &lt;strong&gt;Platinum Suite | Level 3&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Join us to explore the essence of LitmusChaos and its roadmap to becoming a CNCF Graduated project&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Session Talk:&lt;/strong&gt;
&lt;a href="https://sched.co/1td04" rel="noopener noreferrer"&gt;Driving Chaos Engineering Forward: What’s New and Next With LitmusChaos - Sarthak Jain &amp;amp; Saranya Jena, Harness&lt;/a&gt; 
🗓 &lt;strong&gt;Thursday, April 3, 2025&lt;/strong&gt;
🕐 &lt;strong&gt;16:00 - 16:30 BST&lt;/strong&gt;
📍 &lt;strong&gt;Level 3 | ICC Capital Suite 7-9&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Explore the latest advancements in chaos engineering for cloud-native systems. This session will cover key updates from recent releases, including enhanced resilience testing, observability, and scalability features, while showcasing how they address real-world challenges faced by Developers and SREs.&lt;/p&gt;




&lt;h2&gt;
  
  
  📍 Visit Us at the LitmusChaos Booth
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F86kxa03abls6frtsxgdt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F86kxa03abls6frtsxgdt.png" alt="Litmus Booth" width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Want to get hands-on with chaos engineering? Come meet the maintainers, explore live demos, and learn how LitmusChaos can integrate into your SRE and platform engineering workflows.&lt;/p&gt;

&lt;h4&gt;
  
  
  Booth Details:
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Kiosk Number:&lt;/strong&gt; 10A&lt;br&gt;
&lt;strong&gt;Location:&lt;/strong&gt; Excel London | Level 1 | North Hall | Entrance N8-N9 &lt;br&gt;
&lt;strong&gt;Project Pavilion Hours (BST):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Wednesday, April 2:&lt;/strong&gt; 15:30 – 19:45&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Thursday, April 3:&lt;/strong&gt; 14:00 – 17:00&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Friday, April 4:&lt;/strong&gt; 12:30 – 14:00&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We’ll be showcasing new features, running live chaos experiments, and walking through use cases from real production environments. If you’ve been curious about how chaos fits into GitOps, platform engineering, or if you even need an additional layer in your reliability journey, this is the place to be.&lt;/p&gt;




&lt;h2&gt;
  
  
  🤝 Project Engagement Opportunities
&lt;/h2&gt;

&lt;p&gt;There are multiple ways you can engage with us at KubeCon EU with the latest project engagement opportunities for the community as well as for projects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;☕ Meet us at the Project Pavilion Lounge&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The Project Pavilion Lounge, situated at the heart of the Pavilion, offers projects and attendees a retreat for unwinding and networking in a laid-back environment. Come chat with us at booth 10A, where the chaos engineers will be hanging.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;☕ Let’s Chat at Coffee Stations:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Coffee stations will be conveniently located on both sides of the Pavilion, offering a refreshing array of hot beverages to energize and invigorate attendees throughout the event.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;📍 Ad-Hoc Meeting Tables:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Adjacent to the Project Pavilion, designated tables will be available for projects interested in hosting impromptu on-site meetings. These tables operate on a first-come, first-served basis, providing projects and event attendees the opportunity to convene and collaborate throughout the duration of the week.&lt;/p&gt;

&lt;p&gt;Want to plan a quick sync or deep-dive chat with us during the event? &lt;strong&gt;Drop a note at &lt;a href="mailto:sayan.mondal@harness.io"&gt;sayan.mondal@harness.io&lt;/a&gt;&lt;/strong&gt; and we’ll make sure we catch up at KubeCon EU 2025!&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 Come Along and Learn More About Chaos Engineering
&lt;/h2&gt;

&lt;p&gt;Here’s your opportunity to meet the LitmusChaos team, grab some cool LitmusChaos stickers, and ask questions in person. Whether you’re a Chaos Engineering expert, user, enthusiast, or just getting started, the LitmusChaos community is here to help you get the most out of your reliability journey.&lt;/p&gt;

&lt;p&gt;At our booth, you’ll get guidance on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Getting Started with Chaos Engineering&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Getting Started with LitmusChaos&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Learning more about Chaos Engineering adoption&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Questions on LitmusChaos (blockers, doubts, next steps, choosing the right experiments)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Latest updates and enhancements in LitmusChaos&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;LitmusChaos Roadmap&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Participating in the LitmusChaos community&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Becoming a contributor or a future maintainer&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;🌐 Stay Connected with LitmusChaos&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Whether you're attending KubeCon EU 2025 or following the updates from afar, there are plenty of ways to stay connected and be part of the LitmusChaos community.&lt;/p&gt;

&lt;p&gt;We’re an open, welcoming space for chaos engineering enthusiasts, platform engineers, reliability folks, contributors, or anyone simply curious to learn more about building resilient systems. And we’d love to have you join us!&lt;/p&gt;

&lt;p&gt;Here’s how you can get involved:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;💻 Visit the &lt;a href="https://litmuschaos.io/" rel="noopener noreferrer"&gt; LitmusChaos website&lt;/a&gt; to learn about the project, use cases, architecture, and everything chaos engineering.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;💬 Join the conversation on the &lt;code&gt;#litmus&lt;/code&gt; channel in the Kubernetes Slack, ask questions, share ideas, or just hang out with the community.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🛠 Contribute to the project! Check out our&lt;a href="https://github.com/litmuschaos/litmus/blob/master/CONTRIBUTING.md" rel="noopener noreferrer"&gt; Contributing Guide&lt;/a&gt; and start with an issue, suggestion, or PR — every contribution counts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;📺 Subscribe to the &lt;a href="https://www.youtube.com/@LitmusChaos" rel="noopener noreferrer"&gt; LitmusChaos YouTube Channel&lt;/a&gt; for community meetings, demos, tutorials, and project updates.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🐦 Follow &lt;a href="https://twitter.com/LitmusChaos" rel="noopener noreferrer"&gt;@LitmusChaos on Twitter/X&lt;/a&gt; or &lt;a href="https://www.linkedin.com/company/litmuschaos/" rel="noopener noreferrer"&gt;@litmuschaos on LinkedIn&lt;/a&gt; for the latest news, release updates, and community shoutouts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;✍️ Explore the &lt;a href="https://litmuschaos.io/blog" rel="noopener noreferrer"&gt;LitmusChaos blog&lt;/a&gt; for stories, tutorials, and deep dives. Want to share your own experience with Litmus? Publish a blog on&lt;a href="https://dev.to/"&gt; DEV.to&lt;/a&gt; and tag it with &lt;strong&gt;#litmuschaos&lt;/strong&gt;, we’d love to read it!&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;See you in London!&lt;/p&gt;

</description>
      <category>litmuschaos</category>
      <category>opensource</category>
      <category>cloud</category>
      <category>devops</category>
    </item>
    <item>
      <title>Best Practices for Creating Custom Chaos Experiments</title>
      <dc:creator>Smriti S</dc:creator>
      <pubDate>Tue, 25 Feb 2025 07:26:09 +0000</pubDate>
      <link>https://dev.to/litmus-chaos/best-practices-for-creating-custom-chaos-experiments-4963</link>
      <guid>https://dev.to/litmus-chaos/best-practices-for-creating-custom-chaos-experiments-4963</guid>
      <description>&lt;p&gt;Chaos Engineering is all about &lt;strong&gt;breaking things with a purpose&lt;/strong&gt;- to build &lt;strong&gt;resilient systems&lt;/strong&gt;. Many chaos engineering tools offer &lt;strong&gt;predefined faults&lt;/strong&gt;, but where do you start if you want to build custom chaos experiments to suit your infrastructure? And how do you design chaos experiments that are both &lt;strong&gt;effective and safe&lt;/strong&gt;? Let’s break it down.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Define Clear Objectives
&lt;/h2&gt;

&lt;p&gt;Answer this question: &lt;strong&gt;What are you testing?&lt;/strong&gt;&lt;br&gt;
Chaos experiments should have a &lt;strong&gt;specific goal&lt;/strong&gt;. Before creating a custom experiment, ask:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What failure scenario are we simulating?&lt;/strong&gt; (CPU spikes, network latency, disk failures, etc.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What is the expected behavior of the system?&lt;/strong&gt; (Auto-recovery, failover, degraded performance)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What metrics define success or failure?&lt;/strong&gt; (Response time, error rate, downtime)
For example: "I want to test how my application’s microservices handle sudden node failures and verify if traffic automatically shifts to healthy nodes."&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  2. Choose the Right Disruption
&lt;/h2&gt;

&lt;p&gt;Answer this question: &lt;strong&gt;For your application/system, what faults are relevant? What resources should be disrupted?&lt;/strong&gt;&lt;br&gt;
All faults have different consequences (or blast radius). It is recommended to start with low-risk faults (such as network latency, CPU/memory spike, pod restarts) before moving towards destructive tests (such as node failures, killing database instances, packet loss in critical services).&lt;br&gt;
Start executing chaos experiments in a staging environment, analyze results, and gradually increase the chaos impact to different environments (QA, pre-production, production).&lt;/p&gt;
&lt;h2&gt;
  
  
  3. Ensure RBAC Is in Place
&lt;/h2&gt;

&lt;p&gt;Chaos experiments are disruptive if not controlled. Use RBAC policies to prevent unauthorized users from running high-risk experiments. This way, only authorized users/engineers will have the permissions to execute chaos experiments.&lt;br&gt;
The manifest below describes the rules for a user (“chaos-engineer”) who can perform the operations (create, get, and list) on specified resources.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Role&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;rbac.authorization.k8s.io/v1&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;chaos-engineer&lt;/span&gt;
&lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;apiGroups&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;litmuschaos.io"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
    &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;chaosengines"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;chaosexperiments"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
    &lt;span class="na"&gt;verbs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;create"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;get"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;list"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Monitor System Behavior
&lt;/h2&gt;

&lt;p&gt;When a chaos experiment is defined, it is important to audit what goes on when the experiment is in execution. Set up monitoring/observability tools to monitor CPU, memory, and response time, as well as detect unusual errors. This way, you can answer some of the questions such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Did auto-scaling trigger correctly?&lt;/li&gt;
&lt;li&gt;Did users experience downtime?&lt;/li&gt;
&lt;li&gt;Were ale
rts sent to engineers?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. Recovery Plan in-place
&lt;/h2&gt;

&lt;p&gt;Sometimes, chaos experiments may not go as expected, and may disrupt to a higher extent than expected. To address such cases, rollback and recovery should be set up.&lt;br&gt;
For example, Kubernetes self-healing, restarting pods after executing the experiment, and so on.&lt;br&gt;
The manifest below uses Kyverno to auto-restart pods after chaos so that the affected pods don’t persist and affect other resources.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;kyverno.io/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ClusterPolicy&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;restart-failed-pods&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;validationFailureAction&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Enforce&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;restart-on-failure&lt;/span&gt;
      &lt;span class="na"&gt;match&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;kinds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Pod"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;mutate&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;patchStrategicMerge&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;restartPolicy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Always&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Define clear objectives&lt;/strong&gt; → Know what failure you’re testing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Start small, then scale&lt;/strong&gt; → Begin with low-risk chaos.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use RBAC and monitoring&lt;/strong&gt; → Keep experiments safe&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Monitor system behavior&lt;/strong&gt; → Audit what goes on when the experiment runs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Always have a recovery plan&lt;/strong&gt; → Have rollback/recovery plans in case something doesn’t go as expected.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Want to create custom experiments but don’t know where to start? Join the &lt;a href="https://slack.litmuschaos.io/" rel="noopener noreferrer"&gt;Litmus Slack channel&lt;/a&gt;, check out the &lt;a href="https://github.com/litmuschaos/litmus-docs" rel="noopener noreferrer"&gt;official documentation&lt;/a&gt; and &lt;a href="https://dev.to/t/litmuschaos"&gt;blogs&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>litmus</category>
      <category>litmuschaos</category>
      <category>chaosengineering</category>
    </item>
    <item>
      <title>The Hidden Risks of Relying Solely on Testing: Why Chaos Engineering is Essential</title>
      <dc:creator>Smriti S</dc:creator>
      <pubDate>Thu, 06 Feb 2025 04:46:35 +0000</pubDate>
      <link>https://dev.to/litmus-chaos/the-hidden-risks-of-relying-solely-on-testing-why-chaos-engineering-is-essential-57</link>
      <guid>https://dev.to/litmus-chaos/the-hidden-risks-of-relying-solely-on-testing-why-chaos-engineering-is-essential-57</guid>
      <description>&lt;p&gt;This blog explores the challenges organizations face when relying solely on testing to validate deployments, highlights how chaos engineering can bridge these gaps, and showcases various adopters of chaos engineering practices along with their use cases.&lt;/p&gt;

&lt;p&gt;Organizations are rolling out changes almost everyday with the help of CI/CD. You can perform automated, manual, unit and integration tests to validate features before deployment. But what if your system encounters unexpected failures? &lt;/p&gt;

&lt;p&gt;What if there are network disruptions, application crashes or resource exhaustions that would impact the application resulting in downtime or cascading failures? &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjveynuhqt0ryy544rsc6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjveynuhqt0ryy544rsc6.jpg" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These unforeseen failures can’t be addressed using testing because traditional testing methodologies aren’t designed to simulate such complex, real-world conditions.&lt;br&gt;
This is where &lt;strong&gt;chaos engineering&lt;/strong&gt; comes into play. &lt;/p&gt;

&lt;p&gt;You can address the gaps mentioned earlier by incorporating chaos engineering experimentation in your application to build resilient and reliable systems.&lt;/p&gt;

&lt;p&gt;Described below are some organizations (by sector) that leverage chaos engineering to enhance their cloud-native applications and operations:&lt;/p&gt;

&lt;h3&gt;
  
  
  Technology &amp;amp; E-Commerce: The Challenges and Solutions
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. Flipkart: Handling High-Traffic Events Without Downtime&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Challenge:&lt;/strong&gt; During peak shopping events, Flipkart experienced traffic spikes that led to performance degradation and downtime. Traditional load testing failed to capture the full complexity of real-world failures like network congestion and database latency.&lt;br&gt;
&lt;strong&gt;Impact:&lt;/strong&gt; Shoppers faced checkout failures, slow page loads, and abandoned carts, affecting revenue and customer satisfaction.&lt;br&gt;
&lt;strong&gt;Solution:&lt;/strong&gt; Flipkart integrated chaos engineering to simulate failures in production-like environments, testing how microservices and databases handled stress conditions. This approach helped them optimize auto-scaling strategies and build robust failover mechanisms, ensuring seamless shopping experiences.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Delivery Hero: Ensuring Reliability in Food Delivery Services&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Challenge:&lt;/strong&gt; Delivery Hero operates a high-demand food delivery service, where real-time order processing and delivery tracking are critical. Network failures and API downtime led to order failures and frustrated customers.&lt;br&gt;
&lt;strong&gt;Impact:&lt;/strong&gt; Customers faced delays or lost orders, affecting restaurant partnerships and overall brand trust.&lt;br&gt;
&lt;strong&gt;Solution:&lt;/strong&gt; Using chaos engineering, Delivery Hero injected failures into their APIs, databases, and network connections to identify weak points. By proactively fixing these, they improved system redundancy, reduced downtime, and ensured smooth operations even during peak hours.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Talend: Improving Data Pipeline Resiliency&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Challenge:&lt;/strong&gt; Talend, a data integration company, processes massive datasets across multiple cloud environments. Issues like database failures or unexpected API rate limits disrupted data workflows, affecting analytics and reporting.&lt;br&gt;
&lt;strong&gt;Impact:&lt;/strong&gt; Businesses relying on Talend’s data pipelines faced inconsistencies in analytics, leading to misinformed decisions.&lt;br&gt;
&lt;strong&gt;Solution:&lt;/strong&gt; Talend used chaos engineering to introduce controlled disruptions in their ETL (Extract, Transform, Load) processes. This approach helped them refine retry logic, optimize failover configurations, and ensure consistent data processing even under failure conditions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Kitopi: Enhancing Reliability in Cloud Kitchens&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Challenge:&lt;/strong&gt; Kitopi, a cloud kitchen platform, depends on efficient order routing and delivery logistics. Unforeseen infrastructure failures, like database slowdowns or application crashes, led to delayed or missed orders.&lt;br&gt;
&lt;strong&gt;Impact:&lt;/strong&gt; Customers experienced long wait times, and restaurant partners faced reduced efficiency.&lt;br&gt;
&lt;strong&gt;Solution:&lt;/strong&gt; Kitopi adopted chaos engineering to simulate database latencies and system crashes. By analyzing system responses, they improved recovery mechanisms, reduced downtime, and ensured reliable operations for food preparation and delivery.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Lenskart: Ensuring E-Commerce Stability During Scaling&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Challenge:&lt;/strong&gt; As Lenskart scaled its e-commerce operations, performance bottlenecks emerged due to unpredictable user behavior and traffic surges.&lt;br&gt;
&lt;strong&gt;Impact:&lt;/strong&gt; Checkout failures and slow load times led to cart abandonment and lost sales.&lt;br&gt;
&lt;strong&gt;Solution:&lt;/strong&gt; Lenskart employed chaos engineering to test their microservices against network failures and sudden traffic bursts. These experiments helped them fine-tune their cloud infrastructure for better scalability and higher uptime.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. iFood: Strengthening Food Delivery Operations&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Challenge:&lt;/strong&gt; iFood operates a large-scale food delivery service that depends on real-time coordination between customers, restaurants, and delivery partners. System failures disrupted order processing and driver dispatching.&lt;br&gt;
&lt;strong&gt;Impact:&lt;/strong&gt; Delayed or canceled deliveries hurt customer satisfaction and restaurant partnerships.&lt;br&gt;
&lt;strong&gt;Solution:&lt;/strong&gt; iFood used chaos engineering to test service degradations, ensuring their systems could handle API timeouts and database failures. By enhancing their error-handling strategies, they minimized order disruptions and maintained seamless delivery services.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Wingie Enuygun Company: Improving Online Travel &amp;amp; Finance Platform Resilience&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Challenge:&lt;/strong&gt; &lt;a href="https://dev.to/litmus-chaos/fintech-leaders-journey-to-resilience-with-litmus-chaos-3k19"&gt;Wingie Enuygun&lt;/a&gt;, an online travel and finance platform, faced outages due to third-party API failures and unpredictable network issues.&lt;br&gt;
&lt;strong&gt;Impact:&lt;/strong&gt; Users encountered booking failures and delayed transactions, leading to loss of trust.&lt;br&gt;
&lt;strong&gt;Solution:&lt;/strong&gt; By integrating chaos engineering, they simulated API slowdowns and network failures, allowing them to improve fallback strategies and system stability. As a result, they delivered a more reliable user experience.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Organizations that do not use chaos engineering risk falling into a cycle of operational inefficiencies and poor customer experiences. By injecting controlled failures, chaos engineering helps address these challenges, thereby building robust and scalable systems.&lt;/p&gt;

</description>
      <category>litmus</category>
      <category>litmuschaos</category>
      <category>chaos</category>
    </item>
    <item>
      <title>Fintech Leader's journey to resilience with Litmus Chaos</title>
      <dc:creator>Smriti S</dc:creator>
      <pubDate>Thu, 19 Dec 2024 05:40:06 +0000</pubDate>
      <link>https://dev.to/litmus-chaos/fintech-leaders-journey-to-resilience-with-litmus-chaos-3k19</link>
      <guid>https://dev.to/litmus-chaos/fintech-leaders-journey-to-resilience-with-litmus-chaos-3k19</guid>
      <description>&lt;p&gt;In this blog, you will understand the importance of chaos engineering in Fintech and see how &lt;strong&gt;Wingie Enuygun&lt;/strong&gt; has leveraged &lt;a href="https://docs.litmuschaos.io/" rel="noopener noreferrer"&gt;Litmus Chaos&lt;/a&gt;, an open-source CNCF-hosted platform to build and enhance their application’s resilience. &lt;/p&gt;

&lt;h2&gt;
  
  
  Why is Chaos Engineering Essential in Fintech?
&lt;/h2&gt;

&lt;p&gt;In the fintech industry, resilience is crucial. Millions of users rely on financial platforms for transactions, payments, and investments. In such cases, system downtime can lead to significant financial loss, regulatory scrutiny, and loss of customer trust. The complexity of fintech applications often involve microservices, third-party integrations, and real-time data processing, making them vulnerable to unexpected failures.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Chaos Engineering?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Chaos Engineering&lt;/strong&gt; addresses these challenges by intentionally injecting failure into a system before it is in production, to test its ability to withstand and recover from unplanned failures. This proactive approach allows companies to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mitigate Financial Risks&lt;/strong&gt;: Detect issues before they escalate into costly outages or downtime.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ensure Compliance&lt;/strong&gt;: Maintain uninterrupted service to comply with strict financial regulations and SLAs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build Customer Trust&lt;/strong&gt;: Provide a seamless, uninterrupted user experience, which is vital for customer confidence in financial transactions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By testing for failures before they happen, organizations can achieve operational resilience, reduce downtime, and gain the confidence to innovate faster. &lt;/p&gt;

&lt;p&gt;One such organization that uses &lt;strong&gt;LitmusChaos&lt;/strong&gt; is &lt;strong&gt;Wingie Enuygun&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Wingie Enuygun Group, a leader in travel and fintech, employs chaos engineering practices to enhance the resilience of their applications. Using LitmusChaos, they conduct controlled failure experiments during quality assurance (QA) cycles in pre-production environments. This proactive approach allows them to identify and address potential system weaknesses before deployment, ensuring a resilient application and reliable user experience. &lt;/p&gt;

&lt;p&gt;By simulating real-world failure scenarios, such as server crashes or network outages, Wingie analyzes how their application responds and recovers. This process helps in uncovering vulnerabilities that might not be evident through traditional testing methods.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Wingie Enuygun Uses Litmus Chaos?
&lt;/h2&gt;

&lt;p&gt;Travelers expect instant access to booking platforms, and even minor disruptions can have significant consequences. Recognizing this, Wingie Enuygun incorporates Litmus Chaos Engineering to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Identify Bottlenecks&lt;/strong&gt;: By pinpointing performance and scalability issues, Litmus helps optimize its infrastructure to handle peak loads.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Detect Issues Early&lt;/strong&gt;: Controlled failures reveal potential issues before they impact users, enabling the company to address problems preemptively.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Foresee Potential Errors&lt;/strong&gt;: Proactive testing allows teams to predict and mitigate issues, reducing the likelihood of costly downtime.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This approach gives the organization a strategic advantage, allowing teams to take preventive measures that keep their systems resilient, and highly available.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Wingie Enuygun Uses Litmus Chaos?
&lt;/h2&gt;

&lt;p&gt;To maximize the benefits of chaos engineering, Wingie Enuygun has integrated Litmus into its Quality Assurance (QA) cycles. This process ensures that every update, change, or new feature undergoes chaos testing for resilience before going into the production environment. Here’s how it works:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Controlled Chaos in Pre-Production&lt;/strong&gt;: Before releasing changes into production, controlled disruptions are introduced to stress-test the systems. These disruptions simulate real-world failures, such as server crashes or network interruptions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automated Resilience Testing&lt;/strong&gt;: By automating chaos experiments, the company validates its system’s ability to recover from critical failures like network latency, resource depletion, and service interruptions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bug Detection and Verification&lt;/strong&gt;: Chaos experiments force failures that might not otherwise surface while testing or in production. This approach helps identify and resolve bugs before they impact users.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By embedding chaos engineering within its QA process, Wingie Enuygun strengthens its infrastructure and builds confidence in its system’s ability to withstand adverse conditions.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;From QA cycle integration to proactive resilience testing and custom chaos experiments, Wingie Enuygun’s use of chaos engineering has driven continuous improvement and system innovation. &lt;/p&gt;

&lt;p&gt;By leveraging LitmusChaos, the company enhances its ability to detect issues early, optimize performance, and ensure uninterrupted service for its users by improving the resilience of the application.&lt;/p&gt;

</description>
      <category>litmuschaos</category>
    </item>
    <item>
      <title>LitmusChaos is joining Kubecon + CloudNativeCon North America 2024!</title>
      <dc:creator>Sayan Mondal</dc:creator>
      <pubDate>Tue, 05 Nov 2024 12:10:29 +0000</pubDate>
      <link>https://dev.to/litmus-chaos/litmuschaos-is-joining-kubecon-cloudnativecon-north-america-2024-3blg</link>
      <guid>https://dev.to/litmus-chaos/litmuschaos-is-joining-kubecon-cloudnativecon-north-america-2024-3blg</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs752lulge3etcjshg93t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs752lulge3etcjshg93t.png" alt="Meet Litmus at Kubecon NA 2024" width="800" height="233"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hello LitmusChaos Community! 👋&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Over the past few years, LitmusChaos has evolved tremendously, becoming a leading open-source tool for Chaos Engineering within the Cloud Native ecosystem. It's been inspiring to watch our community grow, from engineers just getting started with chaos testing to large teams running complex fault scenarios across cloud and on-prem environments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;On behalf of the maintainers&lt;/strong&gt;, we’re deeply grateful for the energy and passion each of you brings to the project. Your contributions, ideas, and feedback have fueled LitmusChaos' growth and helped tackle real-world resilience challenges in a collaborative, open-source environment. Whether it’s through insightful discussions in our Slack channels, pull requests on GitHub, or your experiences shared at events, it’s clear we’re building something special—together! &lt;/p&gt;

&lt;p&gt;Our maintainers and contributors will be on-site, eager to meet with attendees, discuss how to get started with LitmusChaos, answer questions, and share opportunities to contribute to the project. We invite you to stop by, say hello, and learn more about how chaos engineering is transforming modern cloud-native applications.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4zj1rm4i1hv7intc434o.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4zj1rm4i1hv7intc434o.jpeg" alt="LitmusChaos Maintainers" width="800" height="692"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Where to Find Us: Project Pavilion Kiosk #16A&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Location&lt;/strong&gt;: Level 1 | Halls A-C + 1-5 | Project Pavilion (Hall 1)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Kiosk:&lt;/strong&gt; #16A&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Shift&lt;/strong&gt;: Half-shift AM schedule&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Project Pavilion Hours&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Wednesday, November 13&lt;/strong&gt;: 10:45 AM – 3:15 PM&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Thursday, November 14&lt;/strong&gt;: 10:30 AM – 1:45 PM&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Friday, November 15&lt;/strong&gt;: 10:30 AM – 12:30 PM&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Our team will be at the &lt;strong&gt;Project Pavilion&lt;/strong&gt; ready to talk chaos engineering, share resources, and hand out some awesome LitmusChaos stickers, candies and more. No matter your experience level—whether you’re an expert or just beginning to explore chaos engineering—this is the perfect opportunity to get personalized guidance and learn best practices for using LitmusChaos.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd187m730kf3xphbj1bhd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd187m730kf3xphbj1bhd.png" alt="LitmusChaos Swags" width="800" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Project Engagement Opportunities at KubeCon NA&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;There are plenty of ways to connect with us beyond our kiosk! Here’s where you can find us around the venue:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Project Pavilion Lounge&lt;/strong&gt;: Located in the heart of the Pavilion, the Lounge is a welcoming spot to relax, network, and have insightful discussions with other community members in a casual setting.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Coffee Stations&lt;/strong&gt;: Fuel up and chat with us at the coffee stations on both sides of the Pavilion. Grab a coffee, and let’s discuss your ideas for chaos engineering!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ad-Hoc Meeting Tables&lt;/strong&gt;: Need more time to dive deeper into LitmusChaos? Ad-hoc meeting tables are available next to the Project Pavilion on a first-come, first-served basis, offering a chance for impromptu discussions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you’d like to set up a specific time to meet with us, please feel free to email &lt;strong&gt;&lt;a href="mailto:matthew.schillerstrom@harness.io"&gt;matthew.schillerstrom@harness.io&lt;/a&gt;&lt;/strong&gt; or &lt;strong&gt;&lt;a href="mailto:sayan.mondal@harness.io"&gt;sayan.mondal@harness.io&lt;/a&gt;&lt;/strong&gt;, we’d love to connect at KubeCon NA 2024!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffzxyzk6z3rssajhsoxoh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffzxyzk6z3rssajhsoxoh.png" alt="Meet the Litmus team" width="800" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What You Can Learn at the LitmusChaos Booth&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Our booth offers a hands-on opportunity to dive into chaos engineering, ask questions, and explore the latest developments in LitmusChaos. Here are some highlights:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Getting Started with Chaos Engineering&lt;/li&gt;
&lt;li&gt;Introduction to LitmusChaos: First Steps &amp;amp; Best Practices&lt;/li&gt;
&lt;li&gt;Adopting Chaos Engineering at Scale&lt;/li&gt;
&lt;li&gt;Solving Challenges &amp;amp; Troubleshooting with LitmusChaos&lt;/li&gt;
&lt;li&gt;Latest Updates and Enhancements in LitmusChaos&lt;/li&gt;
&lt;li&gt;Roadmap for LitmusChaos&lt;/li&gt;
&lt;li&gt;How to Get Involved as a Contributor or Future Maintainer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Whether you’re facing blockers, looking for experiment guidance, or curious about the project roadmap, our team is here to help you make the most of chaos engineering with LitmusChaos.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Connect with LitmusChaos Year-Round&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Can’t make it to KubeCon NA 2024? You can still stay connected with the LitmusChaos community:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Website&lt;/strong&gt;: Visit the&lt;a href="https://litmuschaos.io" rel="noopener noreferrer"&gt; LitmusChaos Website&lt;/a&gt; for the latest resources.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Slack&lt;/strong&gt;: Join the conversation on &lt;strong&gt;#litmus&lt;/strong&gt; in the &lt;a href="http://slack.litmuschaos.io" rel="noopener noreferrer"&gt;Kubernetes Slack&lt;/a&gt; to learn, ask questions, and contribute.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Contributing Guide&lt;/strong&gt;: Get started as a contributor by checking out our&lt;a href="https://github.com/litmuschaos/litmus/blob/master/CONTRIBUTING.md" rel="noopener noreferrer"&gt; Contributing Guide&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;YouTube&lt;/strong&gt;: Subscribe to the&lt;a href="https://www.youtube.com/@litmuschaos" rel="noopener noreferrer"&gt; LitmusChaos YouTube Channel&lt;/a&gt; for the latest demos and tutorials.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Twitter&lt;/strong&gt;: Stay updated by following&lt;a href="https://twitter.com/LitmusChaos" rel="noopener noreferrer"&gt; @LitmusChaos&lt;/a&gt; on Twitter.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LinkedIn&lt;/strong&gt;: Connect with&lt;a href="https://twitter.com/LitmusChaos" rel="noopener noreferrer"&gt; @litmuschaos&lt;/a&gt; on LinkedIn for latest updates.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DEV.to&lt;/strong&gt;: Share your insights on &lt;a href="https://dev.to/litmus-chaos"&gt;DEV.to&lt;/a&gt; with #litmuschaos, or check out community-written blogs to learn from other contributors.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>litmuschaos</category>
      <category>kubecon</category>
      <category>kubernetes</category>
      <category>devops</category>
    </item>
    <item>
      <title>Introduction to k6 Load Chaos in LitmusChaos</title>
      <dc:creator>Namkyu Park</dc:creator>
      <pubDate>Mon, 27 May 2024 03:06:13 +0000</pubDate>
      <link>https://dev.to/litmus-chaos/introduction-to-k6-load-chaos-in-litmuschaos-4l2k</link>
      <guid>https://dev.to/litmus-chaos/introduction-to-k6-load-chaos-in-litmuschaos-4l2k</guid>
      <description>&lt;p&gt;In today's complex digital landscape, application resilience is crucial. Chaos engineering, using tools like LitmusChaos, intentionally introduces faults to uncover systemic issues missed by traditional tests. From now on, we can use k6, a load-testing tool with LitmusChaos. This post explores chaos engineering with LitmusChaos and demonstrates a k6 load chaos experiment.&lt;/p&gt;




&lt;h3&gt;
  
  
  Table of Contents
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;What are chaos engineering and LitmusChaos&lt;/li&gt;
&lt;li&gt;Introduction to k6&lt;/li&gt;
&lt;li&gt;Injecting k6 load chaos with LitmusChaos (demo)&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  What are chaos engineering and LitmusChaos
&lt;/h3&gt;

&lt;p&gt;What if our systems suddenly experience an outage? It's difficult to pinpoint the problem these days, especially since our systems are on Kubernetes, meaning they are microservices. While unit tests and integration tests can detect our application's weaknesses, they cannot detect weaknesses in our overall platform.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F66s9si3jmaqf77t9o29g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F66s9si3jmaqf77t9o29g.png" alt="Importance of Resilience" width="800" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.litmuschaos.io/docs/introduction/what-is-litmus#importance-of-resilience" rel="noopener noreferrer"&gt;The above diagram&lt;/a&gt; shows the impact of resilience. Using chaos engineering can be a great way to achieve more than 90% resilience. Chaos Engineering is the discipline of experimenting on a system in order to build confidence in the system’s capability to withstand turbulent conditions in production [1]. Chaos engineering involves intentionally injecting faults into a system to test its resilience. LitmusChaos makes this process easier to implement by simplifying Chaos Engineering.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://litmuschaos.io/" rel="noopener noreferrer"&gt;LitmusChaos&lt;/a&gt; (CNCF incubating project) is a Cloud-Native Chaos Engineering Framework with cross-cloud support. You can use Litmus to inject controlled chaos and run chaos experiments in staging and production environments, allowing SREs to identify bugs and vulnerabilities. If you want to know more about Litmuschaos, Check out the &lt;a href="https://docs.litmuschaos.io/" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;!&lt;/p&gt;

&lt;h3&gt;
  
  
  Introduction to k6
&lt;/h3&gt;

&lt;p&gt;k6 is an open source load testing tool designed for developers to allow teams to create tests-as-code, integrate performance tests as part of the software development lifecycle, and help users test, analyze, and fix application performance issues. k6 supports &lt;a href="https://grafana.com/docs/k6/latest/testing-guides/test-types/" rel="noopener noreferrer"&gt;various types&lt;/a&gt; of load testing (ex. spike, smoke, stress).&lt;/p&gt;

&lt;p&gt;Now LitmusChaos supports k6 load testing as a chaos fault so that we can simulate load generation to the target application as a part of chaos testing on Kubernetes.&lt;/p&gt;

&lt;p&gt;To know more about it, check out this &lt;a href="https://litmuschaos.github.io/litmus/experiments/categories/load/k6-loadgen/" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;. You can also find our integration in the &lt;a href="https://grafana.com/docs/k6/latest/misc/integrations/#chaos-engineering" rel="noopener noreferrer"&gt;k6 documentation&lt;/a&gt; 🚀&lt;/p&gt;

&lt;h3&gt;
  
  
  Injecting k6 load chaos with LitmusChaos (demo)
&lt;/h3&gt;

&lt;p&gt;Let us run the k6-loadgen chaos experiment. For simplicity, we will be injecting chaos into an &lt;a href="https://opentelemetry.io/docs/demo/" rel="noopener noreferrer"&gt;OpenTelemetry Demo&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Prerequisites
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://docs.docker.com/engine/install/" rel="noopener noreferrer"&gt;Docker&lt;/a&gt;, &lt;a href="https://minikube.sigs.k8s.io/docs/start/" rel="noopener noreferrer"&gt;minikube&lt;/a&gt; (If you use your k8s cluster, skip this)&lt;/li&gt;
&lt;li&gt;Check out the otel-demo's &lt;a href="https://opentelemetry.io/docs/demo/kubernetes-deployment/#prerequisites" rel="noopener noreferrer"&gt;Prerequisites&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;If you haven't installed LitmusChaos yet, check out this &lt;a href="https://docs.litmuschaos.io/docs/getting-started/installation" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Install opentelemetry demo
&lt;/h4&gt;

&lt;p&gt;After installing Minikube and LitmusChaos, We now install the opentelemetry demo. All you have to do is enter the code below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts
helm &lt;span class="nb"&gt;install &lt;/span&gt;my-otel-demo open-telemetry/opentelemetry-demo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to customized a deployment setting, check out this &lt;a href="https://opentelemetry.io/docs/demo/kubernetes-deployment/" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We cannot directly access the otel-demo service, so we are using minikube's command to get an external URL&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;minikube service my-otel-demo-frontendproxy &lt;span class="nt"&gt;--url&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the result is like one below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fia3e4at2hz7xbqq7kgk0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fia3e4at2hz7xbqq7kgk0.png" alt="external url" width="800" height="93"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We now access the frontend service&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi05e2j0azq4l0ywajszp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi05e2j0azq4l0ywajszp.png" alt="otel-demo-frontend" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can access Grafana using given URL&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;http://&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;given_url&lt;/span&gt;&lt;span class="sh"&gt;&amp;gt;&amp;gt;/grafana
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will use &lt;code&gt;Home &amp;gt; Dashboards &amp;gt; Demo Dashboard&lt;/code&gt; today.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0z2gu9mhj3yjgldn3neh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0z2gu9mhj3yjgldn3neh.png" alt="grafana-dashboard" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Setup Probes
&lt;/h4&gt;

&lt;p&gt;You can easily create a probe following this &lt;a href="https://docs.litmuschaos.io/docs/user-guides/create-resilience-probe" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;. Enter a value like below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;// URL: http://my-otel-demo-frontendproxy.default.svc.cluster.local:8080
// METHOD: GET
// CRITERIA: &lt;span class="o"&gt;==&lt;/span&gt;
// Response Code: 200
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm2ql5hisdxk8ef20f8r9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm2ql5hisdxk8ef20f8r9.png" alt="result" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Writing a k6 script
&lt;/h4&gt;

&lt;p&gt;You don't have to install a k6 engine! We just have to write a k6 script. We will use the below code and save it as &lt;code&gt;script.js&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;http&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;k6/http&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;sleep&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;k6&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;vus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;30s&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;http&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;http://my-otel-demo-frontendproxy.default.svc.cluster.local:8080&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you'd like to write a more professional script, you can check out this &lt;a href="https://grafana.com/docs/k6/latest/" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;and let's make a secret&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl create secret generic k6-script &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--from-file&lt;/span&gt;&lt;span class="o"&gt;=&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;script&lt;/span&gt;&lt;span class="sh"&gt;-path&amp;gt;&amp;gt;/script.js -n &amp;lt;&amp;lt;chaos_infrastructure_namespace&amp;gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that all the preliminary work is done, let's create a chaos experiment.&lt;/p&gt;

&lt;h4&gt;
  
  
  Let's make a chaos experiment
&lt;/h4&gt;

&lt;p&gt;Click &lt;code&gt;Chaos Experiments&lt;/code&gt; &amp;gt; &lt;code&gt;+ New Experiment&lt;/code&gt; to create a new chaos experiment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2zjcbncaee0p4t7ummfy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2zjcbncaee0p4t7ummfy.png" alt="int" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After clicking the &lt;code&gt;Blank Canvas&lt;/code&gt; and &lt;code&gt;Add&lt;/code&gt; buttons, we can choose chaos fault in ChaosHub. We use &lt;code&gt;k6-loadgen&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0qdoiw7nbogns5npgq1y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0qdoiw7nbogns5npgq1y.png" alt="hub" width="800" height="534"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the &lt;code&gt;Tune Fault&lt;/code&gt; tab, we enter the secret name and key we created before.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqyi9evbnjy2itl8vrlpw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqyi9evbnjy2itl8vrlpw.png" alt="tune" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lastly, We add a probe that was created before.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fydexol36gztshdx3ndpm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fydexol36gztshdx3ndpm.png" alt="probe" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Okay, all done! Let's execute a chaos experiment 🚀&lt;/p&gt;

&lt;p&gt;A few minutes later, Our chaos experiment succeeded. Congratulations 🎉 &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz1ukk56bn2995tov22y6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz1ukk56bn2995tov22y6.png" alt="result" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can see the load testing result on the Grafana dashboard. Go to &lt;code&gt;Dashboards&lt;/code&gt; &amp;gt; &lt;code&gt;Demo Dashboard&lt;/code&gt; &amp;gt; &lt;code&gt;Requests Rate for frontend by span name&lt;/code&gt; &amp;gt; &lt;code&gt;frontend-proxy&lt;/code&gt;. We can see the result below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9zl58h7wgho2fwg70bpf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9zl58h7wgho2fwg70bpf.png" alt="chaos-experiment-result" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;k6-loadgen fault simulates load generation on the target hosts for a specific chaos duration. The effects of chaos engineering can be maximized by designing experiments with k6-loadgen like other chaos faults in LitmusChaos.&lt;/p&gt;

&lt;p&gt;If you are interested in LitmusChaos, Join the community! You can join the LitmusChaos community on &lt;a href="https://github.com/litmuschaos/litmus" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; and &lt;a href="https://kubernetes.slack.com/?redir=%2Farchives%2FCNXNB0ZTN" rel="noopener noreferrer"&gt;Slack&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thank you for reading 🙏&lt;/p&gt;

&lt;p&gt;Namkyu Park&lt;br&gt;
Maintainer of LitmusChaos&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/namkyupark1999/?locale=en_US" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; | &lt;a href="https://github.com/namkyu1999" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Reference
&lt;/h3&gt;

&lt;p&gt;[1] &lt;a href="https://principlesofchaos.org" rel="noopener noreferrer"&gt;PRINCIPLES OF CHAOS ENGINEERING&lt;/a&gt;&lt;/p&gt;

</description>
      <category>chaosengineering</category>
      <category>litmuschaos</category>
      <category>tutorial</category>
      <category>kubernetes</category>
    </item>
    <item>
      <title>Strategies for Writing More Effective Tests in Golang</title>
      <dc:creator>Namkyu Park</dc:creator>
      <pubDate>Mon, 08 May 2023 06:32:42 +0000</pubDate>
      <link>https://dev.to/litmus-chaos/strategies-for-writing-more-effective-tests-in-golang-1fma</link>
      <guid>https://dev.to/litmus-chaos/strategies-for-writing-more-effective-tests-in-golang-1fma</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flsok2jm9r9lonvkngabx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flsok2jm9r9lonvkngabx.png" alt="unit tests" width="800" height="250"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Unit tests are functions that test specific pieces of code from a program or package. The primary objective of unit tests is to check the correctness of an application, leading to better software that is more robust, has fewer bugs, and is more stable. There are many ways to test software other than unit tests. Let's look at the test pyramid.&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyf6324oroitq3lm5dm03.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyf6324oroitq3lm5dm03.png" alt="test-pyramid" width="466" height="246"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;center&gt;&lt;a href="https://martinfowler.com/articles/practical-test-pyramid.html" rel="noopener noreferrer"&gt;image source&lt;/a&gt;&lt;/center&gt;



&lt;p&gt;As the test pyramid metaphor suggests, unit tests are the foundation of all tests. Unit tests are the easiest to write code and the most powerful. Unit tests are especially helpful for microservices. In microservices, each system must work independently. Therefore, unit tests that allow testing against one service while mocking another are very important. &lt;/p&gt;

&lt;p&gt;This &lt;a href="https://lfx.linuxfoundation.org/" rel="noopener noreferrer"&gt;LFX&lt;/a&gt; quarter I got to get my hands on &lt;a href="https://litmuschaos.io/" rel="noopener noreferrer"&gt;LitmusChaos&lt;/a&gt;, a CNCF incubating opensource project that dives deep on making cloud-native chaos-engineering accessible to multiple developer personas.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7ef0ae9ogsuwfc5ookwe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7ef0ae9ogsuwfc5ookwe.png" alt="cloud native" width="800" height="250"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this post, I'll discuss about the testing methodologies and strategies I took to improve the code coverage as well as modify the structure (for a Go based framework) of the litmus project to make it more robust and agile for testing. Before starting, We highly recommend &lt;a href="https://youtu.be/8hQG7QlcLBk" rel="noopener noreferrer"&gt;watching this video&lt;/a&gt;.&lt;/p&gt;


&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Naming Convention&lt;/li&gt;
&lt;li&gt;Testing Structure&lt;/li&gt;
&lt;li&gt;What to test?&lt;/li&gt;
&lt;li&gt;Test Interface&lt;/li&gt;
&lt;li&gt;Mocking&lt;/li&gt;
&lt;li&gt;Table-Driven Test&lt;/li&gt;
&lt;li&gt;Solitary Tests vs Sociable Tests&lt;/li&gt;
&lt;li&gt;Defer vs t.Cleanup()&lt;/li&gt;
&lt;li&gt;Dealing with Before &amp;amp; After tests&lt;/li&gt;
&lt;li&gt;Do not assert an Error message&lt;/li&gt;
&lt;li&gt;Avoid Flaky Test&lt;/li&gt;
&lt;li&gt;Fuzz testing&lt;/li&gt;
&lt;li&gt;Code Coverage&lt;/li&gt;
&lt;li&gt;Test Coverage Report(UI)&lt;/li&gt;
&lt;li&gt;CI Integration&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ol&gt;


&lt;h2&gt;
  
  
  Naming Convention
&lt;/h2&gt;

&lt;p&gt;According to the &lt;a href="https://go.dev/doc/tutorial/add-a-test" rel="noopener noreferrer"&gt;Golang testing package&lt;/a&gt;, we follow &lt;a href="https://pkg.go.dev/testing#pkg-overview" rel="noopener noreferrer"&gt;these naming conventions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;helloWorld&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt; &lt;span class="c"&gt;// target function&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;TestHelloWorld&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;testing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt; &lt;span class="c"&gt;// test function&lt;/span&gt;

&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;FooStruct&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;FooStruct&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;Bar&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt; &lt;span class="c"&gt;// target method&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;TestFooStruct_Bar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;testing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;){}&lt;/span&gt; &lt;span class="c"&gt;// test function&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Testing Structure
&lt;/h2&gt;

&lt;p&gt;A good structure for all unit tests follows these,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Set up the test data&lt;/li&gt;
&lt;li&gt;Call your method under the test&lt;/li&gt;
&lt;li&gt;Assert that the expected results are returned&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These three steps are replaced with &lt;a href="https://martinfowler.com/bliki/GivenWhenThen.html" rel="noopener noreferrer"&gt;“given”, “when”, “then” in BDD&lt;/a&gt;. You can make unit test codes easier if you adopt this pattern.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="c"&gt;// example of given-when-then pattern&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;TestChaosHubService_DeleteChaosHub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;testing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"success"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;testing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="c"&gt;// given&lt;/span&gt;
     &lt;span class="n"&gt;findResult&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;bson&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;D&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"project_id"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"hub_name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"hub1"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"hub_id"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;

     &lt;span class="c"&gt;// when&lt;/span&gt;
     &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;mockService&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DeleteChaosHub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Background&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

     &lt;span class="c"&gt;// then&lt;/span&gt;
     &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NoError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What to test?
&lt;/h2&gt;

&lt;p&gt;Tests that are too close to the production code are not recommended. As soon as you fix your production code, You need to change the test code too(the test code will be broken)! You rather test for observable behavior. Here’s what &lt;a href="https://martinfowler.com/articles/practical-test-pyramid.html" rel="noopener noreferrer"&gt;Martin Fowler’s Blog&lt;/a&gt; suggests.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Think about&lt;br&gt;
if I enter values x and y, will the result be z?&lt;br&gt;
instead of&lt;br&gt;
If I enter x and y, will the method call class A first, then call class B and then return the result of class A plus the result of class B?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We can accomplish this by subtests in the &lt;a href="https://pkg.go.dev/testing#hdr-Subtests_and_Sub_benchmarks" rel="noopener noreferrer"&gt;Golang testing package&lt;/a&gt;. We don’t have to write separate functions. Instead, use &lt;code&gt;t.Run()&lt;/code&gt; so that we can verify the result by various inputs in one function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="c"&gt;// example of subtests&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;TestChaosHubService_UpdateChaosHub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;testing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"cannot find same project_id hub"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;testing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="c"&gt;// given codes&lt;/span&gt;
     &lt;span class="c"&gt;// when codes&lt;/span&gt;
     &lt;span class="c"&gt;// then codes&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;

  &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"success : updated hub type is remote"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;testing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="c"&gt;// given codes&lt;/span&gt;
     &lt;span class="c"&gt;// when codes&lt;/span&gt;
     &lt;span class="c"&gt;// then codes&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;

  &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"success : updated hub type is not remote"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;testing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="c"&gt;// given codes&lt;/span&gt;
     &lt;span class="c"&gt;// when codes&lt;/span&gt;
     &lt;span class="c"&gt;// then codes&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;

  &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"success : updated hub type is not remote, not changed data"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;testing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="c"&gt;// given codes&lt;/span&gt;
     &lt;span class="c"&gt;// when codes&lt;/span&gt;
     &lt;span class="c"&gt;// then codes&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Test Interface
&lt;/h2&gt;

&lt;p&gt;As previously mentioned, We need to test functions' desirable results, not all lines of production code. With subtests, Interface can help what you focus on. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1fxc1i7mbj0tlujf73jb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1fxc1i7mbj0tlujf73jb.png" alt="notebook" width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The interface is like a contract that expresses desired behavior. For example, the Service interface has an &lt;code&gt;AddChaosHub&lt;/code&gt; function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Service&lt;/span&gt; &lt;span class="k"&gt;interface&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;AddChaosHub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chaosHub&lt;/span&gt; &lt;span class="n"&gt;CreateChaosHubRequest&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ChaosHub&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We have not implemented the interface yet. But We can write test code. This method is the method for adding a ChaosHub. If the request parameter is valid, Method success creates a chaoshub object and return object. If not, return the error. According to these instructions, We can write test code like below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="c"&gt;// example of unit test of AddChaosHub function&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;TestChaosHubService_AddChaosHub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;testing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c"&gt;// given&lt;/span&gt;
  &lt;span class="n"&gt;newHub&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CreateChaosHubRequest&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="n"&gt;ProjectID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"4"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="n"&gt;HubName&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;   &lt;span class="s"&gt;"Litmus ChaosHub"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"already existed hub name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;testing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="c"&gt;// given&lt;/span&gt;
     &lt;span class="n"&gt;findResult&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="k"&gt;interface&lt;/span&gt;&lt;span class="p"&gt;{}{&lt;/span&gt;
        &lt;span class="n"&gt;bson&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;D&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt;&lt;span class="s"&gt;"project_id"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"3"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"hub_name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Litmus ChaosHub"&lt;/span&gt;&lt;span class="p"&gt;}},&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;
     &lt;span class="n"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;mongo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NewCursorFromDocuments&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;findResult&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
     &lt;span class="n"&gt;mongoOperator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;On&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="s"&gt;"List"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mock&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Anything&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mongodb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ChaosHubCollection&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mock&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Anything&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Return&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Once&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

     &lt;span class="c"&gt;// when&lt;/span&gt;
     &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;mockService&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddChaosHub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Background&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;newHub&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

     &lt;span class="c"&gt;// then&lt;/span&gt;
     &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;

  &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"success"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;testing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="c"&gt;// given&lt;/span&gt;
     &lt;span class="n"&gt;findResult&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="k"&gt;interface&lt;/span&gt;&lt;span class="p"&gt;{}{&lt;/span&gt;
        &lt;span class="n"&gt;bson&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;D&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt;&lt;span class="s"&gt;"project_id"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"hub_name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"hub1"&lt;/span&gt;&lt;span class="p"&gt;}},&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;
     &lt;span class="n"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;mongo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NewCursorFromDocuments&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;findResult&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
     &lt;span class="n"&gt;mongoOperator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;On&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="s"&gt;"List"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mock&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Anything&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mongodb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ChaosHubCollection&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mock&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Anything&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Return&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Once&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
     &lt;span class="n"&gt;mongoOperator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;On&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="s"&gt;"Create"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mock&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Anything&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mongodb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ChaosHubCollection&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mock&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Anything&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Return&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Once&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

     &lt;span class="c"&gt;// when&lt;/span&gt;
     &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Cleanup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;clearCloneRepository&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;newHub&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ProjectID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;newHub&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HubName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
     &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;mockService&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddChaosHub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Background&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;newHub&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

     &lt;span class="c"&gt;// then&lt;/span&gt;
     &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NoError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
     &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;newHub&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HubName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HubName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Mocking
&lt;/h2&gt;

&lt;p&gt;LitmusChaos project adopted &lt;a href="https://github.com/bxcodec/go-clean-arch" rel="noopener noreferrer"&gt;layered architecture&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx354iqghokmpx4l56ui6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx354iqghokmpx4l56ui6.png" alt="architecture of LitmusChaos Backend" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By applying this architecture, we can see the effect of low coupling and high cohesion. Changes to GraphQL logic only require modifications to the resolver layer, and changes to business logic only require modifications to the service layer. Changes to MongoDB logic only require changes to the operator layer. Since we will be testing on all layers, there is no need to test the sub-layers of each layer, so we mock the sub-layers. In LitmusChaos, we used a library called &lt;a href="https://github.com/stretchr/testify" rel="noopener noreferrer"&gt;testify&lt;/a&gt; for mocking.&lt;/p&gt;

&lt;p&gt;Here’s an example. In graphql-server, &lt;a href="https://github.com/litmuschaos/litmus/blob/master/litmus-portal/graphql-server/pkg/chaoshub/service.go" rel="noopener noreferrer"&gt;ChaosHubService&lt;/a&gt; needs a &lt;code&gt;MongoOperator&lt;/code&gt; to interact with MongoDB. But in unit tests, We don’t have to use real databases, We mocked &lt;code&gt;MongoOperator&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="c"&gt;// example of MockOperator (mongoDB)&lt;/span&gt;
&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;MongoOperator&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;mock&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Mock&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c"&gt;// we don't have to write real logic. Mock object's method will&lt;/span&gt;
&lt;span class="c"&gt;// be replaced at test function.&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="n"&gt;MongoOperator&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;Get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;collectionType&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt; &lt;span class="n"&gt;bson&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;D&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;mongo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SingleResult&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;args&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Called&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;collectionType&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;mongo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SingleResult&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="n"&gt;MongoOperator&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;Update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;collectionType&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;update&lt;/span&gt; &lt;span class="n"&gt;bson&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;D&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;opts&lt;/span&gt; &lt;span class="o"&gt;...*&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UpdateOptions&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;mongo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UpdateResult&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;args&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Called&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;collectionType&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;update&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;opts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;mongo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UpdateResult&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="c"&gt;// chaoshub_test package&lt;/span&gt;
&lt;span class="c"&gt;// Mock object is injected instead of real object.&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;mongoOperator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mocks&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MongoOperator&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;mockOperator&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dbSchemaChaosHub&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NewChaosHubOperator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mongoOperator&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;mockService&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;chaoshub&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NewService&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mockOperator&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;TestChaosHubService_DeleteChaosHub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;testing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"cannot find same project_id hub"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;testing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="c"&gt;// given&lt;/span&gt;
     &lt;span class="c"&gt;// setup expectation by using On() function.&lt;/span&gt;
     &lt;span class="n"&gt;mongoOperator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;On&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="s"&gt;"Get"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mock&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Anything&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mongodb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ChaosHubCollection&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mock&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Anything&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Return&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;mongo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SingleResult&lt;/span&gt;&lt;span class="p"&gt;{},&lt;/span&gt; &lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Once&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

     &lt;span class="c"&gt;// when&lt;/span&gt;
     &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;mockService&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DeleteChaosHub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Background&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

     &lt;span class="c"&gt;// then&lt;/span&gt;
     &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;

  &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"success"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;testing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="c"&gt;// given&lt;/span&gt;
     &lt;span class="n"&gt;findResult&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;bson&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;D&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"project_id"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"hub_name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"hub1"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"hub_id"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;
     &lt;span class="n"&gt;singleResult&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;mongo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NewSingleResultFromDocument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;findResult&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
     &lt;span class="n"&gt;mongoOperator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;On&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="s"&gt;"Get"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mock&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Anything&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mongodb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ChaosHubCollection&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mock&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Anything&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Return&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;singleResult&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Once&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
     &lt;span class="n"&gt;mongoOperator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;On&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="s"&gt;"Update"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mock&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Anything&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mongodb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ChaosHubCollection&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mock&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Anything&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mock&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Anything&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mock&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Anything&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Return&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;mongo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UpdateResult&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;MatchedCount&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Once&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

     &lt;span class="c"&gt;// when&lt;/span&gt;
     &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;mockService&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DeleteChaosHub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Background&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

     &lt;span class="c"&gt;// then&lt;/span&gt;
     &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NoError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Table-Driven Test
&lt;/h2&gt;

&lt;p&gt;You can check &lt;a href="https://dave.cheney.net/2019/05/07/prefer-table-driven-tests" rel="noopener noreferrer"&gt;the basics of table-driven tests here&lt;/a&gt;.  By adopting a table-driven test approach, We can reduce the amount of repetitive code compared to repeating the same code for each test and make it straightforward to add more test cases. More details on the  &lt;a href="https://go.dev/blog/subtests" rel="noopener noreferrer"&gt;Golang dev blog&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="c"&gt;// example of table-driven Test&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;TestChaosHubService_UpdateChaosHub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;testing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c"&gt;// given&lt;/span&gt;
  &lt;span class="n"&gt;utils&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Config&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RemoteHubMaxSize&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"1000000000"&lt;/span&gt;
  &lt;span class="n"&gt;testCases&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="n"&gt;name&lt;/span&gt;    &lt;span class="kt"&gt;string&lt;/span&gt;
     &lt;span class="n"&gt;hub&lt;/span&gt;     &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UpdateChaosHubRequest&lt;/span&gt;
     &lt;span class="n"&gt;got&lt;/span&gt;     &lt;span class="n"&gt;bson&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;D&lt;/span&gt;
     &lt;span class="n"&gt;isError&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt;
  &lt;span class="p"&gt;}{&lt;/span&gt;
     &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"cannot find same project_id hub"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;hub&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UpdateChaosHubRequest&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
           &lt;span class="n"&gt;ProjectID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="n"&gt;HubName&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;   &lt;span class="s"&gt;"updated name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="n"&gt;isError&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="p"&gt;},&lt;/span&gt;
     &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"success : updated hub type is remote"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;hub&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UpdateChaosHubRequest&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
           &lt;span class="n"&gt;ProjectID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="n"&gt;HubName&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;   &lt;span class="s"&gt;"updated name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="n"&gt;RepoURL&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;   &lt;span class="s"&gt;"https://github.com/litmuschaos/chaos-charts/archive/refs/heads/master.zip"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="n"&gt;got&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;     &lt;span class="n"&gt;bson&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;D&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt;&lt;span class="s"&gt;"project_id"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"hub_name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"hub1"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"hub_type"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"REMOTE"&lt;/span&gt;&lt;span class="p"&gt;}},&lt;/span&gt;
        &lt;span class="n"&gt;isError&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="no"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="p"&gt;},&lt;/span&gt;
     &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"success : updated hub type is not remote"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;hub&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UpdateChaosHubRequest&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
           &lt;span class="n"&gt;ProjectID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;  &lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="n"&gt;HubName&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;    &lt;span class="s"&gt;"updated name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="n"&gt;RepoURL&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;    &lt;span class="s"&gt;"https://github.com/litmuschaos/chaos-charts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="n"&gt;RepoBranch&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"master"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="n"&gt;IsPrivate&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;  &lt;span class="no"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="n"&gt;got&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;     &lt;span class="n"&gt;bson&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;D&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt;&lt;span class="s"&gt;"project_id"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"hub_name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"hub1"&lt;/span&gt;&lt;span class="p"&gt;}},&lt;/span&gt;
        &lt;span class="n"&gt;isError&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="no"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="p"&gt;},&lt;/span&gt;
     &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"success : updated hub type is not remote, not changed data"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;hub&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UpdateChaosHubRequest&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
           &lt;span class="n"&gt;ProjectID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;  &lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="n"&gt;HubName&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;    &lt;span class="s"&gt;"updated name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="n"&gt;RepoURL&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;    &lt;span class="s"&gt;"https://github.com/litmuschaos/chaos-charts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="n"&gt;RepoBranch&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"master"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="n"&gt;IsPrivate&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;  &lt;span class="no"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="n"&gt;got&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;     &lt;span class="n"&gt;bson&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;D&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt;&lt;span class="s"&gt;"project_id"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"hub_name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"updated name"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"repo_url"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"https://github.com/litmuschaos/chaos-charts"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"repo_branch"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"master"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"is_private"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;false&lt;/span&gt;&lt;span class="p"&gt;}},&lt;/span&gt;
        &lt;span class="n"&gt;isError&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="no"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tc&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;range&lt;/span&gt; &lt;span class="n"&gt;testCases&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;testing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c"&gt;// given&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;tc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isError&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
           &lt;span class="c"&gt;// given&lt;/span&gt;
           &lt;span class="n"&gt;mongoOperator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;On&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Get"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mock&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Anything&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mongodb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ChaosHubCollection&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mock&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Anything&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Return&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;mongo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SingleResult&lt;/span&gt;&lt;span class="p"&gt;{},&lt;/span&gt; &lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Once&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

           &lt;span class="c"&gt;// when&lt;/span&gt;
           &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;mockService&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UpdateChaosHub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Background&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;tc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hub&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

           &lt;span class="c"&gt;// then&lt;/span&gt;
           &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
           &lt;span class="n"&gt;singleResult&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;mongo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NewSingleResultFromDocument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;got&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
           &lt;span class="n"&gt;mongoOperator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;On&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Get"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mock&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Anything&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mongodb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ChaosHubCollection&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mock&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Anything&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Return&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;singleResult&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Once&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
           &lt;span class="n"&gt;mongoOperator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;On&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Update"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mock&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Anything&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mongodb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ChaosHubCollection&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mock&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Anything&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mock&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Anything&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mock&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Anything&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Return&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;mongo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UpdateResult&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;MatchedCount&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Once&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

           &lt;span class="c"&gt;// when&lt;/span&gt;
           &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Cleanup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;clearCloneRepository&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hub&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ProjectID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hub&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HubName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
           &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;mockService&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UpdateChaosHub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Background&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;tc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hub&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

           &lt;span class="c"&gt;// then&lt;/span&gt;
           &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NoError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
           &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hub&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HubName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HubName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
     &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Solitary Tests vs Sociable Tests
&lt;/h2&gt;

&lt;p&gt;There are two terms in the unit test world, Sociable Tests and Solitary Tests. See the illustration below for an explanation of the two terms.&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fedtrue99ahz623u6vkmi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fedtrue99ahz623u6vkmi.png" alt="solitary tests vs sociable tests" width="800" height="223"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;center&gt;&lt;a href="https://martinfowler.com/bliki/UnitTest.html#footnote-solitary" rel="noopener noreferrer"&gt;image source&lt;/a&gt;&lt;/center&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
Previously, We talked about Mocking. With Mocking, We can make all unit test codes Solitary Tests. However, if you want your code to behave based on the results of actual actions in the lower layers, you should use Sociable Tests. &lt;/p&gt;

&lt;p&gt;For example, In graphql-server’s ChaosHub package, &lt;code&gt;ChaosHubService&lt;/code&gt; uses &lt;a href="https://github.com/litmuschaos/litmus/blob/master/litmus-portal/graphql-server/pkg/chaoshub/ops/gitops.go#L68" rel="noopener noreferrer"&gt;&lt;code&gt;chaosHubOps.GitClone()&lt;/code&gt;&lt;/a&gt; in the &lt;a href="https://github.com/litmuschaos/litmus/blob/d4101da93fbb6f4033f9b0d17f34abb0f5be7ddd/litmus-portal/graphql-server/pkg/chaoshub/service.go#L96" rel="noopener noreferrer"&gt;&lt;code&gt;AddChaosHub&lt;/code&gt; method&lt;/a&gt;. The &lt;code&gt;AddChaosHub&lt;/code&gt; method performs the git clone through a real ChaosHub url, which means that if you mock the git clone part, you need additional logic to determine if the url is valid. Also, the &lt;a href="https://github.com/litmuschaos/litmus/blob/d4101da93fbb6f4033f9b0d17f34abb0f5be7ddd/litmus-portal/graphql-server/pkg/chaoshub/service.go#L361" rel="noopener noreferrer"&gt;&lt;code&gt;GetExperiment&lt;/code&gt; method&lt;/a&gt; performs file I/O operations based on the cloned repository. For these cases, Sociable Tests, which do not mock &lt;code&gt;chaosHubOps.GitClone()&lt;/code&gt;, is more appropriate.&lt;/p&gt;
&lt;h2&gt;
  
  
  Defer vs t.Cleanup()
&lt;/h2&gt;

&lt;p&gt;If you need to clean up the resources used by your test, use &lt;code&gt;t.Cleanup()&lt;/code&gt;. Unlike the defer function, this function also works fine in the event of a panic. You can check the details in &lt;a href="https://stackoverflow.com/questions/61609085/what-is-useful-for-t-cleanup" rel="noopener noreferrer"&gt;this link&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="c"&gt;// Example of t.Cleanup() for cleanup resources&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;TestChaosHubService_AddChaosHub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;testing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"success"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;testing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="c"&gt;// given codes ...&lt;/span&gt;
     &lt;span class="c"&gt;// when : called t.Cleanup() functions before when codes&lt;/span&gt;
     &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Cleanup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;&lt;span class="n"&gt;clearCloneRepository&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;newHub&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ProjectID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;newHub&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HubName&lt;/span&gt;&lt;span class="p"&gt;)})&lt;/span&gt;
     &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;mockService&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddChaosHub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Background&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;newHub&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

     &lt;span class="c"&gt;// then codes&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Dealing with Before &amp;amp; After tests
&lt;/h2&gt;

&lt;p&gt;Sometimes, We need to add additional tasks before or after tests. The &lt;a href="https://pkg.go.dev/testing#hdr-Main" rel="noopener noreferrer"&gt;Golang testing package&lt;/a&gt; gave us a solution. &lt;code&gt;TestMain&lt;/code&gt; function can be declared per package. You can add additional processes like below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;TestMain&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;testing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;M&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c"&gt;// pre-process&lt;/span&gt;
  &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
  &lt;span class="c"&gt;// post-process&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can use the &lt;code&gt;init()&lt;/code&gt; function. But &lt;code&gt;init()&lt;/code&gt; function cannot be used in After logic. So I recommend using the TestMain function rather than the init function.&lt;/p&gt;

&lt;h2&gt;
  
  
  Do not assert an Error message
&lt;/h2&gt;

&lt;p&gt;The Error message is only for human consumption. That means, It can easily change. So, Rather than using an Error message, you can just check if the error is not nil. More details are &lt;a href="https://stackoverflow.com/questions/42035104/how-to-unit-test-go-errors" rel="noopener noreferrer"&gt;in the following conversations&lt;/a&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  Avoid Flaky Test
&lt;/h2&gt;

&lt;p&gt;Test functions needed to be deterministic. Do not make Flaky Tests. Here are common causes of flakiness include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Poorly written tests.&lt;/li&gt;
&lt;li&gt;Async wait&lt;/li&gt;
&lt;li&gt;Test order dependency&lt;/li&gt;
&lt;li&gt;Concurrency&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;More details are in &lt;a href="https://www.datadoghq.com/knowledge-center/flaky-tests/#:~:text=A%20flaky%20test%20is%20a,with%20each%20individual%20test%20run." rel="noopener noreferrer"&gt;this link&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4weyx0roetuiqagm0avb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4weyx0roetuiqagm0avb.png" alt="Flaky Tests" width="800" height="250"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Fuzz testing
&lt;/h2&gt;

&lt;p&gt;The unit test has limitations in that unit tests’ input must be added by the developer. Fuzz testing can test many edge cases like coding interviews so that we can prevent SQL injection, buffer overflow, and more. Fuzz testing involves injecting random data with your original test cases. You can make the Fuzz test function like below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;Reverse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;// function to reverse a string&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;FuzzReverse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;testing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;F&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;// table-driven fuzzing&lt;/span&gt;
    &lt;span class="n"&gt;testcases&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"word1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"word2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"word3"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tc&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;range&lt;/span&gt; &lt;span class="n"&gt;testcases&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;// Use f.Add to provide a seed corpus&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Fuzz&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;testing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="c"&gt;// Value of a will be auto generated and passed&lt;/span&gt;
            &lt;span class="c"&gt;// Assert that the length of the reversed string is the same as the original&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And you can run unit tests with Fuzz like below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;-fuzz&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;Fuzz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;More details are in &lt;a href="https://go.dev/doc/tutorial/fuzz" rel="noopener noreferrer"&gt;this link&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Code Coverage
&lt;/h2&gt;

&lt;p&gt;We use &lt;a href="https://pkg.go.dev/cmd/go" rel="noopener noreferrer"&gt;the Golang command tool&lt;/a&gt; to check test coverage. It's simple but really powerful. You don't need any extra tools if you already installed Go.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F128uenvv2odjlmzuwapb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F128uenvv2odjlmzuwapb.png" alt="code coverage" width="800" height="464"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Golang command tool automatically installs, builds, and tests Go programs using nothing more than the source code as the build specification.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check Specific package's code coverage&lt;/span&gt;
&lt;span class="c"&gt;# in the package root&lt;/span&gt;
go &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;-cover&lt;/span&gt; ./...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check the entire backend code coverage&lt;/span&gt;
&lt;span class="c"&gt;# in the backend module root (in my case, graphql-server)&lt;/span&gt;
go &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;--coverpkg&lt;/span&gt; ./... &lt;span class="nt"&gt;-coverprofile&lt;/span&gt; cover.out ./... &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
 &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="s2"&gt;"total: "&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
 go tool cover &lt;span class="nt"&gt;-func&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;cover.out | &lt;span class="nb"&gt;tail&lt;/span&gt; &lt;span class="nt"&gt;-1&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $NF}'&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Test Coverage Report(UI)
&lt;/h2&gt;

&lt;p&gt;The Golang command tool also gave us to check coverage by HTML UI. &lt;a href="https://go.dev/blog/cover" rel="noopener noreferrer"&gt;Official guide is here&lt;/a&gt;. Once you execute the entire backend unit tests, You can find &lt;code&gt;cover.out&lt;/code&gt; file. If you executed the below code, now you can see a beautiful UI that can check coverage. the green color of codes is covered by your unit tests code and the red one is not.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check the entire backend code coverage&lt;/span&gt;
&lt;span class="c"&gt;# in the project root&lt;/span&gt;
go &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;--coverpkg&lt;/span&gt; ./... &lt;span class="nt"&gt;-coverprofile&lt;/span&gt; cover.out ./... &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
 &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="s2"&gt;"total: "&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
 go tool cover &lt;span class="nt"&gt;-func&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;cover.out | &lt;span class="nb"&gt;tail&lt;/span&gt; &lt;span class="nt"&gt;-1&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $NF}'&lt;/span&gt;
&lt;span class="c"&gt;# cover.out to cover.html&lt;/span&gt;
go tool cover &lt;span class="nt"&gt;-html&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;cover.out &lt;span class="nt"&gt;-o&lt;/span&gt; cover.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fopvtl2f3omhrmgoket74.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fopvtl2f3omhrmgoket74.png" alt="code coverage ui" width="800" height="562"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  CI Integration
&lt;/h2&gt;

&lt;p&gt;If you adopt CI / CD pipeline to your current project, you can integrate unit testing jobs to CI pipeline. CI jobs in the GitHub actions will execute unit tests so developers do not have to run them locally. Here's a sample.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;build-pipeline&lt;/span&gt;
&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;pull_request&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="c1"&gt;# this example CI job runs when you raise PR&lt;/span&gt;
    &lt;span class="na"&gt;branches&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;master&lt;/span&gt;

&lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;DOCKER_BUILDKIT&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;

&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;changes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;

  &lt;span class="na"&gt;backend-unit-tests&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;needs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;changes&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Checkout repository&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v2&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/setup-go@v2&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;go-version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;1.16"&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Backend unit tests&lt;/span&gt;
        &lt;span class="na"&gt;shell&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;bash&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
          &lt;span class="s"&gt;# cd to the backend directory&lt;/span&gt;
          &lt;span class="s"&gt;# run your test here!&lt;/span&gt;
          &lt;span class="s"&gt;go test -cover ./...&lt;/span&gt;

  &lt;span class="na"&gt;docker-build-backend-server&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;needs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;changes&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;backend-unit-tests&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Build backend server docker image&lt;/span&gt;
        &lt;span class="na"&gt;shell&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;bash&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
          &lt;span class="s"&gt;# run docker build job after all the tests are passed&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you seen, you can run unit tests before build docker image. If unit tests failed, no further jobs will be executed.&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Through this post, We discussed several tips of how to write efficient unit test codes. If you have any questions or suggestions, please comment below or send me an email(&lt;a href="mailto:lak9348@gmail.com"&gt;lak9348@gmail.com&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;As I mentioned before, I worked on writing unit tests in LitmusChaos. LitmusChaos can help you find weaknesses in your project by injecting chaos. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvx7odrqb6vd16jdyvf01.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvx7odrqb6vd16jdyvf01.png" alt="chaos injection" width="800" height="343"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are interested in LitmusChaos, Join community! You can join the LitmusChaos community on &lt;a href="https://github.com/litmuschaos/litmus" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; and &lt;a href="https://kubernetes.slack.com/?redir=%2Farchives%2FCNXNB0ZTN" rel="noopener noreferrer"&gt;Slack&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thank you for reading 🙏&lt;/p&gt;

&lt;p&gt;Namkyu Park&lt;br&gt;
Contributor of LitmusChaos&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/namkyupark1999/?locale=en_US" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; | &lt;a href="https://github.com/namkyu1999" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

</description>
      <category>go</category>
      <category>testing</category>
      <category>litmuschaos</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Introduction to HTTP Chaos in LitmusChaos</title>
      <dc:creator>Akash Shrivastava</dc:creator>
      <pubDate>Tue, 13 Sep 2022 15:58:52 +0000</pubDate>
      <link>https://dev.to/litmus-chaos/introduction-to-http-chaos-in-litmuschaos-3hn</link>
      <guid>https://dev.to/litmus-chaos/introduction-to-http-chaos-in-litmuschaos-3hn</guid>
      <description>&lt;p&gt;This article is a getting-started guide for HTTP Chaos in LitmusChaos. We will be talking about&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Introduction to LitmusChaos&lt;/li&gt;
&lt;li&gt; How does HTTP Chaos work — Architecture&lt;/li&gt;
&lt;li&gt; Types of HTTP Chaos Experiments&lt;/li&gt;
&lt;li&gt; HTTP Chaos Demo&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What is LitmusChaos
&lt;/h2&gt;

&lt;p&gt;LitmusChaos is a toolset to do cloud-native chaos engineering. It provides tools to orchestrate chaos on Kubernetes to help SREs find weaknesses in their deployments. SREs use Litmus to run chaos experiments initially in the staging environment and eventually in production to find bugs and vulnerabilities. Fixing the weaknesses leads to increased resilience of the system.&lt;/p&gt;

&lt;p&gt;Litmus takes a cloud-native approach to creating, managing and monitoring chaos. Chaos is orchestrated using the following Kubernetes Custom Resource Definitions (CRDs):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  ChaosEngine: A resource to link a Kubernetes application or Kubernetes node to a ChaosExperiment. ChaosEngine is watched by Litmus’ Chaos-Operator which then invokes Chaos-Experiments&lt;/li&gt;
&lt;li&gt;  ChaosExperiment: A resource to group the configuration parameters of a chaos experiment. ChaosExperiment CRs are created by the operator when experiments are invoked by ChaosEngine.&lt;/li&gt;
&lt;li&gt;  ChaosResult: A resource to hold the results of a chaos experiment. The Chaos-exporter reads the results and exports the metrics into a configured Prometheus server.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For more information, you can visit &lt;a href="https://litmuschaos.io/" rel="noopener noreferrer"&gt;litmuschaos.io&lt;/a&gt; or &lt;a href="https://github.com/litmuschaos/litmus" rel="noopener noreferrer"&gt;github.com/litmuschaos/litmus&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;

&lt;p&gt;The experiments internally use two things to inject HTTP chaos and redirect traffic properly. First, it runs a proxy server that acts as a middleman and modifies the request/response per the experiment type. Second, it creates a routing rule in the network routing table using the IPtables library to redirect all incoming traffic on the targeted service port to the proxy port.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx4f9py92zerbdmpm134l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx4f9py92zerbdmpm134l.png" alt="Without proxy server" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This diagram shows a request without HTTP chaos injected. The request to access Service A comes at port 80 and is forwarded to Service A to be processed&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnls0820dbb8v9fpoolab.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnls0820dbb8v9fpoolab.png" alt="With proxy server" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, after we inject HTTP chaos, the request to access Service A comes to port 80 but is forwarded to port 8000, on which the proxy server listens for requests. This is done by adding a routing rule in the routing table using IPtables. After the proxy server has modified the request, if required, it will forward the request to Service A to be processed. Now the response will follow the same path, the proxy server will modify the response if required and then send it back to the client to complete the request loop.&lt;/p&gt;

&lt;p&gt;The proxy server is running inside the service pod and the service pod routing table is updated by running commands inside the service pod using the &lt;code&gt;nsenter&lt;/code&gt; tool.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1400%2F0%2AZoDUj7m56Bg8mu7f" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1400%2F0%2AZoDUj7m56Bg8mu7f" alt="How proxy server and IPtable are run inside Target Pod" width="1400" height="799"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To facilitate the creation of a proxy server and adding rules to the routing table, a helper pod is run which uses &lt;code&gt;nsenter&lt;/code&gt; to enter inside the target pod to run commands to achieve this.&lt;/p&gt;

&lt;h2&gt;
  
  
  Experiments
&lt;/h2&gt;

&lt;p&gt;Currently, there are 5 different types of HTTP experiments available. They are&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;a href="https://litmuschaos.github.io/litmus/experiments/categories/pods/pod-http-latency/" rel="noopener noreferrer"&gt;HTTP Latency&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://litmuschaos.github.io/litmus/experiments/categories/pods/pod-http-reset-peer/" rel="noopener noreferrer"&gt;HTTP Reset Peer&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://litmuschaos.github.io/litmus/experiments/categories/pods/pod-http-status-code/" rel="noopener noreferrer"&gt;HTTP Status Code&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://litmuschaos.github.io/litmus/experiments/categories/pods/pod-http-modify-header/" rel="noopener noreferrer"&gt;HTTP Modify Header&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://litmuschaos.github.io/litmus/experiments/categories/pods/pod-http-modify-body/" rel="noopener noreferrer"&gt;HTTP Modify Body&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let’s know more about them&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTTP Latency&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;HTTP latency adds latency to the HTTP requests by adding a sleep timer before sending the request forward from the proxy server. It can be used to simulate delayed responses from the APIs. To tune the latency value, use the &lt;code&gt;LATENCY&lt;/code&gt; experiment variable and provide the value in milliseconds.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTTP Reset Peer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;HTTP Reset Peer simulates TCP connection reset error by closing the connection after a specified timeout. It can be used to simulate connection failures. To tune the timeout value, use the &lt;code&gt;RESET_TIMEOUT&lt;/code&gt; experiment variable and provide the value in milliseconds&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTTP Status Code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;HTTP Status Code can modify the status code of the response from the service as well as change the body of the response for the defined status code with a predefined template. It can be used to simulate API failures. To specify the status code using the &lt;code&gt;STATUS_CODE&lt;/code&gt; experiment variable to tune the value. Supported values are available in the docs. You can also provide a comma-separated list of values and the experiment will select a random value from the list to use. If no value is provided then any random value from the supported values will be chosen.&lt;/p&gt;

&lt;p&gt;You can use the &lt;code&gt;MODIFY_RESPONSE_BODY&lt;/code&gt; variable to tune whether the response is changed with a predefined template according to the status code or not.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTTP Modify Header&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;HTTP Modify Header can modify, add or remove headers from a request or response based on provided values. To specify whether you want to modify the request or response, use the &lt;code&gt;HEADER_MODE&lt;/code&gt; variable. You can set it to &lt;code&gt;request&lt;/code&gt; or &lt;code&gt;response&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;HEADERS_MAP&lt;/code&gt; needs a JSON-type input. Suppose you want to add a header &lt;code&gt;litmus&lt;/code&gt; with a value &lt;code&gt;2.12.0&lt;/code&gt; then you should provide it like this &lt;code&gt;{“litmus”: “2.12.0”}&lt;/code&gt; similarly for multiple values as well. To remove a header, you can overwrite its value to an empty string, currently removing the header key is not possible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTTP Modify Body&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;HTTP Modify Body can modify the request/response body completely. This can be used to modify API responses. You can use the &lt;code&gt;RESPONSE_BODY&lt;/code&gt; variable to provide the overwrite value, this can be an HTML, plain text or JSON object.&lt;/p&gt;

&lt;h2&gt;
  
  
  Important Tuneable
&lt;/h2&gt;

&lt;p&gt;These are the tuneable specific to all the HTTP Chaos experiments&lt;/p&gt;

&lt;h3&gt;
  
  
  Toxicity
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;TOXICITY&lt;/code&gt; can be used to provide the probability of requests being affected. Suppose you want only 50% of the requests to be affected, by setting the value &lt;code&gt;TOXICITY&lt;/code&gt; to 50, the probability of a request getting affected is 50%. This doesn’t mean every alternate request will be affected, but each request has a 50–50 chance of being affected. In large requests count, this comes out to be around 50% of requests being affected.&lt;/p&gt;

&lt;h3&gt;
  
  
  Target Service Port
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;TARGET_SERVICE_PORT&lt;/code&gt; is the port of the service you want to target. This should be the port where the application runs at the pod level, not at the service level. This means if the application pod is running the service at port 8080 and we create a service exposing that at port 80, then the target service port should be 8080 and not 80, which is the port at pod-level.&lt;/p&gt;

&lt;p&gt;Proxy Port&lt;/p&gt;

&lt;p&gt;&lt;code&gt;PROXY_PORT&lt;/code&gt; is the port at which the proxy server will be running. You are not required to change the default value (which is 20000) if this port is being used explicitly by any of your other services. If the experiment fails due to a port bind issue for the proxy server, you can change this value to an empty port to make it work.&lt;/p&gt;

&lt;h3&gt;
  
  
  Network Interface
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;NETWORK_INTERFACE&lt;/code&gt; is the interface name for the network which your service is using. The default value is &lt;code&gt;eth0&lt;/code&gt;. If the experiment injection is failing due to a network interface error, you can use this to change it to the correct value.&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;Let us run the HTTP Status Code experiment. For simplicity, we will be injecting chaos into an Nginx service.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm7u2690xiqmra048bdci.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm7u2690xiqmra048bdci.png" alt="Nginx Service" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The service is running on port 80, we will be targeting this.&lt;/p&gt;

&lt;p&gt;If we access the service, we are getting a 200 OK response with the default Nginx webpage. I will be using Postman to verify the status code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3r8zhqrzvsp7umt3lxe0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3r8zhqrzvsp7umt3lxe0.png" alt="Status code before injecting chaos" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, that we have the application set up on which we will be injecting chaos, let’s start creating a chaos scenario with the HTTP Status Code experiment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwliqstiz03rl015276rd.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwliqstiz03rl015276rd.gif" alt="Creating a scenario" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Login to Chaos Centre and get to the Chaos Scenario section. Click on the Schedule a Chaos Scenario button. Select your agent and then select the chaos hub (HTTP experiments are available from ChaosHub version 2.11.0). Add a name for your scenario and move ahead. Now we are at selecting the experiments page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F83j7rgo0mcchw9bjnykj.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F83j7rgo0mcchw9bjnykj.gif" alt="Adding experiment" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will be selecting the &lt;code&gt;generic/pod-http-status-code&lt;/code&gt; experiment from the list of experiments. Moving ahead, we will tune the experiment variables.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6b02ibpvykapjy45tdjh.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6b02ibpvykapjy45tdjh.gif" alt="Tuning the experiment tuneable" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on the pencil icon next to the experiment name to edit the experiment. Now we have to select the app to inject chaos into. The NGINX application we are using is running in the &lt;code&gt;default&lt;/code&gt; namespace, it is of the &lt;code&gt;deployment&lt;/code&gt; kind and has the label &lt;code&gt;app=nginx&lt;/code&gt;. We will skip adding probes to keep it simple. The next section is to tune the experiment variables. Change the &lt;code&gt;STATUS_CODE&lt;/code&gt; to &lt;code&gt;500&lt;/code&gt; and the &lt;code&gt;TARGET_SERVICE_PORT&lt;/code&gt; to the port of the service, in this case, it is &lt;code&gt;port 80&lt;/code&gt;. The &lt;code&gt;MODIFY_RESPONSE_BODY&lt;/code&gt; is a boolean to specify whether the response body should be changed to a pre-defined HTTP template according to the status code. Now we are done with tuning the required variables in this experiment, let’s move ahead and run this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4yjjeq7shz64ezd9ndc7.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4yjjeq7shz64ezd9ndc7.gif" alt="running the experiment" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now LitmusChaos will set up the experiment and then run it, once it starts injecting chaos we will be seeing the status code changing for the service. The output will be something similar to this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftyfk5vbicaxtdcb969tc.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftyfk5vbicaxtdcb969tc.gif" alt="during chaos status code" width="1280" height="720"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That’s it, we have injected HTTP chaos into our application. The experiment passed because we haven’t specified any criteria to verify, we can do this using probes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpio7jfvhy0vmm1kibj9q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpio7jfvhy0vmm1kibj9q.png" alt="Experiment completed graph" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Through this article, we could understand how the HTTP chaos experiment works internally and then talk about the current types of HTTP chaos experiments available. Then we injected the HTTP Status code experiment on a sample NGINX service and saw the experiment in live action. In further tutorial blogs, I will be talking about running the other HTTP experiments as well.&lt;/p&gt;

&lt;p&gt;You can join the LitmusChaos community on &lt;a href="https://github.com/litmuschaos/litmus" rel="noopener noreferrer"&gt;&lt;em&gt;GitHub&lt;/em&gt;&lt;/a&gt;  and &lt;a href="https://www.notepadonline.org/wmtBaRICHQ" rel="noopener noreferrer"&gt;&lt;em&gt;Slack&lt;/em&gt;&lt;/a&gt;. The community is very active and tries to solve queries quickly.&lt;/p&gt;

&lt;p&gt;I hope you enjoyed this journey and found the blog interesting. You can leave your queries or suggestions (appreciation as well) in the comments below.&lt;/p&gt;

&lt;p&gt;Show your ❤️ with a ⭐ on our &lt;a href="https://github.com/litmuschaos/litmus" rel="noopener noreferrer"&gt;Github&lt;/a&gt;. To learn more about Litmus, check out the &lt;a href="https://docs.litmuschaos.io/" rel="noopener noreferrer"&gt;Litmus documentation&lt;/a&gt;. Thank you! 🙏&lt;/p&gt;

&lt;p&gt;Thank you for reading&lt;/p&gt;

&lt;p&gt;Akash Shrivastava&lt;/p&gt;

&lt;p&gt;Software Engineer at Harness&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/in/avaakash/" rel="noopener noreferrer"&gt;Linkedin&lt;/a&gt; | &lt;a href="https://github.com/avaakash" rel="noopener noreferrer"&gt;Github&lt;/a&gt; | &lt;a href="https://instagram.com/avaakash" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; | &lt;a href="https://twitter.com/_avaakash_" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;&lt;/p&gt;

</description>
      <category>chaosengineering</category>
      <category>devops</category>
      <category>http</category>
      <category>litmuschaos</category>
    </item>
  </channel>
</rss>
