Skip to content

Commit d1b7a3f

Browse files
authored
fix: support wait options for any setup and use default timeouts in sample test (#10)
On-behalf-of: @SAP [email protected] Signed-off-by: Christopher Junk <[email protected]>
1 parent 5cc7f7a commit d1b7a3f

File tree

4 files changed

+15
-23
lines changed

4 files changed

+15
-23
lines changed

e2e/main_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ import (
55
"fmt"
66
"os"
77
"testing"
8-
"time"
98

109
"k8s.io/klog/v2"
11-
"sigs.k8s.io/e2e-framework/klient/wait"
1210
"sigs.k8s.io/e2e-framework/pkg/env"
1311
"sigs.k8s.io/e2e-framework/pkg/envconf"
1412

@@ -32,18 +30,12 @@ func TestMain(m *testing.M) {
3230
{
3331
Name: "kind",
3432
Image: "ghcr.io/openmcp-project/images/cluster-provider-kind:v0.0.15",
35-
Opts: []wait.Option{
36-
wait.WithTimeout(time.Minute),
37-
},
3833
},
3934
},
4035
ServiceProviders: []providers.ServiceProviderSetup{
4136
{
4237
Name: "crossplane",
4338
Image: "ghcr.io/openmcp-project/images/service-provider-crossplane:v0.1.4",
44-
Opts: []wait.Option{
45-
wait.WithTimeout(time.Minute),
46-
},
4739
},
4840
},
4941
}

pkg/providers/clusterprovider.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ spec:
4747

4848
// ClusterProviderSetup represents the configuration parameters to set up a cluster provider
4949
type ClusterProviderSetup struct {
50-
Name string
51-
Image string
52-
Opts []wait.Option
50+
Name string
51+
Image string
52+
WaitOpts []wait.Option
5353
}
5454

5555
func mcpRef(ref types.NamespacedName) *unstructured.Unstructured {
@@ -93,7 +93,7 @@ func InstallClusterProvider(ctx context.Context, c *envconf.Config, clusterProvi
9393
if err != nil {
9494
return err
9595
}
96-
return wait.For(conditions.Match(obj, c, "Ready", corev1.ConditionTrue), clusterProvider.Opts...)
96+
return wait.For(conditions.Match(obj, c, "Ready", corev1.ConditionTrue), clusterProvider.WaitOpts...)
9797
}
9898

9999
// DeleteClusterProvider deletes the cluster provider object and waits until the object has been deleted

pkg/providers/serviceprovider.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ spec:
2828

2929
// ServiceProviderSetup represents the configuration parameters to set up a service provider
3030
type ServiceProviderSetup struct {
31-
Name string
32-
Image string
33-
Opts []wait.Option
31+
Name string
32+
Image string
33+
WaitOpts []wait.Option
3434
}
3535

3636
func serviceProviderRef(name string) *unstructured.Unstructured {
@@ -51,7 +51,7 @@ func InstallServiceProvider(ctx context.Context, c *envconf.Config, sp ServicePr
5151
if err != nil {
5252
return err
5353
}
54-
return wait.For(conditions.Match(obj, c, "Ready", corev1.ConditionTrue), sp.Opts...)
54+
return wait.For(conditions.Match(obj, c, "Ready", corev1.ConditionTrue), sp.WaitOpts...)
5555
}
5656

5757
// ImportServiceProviderAPIs iterates over each resource from the passed in directory

pkg/setup/bootstrap.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package setup
22

33
import (
44
"context"
5-
"time"
65

76
apimachinerytypes "k8s.io/apimachinery/pkg/types"
87
"k8s.io/klog/v2"
@@ -23,6 +22,7 @@ type OpenMCPSetup struct {
2322
Operator OpenMCPOperatorSetup
2423
ClusterProviders []providers.ClusterProviderSetup
2524
ServiceProviders []providers.ServiceProviderSetup
25+
WaitOpts []wait.Option
2626
}
2727

2828
type OpenMCPOperatorSetup struct {
@@ -31,6 +31,7 @@ type OpenMCPOperatorSetup struct {
3131
Image string
3232
Environment string
3333
PlatformName string
34+
WaitOpts []wait.Option
3435
}
3536

3637
// Bootstrap sets up a the minimum set of components of an openMCP installation
@@ -57,16 +58,16 @@ func (s *OpenMCPSetup) cleanup() types.EnvFunc {
5758
return func(ctx context.Context, c *envconf.Config) (context.Context, error) {
5859
klog.Info("cleaning up environment...")
5960
for _, sp := range s.ServiceProviders {
60-
if err := providers.DeleteServiceProvider(ctx, c, sp.Name, wait.WithTimeout(time.Minute)); err != nil {
61+
if err := providers.DeleteServiceProvider(ctx, c, sp.Name, sp.WaitOpts...); err != nil {
6162
klog.Errorf("delete service provider failed: %v", err)
6263
}
6364
}
6465
if err := providers.DeleteCluster(ctx, c, apimachinerytypes.NamespacedName{Namespace: s.Namespace, Name: "onboarding"},
65-
wait.WithTimeout(time.Second*20)); err != nil {
66+
s.WaitOpts...); err != nil {
6667
klog.Errorf("delete cluster failed: %v", err)
6768
}
6869
for _, cp := range s.ClusterProviders {
69-
if err := providers.DeleteClusterProvider(ctx, c, cp.Name, wait.WithTimeout(time.Minute)); err != nil {
70+
if err := providers.DeleteClusterProvider(ctx, c, cp.Name, cp.WaitOpts...); err != nil {
7071
klog.Errorf("delete cluster provider failed: %v", err)
7172
}
7273
}
@@ -77,7 +78,7 @@ func (s *OpenMCPSetup) cleanup() types.EnvFunc {
7778
func (s *OpenMCPSetup) verifyEnvironment() types.EnvFunc {
7879
return func(ctx context.Context, c *envconf.Config) (context.Context, error) {
7980
klog.Info("verify environment...")
80-
return ctx, providers.ClustersReady(ctx, c, wait.WithTimeout(time.Minute))
81+
return ctx, providers.ClustersReady(ctx, c, s.WaitOpts...)
8182
}
8283
}
8384

@@ -89,8 +90,7 @@ func (s *OpenMCPSetup) installOpenMCPOperator() types.EnvFunc {
8990
}
9091
// wait for deployment to be ready
9192
if err := wait.For(conditions.New(c.Client().Resources()).
92-
DeploymentAvailable(s.Operator.Name, s.Operator.Namespace),
93-
wait.WithTimeout(time.Minute)); err != nil {
93+
DeploymentAvailable(s.Operator.Name, s.Operator.Namespace), s.Operator.WaitOpts...); err != nil {
9494
return ctx, err
9595
}
9696
klog.Info("openmcp operator ready")

0 commit comments

Comments
 (0)