Skip to content

Commit ead6565

Browse files
Use 'Byf' instead of 'By(fmt.Sprintf())' across e2e tests
Signed-off-by: killianmuldoon <[email protected]>
1 parent c8053fb commit ead6565

File tree

7 files changed

+17
-15
lines changed

7 files changed

+17
-15
lines changed

test/e2e/clusterctl_upgrade.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ type deleteClusterV1alpha3Input struct {
482482

483483
// deleteClusterV1alpha3 deletes the cluster and waits for everything the cluster owned to actually be gone using the older API.
484484
func deleteClusterV1alpha3(ctx context.Context, input deleteClusterV1alpha3Input) {
485-
By(fmt.Sprintf("Deleting cluster %s", input.Cluster.GetName()))
485+
Byf("Deleting cluster %s", input.Cluster.GetName())
486486
Expect(input.Deleter.Delete(ctx, input.Cluster)).To(Succeed())
487487
}
488488

@@ -494,7 +494,7 @@ type waitForClusterDeletedV1alpha3Input struct {
494494

495495
// waitForClusterDeletedV1alpha3 waits until the cluster object has been deleted using the older API.
496496
func waitForClusterDeletedV1alpha3(ctx context.Context, input waitForClusterDeletedV1alpha3Input, intervals ...interface{}) {
497-
By(fmt.Sprintf("Waiting for cluster %s to be deleted", input.Cluster.GetName()))
497+
Byf("Waiting for cluster %s to be deleted", input.Cluster.GetName())
498498
Eventually(func() bool {
499499
cluster := &clusterv1alpha3.Cluster{}
500500
key := client.ObjectKey{
@@ -552,7 +552,7 @@ type deleteClusterV1alpha4Input struct {
552552

553553
// deleteClusterV1alpha4 deletes the cluster and waits for everything the cluster owned to actually be gone using the older API.
554554
func deleteClusterV1alpha4(ctx context.Context, input deleteClusterV1alpha4Input) {
555-
By(fmt.Sprintf("Deleting cluster %s", input.Cluster.GetName()))
555+
Byf("Deleting cluster %s", input.Cluster.GetName())
556556
Expect(input.Deleter.Delete(ctx, input.Cluster)).To(Succeed())
557557
}
558558

@@ -564,7 +564,7 @@ type waitForClusterDeletedV1alpha4Input struct {
564564

565565
// waitForClusterDeletedV1alpha4 waits until the cluster object has been deleted using the older API.
566566
func waitForClusterDeletedV1alpha4(ctx context.Context, input waitForClusterDeletedV1alpha4Input, intervals ...interface{}) {
567-
By(fmt.Sprintf("Waiting for cluster %s to be deleted", input.Cluster.GetName()))
567+
Byf("Waiting for cluster %s to be deleted", input.Cluster.GetName())
568568
Eventually(func() bool {
569569
cluster := &clusterv1alpha4.Cluster{}
570570
key := client.ObjectKey{

test/framework/alltypes_helpers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
"sigs.k8s.io/yaml"
3737

3838
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
39+
. "sigs.k8s.io/cluster-api/test/framework/ginkgoextensions"
3940
)
4041

4142
// GetCAPIResourcesInput is the input for GetCAPIResources.
@@ -167,7 +168,7 @@ func CreateRelatedResources(ctx context.Context, input CreateRelatedResourcesInp
167168
By("creating related resources")
168169
for i := range input.RelatedResources {
169170
obj := input.RelatedResources[i]
170-
By(fmt.Sprintf("creating a/an %s resource", obj.GetObjectKind().GroupVersionKind()))
171+
Byf("creating a/an %s resource", obj.GetObjectKind().GroupVersionKind())
171172
Eventually(func() error {
172173
return input.Creator.Create(ctx, obj)
173174
}, intervals...).Should(Succeed())

test/framework/cluster_helpers.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package framework
1818

1919
import (
2020
"context"
21-
"fmt"
2221

2322
. "github.com/onsi/ginkgo"
2423
. "github.com/onsi/gomega"
@@ -27,6 +26,7 @@ import (
2726
"sigs.k8s.io/controller-runtime/pkg/client"
2827

2928
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
29+
. "sigs.k8s.io/cluster-api/test/framework/ginkgoextensions"
3030
"sigs.k8s.io/cluster-api/test/framework/internal/log"
3131
"sigs.k8s.io/cluster-api/util/patch"
3232
)
@@ -152,7 +152,7 @@ type DeleteClusterInput struct {
152152

153153
// DeleteCluster deletes the cluster and waits for everything the cluster owned to actually be gone.
154154
func DeleteCluster(ctx context.Context, input DeleteClusterInput) {
155-
By(fmt.Sprintf("Deleting cluster %s", input.Cluster.GetName()))
155+
Byf("Deleting cluster %s", input.Cluster.GetName())
156156
Expect(input.Deleter.Delete(ctx, input.Cluster)).To(Succeed())
157157
}
158158

@@ -164,7 +164,7 @@ type WaitForClusterDeletedInput struct {
164164

165165
// WaitForClusterDeleted waits until the cluster object has been deleted.
166166
func WaitForClusterDeleted(ctx context.Context, input WaitForClusterDeletedInput, intervals ...interface{}) {
167-
By(fmt.Sprintf("Waiting for cluster %s to be deleted", input.Cluster.GetName()))
167+
Byf("Waiting for cluster %s to be deleted", input.Cluster.GetName())
168168
Eventually(func() bool {
169169
cluster := &clusterv1.Cluster{}
170170
key := client.ObjectKey{

test/framework/clusterctl/repository.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ import (
2828
"regexp"
2929
"strings"
3030

31-
. "github.com/onsi/ginkgo"
3231
. "github.com/onsi/gomega"
3332
"github.com/pkg/errors"
3433

3534
clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
3635
"sigs.k8s.io/cluster-api/test/framework/exec"
36+
. "sigs.k8s.io/cluster-api/test/framework/ginkgoextensions"
3737
)
3838

3939
const (
@@ -58,7 +58,7 @@ type CreateRepositoryInput struct {
5858
//
5959
// NOTE: this transformation is specifically designed for replacing "data: ${envSubstVar}".
6060
func (i *CreateRepositoryInput) RegisterClusterResourceSetConfigMapTransformation(manifestPath, envSubstVar string) {
61-
By(fmt.Sprintf("Reading the ClusterResourceSet manifest %s", manifestPath))
61+
Byf("Reading the ClusterResourceSet manifest %s", manifestPath)
6262
manifestData, err := os.ReadFile(manifestPath) //nolint:gosec
6363
Expect(err).ToNot(HaveOccurred(), "Failed to read the ClusterResourceSet manifest file")
6464
Expect(manifestData).ToNot(BeEmpty(), "ClusterResourceSet manifest file should not be empty")

test/framework/deployment_helpers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343
"sigs.k8s.io/controller-runtime/pkg/client"
4444

4545
controlplanev1 "sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta1"
46+
. "sigs.k8s.io/cluster-api/test/framework/ginkgoextensions"
4647
"sigs.k8s.io/cluster-api/test/framework/internal/log"
4748
)
4849

@@ -61,7 +62,7 @@ type WaitForDeploymentsAvailableInput struct {
6162
// all the desired replicas are in place.
6263
// This can be used to check if Cluster API controllers installed in the management cluster are working.
6364
func WaitForDeploymentsAvailable(ctx context.Context, input WaitForDeploymentsAvailableInput, intervals ...interface{}) {
64-
By(fmt.Sprintf("Waiting for deployment %s/%s to be available", input.Deployment.GetNamespace(), input.Deployment.GetName()))
65+
Byf("Waiting for deployment %s/%s to be available", input.Deployment.GetNamespace(), input.Deployment.GetName())
6566
deployment := &appsv1.Deployment{}
6667
Eventually(func() bool {
6768
key := client.ObjectKey{

test/framework/machine_helpers.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,15 @@ package framework
1818

1919
import (
2020
"context"
21-
"fmt"
2221

23-
. "github.com/onsi/ginkgo"
2422
. "github.com/onsi/gomega"
2523
"github.com/pkg/errors"
2624
corev1 "k8s.io/api/core/v1"
2725
"k8s.io/apimachinery/pkg/types"
2826
"sigs.k8s.io/controller-runtime/pkg/client"
2927

3028
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
29+
. "sigs.k8s.io/cluster-api/test/framework/ginkgoextensions"
3130
"sigs.k8s.io/cluster-api/test/framework/internal/log"
3231
"sigs.k8s.io/cluster-api/util/conditions"
3332
"sigs.k8s.io/cluster-api/util/patch"
@@ -128,7 +127,7 @@ func WaitForControlPlaneMachinesToBeUpgraded(ctx context.Context, input WaitForC
128127
Expect(input.KubernetesUpgradeVersion).ToNot(BeEmpty(), "Invalid argument. input.KubernetesUpgradeVersion can't be empty when calling WaitForControlPlaneMachinesToBeUpgraded")
129128
Expect(input.MachineCount).To(BeNumerically(">", 0), "Invalid argument. input.MachineCount can't be smaller than 1 when calling WaitForControlPlaneMachinesToBeUpgraded")
130129

131-
By(fmt.Sprintf("Ensuring all control-plane machines have upgraded kubernetes version %s", input.KubernetesUpgradeVersion))
130+
Byf("Ensuring all control-plane machines have upgraded kubernetes version %s", input.KubernetesUpgradeVersion)
132131

133132
Eventually(func() (int, error) {
134133
machines := GetControlPlaneMachinesByCluster(ctx, GetControlPlaneMachinesByClusterInput{

test/framework/machinedeployment_helpers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"sigs.k8s.io/controller-runtime/pkg/client"
3030

3131
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
32+
. "sigs.k8s.io/cluster-api/test/framework/ginkgoextensions"
3233
"sigs.k8s.io/cluster-api/test/framework/internal/log"
3334
"sigs.k8s.io/cluster-api/util"
3435
"sigs.k8s.io/cluster-api/util/patch"
@@ -145,7 +146,7 @@ func AssertMachineDeploymentFailureDomains(ctx context.Context, input AssertMach
145146

146147
machineDeploymentFD := pointer.StringDeref(input.MachineDeployment.Spec.Template.Spec.FailureDomain, "<None>")
147148

148-
By(fmt.Sprintf("Checking all the machines controlled by %s are in the %q failure domain", input.MachineDeployment.Name, machineDeploymentFD))
149+
Byf("Checking all the machines controlled by %s are in the %q failure domain", input.MachineDeployment.Name, machineDeploymentFD)
149150
selectorMap, err := metav1.LabelSelectorAsMap(&input.MachineDeployment.Spec.Selector)
150151
Expect(err).NotTo(HaveOccurred())
151152

0 commit comments

Comments
 (0)