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

e2e: Prefer kubeconfig host to default #40890

Merged
merged 1 commit into from Apr 20, 2017
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
17 changes: 16 additions & 1 deletion test/e2e/framework/test_context.go
Expand Up @@ -18,6 +18,7 @@ package framework

import (
"flag"
"fmt"
"os"
"time"

Expand All @@ -28,6 +29,8 @@ import (
"k8s.io/kubernetes/pkg/cloudprovider"
)

const defaultHost = "http://127.0.0.1:8080"

type TestContextType struct {
KubeConfig string
KubeContext string
Expand Down Expand Up @@ -162,7 +165,8 @@ func RegisterCommonFlags() {
flag.BoolVar(&TestContext.DeleteNamespace, "delete-namespace", true, "If true tests will delete namespace after completion. It is only designed to make debugging easier, DO NOT turn it off by default.")
flag.BoolVar(&TestContext.DeleteNamespaceOnFailure, "delete-namespace-on-failure", true, "If true, framework will delete test namespace on failure. Used only during test debugging.")
flag.IntVar(&TestContext.AllowedNotReadyNodes, "allowed-not-ready-nodes", 0, "If non-zero, framework will allow for that many non-ready nodes when checking for all ready nodes.")
flag.StringVar(&TestContext.Host, "host", "http://127.0.0.1:8080", "The host, or apiserver, to connect to")

flag.StringVar(&TestContext.Host, "host", "", fmt.Sprintf("The host, or apiserver, to connect to. Will default to %s if this argument and --kubeconfig are not set", defaultHost))
flag.StringVar(&TestContext.ReportPrefix, "report-prefix", "", "Optional prefix for JUnit XML reports. Default is empty, which doesn't prepend anything to the default name.")
flag.StringVar(&TestContext.ReportDir, "report-dir", "", "Path to the directory where the JUnit XML reports should be saved. Default is empty, which doesn't generate these reports.")
flag.StringVar(&TestContext.FeatureGates, "feature-gates", "", "A set of key=value pairs that describe feature gates for alpha/experimental features.")
Expand Down Expand Up @@ -259,4 +263,15 @@ func ViperizeFlags() {

// TODO Consider wether or not we want to use overwriteFlagsWithViperConfig().
viper.Unmarshal(&TestContext)

AfterReadingAllFlags(&TestContext)
}

// AfterReadingAllFlags makes changes to the context after all flags
// have been read.
func AfterReadingAllFlags(t *TestContextType) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also call this function here?

Node e2e is still relying on the default apiserver address now. In the future, node e2e should also use a kubeconfig file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry...My bad...Actually should be here, after Parse.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

// Only set a default host if one won't be supplied via kubeconfig
if len(t.Host) == 0 && len(t.KubeConfig) == 0 {
t.Host = defaultHost
}
}
1 change: 1 addition & 0 deletions test/e2e_node/e2e_node_suite_test.go
Expand Up @@ -70,6 +70,7 @@ func init() {

func TestMain(m *testing.M) {
pflag.Parse()
framework.AfterReadingAllFlags(&framework.TestContext)
os.Exit(m.Run())
}

Expand Down