Skip to content

Commit 756e6bc

Browse files
e2e: add composefs update-reboot test
Factor the TestUpdateReboot body into a shared testUpdateReboot helper and use a table-driven pattern to run it against both ostree and composefs disk images. Skip the composefs subtest when the env var is unset. A new WithNodeDiskImage NodeOption lets tests override the VM disk image passed as --node-image to bink node add. The Makefile derives BINK_NODE_DISK_IMAGE_COMPOSEFS from BINK_NODE_DISK_IMAGE by appending -composefs. Bump BINK_COMMIT to pick up the composefs cloud-init fix from bink. Closes: #74 Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
1 parent 6de0da2 commit 756e6bc

4 files changed

Lines changed: 52 additions & 7 deletions

File tree

‎.github/workflows/ci.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
branches: [main]
99

1010
env:
11-
BINK_COMMIT: 3ddb9da3b6e33f5dadd48abdb15ed550bbfe4f31
11+
BINK_COMMIT: 61899a68d69b0de1114e165d24364bf5b8b6da2e
1212

1313
permissions: {}
1414

‎Makefile‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ KUBECONFIG_BINK ?= ./kubeconfig-$(BINK_CLUSTER_NAME)
88
ARTIFACTS ?= $(abspath _output/logs)
99
DEFAULT_KUBE_MINOR ?= 1.35
1010
BINK_NODE_DISK_IMAGE ?= ghcr.io/bootc-dev/bink/node:v$(DEFAULT_KUBE_MINOR)-fedora-44-disk
11+
BINK_NODE_DISK_IMAGE_COMPOSEFS ?= $(BINK_NODE_DISK_IMAGE)-composefs
1112
BINK_LOCAL_REGISTRY_NODE_IMAGE ?= registry.cluster.local:5000/node
1213
# YEAR defines the year value used for substituting the YEAR placeholder in the boilerplate header.
1314
YEAR ?= $(shell date +%Y)
@@ -69,6 +70,7 @@ e2e: ## Run e2e tests (requires: make deploy-bink). V=1 for verbose. RUN=<regex>
6970
cd test/e2e && KUBECONFIG=$(abspath $(KUBECONFIG_BINK)) BINK_CLUSTER_NAME=$(BINK_CLUSTER_NAME) \
7071
$(if $(BINK_NODE_IMAGE),BINK_NODE_IMAGE=$(BINK_NODE_IMAGE)) \
7172
BINK_NODE_DISK_IMAGE=$(BINK_NODE_DISK_IMAGE) \
73+
BINK_NODE_DISK_IMAGE_COMPOSEFS=$(BINK_NODE_DISK_IMAGE_COMPOSEFS) \
7274
BINK_LOCAL_REGISTRY_NODE_IMAGE=$(BINK_LOCAL_REGISTRY_NODE_IMAGE) \
7375
ARTIFACTS=$(ARTIFACTS) \
7476
BINK_NODE_IMAGE_DIGEST=$$(skopeo inspect --tls-verify=false --format '{{.Digest}}' docker://localhost:5000/node:latest) \

‎test/e2e/bootcnode_test.go‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,45 @@ func TestControllerMembership(t *testing.T) {
9191
}).WithTimeout(3 * time.Minute).Should(Succeed())
9292
}
9393

94+
type diskImage struct {
95+
name string
96+
envVar string
97+
}
98+
99+
var diskImages = []diskImage{
100+
{name: "ostree", envVar: "BINK_NODE_DISK_IMAGE"},
101+
{name: "composefs", envVar: "BINK_NODE_DISK_IMAGE_COMPOSEFS"},
102+
}
103+
104+
func forEachDiskImage(t *testing.T, fn func(t *testing.T, nodeOpts ...e2eutil.NodeOption)) {
105+
t.Helper()
106+
for _, di := range diskImages {
107+
t.Run(di.name, func(t *testing.T) {
108+
img := os.Getenv(di.envVar)
109+
if img == "" {
110+
t.Skipf("%s not set", di.envVar)
111+
}
112+
fn(t, e2eutil.WithNodeDiskImage(img))
113+
})
114+
}
115+
}
116+
94117
// TestUpdateReboot provisions a worker node, creates a pool with the
95118
// original image, then updates the pool to a new image and verifies the
96119
// full update lifecycle: staging, reboot, and idle with the new image.
97120
func TestUpdateReboot(t *testing.T) {
121+
forEachDiskImage(t, testUpdateReboot)
122+
}
123+
124+
func testUpdateReboot(t *testing.T, nodeOpts ...e2eutil.NodeOption) {
125+
t.Helper()
126+
98127
g := NewWithT(t)
99128
g.SetDefaultEventuallyTimeout(pollTimeout)
100129
g.SetDefaultEventuallyPollingInterval(pollInterval)
101130

102131
env := e2eutil.New(t)
103-
nodeName := env.AddNode(t)
132+
nodeName := env.AddNode(t, nodeOpts...)
104133

105134
ctx := context.Background()
106135

‎test/e2e/e2eutil/env.go‎

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,10 @@ func New(t *testing.T) *Env {
119119
type NodeOption func(*nodeConfig)
120120

121121
type nodeConfig struct {
122-
memory int
123-
labels map[string]string
124-
targetImgRef string
122+
memory int
123+
labels map[string]string
124+
targetImgRef string
125+
nodeDiskImage string
125126
}
126127

127128
// WithMemory sets the VM memory in MB for the node.
@@ -142,6 +143,14 @@ func WithLabel(key, value string) NodeOption {
142143
}
143144
}
144145

146+
// WithNodeDiskImage sets the VM disk image passed as --node-image
147+
// to bink node add.
148+
func WithNodeDiskImage(img string) NodeOption {
149+
return func(c *nodeConfig) {
150+
c.nodeDiskImage = img
151+
}
152+
}
153+
145154
// WithTargetImgRef sets the target image reference for the node,
146155
// passed as --target-imgref to bink node add. Overrides the automatic
147156
// default that AddNode applies when registry metadata is available.
@@ -180,8 +189,12 @@ func (e *Env) AddNode(t *testing.T, opts ...NodeOption) string {
180189
if cfg.memory > 0 {
181190
args = append(args, "--memory", fmt.Sprintf("%d", cfg.memory))
182191
}
183-
if img := os.Getenv("BINK_NODE_DISK_IMAGE"); img != "" {
184-
args = append(args, "--node-image", img)
192+
diskImage := cfg.nodeDiskImage
193+
if diskImage == "" {
194+
diskImage = os.Getenv("BINK_NODE_DISK_IMAGE")
195+
}
196+
if diskImage != "" {
197+
args = append(args, "--node-image", diskImage)
185198
}
186199
args = append(args, "--target-imgref", cfg.targetImgRef)
187200
t.Logf("Adding node %q...", nodeName)
@@ -324,6 +337,7 @@ func (e *Env) gatherLogs(t *testing.T) {
324337
// Panics if the result exceeds 63 characters (k8s label value limit).
325338
func sanitizeTestName(name string) string {
326339
name = strings.ToLower(name)
340+
name = strings.ReplaceAll(name, "/", "-")
327341
if len(name) > 63 {
328342
panic(fmt.Sprintf("test name %q is %d characters (max 63)", name, len(name)))
329343
}

0 commit comments

Comments
 (0)