Skip to content

Commit 9839744

Browse files
authored
feat: service provider test functionality (#1)
* feat: service provider test functionality On-behalf-of: @SAP [email protected] Signed-off-by: Christopher Junk <[email protected]>
1 parent a86e207 commit 9839744

File tree

17 files changed

+1334
-2
lines changed

17 files changed

+1334
-2
lines changed

.github/workflows/go.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This workflow will build a golang project
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
3+
4+
name: Go
5+
6+
on:
7+
push:
8+
branches: ["main"]
9+
pull_request:
10+
branches: ["main"]
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v5
17+
- name: Set up Go
18+
uses: actions/setup-go@v6
19+
with:
20+
go-version: "1.25"
21+
- name: build
22+
run: go build -v ./...
23+
- name: e2e test
24+
run: go test -v ./e2e/... -count=1

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,28 @@
44

55
## About this project
66

7-
Testing framework for openMCP
7+
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).
8+
9+
* [`pkg/clusterutils`](./pkg/clusterutils/) provides functionality to interact with the different clusters of an openMCP installation
10+
* [`pkg/conditions`](./pkg/conditions/) provides common pre/post condition checks
11+
* [`pkg/providers`](./pkg/providers/) provides functionality to test cluster-providers, platform-services and service-providers
12+
* [`pkg/resources`](./pkg/resources/) provides functionality to (batch) import and delete resources
13+
* [`pkg/setup`](./pkg/setup/) provides functionality to bootstrap an openmcp environment
814

915
## Requirements and Setup
1016

11-
*Insert a short description what is required to get your project running...*
17+
You need [go](https://go.dev/) and [docker](https://www.docker.com/) to execute the sample test suite.
18+
19+
```shell
20+
go test -v ./e2e/...
21+
```
1222

1323
## Support, Feedback, Contributing
1424

1525
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).
1626

1727
## Security / Disclosure
28+
1829
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.
1930

2031
## Code of Conduct

e2e/domainobjects/dummy-cm.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: dummy
5+
data:
6+
foo: bar

e2e/main_test.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package e2e
2+
3+
import (
4+
"flag"
5+
"fmt"
6+
"os"
7+
"testing"
8+
"time"
9+
10+
"github.com/openmcp-project/openmcp-testing/pkg/providers"
11+
"github.com/openmcp-project/openmcp-testing/pkg/setup"
12+
"k8s.io/klog/v2"
13+
"sigs.k8s.io/e2e-framework/klient/wait"
14+
"sigs.k8s.io/e2e-framework/pkg/env"
15+
"sigs.k8s.io/e2e-framework/pkg/envconf"
16+
)
17+
18+
var testenv env.Environment
19+
20+
func TestMain(m *testing.M) {
21+
initLogging()
22+
openmcp := setup.OpenMCPSetup{
23+
Namespace: "openmcp-system",
24+
Operator: setup.OpenMCPOperatorSetup{
25+
Name: "openmcp-operator",
26+
Image: "ghcr.io/openmcp-project/images/openmcp-operator:v0.13.0",
27+
Environment: "debug",
28+
PlatformName: "platform",
29+
},
30+
ClusterProviders: []providers.ClusterProviderSetup{
31+
{
32+
Name: "kind",
33+
Image: "ghcr.io/openmcp-project/images/cluster-provider-kind:v0.0.15",
34+
Opts: []wait.Option{
35+
wait.WithTimeout(time.Minute),
36+
},
37+
},
38+
},
39+
ServiceProviders: []providers.ServiceProviderSetup{
40+
{
41+
Name: "crossplane",
42+
Image: "ghcr.io/openmcp-project/images/service-provider-crossplane:v0.0.4",
43+
Opts: []wait.Option{
44+
wait.WithTimeout(time.Minute),
45+
},
46+
},
47+
},
48+
}
49+
testenv = env.NewWithConfig(envconf.New().WithNamespace(openmcp.Namespace))
50+
if err := openmcp.Bootstrap(testenv); err != nil {
51+
panic(fmt.Errorf("openmcp bootstrap failed: %v", err))
52+
}
53+
os.Exit(testenv.Run(m))
54+
}
55+
56+
func initLogging() {
57+
klog.InitFlags(nil)
58+
if err := flag.Set("v", "2"); err != nil {
59+
panic(err)
60+
}
61+
flag.Parse()
62+
}

e2e/serviceprovider_test.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package e2e
2+
3+
import (
4+
"context"
5+
"testing"
6+
"time"
7+
8+
"github.com/openmcp-project/openmcp-testing/pkg/clusterutils"
9+
"github.com/openmcp-project/openmcp-testing/pkg/providers"
10+
corev1 "k8s.io/api/core/v1"
11+
"sigs.k8s.io/e2e-framework/klient/wait"
12+
"sigs.k8s.io/e2e-framework/pkg/envconf"
13+
"sigs.k8s.io/e2e-framework/pkg/features"
14+
)
15+
16+
func TestServiceProvider(t *testing.T) {
17+
basicProviderTest := features.New("provider test").
18+
Setup(providers.CreateMCP("test-mcp", wait.WithTimeout(2*time.Minute))).
19+
Setup(providers.ImportServiceProviderAPIs("serviceproviderobjects", wait.WithTimeout(time.Minute))).
20+
Setup(providers.ImportDomainAPIs("domainobjects", wait.WithTimeout(time.Minute))).
21+
Assess("verify onboarding cluster objects", func(ctx context.Context, t *testing.T, c *envconf.Config) context.Context {
22+
cfg, err := clusterutils.OnboardingConfig()
23+
if err != nil {
24+
t.Error(err)
25+
return ctx
26+
}
27+
assertDummyConfigMap(ctx, t, cfg)
28+
return ctx
29+
}).
30+
Assess("verify mcp cluster objects", func(ctx context.Context, t *testing.T, c *envconf.Config) context.Context {
31+
cfg, err := clusterutils.McpConfig()
32+
if err != nil {
33+
t.Error(err)
34+
return ctx
35+
}
36+
assertDummyConfigMap(ctx, t, cfg)
37+
return ctx
38+
}).
39+
Teardown(providers.DeleteMCP("test-mcp", wait.WithTimeout(time.Minute)))
40+
testenv.Test(t, basicProviderTest.Feature())
41+
}
42+
43+
func assertDummyConfigMap(ctx context.Context, t *testing.T, cfg *envconf.Config) {
44+
cm := &corev1.ConfigMap{}
45+
if err := cfg.Client().Resources().Get(ctx, "dummy", corev1.NamespaceDefault, cm); err != nil {
46+
t.Error(err)
47+
return
48+
}
49+
v, ok := cm.Data["foo"]
50+
if !ok || v != "bar" {
51+
t.Errorf("expected foo:bar; got: %t %v", ok, v)
52+
}
53+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: dummy
5+
data:
6+
foo: bar

go.mod

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
module github.com/openmcp-project/openmcp-testing
2+
3+
go 1.25.2
4+
5+
require (
6+
k8s.io/api v0.32.1
7+
k8s.io/apimachinery v0.32.1
8+
k8s.io/client-go v0.32.1
9+
k8s.io/klog/v2 v2.130.1
10+
sigs.k8s.io/e2e-framework v0.6.0
11+
)
12+
13+
require (
14+
al.essio.dev/pkg/shellescape v1.5.1 // indirect
15+
github.com/BurntSushi/toml v1.4.0 // indirect
16+
github.com/mattn/go-isatty v0.0.20 // indirect
17+
github.com/pelletier/go-toml v1.9.5 // indirect
18+
github.com/vladimirvivien/gexe v0.4.1 // indirect
19+
go.yaml.in/yaml/v3 v3.0.4 // indirect
20+
)
21+
22+
require (
23+
github.com/beorn7/perks v1.0.1 // indirect
24+
github.com/blang/semver/v4 v4.0.0 // indirect
25+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
26+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
27+
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
28+
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
29+
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
30+
github.com/go-logr/logr v1.4.2 // indirect
31+
github.com/go-openapi/jsonpointer v0.21.0 // indirect
32+
github.com/go-openapi/jsonreference v0.20.2 // indirect
33+
github.com/go-openapi/swag v0.23.0 // indirect
34+
github.com/gogo/protobuf v1.3.2 // indirect
35+
github.com/golang/protobuf v1.5.4 // indirect
36+
github.com/google/gnostic-models v0.6.8 // indirect
37+
github.com/google/go-cmp v0.6.0 // indirect
38+
github.com/google/gofuzz v1.2.0 // indirect
39+
github.com/google/uuid v1.6.0 // indirect
40+
github.com/gorilla/websocket v1.5.0 // indirect
41+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
42+
github.com/josharian/intern v1.0.0 // indirect
43+
github.com/json-iterator/go v1.1.12 // indirect
44+
github.com/mailru/easyjson v0.7.7 // indirect
45+
github.com/moby/spdystream v0.5.0 // indirect
46+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
47+
github.com/modern-go/reflect2 v1.0.2 // indirect
48+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
49+
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
50+
github.com/pkg/errors v0.9.1 // indirect
51+
github.com/prometheus/client_golang v1.19.1 // indirect
52+
github.com/prometheus/client_model v0.6.1 // indirect
53+
github.com/prometheus/common v0.55.0 // indirect
54+
github.com/prometheus/procfs v0.15.1 // indirect
55+
github.com/spf13/cobra v1.8.1 // indirect
56+
github.com/spf13/pflag v1.0.5 // indirect
57+
github.com/x448/float16 v0.8.4 // indirect
58+
go.opentelemetry.io/otel v1.28.0 // indirect
59+
go.opentelemetry.io/otel/trace v1.28.0 // indirect
60+
golang.org/x/net v0.33.0 // indirect
61+
golang.org/x/oauth2 v0.23.0 // indirect
62+
golang.org/x/sys v0.28.0 // indirect
63+
golang.org/x/term v0.27.0 // indirect
64+
golang.org/x/text v0.21.0 // indirect
65+
golang.org/x/time v0.7.0 // indirect
66+
google.golang.org/protobuf v1.35.1 // indirect
67+
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
68+
gopkg.in/inf.v0 v0.9.1 // indirect
69+
gopkg.in/yaml.v3 v3.0.1 // indirect
70+
k8s.io/component-base v0.32.1 // indirect
71+
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
72+
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
73+
sigs.k8s.io/controller-runtime v0.20.0 // indirect
74+
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
75+
sigs.k8s.io/kind v0.30.0
76+
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
77+
sigs.k8s.io/yaml v1.4.0 // indirect
78+
)

0 commit comments

Comments
 (0)