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

Move suites.go to e2e package #85235

Merged
merged 1 commit into from Nov 23, 2019
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
2 changes: 2 additions & 0 deletions test/e2e/BUILD
Expand Up @@ -47,6 +47,7 @@ go_library(
"examples.go",
"gke_local_ssd.go",
"gke_node_pools.go",
"suites.go",
],
importpath = "k8s.io/kubernetes/test/e2e",
deps = [
Expand All @@ -67,6 +68,7 @@ go_library(
"//test/e2e/framework:go_default_library",
"//test/e2e/framework/auth:go_default_library",
"//test/e2e/framework/log:go_default_library",
"//test/e2e/framework/metrics:go_default_library",
"//test/e2e/framework/node:go_default_library",
"//test/e2e/framework/pod:go_default_library",
"//test/e2e/framework/providers/aws:go_default_library",
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/e2e.go
Expand Up @@ -70,9 +70,9 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {
})

var _ = ginkgo.SynchronizedAfterSuite(func() {
framework.CleanupSuite()
CleanupSuite()
}, func() {
framework.AfterSuiteActions()
AfterSuiteActions()
})

// RunE2ETests checks configuration parameters (specified through flags) and then runs
Expand Down
1 change: 0 additions & 1 deletion test/e2e/framework/BUILD
Expand Up @@ -22,7 +22,6 @@ go_library(
"resource_usage_gatherer.go",
"size.go",
"skip.go",
"suites.go",
"test_context.go",
"util.go",
],
Expand Down
34 changes: 17 additions & 17 deletions test/e2e/framework/suites.go → test/e2e/suites.go
Expand Up @@ -14,15 +14,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package framework
package e2e

import (
"fmt"
"io/ioutil"
"path"
"time"

// TODO: Remove the following imports (ref: https://github.com/kubernetes/kubernetes/issues/81245)
"k8s.io/kubernetes/test/e2e/framework"
e2emetrics "k8s.io/kubernetes/test/e2e/framework/metrics"
)

Expand All @@ -32,36 +32,36 @@ import (
// and then the function that only runs on the first Ginkgo node.
func CleanupSuite() {
// Run on all Ginkgo nodes
Logf("Running AfterSuite actions on all nodes")
RunCleanupActions()
framework.Logf("Running AfterSuite actions on all nodes")
framework.RunCleanupActions()
}

// AfterSuiteActions are actions that are run on ginkgo's SynchronizedAfterSuite
func AfterSuiteActions() {
// Run only Ginkgo on node 1
Logf("Running AfterSuite actions on node 1")
if TestContext.ReportDir != "" {
CoreDump(TestContext.ReportDir)
framework.Logf("Running AfterSuite actions on node 1")
if framework.TestContext.ReportDir != "" {
framework.CoreDump(framework.TestContext.ReportDir)
}
if TestContext.GatherSuiteMetricsAfterTest {
if framework.TestContext.GatherSuiteMetricsAfterTest {
if err := gatherTestSuiteMetrics(); err != nil {
Logf("Error gathering metrics: %v", err)
framework.Logf("Error gathering metrics: %v", err)
}
}
if TestContext.NodeKiller.Enabled {
close(TestContext.NodeKiller.NodeKillerStopCh)
if framework.TestContext.NodeKiller.Enabled {
close(framework.TestContext.NodeKiller.NodeKillerStopCh)
}
}

func gatherTestSuiteMetrics() error {
Logf("Gathering metrics")
c, err := LoadClientset()
framework.Logf("Gathering metrics")
c, err := framework.LoadClientset()
if err != nil {
return fmt.Errorf("error loading client: %v", err)
}

// Grab metrics for apiserver, scheduler, controller-manager, kubelet (for non-kubemark case) and cluster autoscaler (optionally).
grabber, err := e2emetrics.NewMetricsGrabber(c, nil, !ProviderIs("kubemark"), true, true, true, TestContext.IncludeClusterAutoscalerMetrics)
grabber, err := e2emetrics.NewMetricsGrabber(c, nil, !framework.ProviderIs("kubemark"), true, true, true, framework.TestContext.IncludeClusterAutoscalerMetrics)
if err != nil {
return fmt.Errorf("failed to create MetricsGrabber: %v", err)
}
Expand All @@ -73,13 +73,13 @@ func gatherTestSuiteMetrics() error {

metricsForE2E := (*e2emetrics.ComponentCollection)(&received)
metricsJSON := metricsForE2E.PrintJSON()
if TestContext.ReportDir != "" {
filePath := path.Join(TestContext.ReportDir, "MetricsForE2ESuite_"+time.Now().Format(time.RFC3339)+".json")
if framework.TestContext.ReportDir != "" {
filePath := path.Join(framework.TestContext.ReportDir, "MetricsForE2ESuite_"+time.Now().Format(time.RFC3339)+".json")
if err := ioutil.WriteFile(filePath, []byte(metricsJSON), 0644); err != nil {
return fmt.Errorf("error writing to %q: %v", filePath, err)
}
} else {
Logf("\n\nTest Suite Metrics:\n%s\n", metricsJSON)
framework.Logf("\n\nTest Suite Metrics:\n%s\n", metricsJSON)
}

return nil
Expand Down