Skip to content

Commit

Permalink
test(e2e): Add self-hosted e2e test (#439)
Browse files Browse the repository at this point in the history
Creating as draft until
kubernetes-sigs/cluster-api-addon-provider-helm#189 is merged and
released.

Depends on #494.

---------

Co-authored-by: Dimitri Koshkin <dimitri.koshkin@nutanix.com>
  • Loading branch information
jimmidyson and dkoshkin committed Apr 29, 2024
1 parent 64e269f commit 3ad5620
Show file tree
Hide file tree
Showing 12 changed files with 972 additions and 1,242 deletions.
24 changes: 23 additions & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,37 @@ jobs:
with:
test-results: test.json

e2e-test:
e2e-quick-start:
strategy:
matrix:
provider:
- Docker
# Uncomment below once we have the ability to run e2e tests on other providers from GHA.
# - AWS
# - Nutanix
fail-fast: false
uses: ./.github/workflows/e2e.yml
with:
provider: ${{ matrix.provider }}
focus: Quick start
secrets: inherit
permissions:
contents: read
checks: write

e2e-self-hosted:
strategy:
matrix:
provider:
- Docker
# Uncomment below once we have the ability to run e2e tests on other providers from GHA.
# - AWS
# - Nutanix
fail-fast: false
uses: ./.github/workflows/e2e.yml
with:
provider: ${{ matrix.provider }}
focus: Self-hosted
secrets: inherit
permissions:
contents: read
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ on:
description: Infrastructure provider to run e2e tests with
type: string
required: true
skip:
description: e2e tests to skip
type: string
focus:
description: e2e tests to focus
type: string

jobs:
e2e-test:
Expand Down Expand Up @@ -37,7 +43,7 @@ jobs:
${{ runner.os }}-go-
- name: Run e2e tests
run: devbox run -- make e2e-test E2E_LABEL='provider:${{ inputs.provider }}'
run: devbox run -- make e2e-test E2E_LABEL='provider:${{ inputs.provider }}' E2E_SKIP='${{ inputs.skip }}' E2E_FOCUS='${{ inputs.focus }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NUTANIX_ENDPOINT: ${{ secrets.NUTANIX_ENDPOINT }}
Expand Down
7 changes: 4 additions & 3 deletions common/pkg/capi/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ import (
"context"
"fmt"

v1 "k8s.io/api/core/v1"
corev1 "k8s.io/api/core/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

// ManagementCluster returns a Cluster object if c is pointing to a management cluster, otherwise returns nil.
func ManagementCluster(ctx context.Context, c client.Client) (*clusterv1.Cluster, error) {
allNodes := &v1.NodeList{}
allNodes := &corev1.NodeList{}
err := c.List(ctx, allNodes)
if err != nil {
return nil, fmt.Errorf("error listing Nodes: %w", err)
Expand All @@ -37,7 +38,7 @@ func ManagementCluster(ctx context.Context, c client.Client) (*clusterv1.Cluster
}
err = c.Get(ctx, key, cluster)
if err != nil {
if k8serrors.IsNotFound(err) {
if k8serrors.IsNotFound(err) || meta.IsNoMatchError(err) {
return nil, nil
}
return nil, fmt.Errorf("error getting Cluster object based on Node annotations: %w", err)
Expand Down
Loading

0 comments on commit 3ad5620

Please sign in to comment.