Skip to content

Commit

Permalink
chore: unnecessary use of fmt.Sprintf (openkruise#1403)
Browse files Browse the repository at this point in the history
  • Loading branch information
testwill authored Sep 6, 2023
1 parent b282fa4 commit 7955c64
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion test/e2e/apps/resourcedistribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ var _ = SIGDescribe("ResourceDistribution", func() {
for _, cs := range cases {
ginkgo.By(cs.name)
allNamespaces := cs.getNamespaces()
ginkgo.By(fmt.Sprintf("creating namespaces"))
ginkgo.By("creating namespaces")
tester.CreateNamespaces(allNamespaces...)

ginkgo.By(fmt.Sprintf("Creating ResourceDistribution %s", resourceDistribution.Name))
Expand Down
38 changes: 19 additions & 19 deletions test/e2e/apps/sidecarset.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ var _ = SIGDescribe("SidecarSet", func() {
gomega.Expect(pods).To(gomega.HaveLen(int(*deployment.Spec.Replicas)))
pod := pods[0]
gomega.Expect(pod.Spec.Containers).To(gomega.HaveLen(len(deployment.Spec.Template.Spec.Containers)))
ginkgo.By(fmt.Sprintf("test no matched sidecarSet done"))
ginkgo.By("test no matched sidecarSet done")
})

framework.ConformanceIt("sidecarset with volumes.downwardAPI", func() {
Expand Down Expand Up @@ -148,7 +148,7 @@ var _ = SIGDescribe("SidecarSet", func() {
for i, except := range exceptContainers {
gomega.Expect(except).To(gomega.Equal(pod.Spec.Containers[i].Name))
}
ginkgo.By(fmt.Sprintf("sidecarSet inject pod sidecar container done"))
ginkgo.By("sidecarSet inject pod sidecar container done")
})

framework.ConformanceIt("sidecarSet inject pod sidecar container volumeMounts", func() {
Expand Down Expand Up @@ -239,7 +239,7 @@ var _ = SIGDescribe("SidecarSet", func() {
gomega.Expect(object).ShouldNot(gomega.BeNil())
}
}
ginkgo.By(fmt.Sprintf("sidecarSet inject pod sidecar container volumeMounts done"))
ginkgo.By("sidecarSet inject pod sidecar container volumeMounts done")
})

framework.ConformanceIt("sidecarSet inject pod sidecar container volumeMounts, SubPathExpr with expanded subpath", func() {
Expand Down Expand Up @@ -342,7 +342,7 @@ var _ = SIGDescribe("SidecarSet", func() {
gomega.Expect(object).ShouldNot(gomega.BeNil())
}
}
ginkgo.By(fmt.Sprintf("sidecarSet inject pod sidecar container volumeMounts, SubPathExpr with expanded subpath done"))
ginkgo.By("sidecarSet inject pod sidecar container volumeMounts, SubPathExpr with expanded subpath done")
})

framework.ConformanceIt("sidecarSet inject pod sidecar container transfer Envs", func() {
Expand Down Expand Up @@ -413,7 +413,7 @@ var _ = SIGDescribe("SidecarSet", func() {
object := util.GetContainerEnvValue(sidecarContainer, key)
gomega.Expect(object).To(gomega.Equal(value))
}
ginkgo.By(fmt.Sprintf("sidecarSet inject pod sidecar container transfer Envs done"))
ginkgo.By("sidecarSet inject pod sidecar container transfer Envs done")
})

framework.ConformanceIt("sidecarSet inject pod sidecar container transfer Envs with downward API by metadata.labels", func() {
Expand Down Expand Up @@ -488,7 +488,7 @@ var _ = SIGDescribe("SidecarSet", func() {
object := util.GetContainerEnvValue(sidecarContainer, key)
gomega.Expect(object).To(gomega.Equal(value))
}
ginkgo.By(fmt.Sprintf("sidecarSet inject pod sidecar container transfer Envs with downward API by metadata.labels done"))
ginkgo.By("sidecarSet inject pod sidecar container transfer Envs with downward API by metadata.labels done")
})

framework.ConformanceIt("sidecarSet inject pod sidecar container transfer Envs with downward API by metadata.annotations", func() {
Expand Down Expand Up @@ -563,7 +563,7 @@ var _ = SIGDescribe("SidecarSet", func() {
object := util.GetContainerEnvValue(sidecarContainer, key)
gomega.Expect(object).To(gomega.Equal(value))
}
ginkgo.By(fmt.Sprintf("sidecarSet inject pod sidecar container transfer Envs with downward API by metadata.annotations done"))
ginkgo.By("sidecarSet inject pod sidecar container transfer Envs with downward API by metadata.annotations done")
})
})

Expand Down Expand Up @@ -668,7 +668,7 @@ var _ = SIGDescribe("SidecarSet", func() {
gomega.Expect(pod.Spec.Containers[0].Image).Should(gomega.Equal(BusyboxImage))
gomega.Expect(pod.Annotations["key"]).Should(gomega.Equal(`{"nginx-sidecar":2}`))
}
ginkgo.By(fmt.Sprintf("sidecarSet update pod annotations done"))
ginkgo.By("sidecarSet update pod annotations done")
})

framework.ConformanceIt("sidecarSet upgrade cold sidecar container image only", func() {
Expand Down Expand Up @@ -743,7 +743,7 @@ var _ = SIGDescribe("SidecarSet", func() {
_, sidecarSetUpgradable := podutil.GetPodCondition(&pod.Status, sidecarcontrol.SidecarSetUpgradable)
gomega.Expect(sidecarSetUpgradable.Status).Should(gomega.Equal(corev1.ConditionTrue))
}
ginkgo.By(fmt.Sprintf("sidecarSet upgrade cold sidecar container image done"))
ginkgo.By("sidecarSet upgrade cold sidecar container image done")
})

framework.ConformanceIt("sidecarSet upgrade cold sidecar container failed image, and only update one pod", func() {
Expand Down Expand Up @@ -833,7 +833,7 @@ var _ = SIGDescribe("SidecarSet", func() {
gomega.Expect(reflect.DeepEqual(origin.List(), target2.List())).To(gomega.Equal(true))
}

ginkgo.By(fmt.Sprintf("sidecarSet upgrade cold sidecar container failed image, and only update one pod done"))
ginkgo.By("sidecarSet upgrade cold sidecar container failed image, and only update one pod done")
})

framework.ConformanceIt("sidecarSet upgrade sidecar container (more than image field), no pod should be updated", func() {
Expand Down Expand Up @@ -1029,7 +1029,7 @@ var _ = SIGDescribe("SidecarSet", func() {
ReadyPods: 2,
}
tester.WaitForSidecarSetUpgradeComplete(sidecarSetIn, except)
ginkgo.By(fmt.Sprintf("sidecarSet upgrade cold sidecar container image, and paused done"))
ginkgo.By("sidecarSet upgrade cold sidecar container image, and paused done")
})

framework.ConformanceIt("sidecarSet upgrade cold sidecar container image, and selector", func() {
Expand Down Expand Up @@ -1102,7 +1102,7 @@ var _ = SIGDescribe("SidecarSet", func() {
}
time.Sleep(time.Minute)
tester.WaitForSidecarSetUpgradeComplete(sidecarSetIn, except)
ginkgo.By(fmt.Sprintf("sidecarSet upgrade cold sidecar container image, and selector done"))
ginkgo.By("sidecarSet upgrade cold sidecar container image, and selector done")
})

framework.ConformanceIt("sidecarSet upgrade cold sidecar container image, and partition", func() {
Expand Down Expand Up @@ -1157,7 +1157,7 @@ var _ = SIGDescribe("SidecarSet", func() {
}
tester.WaitForSidecarSetUpgradeComplete(sidecarSetIn, except)

ginkgo.By(fmt.Sprintf("sidecarSet upgrade cold sidecar container image, and partition done"))
ginkgo.By("sidecarSet upgrade cold sidecar container image, and partition done")
})

framework.ConformanceIt("sidecarSet upgrade cold sidecar container image, and maxUnavailable", func() {
Expand Down Expand Up @@ -1205,7 +1205,7 @@ var _ = SIGDescribe("SidecarSet", func() {
ReadyPods: 4,
}
tester.WaitForSidecarSetUpgradeComplete(sidecarSetIn, except)
ginkgo.By(fmt.Sprintf("sidecarSet upgrade cold sidecar container image, and maxUnavailable done"))
ginkgo.By("sidecarSet upgrade cold sidecar container image, and maxUnavailable done")
})

framework.ConformanceIt("sidecarSet update init sidecar container, and don't upgrade", func() {
Expand Down Expand Up @@ -1239,13 +1239,13 @@ var _ = SIGDescribe("SidecarSet", func() {
// update sidecarSet sidecar container
sidecarSetIn.Spec.InitContainers[0].Image = InvalidImage
tester.UpdateSidecarSet(sidecarSetIn)
ginkgo.By(fmt.Sprintf("update sidecarset init container image, and sidecarSet hash not changed"))
ginkgo.By("update sidecarset init container image, and sidecarSet hash not changed")
time.Sleep(time.Second * 5)
sidecarSetIn, _ = kc.AppsV1alpha1().SidecarSets().Get(context.TODO(), sidecarSetIn.Name, metav1.GetOptions{})
hash2 := sidecarSetIn.Annotations[sidecarcontrol.SidecarSetHashAnnotation]
// hash not changed
gomega.Expect(hash1).To(gomega.Equal(hash2))
ginkgo.By(fmt.Sprintf("sidecarSet upgrade init sidecar container, and don't upgrade done"))
ginkgo.By("sidecarSet upgrade init sidecar container, and don't upgrade done")
})

framework.ConformanceIt("sidecarSet history revision checker", func() {
Expand Down Expand Up @@ -1310,7 +1310,7 @@ var _ = SIGDescribe("SidecarSet", func() {
waitingForSidecarSetReconcile(sidecarSetIn.Name)
expectedOrder = []int64{6, 7, 8, 9, 10, 11, 13, 14, 15, 16}
revisionChecker(sidecarSetIn, 10, expectedOrder)
ginkgo.By(fmt.Sprintf("sidecarSet history revision check done"))
ginkgo.By("sidecarSet history revision check done")
})

framework.ConformanceIt("sidecarSet history revision data checker", func() {
Expand Down Expand Up @@ -1376,7 +1376,7 @@ var _ = SIGDescribe("SidecarSet", func() {
waitingForSidecarSetReconcile(sidecarSetIn.Name)
list := tester.ListControllerRevisions(sidecarSetIn)
revisionChecker(list)
ginkgo.By(fmt.Sprintf("sidecarSet history revision data check done"))
ginkgo.By("sidecarSet history revision data check done")
})

framework.ConformanceIt("sidecarSet InjectionStrategy.Revision checker", func() {
Expand Down Expand Up @@ -1461,7 +1461,7 @@ var _ = SIGDescribe("SidecarSet", func() {
err = json.Unmarshal([]byte(pods[0].Annotations[sidecarcontrol.SidecarSetHashAnnotation]), &hash)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Expect(hash[sidecarSetIn.Name].SidecarSetControllerRevision).To(gomega.Equal(list[5].Name))
ginkgo.By(fmt.Sprintf("sidecarSet InjectionStrategy.Revision check done"))
ginkgo.By("sidecarSet InjectionStrategy.Revision check done")
})
})
})
6 changes: 3 additions & 3 deletions test/e2e/apps/sidecarset_hotupgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ var _ = SIGDescribe("SidecarSet", func() {
gomega.Expect(sidecarContainer).ShouldNot(gomega.BeNil())
gomega.Expect(sidecarContainer.Image).To(gomega.Equal(image))
}
ginkgo.By(fmt.Sprintf("sidecarSet inject pod hot upgrade sidecar container done"))
ginkgo.By("sidecarSet inject pod hot upgrade sidecar container done")
})

framework.ConformanceIt("sidecarSet upgrade hot sidecar container image", func() {
Expand Down Expand Up @@ -204,7 +204,7 @@ var _ = SIGDescribe("SidecarSet", func() {
time.Sleep(time.Second * 30)
tester.WaitForSidecarSetUpgradeComplete(sidecarSetIn, except)

ginkgo.By(fmt.Sprintf("sidecarSet upgrade hot sidecar container image done"))
ginkgo.By("sidecarSet upgrade hot sidecar container image done")
})

framework.ConformanceIt("sidecarSet upgrade hot sidecar container failed image", func() {
Expand Down Expand Up @@ -289,7 +289,7 @@ var _ = SIGDescribe("SidecarSet", func() {
gomega.Expect(emptySidecarContainer.Name).To(gomega.Equal("nginx-sidecar-1"))
gomega.Expect(emptySidecarContainer.Image).To(gomega.Equal(BusyboxImage))

ginkgo.By(fmt.Sprintf("sidecarSet upgrade hot sidecar container failed image done"))
ginkgo.By("sidecarSet upgrade hot sidecar container failed image done")
})
})
})
2 changes: 1 addition & 1 deletion test/e2e/apps/workloadspread.go
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ var _ = SIGDescribe("workloadspread", func() {
gomega.Expect(subset2Pods).To(gomega.Equal(5))

// wait subset-a to schedulable
ginkgo.By(fmt.Sprintf("wait subset-a to schedulable"))
ginkgo.By("wait subset-a to schedulable")
err = wait.PollImmediate(time.Second, time.Minute*5, func() (bool, error) {
ws, err := kc.AppsV1alpha1().WorkloadSpreads(workloadSpread.Namespace).Get(context.TODO(), workloadSpread.Name, metav1.GetOptions{})
if err != nil {
Expand Down
14 changes: 7 additions & 7 deletions test/e2e/policy/podunavailablebudget.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ var _ = SIGDescribe("PodUnavailableBudget", func() {

time.Sleep(time.Second)
// check sidecarSet inject sidecar container
ginkgo.By(fmt.Sprintf("check sidecarSet inject sidecar container and pub status"))
ginkgo.By("check sidecarSet inject sidecar container and pub status")
pods, err := sidecarTester.GetSelectorPods(deployment.Namespace, deployment.Spec.Selector)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
pod := pods[0]
Expand All @@ -652,14 +652,14 @@ var _ = SIGDescribe("PodUnavailableBudget", func() {
}, 30*time.Second, time.Second).Should(gomega.Equal(expectStatus))

// update sidecar container failed image
ginkgo.By(fmt.Sprintf("update sidecar container failed image"))
ginkgo.By("update sidecar container failed image")
sidecarSet, err = kc.AppsV1alpha1().SidecarSets().Get(context.TODO(), sidecarSet.Name, metav1.GetOptions{})
gomega.Expect(err).NotTo(gomega.HaveOccurred())
sidecarSet.Spec.Containers[0].Image = InvalidImage
sidecarTester.UpdateSidecarSet(sidecarSet)

// wait 1 seconds, and check sidecarSet upgrade block
ginkgo.By(fmt.Sprintf("wait 1 seconds, and check sidecarSet upgrade block"))
ginkgo.By("wait 1 seconds, and check sidecarSet upgrade block")
time.Sleep(time.Second)
except := &appsv1alpha1.SidecarSetStatus{
MatchedPods: 5,
Expand Down Expand Up @@ -691,15 +691,15 @@ var _ = SIGDescribe("PodUnavailableBudget", func() {
}, 20*time.Second, time.Second).Should(gomega.Equal(expectStatus))

// update sidecar container success image
ginkgo.By(fmt.Sprintf("update sidecar container success image"))
ginkgo.By("update sidecar container success image")
sidecarSet, err = kc.AppsV1alpha1().SidecarSets().Get(context.TODO(), sidecarSet.Name, metav1.GetOptions{})
gomega.Expect(err).NotTo(gomega.HaveOccurred())
sidecarSet.Spec.Containers[0].Image = NewNginxImage
sidecarTester.UpdateSidecarSet(sidecarSet)

time.Sleep(time.Second)
// check sidecarSet upgrade success
ginkgo.By(fmt.Sprintf("check sidecarSet upgrade success"))
ginkgo.By("check sidecarSet upgrade success")
except = &appsv1alpha1.SidecarSetStatus{
MatchedPods: 5,
UpdatedPods: 5,
Expand Down Expand Up @@ -1121,7 +1121,7 @@ var _ = SIGDescribe("PodUnavailableBudget", func() {

time.Sleep(time.Second)
// check sidecarSet inject sidecar container
ginkgo.By(fmt.Sprintf("check sidecarSet inject sidecar container and pub status"))
ginkgo.By("check sidecarSet inject sidecar container and pub status")
pods, err := sidecarTester.GetSelectorPods(cloneset.Namespace, cloneset.Spec.Selector)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
pod := pods[0]
Expand Down Expand Up @@ -1150,7 +1150,7 @@ var _ = SIGDescribe("PodUnavailableBudget", func() {
cloneset, err = kc.AppsV1alpha1().CloneSets(cloneset.Namespace).Update(context.TODO(), cloneset, metav1.UpdateOptions{})
gomega.Expect(err).NotTo(gomega.HaveOccurred())
// update sidecar container success image
ginkgo.By(fmt.Sprintf("update sidecar container success image"))
ginkgo.By("update sidecar container success image")
sidecarSet.Spec.Containers[0].Image = NewNginxImage
sidecarTester.UpdateSidecarSet(sidecarSet)
time.Sleep(time.Second)
Expand Down

0 comments on commit 7955c64

Please sign in to comment.