Merge pull request #114431 from pohly/e2e-list-cmdline

e2e: clean up listing
This commit is contained in:
Kubernetes Prow Robot 2022-12-23 02:43:26 -08:00 committed by GitHub
commit 24304ce55c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 9 deletions

View File

@ -42,7 +42,6 @@ import (
"k8s.io/kubernetes/test/e2e/framework/testfiles"
e2etestingmanifests "k8s.io/kubernetes/test/e2e/testing-manifests"
testfixtures "k8s.io/kubernetes/test/fixtures"
"k8s.io/kubernetes/test/utils/image"
// test sources
_ "k8s.io/kubernetes/test/e2e/apimachinery"
@ -83,16 +82,11 @@ func handleFlags() {
func TestMain(m *testing.M) {
var versionFlag bool
flag.CommandLine.BoolVar(&versionFlag, "version", false, "Displays version information.")
listConformanceTests := flag.CommandLine.Bool("list-conformance-tests", false, "If true, will show list of conformance tests.")
// Register test flags, then parse flags.
handleFlags()
if framework.TestContext.ListImages {
for _, v := range image.GetImageConfigs() {
fmt.Println(v.GetE2EImage())
}
os.Exit(0)
}
if versionFlag {
fmt.Printf("%s\n", version.Get())
os.Exit(0)
@ -103,7 +97,7 @@ func TestMain(m *testing.M) {
testfiles.AddFileSource(testfixtures.GetTestFixturesFS())
testfiles.AddFileSource(conformancetestdata.GetConformanceTestdataFS())
if framework.TestContext.ListConformanceTests {
if *listConformanceTests {
var tests []struct {
Testname string `yaml:"testname"`
Codename string `yaml:"codename"`

View File

@ -41,6 +41,7 @@ import (
kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config"
"k8s.io/kubernetes/test/e2e/framework/internal/junit"
"k8s.io/kubernetes/test/utils/image"
"k8s.io/kubernetes/test/utils/kubeconfig"
)
@ -345,7 +346,6 @@ func RegisterCommonFlags(flags *flag.FlagSet) {
flags.StringVar(&TestContext.NonblockingTaints, "non-blocking-taints", `node-role.kubernetes.io/control-plane,node-role.kubernetes.io/master`, "Nodes with taints in this comma-delimited list will not block the test framework from starting tests. The default taint 'node-role.kubernetes.io/master' is DEPRECATED and will be removed from the list in a future release.")
flags.BoolVar(&TestContext.ListImages, "list-images", false, "If true, will show list of images used for running tests.")
flags.BoolVar(&TestContext.ListConformanceTests, "list-conformance-tests", false, "If true, will show list of conformance tests.")
flags.StringVar(&TestContext.KubectlPath, "kubectl-path", "kubectl", "The kubectl binary to use. For development, you might use 'cluster/kubectl.sh' here.")
flags.StringVar(&TestContext.ProgressReportURL, "progress-report-url", "", "The URL to POST progress updates to as the suite runs to assist in aiding integrations. If empty, no messages sent.")
@ -462,6 +462,13 @@ func AfterReadingAllFlags(t *TestContextType) {
fs.Set("stderrthreshold", "10" /* higher than any of the severities -> none pass the threshold */)
klog.SetOutput(ginkgo.GinkgoWriter)
if t.ListImages {
for _, v := range image.GetImageConfigs() {
fmt.Println(v.GetE2EImage())
}
os.Exit(0)
}
// Only set a default host if one won't be supplied via kubeconfig
if len(t.Host) == 0 && len(t.KubeConfig) == 0 {
// Check if we can use the in-cluster config