You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`GiteaClient` and `KubeClient` follow the same pattern. In production we use HTTP-backed implementations. In tests we swap in mocks that track calls and can simulate failures.
85
84
86
-
This lets us validate the full teardown lifecycle without spinning up a single server:
85
+
This lets us validate the full teardown lifecycle without spinning up a single server. The following pseudo-code illustrates the approach — seed an idle node and assert both the state transition and the external API call:
Each call to `teardown_step` advances the node exactly one state forward. The test verifies the exact ordering of deregister, drain and remove, and the mocks let us assert which API calls were made along the way.
118
+
Each call to `teardown_step` advances the node exactly one state forward. More importantly, the test verifies both the ordering of deregister, drain and remove and the side effects at each step. That is the practical benefit of the trait-based split: we can assert which external API call happened without touching real cloud resources.
Copy file name to clipboardExpand all lines: docs/blog/2026/03-30-gitea-ci-autoscaler/index.html
+12-5Lines changed: 12 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -27,8 +27,6 @@
27
27
<divid="blogpage">
28
28
<divclass="date">2026-03-30</div>
29
29
30
-
<divclass="hidden">hidden</div>
31
-
32
30
<h1class="title">
33
31
Autoscaling CI for Gitea in Rust
34
32
</h1>
@@ -88,17 +86,26 @@ <h1 id="testing-without-cloud-resources">Testing without cloud resources</h1>
88
86
</span><spanstyle="color:#89ddff;">}
89
87
</span></code></pre>
90
88
<p><code>GiteaClient</code> and <code>KubeClient</code> follow the same pattern. In production we use HTTP-backed implementations. In tests we swap in mocks that track calls and can simulate failures.</p>
91
-
<p>This lets us validate the full teardown lifecycle without spinning up a single server:</p>
89
+
<p>This lets us validate the full teardown lifecycle without spinning up a single server. The following pseudo-code illustrates the approach — seed an idle node and assert both the state transition and the external API call:</p>
<p>Each call to <code>teardown_step</code> advances the node exactly one state forward. The test verifies the exact ordering of deregister, drain and remove, and the mocks let us assert which API calls were made along the way.</p>
119
+
<p>Each call to <code>teardown_step</code> advances the node exactly one state forward. More importantly, the test verifies both the ordering of deregister, drain and remove and the side effects at each step. That is the practical benefit of the trait-based split: we can assert which external API call happened without touching real cloud resources.</p>
113
120
<h1id="further-steps">Further steps</h1>
114
121
<p>The current version is built around our stack: Hetzner and K3s. But the trait-based architecture also lends itself to a few obvious extensions:</p>
0 commit comments