@@ -17,12 +17,9 @@ limitations under the License.
17
17
package e2e
18
18
19
19
import (
20
- "context"
21
20
"fmt"
22
21
23
22
"github.com/onsi/ginkgo/v2"
24
- "github.com/onsi/gomega"
25
- "k8s.io/apimachinery/pkg/api/meta"
26
23
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27
24
"k8s.io/apimachinery/pkg/util/rand"
28
25
"k8s.io/apimachinery/pkg/util/sets"
@@ -66,15 +63,10 @@ var _ = framework.SerialDescribe("remedy testing", func() {
66
63
67
64
ginkgo .It ("Cluster domain name resolution function encounters an exception and recover" , func () {
68
65
ginkgo .By (fmt .Sprintf ("update Cluster(%s) %s condition to false" , targetCluster , remedyv1alpha1 .ServiceDomainNameResolutionReady ), func () {
69
- clusterObj , err := karmadaClient .ClusterV1alpha1 ().Clusters ().Get (context .TODO (), targetCluster , metav1.GetOptions {})
70
- gomega .Expect (err ).ShouldNot (gomega .HaveOccurred ())
71
-
72
- meta .SetStatusCondition (& clusterObj .Status .Conditions , metav1.Condition {
66
+ framework .UpdateClusterStatusCondition (karmadaClient , targetCluster , metav1.Condition {
73
67
Type : string (remedyv1alpha1 .ServiceDomainNameResolutionReady ),
74
68
Status : metav1 .ConditionFalse ,
75
69
})
76
- _ , err = karmadaClient .ClusterV1alpha1 ().Clusters ().UpdateStatus (context .TODO (), clusterObj , metav1.UpdateOptions {})
77
- gomega .Expect (err ).ShouldNot (gomega .HaveOccurred ())
78
70
})
79
71
80
72
ginkgo .By (fmt .Sprintf ("wait Cluster(%s) status has TrafficControl RemedyAction" , targetCluster ), func () {
@@ -86,15 +78,10 @@ var _ = framework.SerialDescribe("remedy testing", func() {
86
78
})
87
79
88
80
ginkgo .By (fmt .Sprintf ("recover Cluster(%s) %s condition to true" , targetCluster , remedyv1alpha1 .ServiceDomainNameResolutionReady ), func () {
89
- clusterObj , err := karmadaClient .ClusterV1alpha1 ().Clusters ().Get (context .TODO (), targetCluster , metav1.GetOptions {})
90
- gomega .Expect (err ).ShouldNot (gomega .HaveOccurred ())
91
-
92
- meta .SetStatusCondition (& clusterObj .Status .Conditions , metav1.Condition {
81
+ framework .UpdateClusterStatusCondition (karmadaClient , targetCluster , metav1.Condition {
93
82
Type : string (remedyv1alpha1 .ServiceDomainNameResolutionReady ),
94
83
Status : metav1 .ConditionTrue ,
95
84
})
96
- _ , err = karmadaClient .ClusterV1alpha1 ().Clusters ().UpdateStatus (context .TODO (), clusterObj , metav1.UpdateOptions {})
97
- gomega .Expect (err ).ShouldNot (gomega .HaveOccurred ())
98
85
})
99
86
100
87
ginkgo .By (fmt .Sprintf ("wait Cluster(%s) status doesn't has TrafficControl RemedyAction" , targetCluster ), func () {
@@ -112,15 +99,10 @@ var _ = framework.SerialDescribe("remedy testing", func() {
112
99
113
100
ginkgo .It ("Cluster domain name resolution function encounters an exception, then remove the remedy resource" , func () {
114
101
ginkgo .By (fmt .Sprintf ("update Cluster(%s) %s condition to false" , targetCluster , remedyv1alpha1 .ServiceDomainNameResolutionReady ), func () {
115
- clusterObj , err := karmadaClient .ClusterV1alpha1 ().Clusters ().Get (context .TODO (), targetCluster , metav1.GetOptions {})
116
- gomega .Expect (err ).ShouldNot (gomega .HaveOccurred ())
117
-
118
- meta .SetStatusCondition (& clusterObj .Status .Conditions , metav1.Condition {
102
+ framework .UpdateClusterStatusCondition (karmadaClient , targetCluster , metav1.Condition {
119
103
Type : string (remedyv1alpha1 .ServiceDomainNameResolutionReady ),
120
104
Status : metav1 .ConditionFalse ,
121
105
})
122
- _ , err = karmadaClient .ClusterV1alpha1 ().Clusters ().UpdateStatus (context .TODO (), clusterObj , metav1.UpdateOptions {})
123
- gomega .Expect (err ).ShouldNot (gomega .HaveOccurred ())
124
106
})
125
107
126
108
ginkgo .By (fmt .Sprintf ("wait Cluster(%s) status has TrafficControl RemedyAction" , targetCluster ), func () {
@@ -144,15 +126,10 @@ var _ = framework.SerialDescribe("remedy testing", func() {
144
126
})
145
127
146
128
ginkgo .By (fmt .Sprintf ("cleanup: recover Cluster(%s) %s to true" , targetCluster , remedyv1alpha1 .ServiceDomainNameResolutionReady ), func () {
147
- clusterObj , err := karmadaClient .ClusterV1alpha1 ().Clusters ().Get (context .TODO (), targetCluster , metav1.GetOptions {})
148
- gomega .Expect (err ).ShouldNot (gomega .HaveOccurred ())
149
-
150
- meta .SetStatusCondition (& clusterObj .Status .Conditions , metav1.Condition {
129
+ framework .UpdateClusterStatusCondition (karmadaClient , targetCluster , metav1.Condition {
151
130
Type : string (remedyv1alpha1 .ServiceDomainNameResolutionReady ),
152
131
Status : metav1 .ConditionTrue ,
153
132
})
154
- _ , err = karmadaClient .ClusterV1alpha1 ().Clusters ().UpdateStatus (context .TODO (), clusterObj , metav1.UpdateOptions {})
155
- gomega .Expect (err ).ShouldNot (gomega .HaveOccurred ())
156
133
})
157
134
})
158
135
})
0 commit comments