Merge pull request #70939 from smarterclayton/skip_delta

e2e: Show the caller's stack for Skipf() instead of the local one
This commit is contained in:
Kubernetes Prow Robot 2018-12-18 15:44:04 -08:00 committed by GitHub
commit a17a392d4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -286,95 +286,99 @@ func FailfWithOffset(offset int, format string, args ...interface{}) {
ginkgowrapper.Fail(nowStamp()+": "+msg, 1+offset) ginkgowrapper.Fail(nowStamp()+": "+msg, 1+offset)
} }
func Skipf(format string, args ...interface{}) { func skipInternalf(caller int, format string, args ...interface{}) {
msg := fmt.Sprintf(format, args...) msg := fmt.Sprintf(format, args...)
log("INFO", msg) log("INFO", msg)
ginkgowrapper.Skip(nowStamp() + ": " + msg) ginkgowrapper.Skip(msg, caller+1)
}
func Skipf(format string, args ...interface{}) {
skipInternalf(1, format, args...)
} }
func SkipUnlessNodeCountIsAtLeast(minNodeCount int) { func SkipUnlessNodeCountIsAtLeast(minNodeCount int) {
if TestContext.CloudConfig.NumNodes < minNodeCount { if TestContext.CloudConfig.NumNodes < minNodeCount {
Skipf("Requires at least %d nodes (not %d)", minNodeCount, TestContext.CloudConfig.NumNodes) skipInternalf(1, "Requires at least %d nodes (not %d)", minNodeCount, TestContext.CloudConfig.NumNodes)
} }
} }
func SkipUnlessNodeCountIsAtMost(maxNodeCount int) { func SkipUnlessNodeCountIsAtMost(maxNodeCount int) {
if TestContext.CloudConfig.NumNodes > maxNodeCount { if TestContext.CloudConfig.NumNodes > maxNodeCount {
Skipf("Requires at most %d nodes (not %d)", maxNodeCount, TestContext.CloudConfig.NumNodes) skipInternalf(1, "Requires at most %d nodes (not %d)", maxNodeCount, TestContext.CloudConfig.NumNodes)
} }
} }
func SkipUnlessAtLeast(value int, minValue int, message string) { func SkipUnlessAtLeast(value int, minValue int, message string) {
if value < minValue { if value < minValue {
Skipf(message) skipInternalf(1, message)
} }
} }
func SkipIfProviderIs(unsupportedProviders ...string) { func SkipIfProviderIs(unsupportedProviders ...string) {
if ProviderIs(unsupportedProviders...) { if ProviderIs(unsupportedProviders...) {
Skipf("Not supported for providers %v (found %s)", unsupportedProviders, TestContext.Provider) skipInternalf(1, "Not supported for providers %v (found %s)", unsupportedProviders, TestContext.Provider)
} }
} }
func SkipUnlessLocalEphemeralStorageEnabled() { func SkipUnlessLocalEphemeralStorageEnabled() {
if !utilfeature.DefaultFeatureGate.Enabled(features.LocalStorageCapacityIsolation) { if !utilfeature.DefaultFeatureGate.Enabled(features.LocalStorageCapacityIsolation) {
Skipf("Only supported when %v feature is enabled", features.LocalStorageCapacityIsolation) skipInternalf(1, "Only supported when %v feature is enabled", features.LocalStorageCapacityIsolation)
} }
} }
func SkipUnlessSSHKeyPresent() { func SkipUnlessSSHKeyPresent() {
if _, err := GetSigner(TestContext.Provider); err != nil { if _, err := GetSigner(TestContext.Provider); err != nil {
Skipf("No SSH Key for provider %s: '%v'", TestContext.Provider, err) skipInternalf(1, "No SSH Key for provider %s: '%v'", TestContext.Provider, err)
} }
} }
func SkipUnlessProviderIs(supportedProviders ...string) { func SkipUnlessProviderIs(supportedProviders ...string) {
if !ProviderIs(supportedProviders...) { if !ProviderIs(supportedProviders...) {
Skipf("Only supported for providers %v (not %s)", supportedProviders, TestContext.Provider) skipInternalf(1, "Only supported for providers %v (not %s)", supportedProviders, TestContext.Provider)
} }
} }
func SkipUnlessMultizone(c clientset.Interface) { func SkipUnlessMultizone(c clientset.Interface) {
zones, err := GetClusterZones(c) zones, err := GetClusterZones(c)
if err != nil { if err != nil {
Skipf("Error listing cluster zones") skipInternalf(1, "Error listing cluster zones")
} }
if zones.Len() <= 1 { if zones.Len() <= 1 {
Skipf("Requires more than one zone") skipInternalf(1, "Requires more than one zone")
} }
} }
func SkipIfMultizone(c clientset.Interface) { func SkipIfMultizone(c clientset.Interface) {
zones, err := GetClusterZones(c) zones, err := GetClusterZones(c)
if err != nil { if err != nil {
Skipf("Error listing cluster zones") skipInternalf(1, "Error listing cluster zones")
} }
if zones.Len() > 1 { if zones.Len() > 1 {
Skipf("Requires at most one zone") skipInternalf(1, "Requires at most one zone")
} }
} }
func SkipUnlessClusterMonitoringModeIs(supportedMonitoring ...string) { func SkipUnlessClusterMonitoringModeIs(supportedMonitoring ...string) {
if !ClusterMonitoringModeIs(supportedMonitoring...) { if !ClusterMonitoringModeIs(supportedMonitoring...) {
Skipf("Only next monitoring modes are supported %v (not %s)", supportedMonitoring, TestContext.ClusterMonitoringMode) skipInternalf(1, "Only next monitoring modes are supported %v (not %s)", supportedMonitoring, TestContext.ClusterMonitoringMode)
} }
} }
func SkipUnlessPrometheusMonitoringIsEnabled(supportedMonitoring ...string) { func SkipUnlessPrometheusMonitoringIsEnabled(supportedMonitoring ...string) {
if !TestContext.EnablePrometheusMonitoring { if !TestContext.EnablePrometheusMonitoring {
Skipf("Skipped because prometheus monitoring is not enabled") skipInternalf(1, "Skipped because prometheus monitoring is not enabled")
} }
} }
func SkipUnlessMasterOSDistroIs(supportedMasterOsDistros ...string) { func SkipUnlessMasterOSDistroIs(supportedMasterOsDistros ...string) {
if !MasterOSDistroIs(supportedMasterOsDistros...) { if !MasterOSDistroIs(supportedMasterOsDistros...) {
Skipf("Only supported for master OS distro %v (not %s)", supportedMasterOsDistros, TestContext.MasterOSDistro) skipInternalf(1, "Only supported for master OS distro %v (not %s)", supportedMasterOsDistros, TestContext.MasterOSDistro)
} }
} }
func SkipUnlessNodeOSDistroIs(supportedNodeOsDistros ...string) { func SkipUnlessNodeOSDistroIs(supportedNodeOsDistros ...string) {
if !NodeOSDistroIs(supportedNodeOsDistros...) { if !NodeOSDistroIs(supportedNodeOsDistros...) {
Skipf("Only supported for node OS distro %v (not %s)", supportedNodeOsDistros, TestContext.NodeOSDistro) skipInternalf(1, "Only supported for node OS distro %v (not %s)", supportedNodeOsDistros, TestContext.NodeOSDistro)
} }
} }
@ -389,21 +393,21 @@ func SkipUnlessSecretExistsAfterWait(c clientset.Interface, name, namespace stri
} }
return true, nil return true, nil
}) != nil { }) != nil {
Skipf("Secret %v in namespace %v did not exist after timeout of %v", name, namespace, timeout) skipInternalf(1, "Secret %v in namespace %v did not exist after timeout of %v", name, namespace, timeout)
} }
Logf("Secret %v in namespace %v found after duration %v", name, namespace, time.Since(start)) Logf("Secret %v in namespace %v found after duration %v", name, namespace, time.Since(start))
} }
func SkipUnlessTaintBasedEvictionsEnabled() { func SkipUnlessTaintBasedEvictionsEnabled() {
if !utilfeature.DefaultFeatureGate.Enabled(features.TaintBasedEvictions) { if !utilfeature.DefaultFeatureGate.Enabled(features.TaintBasedEvictions) {
Skipf("Only supported when %v feature is enabled", features.TaintBasedEvictions) skipInternalf(1, "Only supported when %v feature is enabled", features.TaintBasedEvictions)
} }
} }
func SkipIfContainerRuntimeIs(runtimes ...string) { func SkipIfContainerRuntimeIs(runtimes ...string) {
for _, runtime := range runtimes { for _, runtime := range runtimes {
if runtime == TestContext.ContainerRuntime { if runtime == TestContext.ContainerRuntime {
Skipf("Not supported under container runtime %s", runtime) skipInternalf(1, "Not supported under container runtime %s", runtime)
} }
} }
} }
@ -414,7 +418,7 @@ func RunIfContainerRuntimeIs(runtimes ...string) {
return return
} }
} }
Skipf("Skipped because container runtime %q is not in %s", TestContext.ContainerRuntime, runtimes) skipInternalf(1, "Skipped because container runtime %q is not in %s", TestContext.ContainerRuntime, runtimes)
} }
func RunIfSystemSpecNameIs(names ...string) { func RunIfSystemSpecNameIs(names ...string) {
@ -423,7 +427,7 @@ func RunIfSystemSpecNameIs(names ...string) {
return return
} }
} }
Skipf("Skipped because system spec name %q is not in %v", TestContext.SystemSpecName, names) skipInternalf(1, "Skipped because system spec name %q is not in %v", TestContext.SystemSpecName, names)
} }
func ProviderIs(providers ...string) bool { func ProviderIs(providers ...string) bool {
@ -497,7 +501,7 @@ func SkipUnlessServerVersionGTE(v *utilversion.Version, c discovery.ServerVersio
Failf("Failed to get server version: %v", err) Failf("Failed to get server version: %v", err)
} }
if !gte { if !gte {
Skipf("Not supported for server versions before %q", v) skipInternalf(1, "Not supported for server versions before %q", v)
} }
} }
@ -507,7 +511,7 @@ func SkipIfMissingResource(dynamicClient dynamic.Interface, gvr schema.GroupVers
if err != nil { if err != nil {
// not all resources support list, so we ignore those // not all resources support list, so we ignore those
if apierrs.IsMethodNotSupported(err) || apierrs.IsNotFound(err) || apierrs.IsForbidden(err) { if apierrs.IsMethodNotSupported(err) || apierrs.IsNotFound(err) || apierrs.IsForbidden(err) {
Skipf("Could not find %s resource, skipping test: %#v", gvr, err) skipInternalf(1, "Could not find %s resource, skipping test: %#v", gvr, err)
} }
Failf("Unexpected error getting %v: %v", gvr, err) Failf("Unexpected error getting %v: %v", gvr, err)
} }
@ -1943,7 +1947,7 @@ func SkipUnlessKubectlVersionGTE(v *utilversion.Version) {
Failf("Failed to get kubectl version: %v", err) Failf("Failed to get kubectl version: %v", err)
} }
if !gte { if !gte {
Skipf("Not supported for kubectl versions before %q", v) skipInternalf(1, "Not supported for kubectl versions before %q", v)
} }
} }