Skip to content

Commit

Permalink
run kind targets on the new repo
Browse files Browse the repository at this point in the history
Signed-off-by: Mohamed Mahmoud <mmahmoud@redhat.com>
  • Loading branch information
msherif1234 committed May 30, 2024
1 parent 8c60b32 commit cc1e09b
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 41 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,61 @@ jobs:
fail_ci_if_error: true
verbose: true

kubernetes-integration-tests:
runs-on: ubuntu-latest
strategy:
matrix:
go: ['1.21']
env:
BPFMAN_AGENT_IMG: quay.io/bpfman/bpfman-agent:int-test
BPFMAN_OPERATOR_IMG: quay.io/bpfman/bpfman-operator:int-test
XDP_PASS_PRIVATE_IMAGE_CREDS: ${{ secrets.XDP_PASS_PRIVATE_IMAGE_CREDS }}
steps:
- name: Check disk space
run: df -h

- name: Free up space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
sudo rm -rf /usr/local/lib/android
- name: Check disk space again
run: df -h

- name: set up go 1.x
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}

- name: cache go modules
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-build-codegen-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-build-codegen-
- name: checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: build images
run: make build-images

- name: run integration tests
run: make test-integration

- name: Check disk space
run: df -h

## Upload diagnostics if integration test step failed.
- name: upload diagnostics
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: kubernetes-integration-test-diag
path: /tmp/ktf-diag*
if-no-files-found: ignore
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,13 @@ build-images: ## Build bpfman, bpfman-agent, and bpfman-operator images.
docker build -t ${BPFMAN_AGENT_IMG} -f Containerfile.bpfman-agent ./

.PHONY: push-images
push-images: ## Push bpfman, bpfman-agent, bpfman-operator images.
push-images: ## Push bpfman-agent, bpfman-operator images.
docker push ${BPFMAN_OPERATOR_IMG}
docker push ${BPFMAN_AGENT_IMG}
docker push ${BPFMAN_IMG}

.PHONY: load-images-kind
load-images-kind: ## Load bpfman, bpfman-agent, and bpfman-operator images into the running local kind devel cluster.
kind load docker-image ${BPFMAN_IMG} ${BPFMAN_OPERATOR_IMG} ${BPFMAN_AGENT_IMG} --name ${KIND_CLUSTER_NAME}
load-images-kind: ## Load bpfman-agent, and bpfman-operator images into the running local kind devel cluster.
kind load docker-image ${BPFMAN_OPERATOR_IMG} ${BPFMAN_AGENT_IMG} --name ${KIND_CLUSTER_NAME}

.PHONY: bundle-build
bundle-build: ## Build the bundle image.
Expand Down Expand Up @@ -361,6 +360,10 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified
setup-kind: ## Setup Kind cluster
kind delete cluster --name ${KIND_CLUSTER_NAME} && kind create cluster --config hack/kind-config.yaml --name ${KIND_CLUSTER_NAME}

.PHONY: destroy-kind
destroy-kind: ## Destroy Kind cluster
kind delete cluster --name ${KIND_CLUSTER_NAME}

## Default deploy target is KIND based with its CSI driver initialized.
.PHONY: deploy
deploy: manifests kustomize ## Deploy bpfman-operator to the K8s cluster specified in ~/.kube/config with the csi driver initialized.
Expand Down
2 changes: 1 addition & 1 deletion config/test/patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ metadata:
namespace: kube-system
data:
bpfman.agent.image: quay.io/bpfman/bpfman-agent:int-test
bpfman.image: quay.io/bpfman/bpfman:int-test
bpfman.image: quay.io/bpfman/bpfman:latest
bpfman.log.level: bpfman=debug
bpfman.agent.log.level: debug
2 changes: 1 addition & 1 deletion controllers/bpfman-agent/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ func (r *ReconcilerCommon) updateStatus(ctx context.Context, bpfProgram *bpfmani
meta.SetStatusCondition(&bpfProgram.Status.Conditions, cond.Condition())

r.Logger.V(1).Info("Updating bpfProgram condition", "bpfProgram", bpfProgram.Name, "condition", cond.Condition().Type)
if err := r.Update(ctx, bpfProgram); err != nil {
if err := r.Status().Update(ctx, bpfProgram); err != nil {
r.Logger.Error(err, "failed to set bpfProgram object status")
}

Expand Down
4 changes: 2 additions & 2 deletions controllers/bpfman-operator/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ func (r *ReconcilerCommon) updateCondition(ctx context.Context, obj client.Objec

meta.SetStatusCondition(conditions, cond.Condition(message))

if err := r.Update(ctx, obj); err != nil {
r.Logger.V(1).Info("failed to set *Program object status...requeuing")
if err := r.Status().Update(ctx, obj); err != nil {
r.Logger.V(1).Info("failed to set *Program object status...requeuing", "error", err)
return ctrl.Result{Requeue: true, RequeueAfter: retryDurationOperator}, nil
}

Expand Down
6 changes: 3 additions & 3 deletions test/integration/kprobe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

const (
kprobeGoCounterKustomize = "../../../examples/config/default/go-kprobe-counter"
kprobeGoCounterKustomize = "https://github.com/bpfman/bpfman/examples/config/default/go-kprobe-counter/?timeout=120&ref=main"
kprobeGoCounterUserspaceNs = "go-kprobe-counter"
kprobeGoCounterUserspaceDsName = "go-kprobe-counter-ds"
)
Expand All @@ -38,8 +38,8 @@ func TestKprobeGoCounter(t *testing.T) {
require.NoError(t, err)
return daemon.Status.DesiredNumberScheduled == daemon.Status.NumberAvailable
},
// Wait 5 minutes since cosign is slow, https://github.com/bpfman/bpfman/issues/1043
5*time.Minute, 10*time.Second)
// Wait 5 minutes since cosign is slow, https://github.com/bpfman/bpfman/issues/1043
5*time.Minute, 10*time.Second)

pods, err := env.Cluster().Client().CoreV1().Pods(kprobeGoCounterUserspaceNs).List(ctx, metav1.ListOptions{LabelSelector: "name=go-kprobe-counter"})
require.NoError(t, err)
Expand Down
22 changes: 5 additions & 17 deletions test/integration/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,8 @@ var (

// These images should already be built on the node so they can
// be loaded into kind.
bpfmanImage = os.Getenv("BPFMAN_IMG")
bpfmanAgentImage = os.Getenv("BPFMAN_AGENT_IMG")
bpfmanOperatorImage = os.Getenv("BPFMAN_OPERATOR_IMG")
tcExampleUsImage = "quay.io/bpfman-userspace/go-tc-counter:latest"
xdpExampleUsImage = "quay.io/bpfman-userspace/go-xdp-counter:latest"
tpExampleUsImage = "quay.io/bpfman-userspace/go-tracepoint-counter:latest"

existingCluster = os.Getenv("USE_EXISTING_KIND_CLUSTER")
keepTestCluster = func() bool { return os.Getenv("TEST_KEEP_CLUSTER") == "true" || existingCluster != "" }()
Expand All @@ -50,30 +46,22 @@ const (
)

func TestMain(m *testing.M) {
// check that we have the bpfman, bpfman-agent, and bpfman-operator images to use for the tests.
// check that we have the bpfman-agent, and bpfman-operator images to use for the tests.
// generally the runner of the tests should have built these from the latest
// changes prior to the tests and fed them to the test suite.
if bpfmanImage == "" || bpfmanAgentImage == "" || bpfmanOperatorImage == "" {
exitOnErr(fmt.Errorf("BPFMAN_IMG, BPFMAN_AGENT_IMG, and BPFMAN_OPERATOR_IMG must be provided"))
if bpfmanAgentImage == "" || bpfmanOperatorImage == "" {
exitOnErr(fmt.Errorf("BPFMAN_AGENT_IMG, and BPFMAN_OPERATOR_IMG must be provided"))
}

ctx, cancel = context.WithCancel(context.Background())
defer cancel()

// to use the provided bpfman, bpfman-agent, and bpfman-operator images we will need to add
// to use the provided bpfman-agent, and bpfman-operator images we will need to add
// them as images to load in the test cluster via an addon.
loadImages, err := loadimage.NewBuilder().WithImage(bpfmanImage)
exitOnErr(err)
loadImages, err = loadImages.WithImage(bpfmanAgentImage)
loadImages, err := loadimage.NewBuilder().WithImage(bpfmanAgentImage)
exitOnErr(err)
loadImages, err = loadImages.WithImage(bpfmanOperatorImage)
exitOnErr(err)
loadImages, err = loadImages.WithImage(tcExampleUsImage)
exitOnErr(err)
loadImages, err = loadImages.WithImage(xdpExampleUsImage)
exitOnErr(err)
loadImages, err = loadImages.WithImage(tpExampleUsImage)
exitOnErr(err)

if existingCluster != "" {
fmt.Printf("INFO: existing kind cluster %s was provided\n", existingCluster)
Expand Down
8 changes: 4 additions & 4 deletions test/integration/tc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

const (
tcGoCounterKustomize = "../../../examples/config/default/go-tc-counter"
tcGoCounterKustomize = "https://github.com/bpfman/bpfman/examples/config/default/go-tc-counter/?timeout=120&ref=main"
tcGoCounterUserspaceNs = "go-tc-counter"
tcGoCounterUserspaceDsName = "go-tc-counter-ds"
)
Expand All @@ -36,9 +36,9 @@ func TestTcGoCounter(t *testing.T) {
daemon, err := env.Cluster().Client().AppsV1().DaemonSets(tcGoCounterUserspaceNs).Get(ctx, tcGoCounterUserspaceDsName, metav1.GetOptions{})
require.NoError(t, err)
return daemon.Status.DesiredNumberScheduled == daemon.Status.NumberAvailable
},
// Wait 5 minutes since cosign is slow, https://github.com/bpfman/bpfman/issues/1043
5 * time.Minute, 10 * time.Second)
},
// Wait 5 minutes since cosign is slow, https://github.com/bpfman/bpfman/issues/1043
5*time.Minute, 10*time.Second)

pods, err := env.Cluster().Client().CoreV1().Pods(tcGoCounterUserspaceNs).List(ctx, metav1.ListOptions{LabelSelector: "name=go-tc-counter"})
require.NoError(t, err)
Expand Down
8 changes: 4 additions & 4 deletions test/integration/tracepoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

const (
tracepointGoCounterKustomize = "../../../examples/config/default/go-tracepoint-counter"
tracepointGoCounterKustomize = "https://github.com/bpfman/bpfman/examples/config/default/go-tracepoint-counter/?timeout=120&ref=main"
tracepointGoCounterUserspaceNs = "go-tracepoint-counter"
tracepointGoCounterUserspaceDsName = "go-tracepoint-counter-ds"
)
Expand All @@ -38,9 +38,9 @@ func TestTracepointGoCounter(t *testing.T) {
require.NoError(t, err)
return daemon.Status.DesiredNumberScheduled == daemon.Status.NumberAvailable
},
// Wait 5 minutes since cosign is slow, https://github.com/bpfman/bpfman/issues/1043
5 * time.Minute, 10 * time.Second)
// Wait 5 minutes since cosign is slow, https://github.com/bpfman/bpfman/issues/1043
5*time.Minute, 10*time.Second)

pods, err := env.Cluster().Client().CoreV1().Pods(tracepointGoCounterUserspaceNs).List(ctx, metav1.ListOptions{LabelSelector: "name=go-tracepoint-counter"})
require.NoError(t, err)
goTracepointCounterPod := pods.Items[0]
Expand Down
8 changes: 4 additions & 4 deletions test/integration/uprobe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import (
)

const (
uprobeGoCounterKustomize = "../../../examples/config/default/go-uprobe-counter"
uprobeGoCounterKustomize = "https://github.com/bpfman/bpfman/examples/config/default/go-uprobe-counter/?timeout=120&ref=main"
uprobeGoCounterUserspaceNs = "go-uprobe-counter"
uprobeGoCounterUserspaceDsName = "go-uprobe-counter-ds"
targetKustomize = "../../../examples/config/default/go-target"
targetKustomize = "https://github.com/bpfman/bpfman/examples/config/default/go-target/?timeout=120&ref=main"
targetUserspaceNs = "go-target"
targetUserspaceDsName = "go-target-ds"
)
Expand All @@ -41,8 +41,8 @@ func TestUprobeGoCounter(t *testing.T) {
require.NoError(t, err)
return daemon.Status.DesiredNumberScheduled == daemon.Status.NumberAvailable
},
// Wait 5 minutes since cosign is slow, https://github.com/bpfman/bpfman/issues/1043
5*time.Minute, 10*time.Second)
// Wait 5 minutes since cosign is slow, https://github.com/bpfman/bpfman/issues/1043
5*time.Minute, 10*time.Second)

t.Log("deploying uprobe counter program")
require.NoError(t, clusters.KustomizeDeployForCluster(ctx, env.Cluster(), uprobeGoCounterKustomize))
Expand Down
2 changes: 1 addition & 1 deletion test/integration/xdp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
)

const (
xdpGoCounterKustomize = "../../../examples/config/default/go-xdp-counter"
xdpGoCounterKustomize = "https://github.com/bpfman/bpfman/examples/config/default/go-xdp-counter/?timeout=120&ref=main"
xdpGoCounterUserspaceNs = "go-xdp-counter"
xdpGoCounterUserspaceDsName = "go-xdp-counter-ds"
)
Expand Down

0 comments on commit cc1e09b

Please sign in to comment.