mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
Provide an e2e skip helper checking for available resource.
This commit is contained in:
parent
08b6eaff92
commit
7ee8f867d9
@ -433,6 +433,22 @@ func SkipUnlessFederated(c *client.Client) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SkipIfMissingResource(clientPool dynamic.ClientPool, gvr unversioned.GroupVersionResource, namespace string) {
|
||||||
|
dynamicClient, err := clientPool.ClientForGroupVersion(gvr.GroupVersion())
|
||||||
|
if err != nil {
|
||||||
|
Failf("Unexpected error getting dynamic client for %v: %v", gvr.GroupVersion(), err)
|
||||||
|
}
|
||||||
|
apiResource := unversioned.APIResource{Name: gvr.Resource, Namespaced: true}
|
||||||
|
_, err = dynamicClient.Resource(&apiResource, namespace).List(&v1.ListOptions{})
|
||||||
|
if err != nil {
|
||||||
|
// not all resources support list, so we ignore those
|
||||||
|
if apierrs.IsMethodNotSupported(err) || apierrs.IsNotFound(err) || apierrs.IsForbidden(err) {
|
||||||
|
Skipf("Could not find %s resource, skipping test: %#v", gvr, err)
|
||||||
|
}
|
||||||
|
Failf("Unexpected error getting %v: %v", gvr, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ProvidersWithSSH are those providers where each node is accessible with SSH
|
// ProvidersWithSSH are those providers where each node is accessible with SSH
|
||||||
var ProvidersWithSSH = []string{"gce", "gke", "aws"}
|
var ProvidersWithSSH = []string{"gce", "gke", "aws"}
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ import (
|
|||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
apierrs "k8s.io/kubernetes/pkg/api/errors"
|
|
||||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||||
"k8s.io/kubernetes/pkg/apis/batch"
|
"k8s.io/kubernetes/pkg/apis/batch"
|
||||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||||
@ -47,11 +46,7 @@ var _ = framework.KubeDescribe("[Feature:ScheduledJob]", func() {
|
|||||||
f := framework.NewFramework("scheduledjob", options, nil)
|
f := framework.NewFramework("scheduledjob", options, nil)
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
if _, err := f.Client.Batch().ScheduledJobs(f.Namespace.Name).List(api.ListOptions{}); err != nil {
|
framework.SkipIfMissingResource(f.ClientPool, unversioned.GroupVersionResource{Group: batch.GroupName, Version: "v2alpha1", Resource: "scheduledjobs"}, f.Namespace.Name)
|
||||||
if apierrs.IsNotFound(err) {
|
|
||||||
framework.Skipf("Could not find ScheduledJobs resource, skipping test: %#v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// multiple jobs running at once
|
// multiple jobs running at once
|
||||||
|
Loading…
Reference in New Issue
Block a user