@@ -55,6 +55,7 @@ var invalidCert = []byte("Cg==")
55
55
56
56
// Invalid CABundle should prevent new CRD from being set to Established
57
57
func TestInvalidCABundle (t * testing.T ) {
58
+ ctx := context .Background ()
58
59
tearDown , apiExtensionClient , _ , err := fixtures .StartDefaultServerWithClients (t )
59
60
if err != nil {
60
61
t .Fatal (err )
@@ -75,13 +76,13 @@ func TestInvalidCABundle(t *testing.T) {
75
76
ConversionReviewVersions : []string {"v1beta1" },
76
77
},
77
78
}
78
- crd , err = apiExtensionClient .ApiextensionsV1 ().CustomResourceDefinitions ().Create (context . TODO () , crd , metav1.CreateOptions {})
79
+ crd , err = apiExtensionClient .ApiextensionsV1 ().CustomResourceDefinitions ().Create (ctx , crd , metav1.CreateOptions {})
79
80
if err != nil {
80
81
t .Fatal (err )
81
82
}
82
83
// Ensure that Established is false with reason InvalidCABundle
83
- err = wait .Poll ( 100 * time .Millisecond , 10 * time .Second , func () (bool , error ) {
84
- localCrd , err := apiExtensionClient .ApiextensionsV1 ().CustomResourceDefinitions ().Get (context . TODO () , crd .Name , metav1.GetOptions {})
84
+ err = wait .PollUntilContextTimeout ( ctx , 100 * time .Millisecond , 10 * time .Second , true , func (ctx context. Context ) (bool , error ) {
85
+ localCrd , err := apiExtensionClient .ApiextensionsV1 ().CustomResourceDefinitions ().Get (ctx , crd .Name , metav1.GetOptions {})
85
86
if err != nil {
86
87
return false , err
87
88
}
@@ -101,6 +102,7 @@ func TestInvalidCABundle(t *testing.T) {
101
102
102
103
// Valid CABundle should set CRD to Established.
103
104
func TestValidCABundle (t * testing.T ) {
105
+ ctx := context .Background ()
104
106
tearDown , apiExtensionClient , _ , err := fixtures .StartDefaultServerWithClients (t )
105
107
if err != nil {
106
108
t .Fatal (err )
@@ -122,13 +124,13 @@ func TestValidCABundle(t *testing.T) {
122
124
},
123
125
}
124
126
125
- crd , err = apiExtensionClient .ApiextensionsV1 ().CustomResourceDefinitions ().Create (context . TODO () , crd , metav1.CreateOptions {})
127
+ crd , err = apiExtensionClient .ApiextensionsV1 ().CustomResourceDefinitions ().Create (ctx , crd , metav1.CreateOptions {})
126
128
if err != nil {
127
129
t .Fatal (err )
128
130
}
129
131
// wait until the CRD is established
130
- err = wait .Poll ( 100 * time .Millisecond , 10 * time .Second , func () (bool , error ) {
131
- localCrd , err := apiExtensionClient .ApiextensionsV1 ().CustomResourceDefinitions ().Get (context . TODO () , crd .Name , metav1.GetOptions {})
132
+ err = wait .PollUntilContextTimeout ( ctx , 100 * time .Millisecond , 10 * time .Second , true , func (ctx context. Context ) (bool , error ) {
133
+ localCrd , err := apiExtensionClient .ApiextensionsV1 ().CustomResourceDefinitions ().Get (ctx , crd .Name , metav1.GetOptions {})
132
134
if err != nil {
133
135
return false , err
134
136
}
@@ -149,19 +151,20 @@ func TestValidCABundle(t *testing.T) {
149
151
150
152
// No CABundle should set CRD to Established.
151
153
func TestMissingCABundle (t * testing.T ) {
154
+ ctx := context .Background ()
152
155
tearDown , apiExtensionClient , _ , err := fixtures .StartDefaultServerWithClients (t )
153
156
if err != nil {
154
157
t .Fatal (err )
155
158
}
156
159
defer tearDown ()
157
160
158
161
crd := fixtures .NewRandomNameV1CustomResourceDefinition (apiextensionsv1 .NamespaceScoped )
159
- crd , err = apiExtensionClient .ApiextensionsV1 ().CustomResourceDefinitions ().Create (context . TODO () , crd , metav1.CreateOptions {})
162
+ crd , err = apiExtensionClient .ApiextensionsV1 ().CustomResourceDefinitions ().Create (ctx , crd , metav1.CreateOptions {})
160
163
if err != nil {
161
164
t .Fatal (err )
162
165
}
163
- err = wait .Poll ( 100 * time .Millisecond , 10 * time .Second , func () (bool , error ) {
164
- localCrd , err := apiExtensionClient .ApiextensionsV1 ().CustomResourceDefinitions ().Get (context . TODO () , crd .Name , metav1.GetOptions {})
166
+ err = wait .PollUntilContextTimeout ( ctx , 100 * time .Millisecond , 10 * time .Second , true , func (ctx context. Context ) (bool , error ) {
167
+ localCrd , err := apiExtensionClient .ApiextensionsV1 ().CustomResourceDefinitions ().Get (ctx , crd .Name , metav1.GetOptions {})
165
168
if err != nil {
166
169
return false , err
167
170
}
0 commit comments