<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><generator uri="https://gohugo.io/" version="0.88.1">Hugo</generator><title type="html">Potato Stones</title><subtitle type="html">Dale Emery's Apache Geode Development Blog</subtitle><link href="https://demery-pivotal.github.io/" rel="alternate" type="text/html" title="HTML"/><link href="https://demery-pivotal.github.io/atom.xml" rel="self" type="application/atom+xml" title="Atom"/><updated>2021-09-28T23:51:34+00:00</updated><id>https://demery-pivotal.github.io/</id><entry><title type="html">Testability</title><link href="https://demery-pivotal.github.io/blog/testability/?utm_source=atom_feed" rel="alternate" type="text/html" hreflang="en"/><id>https://demery-pivotal.github.io/blog/testability/</id><published>2021-09-26T00:00:00+00:00</published><updated>2021-09-28T16:50:47-07:00</updated><content type="html"><![CDATA[<p><strong>Testability</strong> is the ease of determining how well a component satisfies its responsibilities.
A component&rsquo;s testability depends on how easy it is
to <strong>control</strong> the variables that affect the component and
to <strong>observe</strong> the variables affected by it.</p>
<p>Suppose we want to test some responsibility of a technical component.
The component might be as small as a single, standalone function
or as large as a multi-cluster distributed cache running on multiple machines
in different parts of the world.
Regardless of the component&rsquo;s size,
we test the responsibility by:</p>
<ol>
<li>Establishing relevant preconditions in the component and in its environment.</li>
<li>Sending the component a message that triggers it to carry out the responsibility.</li>
<li>Comparing the results that the system produced to the results we want.</li>
</ol>
<p>Step 1 requires us
to <em>control</em> the variables<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup> that affect the component
as it carries out the responsibility.
Step 3 requires us
to <em>observe</em> the variables affected by the component
as it carries out the responsibilty.</p>
<p>The easier it is to control and observe these variables,
the easier the component is to test.
The harder it is to control and observe these variables,
the harder the component is to test.</p>
<blockquote>
<p><strong>Testability = Controllability + Observability.</strong></p>
</blockquote>
<div class="gblog-post__anchorwrap">
    <h2 id="improving-testability">
        Improving Testability
        <a data-clipboard-text="https://demery-pivotal.github.io/blog/testability/#improving-testability" class="gblog-post__anchor gblog-post__anchor--right clip" aria-label="Anchor Improving Testability" href="#improving-testability">
            <svg class="icon gblog_link"><use xlink:href="#gblog_link"></use></svg>
        </a>
    </h2>
</div><p>To make a component more testable:</p>
<ul>
<li>Identify the variables that affect how the component carries out its responsibilities, and make those variables easier to control.</li>
<li>Identify the variables affected by the component as it carries out its responsibilities, and make those variables easier to observe.</li>
</ul>
<p>These steps may seem obvious or simple.
The next section hints at some of the factors
that make these seemingly simple, obvious tasks
less obvious and simple.
In future posts I&rsquo;ll have more to say about these challenges and how to address them.</p>
<div class="gblog-post__anchorwrap">
    <h2 id="factors-that-affect-testability">
        Factors that Affect Testability
        <a data-clipboard-text="https://demery-pivotal.github.io/blog/testability/#factors-that-affect-testability" class="gblog-post__anchor gblog-post__anchor--right clip" aria-label="Anchor Factors that Affect Testability" href="#factors-that-affect-testability">
            <svg class="icon gblog_link"><use xlink:href="#gblog_link"></use></svg>
        </a>
    </h2>
</div><p>Any factor that makes key varaibles
harder to control and observe
makes a component less testable.</p>
<p><strong>Component Complexity.</strong>
The larger and more complex a component,
the more variables are likely to be involved in its responsibilities.
Refactoring a large component into smaller, more focused subcomponents
can greatly reduce the number of variables
that each test must control or observe.</p>
<p><strong>Coupling.</strong>
The more coupled a component is to other components,
the harder it is to control and observe the variables involved in its responsibilities.
Coupling makes a component depend <em>indirectly</em>
on the variables that affect its collaborators.
Testing a highly-coupled component
may require controlling and observing key variables <em>indirectly</em>
through the component&rsquo;s collaborators,
the collaborators' collaborators,
the collaborators' collaborators' collaborators,
and so on through many layers of indirection.</p>
<p><strong>Visibility of Dependencies.</strong>
Coupling is especially challenging when the component&rsquo;s dependencies are <em>hidden.</em>
A <em>hidden dependency</em> is any dependency
that a component acquires in some way other than through its own interface.
A component has a hidden dependency
on any component it creates or that it retrieves from a hard-coded source,
such as a static method of another class.
Hidden dependencies can make key variables extremely difficult to control or observe.</p>
<section class="footnotes" role="doc-endnotes">
<hr>
<ol>
<li id="fn:1" role="doc-endnote">
<p>Note that by <em>variable</em> I mean <em>anything that can vary.</em> For an example of how even the simplest software involves a multitude of variables, see <a class="gblog-markdown__link" href="https://vimeo.com/34356209">Testing With Variables</a>, a 20-minute video by Elisabeth Hendrickson and me.&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</section>]]></content></entry><entry><title type="html">Diagnosing Intermittent Failures</title><link href="https://demery-pivotal.github.io/blog/diagnosing-intermittent-failures/?utm_source=atom_feed" rel="alternate" type="text/html" hreflang="en"/><id>https://demery-pivotal.github.io/blog/diagnosing-intermittent-failures/</id><published>2021-08-10T00:00:00+00:00</published><updated>2021-08-10T11:31:22-07:00</updated><content type="html"><![CDATA[<p>To diagnose a frustrating intermittent failure, start by distinguishing three key ideas: failure, fault, and conditions. Then take a systematic approach to exploring the conditions and seeking the fault.</p>
<div class="gblog-post__anchorwrap">
    <h2 id="anatomy-of-an-intermittent-failure">
        Anatomy of an Intermittent Failure
        <a data-clipboard-text="https://demery-pivotal.github.io/blog/diagnosing-intermittent-failures/#anatomy-of-an-intermittent-failure" class="gblog-post__anchor gblog-post__anchor--right clip" aria-label="Anchor Anatomy of an Intermittent Failure" href="#anatomy-of-an-intermittent-failure">
            <svg class="icon gblog_link"><use xlink:href="#gblog_link"></use></svg>
        </a>
    </h2>
</div><p>An intermittent failure always includes these three parts: <em>Failure</em>, <em>Fault</em>, and <em>Conditions</em>.</p>
<ul>
<li>A <strong>failure</strong> is an incorrect result.</li>
<li>A <strong>fault</strong> is an incorrect process, step, or data definition.</li>
<li><strong>Conditions</strong> are combinations of inputs, states, and events that affect the results.</li>
</ul>
<p>An <strong>intermittent failure</strong> means that some component has a fault that under some conditions causes a failure.</p>
<div class="gblog-post__anchorwrap">
    <h2 id="laws-of-intermittent-failures">
        Laws of Intermittent Failures
        <a data-clipboard-text="https://demery-pivotal.github.io/blog/diagnosing-intermittent-failures/#laws-of-intermittent-failures" class="gblog-post__anchor gblog-post__anchor--right clip" aria-label="Anchor Laws of Intermittent Failures" href="#laws-of-intermittent-failures">
            <svg class="icon gblog_link"><use xlink:href="#gblog_link"></use></svg>
        </a>
    </h2>
</div><blockquote>
<p>If there&rsquo;s a failure, there&rsquo;s a fault.</p>
</blockquote>
<p>If there&rsquo;s a failure (intermittent or not), some process, step, or data definition is incorrect. The fault may be in the system we&rsquo;re testing. It may be in the test. There may be multiple faults. But if there&rsquo;s a failure, there is at least one fault.</p>
<blockquote>
<p>Even if the failure is intermittent, the fault is not.</p>
</blockquote>
<p>The fault is present even when no failure occurs. We may not know what the fault is, or where to look for it, but it&rsquo;s there.</p>
<blockquote>
<p>If the failure is intermittent, success or failure must depend on conditions that can vary.</p>
</blockquote>
<p>If the fault is always present, the difference between success and failure must come from <em>varying conditions.</em> These varying conditions determine (among other things) whether the fault is executed, at what moment, and with what values.</p>
<blockquote>
<p>If the failure is intermittent, we are not in control of the conditions that determine success or failure.</p>
</blockquote>
<p>We call a failure <em>intermittent</em> only when we cannot produce it at will. We cannot produce the failure at will because at least one relevant condition is not under our control. And very often we don&rsquo;t even know what the relevant conditions are.</p>
<div class="gblog-post__anchorwrap">
    <h2 id="diagnosing-with-variables">
        Diagnosing with Variables
        <a data-clipboard-text="https://demery-pivotal.github.io/blog/diagnosing-intermittent-failures/#diagnosing-with-variables" class="gblog-post__anchor gblog-post__anchor--right clip" aria-label="Anchor Diagnosing with Variables" href="#diagnosing-with-variables">
            <svg class="icon gblog_link"><use xlink:href="#gblog_link"></use></svg>
        </a>
    </h2>
</div><p>Sometimes you can diagnose an intermittent failure quickly, guided by your intuition and expertise. But if you&rsquo;re frustrated, that&rsquo;s a sign that some important condition is outside of your control, and perhaps not yet in your awareness.</p>
<p>Consider trying this systematic approach to diagnosis, to generate a richer set of ideas to power your intuition and expertise.</p>
<div class="gblog-post__anchorwrap">
    <h3 id="step-1-brainstorm-variables">
        Step 1: Brainstorm Variables
        <a data-clipboard-text="https://demery-pivotal.github.io/blog/diagnosing-intermittent-failures/#step-1-brainstorm-variables" class="gblog-post__anchor gblog-post__anchor--right clip" aria-label="Anchor Step 1: Brainstorm Variables" href="#step-1-brainstorm-variables">
            <svg class="icon gblog_link"><use xlink:href="#gblog_link"></use></svg>
        </a>
    </h3>
</div><p>Write down every variable you can think of that could possibly be involved. By <em>variable,</em> I don&rsquo;t mean just the things you might declare in some source code. I mean <em>anything that could vary.</em><sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>
For this step in particular, it&rsquo;s often helpful to team up with a few other people.</p>
<p>During this brainstorming step, do not limit yourself to variables that you think are <em>likely</em> to be involved. Accept any variable that could <em>possibly</em> be involved… and don&rsquo;t be too quick to conclude that a variable could <em>not</em> be involved. If you think of it, write it down. We will assess the utility of these variables in a later step.</p>
<p>Here are some ideas for identifying variables:</p>
<ul>
<li><strong>Start with the result.</strong> If the failure is intermittent, we know the result is variable. Write it down as a starting point.</li>
<li><strong>Include any conditions you know or suspect.</strong> If you know of any conditions that seem to be involved, or if you <em>suspect</em> any, express them as variables and add them to the list. Even if you don&rsquo;t know how or why a condition is involved, writing it down can help trigger new ideas.</li>
<li><strong>Work forward from each variable on the list.</strong> If this variable were to change, what other variables might be affected?</li>
<li><strong>Work backward from each variable on the list.</strong> What other variables might affect the value of this one?</li>
<li><strong>Look for states, durations, and the order of events.</strong> Intermittent failures very often arise when a specific event occurs while some part of the system is in a specific state.</li>
</ul>
<div class="gblog-post__anchorwrap">
    <h3 id="step-2-categorize-the-variables">
        Step 2: Categorize the Variables
        <a data-clipboard-text="https://demery-pivotal.github.io/blog/diagnosing-intermittent-failures/#step-2-categorize-the-variables" class="gblog-post__anchor gblog-post__anchor--right clip" aria-label="Anchor Step 2: Categorize the Variables" href="#step-2-categorize-the-variables">
            <svg class="icon gblog_link"><use xlink:href="#gblog_link"></use></svg>
        </a>
    </h3>
</div><p>Organize the variables into categories (and sub-categories, and sub-sub-categories, …), using whatever criteria seem appropriate.</p>
<p>As you categorize, you will very likely think of additional variables. Write them down and include them in your categorization.</p>
<p>You may want to use mind-mapping software or outlining software for this. Any tool that helps you categorize the variables will do.</p>
<p>Instead of categorizing, or in addition, you may want to create a graph of how the variables affect each other. Any kind of model helps you understand the relevant variables will do.</p>
<div class="gblog-post__anchorwrap">
    <h3 id="step-3-select-a-variable">
        Step 3: Select a Variable
        <a data-clipboard-text="https://demery-pivotal.github.io/blog/diagnosing-intermittent-failures/#step-3-select-a-variable" class="gblog-post__anchor gblog-post__anchor--right clip" aria-label="Anchor Step 3: Select a Variable" href="#step-3-select-a-variable">
            <svg class="icon gblog_link"><use xlink:href="#gblog_link"></use></svg>
        </a>
    </h3>
</div><p>Assess the categories and pick the one whose seem most likely to affect the results.</p>
<p>Assess the variables in the selected category and pick the one that seems most likely to affect the results.</p>
<div class="gblog-post__anchorwrap">
    <h3 id="step-4-experiment-by-varying-the-variable">
        Step 4: Experiment by Varying the Variable
        <a data-clipboard-text="https://demery-pivotal.github.io/blog/diagnosing-intermittent-failures/#step-4-experiment-by-varying-the-variable" class="gblog-post__anchor gblog-post__anchor--right clip" aria-label="Anchor Step 4: Experiment by Varying the Variable" href="#step-4-experiment-by-varying-the-variable">
            <svg class="icon gblog_link"><use xlink:href="#gblog_link"></use></svg>
        </a>
    </h3>
</div><p>Assess the possible values of the selected variable and pick one that seems most likely to increase your understanding of what is happening.</p>
<p>Gain control of the selected variable<sup id="fnref:2"><a href="#fn:2" class="footnote-ref" role="doc-noteref">2</a></sup>, and arrange for it to have the selected value.</p>
<p>Run the test, or exercise the system in some other way, and observe the results.</p>
<p>Repeat with different values for the selected variable as long as it seems fruitful.</p>
<div class="gblog-post__anchorwrap">
    <h3 id="step-5-repeat-as-necessary">
        Step 5: Repeat as Necessary
        <a data-clipboard-text="https://demery-pivotal.github.io/blog/diagnosing-intermittent-failures/#step-5-repeat-as-necessary" class="gblog-post__anchor gblog-post__anchor--right clip" aria-label="Anchor Step 5: Repeat as Necessary" href="#step-5-repeat-as-necessary">
            <svg class="icon gblog_link"><use xlink:href="#gblog_link"></use></svg>
        </a>
    </h3>
</div><p>Given what you&rsquo;ve learned from your experiments so far, return to whatever earlier step is most likely to increase your understanding.</p>
<section class="footnotes" role="doc-endnotes">
<hr>
<ol>
<li id="fn:1" role="doc-endnote">
<p>For more ideas about variables and how to identify them, see <a class="gblog-markdown__link" href="https://vimeo.com/34356209">Testing With Variables</a>, a 20-minute video by Elisabeth Hendrickson and me.&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
<li id="fn:2" role="doc-endnote">
<p>Yeah, I know: Easier said than done.&#160;<a href="#fnref:2" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</section>]]></content></entry></feed>