Skip to content

Commit

Permalink
fix UT
Browse files Browse the repository at this point in the history
  • Loading branch information
fgksgf committed Jan 13, 2025
1 parent c172158 commit 957df63
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pkg/controllers/tidb/tasks/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (

const (
fakeVersion = "v1.2.3"
podSpecHash = "9bbf8897b"
podSpecHash = "6cfdc7d895"
)

func TestTaskPod(t *testing.T) {
Expand Down
15 changes: 9 additions & 6 deletions pkg/controllers/tiflash/tasks/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ import (
"github.com/pingcap/tidb-operator/pkg/utils/task/v3"
)

const fakeVersion = "v1.2.3"
const (
fakeVersion = "v1.2.3"
podSpecHash = "5575684b96"
)

func TestTaskPod(t *testing.T) {
cases := []struct {
Expand Down Expand Up @@ -123,7 +126,7 @@ func TestTaskPod(t *testing.T) {
pod: fake.FakeObj("aaa-tiflash-xxx", func(obj *corev1.Pod) *corev1.Pod {
obj.Labels = map[string]string{
v1alpha1.LabelKeyConfigHash: "newest",
v1alpha1.LabelKeyPodSpecHash: "556796549d",
v1alpha1.LabelKeyPodSpecHash: podSpecHash,
}
return obj
}),
Expand All @@ -147,7 +150,7 @@ func TestTaskPod(t *testing.T) {
pod: fake.FakeObj("aaa-tiflash-xxx", func(obj *corev1.Pod) *corev1.Pod {
obj.Labels = map[string]string{
v1alpha1.LabelKeyConfigHash: "old",
v1alpha1.LabelKeyPodSpecHash: "556796549d",
v1alpha1.LabelKeyPodSpecHash: podSpecHash,
}
return obj
}),
Expand All @@ -171,7 +174,7 @@ func TestTaskPod(t *testing.T) {
pod: fake.FakeObj("aaa-tiflash-xxx", func(obj *corev1.Pod) *corev1.Pod {
obj.Labels = map[string]string{
v1alpha1.LabelKeyConfigHash: "newest",
v1alpha1.LabelKeyPodSpecHash: "556796549d",
v1alpha1.LabelKeyPodSpecHash: podSpecHash,
"xxx": "yyy",
}
return obj
Expand All @@ -196,7 +199,7 @@ func TestTaskPod(t *testing.T) {
pod: fake.FakeObj("aaa-tiflash-xxx", func(obj *corev1.Pod) *corev1.Pod {
obj.Labels = map[string]string{
v1alpha1.LabelKeyConfigHash: "newest",
v1alpha1.LabelKeyPodSpecHash: "556796549d",
v1alpha1.LabelKeyPodSpecHash: podSpecHash,
"xxx": "yyy",
}
return obj
Expand All @@ -222,7 +225,7 @@ func TestTaskPod(t *testing.T) {
obj.Labels = map[string]string{
v1alpha1.LabelKeyInstance: "aaa-xxx",
v1alpha1.LabelKeyConfigHash: "newest",
v1alpha1.LabelKeyPodSpecHash: "556796549d",
v1alpha1.LabelKeyPodSpecHash: podSpecHash,
}
return obj
}),
Expand Down
15 changes: 9 additions & 6 deletions pkg/controllers/tikv/tasks/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ import (
"github.com/pingcap/tidb-operator/pkg/utils/task/v3"
)

const fakeVersion = "v1.2.3"
const (
fakeVersion = "v1.2.3"
podSpecHash = "6b85d6945f"
)

func TestTaskPod(t *testing.T) {
now := metav1.Now()
Expand Down Expand Up @@ -173,7 +176,7 @@ func TestTaskPod(t *testing.T) {
pod: fake.FakeObj("aaa-tikv-xxx", func(obj *corev1.Pod) *corev1.Pod {
obj.Labels = map[string]string{
v1alpha1.LabelKeyConfigHash: "newest",
v1alpha1.LabelKeyPodSpecHash: "59f798884b",
v1alpha1.LabelKeyPodSpecHash: podSpecHash,
}
return obj
}),
Expand All @@ -197,7 +200,7 @@ func TestTaskPod(t *testing.T) {
pod: fake.FakeObj("aaa-tikv-xxx", func(obj *corev1.Pod) *corev1.Pod {
obj.Labels = map[string]string{
v1alpha1.LabelKeyConfigHash: "old",
v1alpha1.LabelKeyPodSpecHash: "59f798884b",
v1alpha1.LabelKeyPodSpecHash: podSpecHash,
}
return obj
}),
Expand All @@ -221,7 +224,7 @@ func TestTaskPod(t *testing.T) {
pod: fake.FakeObj("aaa-tikv-xxx", func(obj *corev1.Pod) *corev1.Pod {
obj.Labels = map[string]string{
v1alpha1.LabelKeyConfigHash: "newest",
v1alpha1.LabelKeyPodSpecHash: "59f798884b",
v1alpha1.LabelKeyPodSpecHash: podSpecHash,
"xxx": "yyy",
}
return obj
Expand All @@ -246,7 +249,7 @@ func TestTaskPod(t *testing.T) {
pod: fake.FakeObj("aaa-tikv-xxx", func(obj *corev1.Pod) *corev1.Pod {
obj.Labels = map[string]string{
v1alpha1.LabelKeyConfigHash: "newest",
v1alpha1.LabelKeyPodSpecHash: "59f798884b",
v1alpha1.LabelKeyPodSpecHash: podSpecHash,
"xxx": "yyy",
}
return obj
Expand All @@ -272,7 +275,7 @@ func TestTaskPod(t *testing.T) {
obj.Labels = map[string]string{
v1alpha1.LabelKeyInstance: "aaa-xxx",
v1alpha1.LabelKeyConfigHash: "newest",
v1alpha1.LabelKeyPodSpecHash: "59f798884b",
v1alpha1.LabelKeyPodSpecHash: podSpecHash,
}
return obj
}),
Expand Down

0 comments on commit 957df63

Please sign in to comment.