Skip to content

Commit 5330e8f

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 223922b commit 5330e8f

4 files changed

Lines changed: 55 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: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,44 @@ func TestControllerMembership(t *testing.T) {
9595
// original image, then updates the pool to a new image and verifies the
9696
// full update lifecycle: staging, reboot, and idle with the new image.
9797
func TestUpdateReboot(t *testing.T) {
98+
tests := []struct {
99+
name string
100+
envVar string
101+
}{
102+
{
103+
name: "ostree",
104+
envVar: "BINK_NODE_DISK_IMAGE",
105+
},
106+
{
107+
name: "composefs",
108+
envVar: "BINK_NODE_DISK_IMAGE_COMPOSEFS",
109+
},
110+
}
111+
112+
for _, tc := range tests {
113+
t.Run(tc.name, func(t *testing.T) {
114+
var nodeOpts []e2eutil.NodeOption
115+
if tc.envVar != "" {
116+
img := os.Getenv(tc.envVar)
117+
if img == "" {
118+
t.Skipf("%s not set", tc.envVar)
119+
}
120+
nodeOpts = append(nodeOpts, e2eutil.WithNodeDiskImage(img))
121+
}
122+
testUpdateReboot(t, nodeOpts...)
123+
})
124+
}
125+
}
126+
127+
func testUpdateReboot(t *testing.T, nodeOpts ...e2eutil.NodeOption) {
128+
t.Helper()
129+
98130
g := NewWithT(t)
99131
g.SetDefaultEventuallyTimeout(pollTimeout)
100132
g.SetDefaultEventuallyPollingInterval(pollInterval)
101133

102134
env := e2eutil.New(t)
103-
nodeName := env.AddNode(t)
135+
nodeName := env.AddNode(t, nodeOpts...)
104136

105137
ctx := context.Background()
106138

test/e2e/e2eutil/env.go

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

119119
type nodeConfig struct {
120-
memory int
121-
labels map[string]string
122-
targetImgRef string
120+
memory int
121+
labels map[string]string
122+
targetImgRef string
123+
nodeDiskImage string
123124
}
124125

125126
// WithMemory sets the VM memory in MB for the node.
@@ -140,6 +141,14 @@ func WithLabel(key, value string) NodeOption {
140141
}
141142
}
142143

144+
// WithNodeDiskImage sets the VM disk image passed as --node-image
145+
// to bink node add.
146+
func WithNodeDiskImage(img string) NodeOption {
147+
return func(c *nodeConfig) {
148+
c.nodeDiskImage = img
149+
}
150+
}
151+
143152
// WithTargetImgRef sets the target image reference for the node,
144153
// passed as --target-imgref to bink node add. Overrides the automatic
145154
// default that AddNode applies when registry metadata is available.
@@ -178,8 +187,12 @@ func (e *Env) AddNode(t *testing.T, opts ...NodeOption) string {
178187
if cfg.memory > 0 {
179188
args = append(args, "--memory", fmt.Sprintf("%d", cfg.memory))
180189
}
181-
if img := os.Getenv("BINK_NODE_DISK_IMAGE"); img != "" {
182-
args = append(args, "--node-image", img)
190+
diskImage := cfg.nodeDiskImage
191+
if diskImage == "" {
192+
diskImage = os.Getenv("BINK_NODE_DISK_IMAGE")
193+
}
194+
if diskImage != "" {
195+
args = append(args, "--node-image", diskImage)
183196
}
184197
args = append(args, "--target-imgref", cfg.targetImgRef)
185198
t.Logf("Adding node %q...", nodeName)
@@ -289,6 +302,7 @@ func (e *Env) gatherLogs(t *testing.T) {
289302
// Panics if the result exceeds 63 characters (k8s label value limit).
290303
func sanitizeTestName(name string) string {
291304
name = strings.ToLower(name)
305+
name = strings.ReplaceAll(name, "/", "-")
292306
if len(name) > 63 {
293307
panic(fmt.Sprintf("test name %q is %d characters (max 63)", name, len(name)))
294308
}

0 commit comments

Comments
 (0)