Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: raise e2e-framework to v0.3.0 #3

Merged
merged 8 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ jobs:
go-version: '1.20'

- name: Build
run: go build -v ./...
run: make build

- name: Test
run: go test -v ./...
run: make test

- name: E2E Test
run: make e2e
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ go.work


.idea

e2e/logs
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ run:
skip-files:
- "zz_generated\\..+\\.go$"

build-tags:
- e2e
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
format: colored-line-number
Expand Down
21 changes: 21 additions & 0 deletions Makefile
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

22 changes: 22 additions & 0 deletions e2e/crs/Nop/instant-ready.yaml
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
68 changes: 68 additions & 0 deletions e2e/main_test.go
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()))
}
}
25 changes: 25 additions & 0 deletions e2e/nop_test.go
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())

}
1 change: 1 addition & 0 deletions e2e/provider/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
68 changes: 33 additions & 35 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,56 @@ go 1.20

require (
github.com/GoogleContainerTools/container-diff v0.17.0
github.com/crossplane/crossplane v1.11.5
github.com/crossplane/crossplane-runtime v0.19.2
github.com/crossplane/crossplane v1.14.0
github.com/crossplane/crossplane-runtime v1.14.0
github.com/google/go-cmp v0.6.0
github.com/pkg/errors v0.9.1
github.com/samber/lo v1.38.1
github.com/stretchr/testify v1.8.4
github.com/vladimirvivien/gexe v0.2.0
k8s.io/api v0.26.3
k8s.io/apiextensions-apiserver v0.26.1
k8s.io/apimachinery v0.26.3
k8s.io/client-go v0.26.3
k8s.io/api v0.28.3
k8s.io/apiextensions-apiserver v0.28.3
k8s.io/apimachinery v0.28.3
k8s.io/client-go v0.28.3
k8s.io/klog/v2 v2.100.1
sigs.k8s.io/controller-runtime v0.14.6
sigs.k8s.io/e2e-framework v0.2.0
sigs.k8s.io/controller-runtime v0.16.3
sigs.k8s.io/e2e-framework v0.3.0
sigs.k8s.io/kind v0.20.0
)

require (
dario.cat/mergo v1.0.0 // indirect
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/alessio/shellescape v1.4.1 // indirect
github.com/containerd/continuity v0.0.0-20181203112020-004b46473808 // indirect
github.com/containerd/stargz-snapshotter/estargz v0.14.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/cli v24.0.4+incompatible // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/docker v24.0.4+incompatible // indirect
github.com/docker/docker-credential-helpers v0.7.0 // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/docker/cli v24.0.6+incompatible // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker v24.0.6+incompatible // indirect
github.com/docker/docker-credential-helpers v0.8.0 // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-containerregistry v0.16.1 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/klauspost/compress v1.17.1 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
Expand All @@ -60,39 +62,35 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc4 // indirect
github.com/opencontainers/image-spec v1.1.0-rc5 // indirect
github.com/opencontainers/runc v0.1.1 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/afero v1.10.0 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/vbatts/tar-split v0.11.3 // indirect
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/oauth2 v0.8.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/term v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
github.com/vbatts/tar-split v0.11.5 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.11.0 // indirect
golang.org/x/sync v0.4.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.11.0 // indirect
golang.org/x/tools v0.14.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/kube-openapi v0.0.0-20230525220651-2546d827e515 // indirect
k8s.io/utils v0.0.0-20230505201702-9f6742963106 // indirect
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace github.com/crossplane/crossplane => github.com/crossplane/crossplane v1.11.5

replace github.com/crossplane/crossplane-runtime => github.com/crossplane/crossplane-runtime v0.19.2

replace github.com/docker/docker => github.com/docker/docker v1.4.2-0.20190219180918-740349757396
Loading
Loading