Skip to content

Commit

Permalink
add k8s intg test to pull pr workflow
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 29, 2024
1 parent f34acc0 commit 73ccdb0
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 16 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,65 @@ jobs:
fail_ci_if_error: true
verbose: true

kubernetes-integration-tests:
needs: [ build-lint-test ]
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

## TODO(astoycos) Currently this is just done to ensure we have coverage
## on all image builds. Ultimately we should be running the integration
## tests with these locally built bytecode images.
- 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
20 changes: 4 additions & 16 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
// 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

0 comments on commit 73ccdb0

Please sign in to comment.