Skip to content

Commit 0dddf1a

Browse files
committed
feat: e2e test updates
- remove unused functions - add new required functions - rename of one mhc remediation test Signed-off-by: Chris Privitere <[email protected]>
1 parent c55796f commit 0dddf1a

File tree

2 files changed

+13
-33
lines changed

2 files changed

+13
-33
lines changed

test/e2e/capi_e2e_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ var _ = Describe("[General] Running the Cluster API E2E tests", func() {
4141
// - capi_e2e.MachineDeploymentRolloutSpec
4242

4343
Context("Running the mhc-remediation spec", func() {
44-
capi_e2e.MachineRemediationSpec(ctx, func() capi_e2e.MachineRemediationSpecInput {
45-
return capi_e2e.MachineRemediationSpecInput{
44+
capi_e2e.MachineDeploymentRemediationSpec(ctx, func() capi_e2e.MachineDeploymentRemediationSpecInput {
45+
return capi_e2e.MachineDeploymentRemediationSpecInput{
4646
E2EConfig: e2eConfig,
4747
ClusterctlConfigPath: clusterctlConfigPath,
4848
BootstrapClusterProxy: bootstrapClusterProxy,

test/e2e/common_test.go

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ import (
2525
"net/url"
2626
"os"
2727
goruntime "runtime"
28-
"strings"
2928

30-
"github.com/blang/semver"
31-
"github.com/docker/distribution/reference"
3229
metal "github.com/equinix-labs/metal-go/metal/v1"
3330
. "github.com/onsi/ginkgo/v2"
3431
. "github.com/onsi/gomega"
@@ -45,7 +42,7 @@ import (
4542
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
4643
"sigs.k8s.io/cluster-api/test/framework"
4744
"sigs.k8s.io/cluster-api/test/infrastructure/container"
48-
capiversionutil "sigs.k8s.io/cluster-api/util/version"
45+
"sigs.k8s.io/controller-runtime/pkg/cache"
4946
"sigs.k8s.io/controller-runtime/pkg/client"
5047
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
5148
)
@@ -124,6 +121,11 @@ func (w *wrappedClusterProxy) GetRESTConfig() *rest.Config {
124121
return w.clusterProxy.GetRESTConfig()
125122
}
126123

124+
// GetCache returns a controller-runtime cache to create informer from.
125+
func (w *wrappedClusterProxy) GetCache(ctx context.Context) cache.Cache {
126+
return w.clusterProxy.GetCache(ctx)
127+
}
128+
127129
// GetLogCollector returns the machine log collector for the Kubernetes cluster.
128130
func (w *wrappedClusterProxy) GetLogCollector() framework.ClusterLogCollector {
129131
return w.clusterProxy.GetLogCollector()
@@ -366,37 +368,15 @@ func (wc *wrappedClient) RESTMapper() meta.RESTMapper {
366368
return wc.client.RESTMapper()
367369
}
368370

371+
// SubResource returns the sub resource this client is using.
372+
func (wc *wrappedClient) SubResource(subResource string) client.SubResourceClient {
373+
return wc.client.SubResource(subResource)
374+
}
375+
369376
func (wc *wrappedClient) Scheme() *runtime.Scheme {
370377
return wc.client.Scheme()
371378
}
372379

373380
func (wc *wrappedClient) Status() client.StatusWriter {
374381
return wc.client.Status()
375382
}
376-
377-
func containerImageGTE(container corev1.Container, version semver.Version) (bool, error) {
378-
ref, err := reference.ParseNormalizedNamed(container.Image)
379-
if err != nil {
380-
return false, fmt.Errorf("failed to parse container reference %s: %w", container.Image, err)
381-
}
382-
383-
ref = reference.TagNameOnly(ref)
384-
tagged, _ := ref.(reference.Tagged)
385-
tag := tagged.Tag()
386-
387-
if tag == "latest" {
388-
return false, nil
389-
}
390-
391-
// If the image tag starts with sha-, assume we are running in CI and can assume the version is new enough
392-
if strings.HasPrefix(tag, "sha-") {
393-
return false, nil
394-
}
395-
396-
imageVersion, err := capiversionutil.ParseMajorMinorPatchTolerant(tag)
397-
if err != nil {
398-
return false, fmt.Errorf("failed to get version from image: %w", err)
399-
}
400-
401-
return imageVersion.GTE(version), nil
402-
}

0 commit comments

Comments
 (0)