Skip to content

Commit

Permalink
fix: refactor E2E tests to be context-aware
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobmoellerdev committed Aug 9, 2023
1 parent 6f10571 commit 45d76ef
Show file tree
Hide file tree
Showing 12 changed files with 682 additions and 642 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ jsonnet: ## Download jsonnet locally if necessary.

GINKGO = $(shell pwd)/bin/ginkgo
ginkgo: ## Download ginkgo and gomega locally if necessary.
$(call go-get-tool,$(GINKGO),github.com/onsi/ginkgo/v2/[email protected].4)
$(call go-get-tool,$(GINKGO),github.com/onsi/ginkgo/v2/[email protected].5)

# go-get-tool will 'go get' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
Expand Down
3 changes: 2 additions & 1 deletion controllers/lvmcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ func (r *LVMClusterReconciler) reconcile(ctx context.Context, instance *lvmv1alp
}
}
if err != nil {
return ctrl.Result{Requeue: true, RequeueAfter: time.Minute * 1}, err
// check every 10 seconds if there are still PVCs present or the LogicalVolumes are removed
return ctrl.Result{Requeue: true, RequeueAfter: time.Second * 10}, err
} else {
return reconcile.Result{}, nil
}
Expand Down
15 changes: 12 additions & 3 deletions controllers/topolvm_snapshotclass.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ package controllers

import (
"context"
"errors"
"fmt"

snapapi "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1"
lvmv1alpha1 "github.com/openshift/lvm-operator/api/v1alpha1"
"k8s.io/apimachinery/pkg/api/errors"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/discovery"
cutil "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
)

Expand Down Expand Up @@ -72,10 +75,16 @@ func (s topolvmVolumeSnapshotClass) ensureDeleted(r *LVMClusterReconciler, ctx c

if err != nil {
// already deleted in previous reconcile
if errors.IsNotFound(err) {
if k8serrors.IsNotFound(err) {
r.Log.Info("topolvm volume snapshot class is deleted", "VolumeSnapshotClass", vscName)
return nil
}
if runtime.IsNotRegisteredError(err) || meta.IsNoMatchError(err) ||
// this is necessary in case the VolumeSnapshotClass CRDs are not registered in the Distro, e.g. for OpenShift Local
discovery.IsGroupDiscoveryFailedError(err) || discovery.IsGroupDiscoveryFailedError(errors.Unwrap(err)) {
r.Log.Info("topolvm volume snapshot classes do not exist on the cluster, ignoring", "VolumeSnapshotClass", vscName)
return nil
}
r.Log.Error(err, "failed to retrieve topolvm volume snapshot class", "VolumeSnapshotClass", vscName)
return err
}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.20
require (
github.com/aws/aws-sdk-go v1.44.10
github.com/go-logr/logr v1.2.4
github.com/go-logr/zapr v1.2.4
github.com/google/go-cmp v0.5.9
github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0
github.com/onsi/ginkgo/v2 v2.9.5
Expand All @@ -18,6 +19,7 @@ require (
github.com/prometheus/client_golang v1.16.0
github.com/stretchr/testify v1.8.4
github.com/topolvm/topolvm v0.15.4-0.20221116041433-d58476400ff1
go.uber.org/zap v1.24.0
gotest.tools/v3 v3.0.3
k8s.io/api v0.27.4
k8s.io/apimachinery v0.27.4
Expand All @@ -41,7 +43,6 @@ require (
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/zapr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
Expand Down Expand Up @@ -82,7 +83,6 @@ require (
github.com/subosito/gotenv v1.2.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/oauth2 v0.10.0 // indirect
golang.org/x/sys v0.10.0 // indirect
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func getKubeconfig(kubeconfig string) (*rest.Config, error) {
config, err = rest.InClusterConfig()
}
if err != nil {
return config, nil
return nil, err
}
return config, err
}
Loading

0 comments on commit 45d76ef

Please sign in to comment.