Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: raise e2e-framework to v0.3.0 (#3)
Raising deps e2e-framework to v.0.3.0 and Crossplane to v.1.14.0 e2e-framwork v0.3.0 enables more cluster providers, this is currently not partially supported, since some setup functions have the assumption that we run on kind. The default setup hints into that direction. Additionally: * Added an e2e test with `provider-nop` * Added a method to register Cluster Name aware functions which run after cluster creation * Renamed a couple of functions, to make clear they run on with kind * Where possible removed the kind assumptions * Removed a duplicate function for exporting the clusters logs * Make the `k8s.Object` for features optional.
- Loading branch information
Showing
15 changed files
with
322 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,5 @@ go.work | |
|
||
|
||
.idea | ||
|
||
e2e/logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
.PHONY: lint | ||
lint: | ||
golangci-lint run ./... | ||
|
||
|
||
.PHONY: test | ||
test: | ||
go test -coverprofile cover.out -v ./... | ||
|
||
.PHONY: e2e | ||
e2e: | ||
go test -v ./e2e/... -tags=e2e -count=1 -test.v | ||
|
||
.PHONY: build | ||
build: | ||
go build -v ./... | ||
|
||
.PHONY: all | ||
all: lint build test e2e | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apiVersion: nop.crossplane.io/v1alpha1 | ||
kind: NopResource | ||
metadata: | ||
name: example | ||
spec: | ||
forProvider: | ||
conditionAfter: | ||
- conditionStatus: "True" | ||
conditionType: Ready | ||
time: 1s | ||
fields: | ||
arrayField: | ||
- stringField: cool | ||
integerField: 42 | ||
objectField: | ||
stringField: cool | ||
stringField: cool | ||
providerConfigRef: | ||
name: default | ||
writeConnectionSecretToRef: | ||
name: nop-example-resource | ||
namespace: crossplane-system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
//go:build e2e | ||
|
||
package e2e | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"github.com/vladimirvivien/gexe" | ||
"k8s.io/klog/v2" | ||
"sigs.k8s.io/e2e-framework/pkg/envconf" | ||
"sigs.k8s.io/e2e-framework/support/kind" | ||
|
||
xpv1alpha1 "github.com/crossplane/crossplane/apis/pkg/v1alpha1" | ||
"sigs.k8s.io/e2e-framework/pkg/env" | ||
|
||
"github.com/crossplane-contrib/xp-testing/pkg/images" | ||
"github.com/crossplane-contrib/xp-testing/pkg/logging" | ||
"github.com/crossplane-contrib/xp-testing/pkg/setup" | ||
) | ||
|
||
var testenv env.Environment | ||
|
||
func TestMain(m *testing.M) { | ||
var verbosity = 4 | ||
logging.EnableVerboseLogging(&verbosity) | ||
testenv = env.NewParallel() | ||
|
||
imgs := images.ProviderImages{ | ||
Package: "xpkg.upbound.io/crossplane-contrib/provider-nop:v0.2.0", | ||
} | ||
imgs.ControllerImage = &imgs.Package | ||
|
||
// We pull the image here, usually this would have been done by the build tool | ||
pullPackageOrPanic(imgs.Package) | ||
|
||
// Enhance interface for one- based providers | ||
clusterSetup := setup.ClusterSetup{ | ||
ProviderName: "provider-nop", | ||
Images: imgs, | ||
CrossplaneVersion: "1.14.0", | ||
ControllerConfig: &xpv1alpha1.ControllerConfig{ | ||
Spec: xpv1alpha1.ControllerConfigSpec{ | ||
Image: &imgs.Package, | ||
}, | ||
}, | ||
} | ||
clusterSetup.PostCreate(func(clusterName string) env.Func { | ||
return func(ctx context.Context, config *envconf.Config) (context.Context, error) { | ||
klog.V(4).Infof("Some function running after the cluster %s has been created", clusterName) | ||
return ctx, nil | ||
} | ||
}) | ||
_ = clusterSetup.Configure(testenv, &kind.Cluster{}) | ||
os.Exit(testenv.Run(m)) | ||
} | ||
|
||
func pullPackageOrPanic(image string) { | ||
klog.Info("Pulling %s", image) | ||
runner := gexe.New() | ||
p := runner.RunProc(fmt.Sprintf("docker pull %s", image)) | ||
klog.V(4).Info(p.Out()) | ||
if p.Err() != nil { | ||
panic(fmt.Errorf("docker pull %v failed: %w: %s", image, p.Err(), p.Result())) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//go:build e2e | ||
|
||
package e2e | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/crossplane-contrib/xp-testing/pkg/resources" | ||
"sigs.k8s.io/e2e-framework/pkg/features" | ||
) | ||
|
||
func Test_Nop_v1alpha1(t *testing.T) { | ||
|
||
resource := resources.NewResourceTestConfig(nil, "Nop") | ||
|
||
fB := features.New(fmt.Sprintf("%v", resource.Kind)) | ||
fB.WithLabel("kind", resource.Kind) | ||
fB.Setup(resource.Setup) | ||
fB.Assess("create", resource.AssessCreate) | ||
fB.Assess("delete", resource.AssessDelete) | ||
|
||
testenv.Test(t, fB.Feature()) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.