Skip to content

Commit 405ed9e

Browse files
committed
Use OCI_BIN to determine where to load images from in integration tests
Modified the Makefile to respect the `OCI_BIN` environment variable, switching from `kind load docker-image` to `kind load image-archive`. This change enables support for both Docker and Podman, depending on the value of `OCI_BIN`. Updated the integration test suite to utilise the new loadimagearchive addon instead of the original loadimage addon. The addon also respects the `OCI_BIN` variable, ensuring images are loaded into kind clusters from the correct container engine. Signed-off-by: Andrew McDermott <amcdermo@redhat.com>
1 parent db665c4 commit 405ed9e

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

Makefile

+6-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,12 @@ push-images: ## Push bpfman-agent and bpfman-operator images.
339339

340340
.PHONY: load-images-kind
341341
load-images-kind: ## Load bpfman-agent, and bpfman-operator images into the running local kind devel cluster.
342-
kind load docker-image ${BPFMAN_OPERATOR_IMG} ${BPFMAN_AGENT_IMG} --name ${KIND_CLUSTER_NAME}
342+
TMP_DIR=$$(mktemp -d -t bpfman-XXXXXX); \
343+
$(OCI_BIN) save -o $$TMP_DIR/bpfman-operator-img.tar ${BPFMAN_OPERATOR_IMG}; \
344+
$(OCI_BIN) save -o $$TMP_DIR/bpfman-agent-img.tar ${BPFMAN_AGENT_IMG}; \
345+
kind load image-archive --name ${KIND_CLUSTER_NAME} $$TMP_DIR/bpfman-operator-img.tar; \
346+
kind load image-archive --name ${KIND_CLUSTER_NAME} $$TMP_DIR/bpfman-agent-img.tar; \
347+
$(RM) -r $$TMP_DIR
343348

344349
.PHONY: bundle-build
345350
bundle-build: ## Build the bundle image.

test/integration/suite_test.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"time"
1212

1313
"github.com/kong/kubernetes-testing-framework/pkg/clusters"
14-
"github.com/kong/kubernetes-testing-framework/pkg/clusters/addons/loadimage"
1514
"github.com/kong/kubernetes-testing-framework/pkg/clusters/types/kind"
1615
"github.com/kong/kubernetes-testing-framework/pkg/environments"
1716
"k8s.io/apimachinery/pkg/api/errors"
@@ -22,6 +21,8 @@ import (
2221
"github.com/bpfman/bpfman-operator/internal"
2322
"github.com/bpfman/bpfman-operator/pkg/client/clientset"
2423
bpfmanHelpers "github.com/bpfman/bpfman-operator/pkg/helpers"
24+
25+
"github.com/bpfman/bpfman-operator/test/integration/loadimagearchive"
2526
)
2627

2728
var (
@@ -50,6 +51,11 @@ const (
5051
func TestMain(m *testing.M) {
5152
logf.SetLogger(zap.New())
5253

54+
ociBin := os.Getenv("OCI_BIN")
55+
if ociBin == "" {
56+
ociBin = "docker" // default if OCI_BIN is not set.
57+
}
58+
5359
// check that we have the bpfman-agent, and bpfman-operator images to use for the tests.
5460
// generally the runner of the tests should have built these from the latest
5561
// changes prior to the tests and fed them to the test suite.
@@ -64,7 +70,7 @@ func TestMain(m *testing.M) {
6470

6571
// to use the provided bpfman-agent, and bpfman-operator images we will need to add
6672
// them as images to load in the test cluster via an addon.
67-
loadImages, err := loadimage.NewBuilder().WithImage(bpfmanAgentImage)
73+
loadImages, err := loadimagearchive.NewBuilder(ociBin).WithImage(bpfmanAgentImage)
6874
exitOnErr(err)
6975
loadImages, err = loadImages.WithImage(bpfmanOperatorImage)
7076
exitOnErr(err)
@@ -93,7 +99,7 @@ func TestMain(m *testing.M) {
9399
})
94100
}
95101

96-
// deploy the BPFMAN Operator and revelevant CRDs
102+
// deploy the BPFMAN Operator and relevant CRDs.
97103
fmt.Println("INFO: deploying bpfman operator to test cluster")
98104
exitOnErr(clusters.KustomizeDeployForCluster(ctx, env.Cluster(), bpfmanKustomize))
99105
if !keepKustomizeDeploys {

0 commit comments

Comments
 (0)