@@ -55,6 +55,7 @@ var invalidCert = []byte("Cg==")
5555
5656// Invalid CABundle should prevent new CRD from being set to Established
5757func TestInvalidCABundle (t * testing.T ) {
58+ ctx := context .Background ()
5859 tearDown , apiExtensionClient , _ , err := fixtures .StartDefaultServerWithClients (t )
5960 if err != nil {
6061 t .Fatal (err )
@@ -75,13 +76,13 @@ func TestInvalidCABundle(t *testing.T) {
7576 ConversionReviewVersions : []string {"v1beta1" },
7677 },
7778 }
78- crd , err = apiExtensionClient .ApiextensionsV1 ().CustomResourceDefinitions ().Create (context . TODO () , crd , metav1.CreateOptions {})
79+ crd , err = apiExtensionClient .ApiextensionsV1 ().CustomResourceDefinitions ().Create (ctx , crd , metav1.CreateOptions {})
7980 if err != nil {
8081 t .Fatal (err )
8182 }
8283 // 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 {})
8586 if err != nil {
8687 return false , err
8788 }
@@ -101,6 +102,7 @@ func TestInvalidCABundle(t *testing.T) {
101102
102103// Valid CABundle should set CRD to Established.
103104func TestValidCABundle (t * testing.T ) {
105+ ctx := context .Background ()
104106 tearDown , apiExtensionClient , _ , err := fixtures .StartDefaultServerWithClients (t )
105107 if err != nil {
106108 t .Fatal (err )
@@ -122,13 +124,13 @@ func TestValidCABundle(t *testing.T) {
122124 },
123125 }
124126
125- crd , err = apiExtensionClient .ApiextensionsV1 ().CustomResourceDefinitions ().Create (context . TODO () , crd , metav1.CreateOptions {})
127+ crd , err = apiExtensionClient .ApiextensionsV1 ().CustomResourceDefinitions ().Create (ctx , crd , metav1.CreateOptions {})
126128 if err != nil {
127129 t .Fatal (err )
128130 }
129131 // 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 {})
132134 if err != nil {
133135 return false , err
134136 }
@@ -149,19 +151,20 @@ func TestValidCABundle(t *testing.T) {
149151
150152// No CABundle should set CRD to Established.
151153func TestMissingCABundle (t * testing.T ) {
154+ ctx := context .Background ()
152155 tearDown , apiExtensionClient , _ , err := fixtures .StartDefaultServerWithClients (t )
153156 if err != nil {
154157 t .Fatal (err )
155158 }
156159 defer tearDown ()
157160
158161 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 {})
160163 if err != nil {
161164 t .Fatal (err )
162165 }
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 {})
165168 if err != nil {
166169 return false , err
167170 }
0 commit comments