@@ -48,20 +48,15 @@ import (
48
48
rbacv1 "k8s.io/api/rbac/v1"
49
49
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
50
50
apierrors "k8s.io/apimachinery/pkg/api/errors"
51
- "k8s.io/apimachinery/pkg/api/meta"
52
51
"k8s.io/apimachinery/pkg/api/resource"
53
52
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
54
- "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
55
53
"k8s.io/apimachinery/pkg/labels"
56
54
"k8s.io/apimachinery/pkg/runtime/schema"
57
55
utilnet "k8s.io/apimachinery/pkg/util/net"
58
- "k8s.io/apimachinery/pkg/util/rand"
59
56
"k8s.io/apimachinery/pkg/util/uuid"
60
57
"k8s.io/apimachinery/pkg/util/wait"
61
58
"k8s.io/apiserver/pkg/authentication/serviceaccount"
62
59
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
63
- "k8s.io/client-go/discovery"
64
- "k8s.io/client-go/dynamic"
65
60
clientset "k8s.io/client-go/kubernetes"
66
61
"k8s.io/kubectl/pkg/polymorphichelpers"
67
62
"k8s.io/kubernetes/pkg/controller"
@@ -74,7 +69,6 @@ import (
74
69
e2eservice "k8s.io/kubernetes/test/e2e/framework/service"
75
70
"k8s.io/kubernetes/test/e2e/framework/testfiles"
76
71
"k8s.io/kubernetes/test/e2e/scheduling"
77
- "k8s.io/kubernetes/test/integration/etcd"
78
72
testutils "k8s.io/kubernetes/test/utils"
79
73
"k8s.io/kubernetes/test/utils/crd"
80
74
imageutils "k8s.io/kubernetes/test/utils/image"
@@ -349,107 +343,6 @@ var _ = SIGDescribe("Kubectl client", func() {
349
343
})
350
344
})
351
345
352
- ginkgo .Describe ("kubectl get output" , func () {
353
- ginkgo .It ("should contain custom columns for each resource" , func () {
354
- randString := rand .String (10 )
355
-
356
- ignoredResources := map [string ]bool {
357
- // ignored for intentionally using standard fields.
358
- // This assumption is based on a lack of TableColumnDefinition
359
- // in pkg/printers/internalversion/printers.go
360
- "ClusterRole" : true ,
361
- "Role" : true ,
362
- "LimitRange" : true ,
363
- "PodPreset" : true ,
364
-
365
- // ignored for being disruptive in an e2e, and getting automatically deleted by a controller
366
- "Node" : true ,
367
-
368
- // ignored temporarily while waiting for bug fix.
369
- "CustomResourceDefinition" : true ,
370
-
371
- // ignored because no test data exists.
372
- // Do not add anything to this list, instead add fixtures in
373
- // the test/integration/etcd package.
374
- "BackendConfig" : true ,
375
- "ComponentStatus" : true ,
376
- "NodeMetrics" : true ,
377
- "PodMetrics" : true ,
378
- "VolumeSnapshotClass" : true ,
379
- "VolumeSnapshotContent" : true ,
380
- "VolumeSnapshot" : true ,
381
- }
382
-
383
- apiGroups , err := c .Discovery ().ServerPreferredResources ()
384
-
385
- if discovery .IsGroupDiscoveryFailedError (err ) {
386
- discoveryErr := err .(* discovery.ErrGroupDiscoveryFailed )
387
- for gv := range discoveryErr .Groups {
388
- if strings .Contains (gv .Group , "." ) && ! strings .HasSuffix (gv .Group , ".k8s.io" ) {
389
- // tolerate discovery errors for non-k8s.io groups (like aggregated/crd groups)
390
- continue
391
- }
392
- if gv .Group == "metrics.k8s.io" {
393
- // tolerate discovery errors for known test k8s.io groups like aggregated/metrics groups
394
- continue
395
- }
396
- // otherwise, fail
397
- framework .ExpectNoError (err )
398
- }
399
- } else {
400
- // fail immediately if this isn't a discovery error
401
- framework .ExpectNoError (err )
402
-
403
- }
404
-
405
- testableResources := etcd .GetEtcdStorageDataForNamespace (f .Namespace .Name )
406
-
407
- for _ , group := range apiGroups {
408
- // This limits the scope of this test to exclude CRDs. This
409
- // assumes that CRDs will not have a .k8s.io group and will have
410
- // a . in their name.
411
- if ! strings .Contains (group .GroupVersion , ".k8s.io" ) && strings .Contains (group .GroupVersion , "." ) {
412
- continue
413
- }
414
-
415
- for _ , resource := range group .APIResources {
416
- if ! verbsContain (resource .Verbs , "get" ) || ignoredResources [resource .Kind ] || strings .HasPrefix (resource .Name , "e2e-test" ) {
417
- continue
418
- }
419
-
420
- // compute gvr
421
- gv , err := schema .ParseGroupVersion (group .GroupVersion )
422
- framework .ExpectNoError (err )
423
- gvr := gv .WithResource (resource .Name )
424
-
425
- // assert test data exists
426
- testData := testableResources [gvr ]
427
- gomega .ExpectWithOffset (1 , testData ).ToNot (gomega .BeZero (), "No test data available for %s" , gvr )
428
-
429
- // create test resource
430
- mapping := & meta.RESTMapping {
431
- Resource : gvr ,
432
- GroupVersionKind : gv .WithKind (resource .Kind ),
433
- }
434
-
435
- if resource .Namespaced {
436
- mapping .Scope = meta .RESTScopeNamespace
437
- } else {
438
- mapping .Scope = meta .RESTScopeRoot
439
- }
440
-
441
- client , obj , err := etcd .JSONToUnstructured (testData .Stub , f .Namespace .Name , mapping , f .DynamicClient )
442
- framework .ExpectNoError (err )
443
- if resource .Kind != "APIService" && resource .Kind != "CustomResourceDefinition" {
444
- obj .SetName (obj .GetName () + randString )
445
- }
446
-
447
- createObjValidateOutputAndCleanup (f .Namespace .Name , client , obj , resource )
448
- }
449
- }
450
- })
451
- })
452
-
453
346
ginkgo .Describe ("Simple pod" , func () {
454
347
var podYaml string
455
348
ginkgo .BeforeEach (func () {
@@ -2224,52 +2117,3 @@ waitLoop:
2224
2117
// Reaching here means that one of more checks failed multiple times. Assuming its not a race condition, something is broken.
2225
2118
framework .Failf ("Timed out after %v seconds waiting for %s pods to reach valid state" , framework .PodStartTimeout .Seconds (), testname )
2226
2119
}
2227
-
2228
- // verbsContain returns true if the provided list of verbs contain the provided
2229
- // verb string.
2230
- func verbsContain (verbs metav1.Verbs , str string ) bool {
2231
- for _ , v := range verbs {
2232
- if v == str {
2233
- return true
2234
- }
2235
- }
2236
- return false
2237
- }
2238
-
2239
- // deleteObj deletes an Object with the provided client and name.
2240
- func deleteObj (client dynamic.ResourceInterface , name string ) {
2241
- err := client .Delete (context .TODO (), name , metav1.DeleteOptions {})
2242
- framework .ExpectNoError (err )
2243
- }
2244
-
2245
- // createObjValidateOutputAndCleanup creates an object using the provided client
2246
- // and then verifies that the kubectl get output provides custom columns. Once
2247
- // the test has completed, it deletes the object.
2248
- func createObjValidateOutputAndCleanup (namespace string , client dynamic.ResourceInterface , obj * unstructured.Unstructured , resource metav1.APIResource ) {
2249
- _ , err := client .Create (context .TODO (), obj , metav1.CreateOptions {})
2250
- framework .ExpectNoError (err )
2251
- defer deleteObj (client , obj .GetName ())
2252
-
2253
- // get test resource
2254
- output := framework .RunKubectlOrDie (namespace , "get" , resource .Name , "--all-namespaces" )
2255
- if output == "" {
2256
- framework .Failf ("No stdout from kubectl get for %s (likely need to define test resources)" , resource .Name )
2257
- }
2258
-
2259
- splitOutput := strings .SplitN (output , "\n " , 2 )
2260
- fields := strings .Fields (splitOutput [0 ])
2261
-
2262
- defaultColumns := [][]string {
2263
- // namespaced, server-side
2264
- {"NAMESPACE" , "NAME" , "CREATED" , "AT" },
2265
- // namespaced, client-side
2266
- {"NAMESPACE" , "NAME" , "AGE" },
2267
- // cluster-scoped, server-side
2268
- {"NAME" , "CREATED" , "AT" },
2269
- // cluster-scoped, client-side
2270
- {"NAME" , "AGE" },
2271
- }
2272
- for _ , defaults := range defaultColumns {
2273
- framework .ExpectNotEqual (fields , defaults , fmt .Sprintf ("expected non-default fields for resource: %s" , resource .Name ))
2274
- }
2275
- }
0 commit comments