Skip to content

Commit 150fb4b

Browse files
alicefrjlebon
authored andcommitted
e2e: assert booted image matches seeded registry image
Verify that the BootcNode booted image and digest match the seeded registry image when available. Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c85ced2 commit 150fb4b

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

test/e2e/bootcnode_test.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414

1515
bootcv1alpha1 "github.com/jlebon/bootc-operator/api/v1alpha1"
1616
"github.com/jlebon/bootc-operator/test/e2e/e2eutil"
17-
testutil "github.com/jlebon/bootc-operator/test/util"
1817
)
1918

2019
const (
@@ -35,13 +34,7 @@ func TestControllerMembership(t *testing.T) {
3534

3635
ctx := context.Background()
3736

38-
// Use real registry image when seeded; fall back to fake ref for
39-
// local dev runs without deploy-bink.
40-
imageRef := testutil.ImageDigestRefA
41-
if ref := env.NodeImageDigestedPullSpec(); ref != "" {
42-
imageRef = ref
43-
}
44-
pool := env.NewPool("workers", imageRef)
37+
pool := env.NewPool("workers", env.NodeImageDigestedPullSpec())
4538
g.Expect(env.Client.Create(ctx, pool)).To(Succeed())
4639

4740
// Wait for BootcNode to appear for the worker.
@@ -56,7 +49,7 @@ func TestControllerMembership(t *testing.T) {
5649
g.Expect(owner.Name).To(Equal(pool.Name))
5750

5851
// Verify desiredImage.
59-
g.Expect(bn.Spec.DesiredImage).To(Equal(imageRef))
52+
g.Expect(bn.Spec.DesiredImage).To(Equal(env.NodeImageDigestedPullSpec()))
6053

6154
// Verify the worker has the managed label.
6255
var node corev1.Node
@@ -83,8 +76,10 @@ func TestControllerMembership(t *testing.T) {
8376
g.Eventually(func(g Gomega) {
8477
g.Expect(env.Client.Get(ctx, client.ObjectKey{Name: nodeName}, &bn)).To(Succeed())
8578
g.Expect(bn.Status.Booted).NotTo(BeNil(), "expected booted status to be populated")
86-
g.Expect(bn.Status.Booted.Image).NotTo(BeEmpty(), "expected booted image to be non-empty")
87-
g.Expect(bn.Status.Booted.ImageDigest).NotTo(BeEmpty(), "expected booted imageDigest to be non-empty")
79+
g.Expect(bn.Status.Booted.Image).To(Equal(env.NodeImageDigestedPullSpec()),
80+
"booted image should match seeded registry image")
81+
g.Expect(bn.Status.Booted.ImageDigest).To(Equal(env.NodeImageDigest()),
82+
"booted image digest should match seeded registry image")
8883
g.Expect(bn.Status.Conditions).To(ContainElement(And(
8984
HaveField("Type", bootcv1alpha1.NodeIdle),
9085
HaveField("Status", metav1.ConditionTrue),

test/e2e/e2eutil/env.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ func (e *Env) AddNode(t *testing.T, opts ...NodeOption) string {
146146
}
147147

148148
if cfg.targetImgRef == "" {
149-
if e.nodeImageRegistry == "" {
150-
t.Fatal("BINK_LOCAL_REGISTRY_NODE_IMAGE must be set (or use WithTargetImgRef)")
149+
if e.nodeImageRegistry == "" || e.nodeImageDigest == "" {
150+
t.Fatal("BINK_LOCAL_REGISTRY_NODE_IMAGE and NODE_IMAGE_DIGEST must be set (or use WithTargetImgRef)")
151151
}
152-
cfg.targetImgRef = e.nodeImageRegistry + ":latest"
152+
cfg.targetImgRef = e.nodeImageRegistry + "@" + e.nodeImageDigest
153153
}
154154

155155
nodeName := e.generateNodeName(t)
@@ -209,6 +209,11 @@ func (e *Env) NodeImageDigestedPullSpec() string {
209209
return e.nodeImageRegistry + "@" + e.nodeImageDigest
210210
}
211211

212+
// NodeImageDigest returns the manifest digest of the seeded node image.
213+
func (e *Env) NodeImageDigest() string {
214+
return e.nodeImageDigest
215+
}
216+
212217
// cleanup gathers diagnostic logs, then deletes test-scoped resources
213218
// and bink nodes.
214219
func (e *Env) cleanup(t *testing.T) {

0 commit comments

Comments
 (0)