Skip to content
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
24 changes: 24 additions & 0 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: "1.25"
- name: build
run: go build -v ./...
- name: e2e test
run: go test -v ./e2e/... -count=1
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,28 @@

## About this project

Testing framework for openMCP
OpenMCP-testing helps to set up e2e test suites for openmcp applications. Like [xp-testing](https://github.com/crossplane-contrib/xp-testing) but for [openmcp](https://github.com/openmcp-project).

* [`pkg/clusterutils`](./pkg/clusterutils/) provides functionality to interact with the different clusters of an openMCP installation
* [`pkg/conditions`](./pkg/conditions/) provides common pre/post condition checks
* [`pkg/providers`](./pkg/providers/) provides functionality to test cluster-providers, platform-services and service-providers
* [`pkg/resources`](./pkg/resources/) provides functionality to (batch) import and delete resources
* [`pkg/setup`](./pkg/setup/) provides functionality to bootstrap an openmcp environment

## Requirements and Setup

*Insert a short description what is required to get your project running...*
You need [go](https://go.dev/) and [docker](https://www.docker.com/) to execute the sample test suite.

```shell
go test -v ./e2e/...
```

## Support, Feedback, Contributing

This project is open to feature requests/suggestions, bug reports etc. via [GitHub issues](https://github.com/openmcp-project/openmcp-testing/issues). Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](CONTRIBUTING.md).

## Security / Disclosure

If you find any bug that may be a security problem, please follow our instructions at [in our security policy](https://github.com/openmcp-project/openmcp-testing/security/policy) on how to report it. Please do not create GitHub issues for security-related doubts or problems.

## Code of Conduct
Expand Down
6 changes: 6 additions & 0 deletions e2e/domainobjects/dummy-cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: dummy
data:
foo: bar
62 changes: 62 additions & 0 deletions e2e/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package e2e

import (
"flag"
"fmt"
"os"
"testing"
"time"

"github.com/openmcp-project/openmcp-testing/pkg/providers"
"github.com/openmcp-project/openmcp-testing/pkg/setup"
"k8s.io/klog/v2"
"sigs.k8s.io/e2e-framework/klient/wait"
"sigs.k8s.io/e2e-framework/pkg/env"
"sigs.k8s.io/e2e-framework/pkg/envconf"
)

var testenv env.Environment

func TestMain(m *testing.M) {
initLogging()
openmcp := setup.OpenMCPSetup{
Namespace: "openmcp-system",
Operator: setup.OpenMCPOperatorSetup{
Name: "openmcp-operator",
Image: "ghcr.io/openmcp-project/images/openmcp-operator:v0.13.0",
Environment: "debug",
PlatformName: "platform",
},
ClusterProviders: []providers.ClusterProviderSetup{
{
Name: "kind",
Image: "ghcr.io/openmcp-project/images/cluster-provider-kind:v0.0.15",
Opts: []wait.Option{
wait.WithTimeout(time.Minute),
},
},
},
ServiceProviders: []providers.ServiceProviderSetup{
{
Name: "crossplane",
Image: "ghcr.io/openmcp-project/images/service-provider-crossplane:v0.0.4",
Opts: []wait.Option{
wait.WithTimeout(time.Minute),
},
},
},
}
testenv = env.NewWithConfig(envconf.New().WithNamespace(openmcp.Namespace))
if err := openmcp.Bootstrap(testenv); err != nil {
panic(fmt.Errorf("openmcp bootstrap failed: %v", err))
}
os.Exit(testenv.Run(m))
}

func initLogging() {
klog.InitFlags(nil)
if err := flag.Set("v", "2"); err != nil {
panic(err)
}
flag.Parse()
}
53 changes: 53 additions & 0 deletions e2e/serviceprovider_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package e2e

import (
"context"
"testing"
"time"

"github.com/openmcp-project/openmcp-testing/pkg/clusterutils"
"github.com/openmcp-project/openmcp-testing/pkg/providers"
corev1 "k8s.io/api/core/v1"
"sigs.k8s.io/e2e-framework/klient/wait"
"sigs.k8s.io/e2e-framework/pkg/envconf"
"sigs.k8s.io/e2e-framework/pkg/features"
)

func TestServiceProvider(t *testing.T) {
basicProviderTest := features.New("provider test").
Setup(providers.CreateMCP("test-mcp", wait.WithTimeout(2*time.Minute))).
Setup(providers.ImportServiceProviderAPIs("serviceproviderobjects", wait.WithTimeout(time.Minute))).
Setup(providers.ImportDomainAPIs("domainobjects", wait.WithTimeout(time.Minute))).
Assess("verify onboarding cluster objects", func(ctx context.Context, t *testing.T, c *envconf.Config) context.Context {
cfg, err := clusterutils.OnboardingConfig()
if err != nil {
t.Error(err)
return ctx
}
assertDummyConfigMap(ctx, t, cfg)
return ctx
}).
Assess("verify mcp cluster objects", func(ctx context.Context, t *testing.T, c *envconf.Config) context.Context {
cfg, err := clusterutils.McpConfig()
if err != nil {
t.Error(err)
return ctx
}
assertDummyConfigMap(ctx, t, cfg)
return ctx
}).
Teardown(providers.DeleteMCP("test-mcp", wait.WithTimeout(time.Minute)))
testenv.Test(t, basicProviderTest.Feature())
}

func assertDummyConfigMap(ctx context.Context, t *testing.T, cfg *envconf.Config) {
cm := &corev1.ConfigMap{}
if err := cfg.Client().Resources().Get(ctx, "dummy", corev1.NamespaceDefault, cm); err != nil {
t.Error(err)
return
}
v, ok := cm.Data["foo"]
if !ok || v != "bar" {
t.Errorf("expected foo:bar; got: %t %v", ok, v)
}
}
6 changes: 6 additions & 0 deletions e2e/serviceproviderobjects/dummy-cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: dummy
data:
foo: bar
78 changes: 78 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
module github.com/openmcp-project/openmcp-testing

go 1.25.2

require (
k8s.io/api v0.32.1
k8s.io/apimachinery v0.32.1
k8s.io/client-go v0.32.1
k8s.io/klog/v2 v2.130.1
sigs.k8s.io/e2e-framework v0.6.0
)

require (
al.essio.dev/pkg/shellescape v1.5.1 // indirect
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/vladimirvivien/gexe v0.4.1 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.0 // 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/mailru/easyjson v0.7.7 // indirect
github.com/moby/spdystream v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.opentelemetry.io/otel v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.7.0 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/component-base v0.32.1 // indirect
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
sigs.k8s.io/controller-runtime v0.20.0 // indirect
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
sigs.k8s.io/kind v0.30.0
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading