Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated cherry pick of #32374 #32632 #33225

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions test/e2e/framework/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,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
var ProvidersWithSSH = []string{"gce", "gke", "aws"}

Expand Down
16 changes: 9 additions & 7 deletions test/e2e/petset.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,21 @@ const (
// GCE Quota requirements: 3 pds, one per pet manifest declared above.
// GCE Api requirements: nodes and master need storage r/w permissions.
var _ = framework.KubeDescribe("PetSet [Slow] [Feature:PetSet]", func() {
f := framework.NewDefaultFramework("petset")
options := framework.FrameworkOptions{
GroupVersion: &unversioned.GroupVersion{Group: apps.GroupName, Version: "v1alpha1"},
}
f := framework.NewFramework("petset", options, nil)
var ns string
var c *client.Client

BeforeEach(func() {
// PetSet is in alpha, so it's disabled on all platforms except GCE.
// PetSet is in alpha, so it's disabled on some platforms. We skip this
// test if a resource get fails on non-GCE platforms.
// In theory, tests that restart pets should pass on any platform with a
// dynamic volume provisioner.
framework.SkipUnlessProviderIs("gce")
if !framework.ProviderIs("gce") {
framework.SkipIfMissingResource(f.ClientPool, unversioned.GroupVersionResource{Group: apps.GroupName, Version: "v1alpha1", Resource: "petsets"}, f.Namespace.Name)
}

c = f.Client
ns = f.Namespace.Name
Expand Down Expand Up @@ -166,10 +172,6 @@ var _ = framework.KubeDescribe("PetSet [Slow] [Feature:PetSet]", func() {
})

framework.KubeDescribe("Deploy clustered applications [Slow] [Feature:PetSet]", func() {
BeforeEach(func() {
framework.SkipUnlessProviderIs("gce")
})

AfterEach(func() {
if CurrentGinkgoTestDescription().Failed {
dumpDebugInfo(c, ns)
Expand Down
7 changes: 1 addition & 6 deletions test/e2e/scheduledjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
. "github.com/onsi/gomega"

"k8s.io/kubernetes/pkg/api"
apierrs "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/batch"
client "k8s.io/kubernetes/pkg/client/unversioned"
Expand All @@ -47,11 +46,7 @@ var _ = framework.KubeDescribe("ScheduledJob", func() {
f := framework.NewFramework("scheduledjob", options, nil)

BeforeEach(func() {
if _, err := f.Client.Batch().ScheduledJobs(f.Namespace.Name).List(api.ListOptions{}); err != nil {
if apierrs.IsNotFound(err) {
framework.Skipf("Could not find ScheduledJobs resource, skipping test: %#v", err)
}
}
framework.SkipIfMissingResource(f.ClientPool, unversioned.GroupVersionResource{Group: batch.GroupName, Version: "v2alpha1", Resource: "scheduledjobs"}, f.Namespace.Name)
})

// multiple jobs running at once
Expand Down