mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 12:18:16 +00:00 
			
		
		
		
	Add support for listing conformance tests
we print yaml, so you can use yaml tools like `yq`: ``` e2e.test --list-conformance-tests | yq r - --collect *.testname ``` Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
		@@ -34,6 +34,7 @@ filegroup(
 | 
				
			|||||||
        ":package-srcs",
 | 
					        ":package-srcs",
 | 
				
			||||||
        "//test/conformance/behaviors:all-srcs",
 | 
					        "//test/conformance/behaviors:all-srcs",
 | 
				
			||||||
        "//test/conformance/kubeconform:all-srcs",
 | 
					        "//test/conformance/kubeconform:all-srcs",
 | 
				
			||||||
 | 
					        "//test/conformance/testdata:all-srcs",
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
    tags = ["automanaged"],
 | 
					    tags = ["automanaged"],
 | 
				
			||||||
    visibility = ["//visibility:public"],
 | 
					    visibility = ["//visibility:public"],
 | 
				
			||||||
@@ -68,8 +69,8 @@ sh_test(
 | 
				
			|||||||
    name = "conformance_test",
 | 
					    name = "conformance_test",
 | 
				
			||||||
    srcs = ["conformance_test.sh"],
 | 
					    srcs = ["conformance_test.sh"],
 | 
				
			||||||
    data = [
 | 
					    data = [
 | 
				
			||||||
        "testdata/conformance.yaml",
 | 
					 | 
				
			||||||
        ":list_conformance_tests",
 | 
					        ":list_conformance_tests",
 | 
				
			||||||
 | 
					        ":testdata",
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										14
									
								
								test/conformance/testdata/BUILD
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								test/conformance/testdata/BUILD
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
				
			|||||||
 | 
					package(default_visibility = ["//visibility:public"])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					filegroup(
 | 
				
			||||||
 | 
					    name = "package-srcs",
 | 
				
			||||||
 | 
					    srcs = glob(["**"]),
 | 
				
			||||||
 | 
					    tags = ["automanaged"],
 | 
				
			||||||
 | 
					    visibility = ["//visibility:private"],
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					filegroup(
 | 
				
			||||||
 | 
					    name = "all-srcs",
 | 
				
			||||||
 | 
					    srcs = [":package-srcs"],
 | 
				
			||||||
 | 
					    tags = ["automanaged"],
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
@@ -43,6 +43,7 @@ go_test(
 | 
				
			|||||||
        "//test/e2e/windows:go_default_library",
 | 
					        "//test/e2e/windows:go_default_library",
 | 
				
			||||||
        "//test/utils/image:go_default_library",
 | 
					        "//test/utils/image:go_default_library",
 | 
				
			||||||
        "//vendor/github.com/stretchr/testify/require:go_default_library",
 | 
					        "//vendor/github.com/stretchr/testify/require:go_default_library",
 | 
				
			||||||
 | 
					        "//vendor/gopkg.in/yaml.v2:go_default_library",
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,6 +24,8 @@ import (
 | 
				
			|||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"gopkg.in/yaml.v2"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Never, ever remove the line with "/ginkgo". Without it,
 | 
						// Never, ever remove the line with "/ginkgo". Without it,
 | 
				
			||||||
	// the ginkgo test runner will not detect that this
 | 
						// the ginkgo test runner will not detect that this
 | 
				
			||||||
	// directory contains a Ginkgo test suite.
 | 
						// directory contains a Ginkgo test suite.
 | 
				
			||||||
@@ -94,6 +96,32 @@ func TestMain(m *testing.M) {
 | 
				
			|||||||
		os.Exit(0)
 | 
							os.Exit(0)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Enable bindata file lookup as fallback.
 | 
				
			||||||
 | 
						testfiles.AddFileSource(testfiles.BindataFileSource{
 | 
				
			||||||
 | 
							Asset:      generated.Asset,
 | 
				
			||||||
 | 
							AssetNames: generated.AssetNames,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if framework.TestContext.ListConformanceTests {
 | 
				
			||||||
 | 
							var tests []struct {
 | 
				
			||||||
 | 
								Testname    string `yaml:"testname"`
 | 
				
			||||||
 | 
								Codename    string `yaml:"codename"`
 | 
				
			||||||
 | 
								Description string `yaml:"description"`
 | 
				
			||||||
 | 
								Release     string `yaml:"release"`
 | 
				
			||||||
 | 
								File        string `yaml:"file"`
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							data := testfiles.ReadOrDie("test/conformance/testdata/conformance.yaml")
 | 
				
			||||||
 | 
							if err := yaml.Unmarshal(data, &tests); err != nil {
 | 
				
			||||||
 | 
								fmt.Fprintln(os.Stderr, err)
 | 
				
			||||||
 | 
								os.Exit(1)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if err := yaml.NewEncoder(os.Stdout).Encode(tests); err != nil {
 | 
				
			||||||
 | 
								fmt.Fprintln(os.Stderr, err)
 | 
				
			||||||
 | 
								os.Exit(1)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							os.Exit(0)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	framework.AfterReadingAllFlags(&framework.TestContext)
 | 
						framework.AfterReadingAllFlags(&framework.TestContext)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// TODO: Deprecating repo-root over time... instead just use gobindata_util.go , see #23987.
 | 
						// TODO: Deprecating repo-root over time... instead just use gobindata_util.go , see #23987.
 | 
				
			||||||
@@ -105,12 +133,6 @@ func TestMain(m *testing.M) {
 | 
				
			|||||||
		testfiles.AddFileSource(testfiles.RootFileSource{Root: framework.TestContext.RepoRoot})
 | 
							testfiles.AddFileSource(testfiles.RootFileSource{Root: framework.TestContext.RepoRoot})
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Enable bindata file lookup as fallback.
 | 
					 | 
				
			||||||
	testfiles.AddFileSource(testfiles.BindataFileSource{
 | 
					 | 
				
			||||||
		Asset:      generated.Asset,
 | 
					 | 
				
			||||||
		AssetNames: generated.AssetNames,
 | 
					 | 
				
			||||||
	})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	rand.Seed(time.Now().UnixNano())
 | 
						rand.Seed(time.Now().UnixNano())
 | 
				
			||||||
	os.Exit(m.Run())
 | 
						os.Exit(m.Run())
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -83,6 +83,9 @@ type TestContextType struct {
 | 
				
			|||||||
	// ListImages will list off all images that are used then quit
 | 
						// ListImages will list off all images that are used then quit
 | 
				
			||||||
	ListImages bool
 | 
						ListImages bool
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// ListConformanceTests will list off all conformance tests that are available then quit
 | 
				
			||||||
 | 
						ListConformanceTests bool
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Provider identifies the infrastructure provider (gce, gke, aws)
 | 
						// Provider identifies the infrastructure provider (gce, gke, aws)
 | 
				
			||||||
	Provider string
 | 
						Provider string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -301,6 +304,7 @@ func RegisterCommonFlags(flags *flag.FlagSet) {
 | 
				
			|||||||
	flags.StringVar(&TestContext.NonblockingTaints, "non-blocking-taints", `node-role.kubernetes.io/master`, "Nodes with taints in this comma-delimited list will not block the test framework from starting tests.")
 | 
						flags.StringVar(&TestContext.NonblockingTaints, "non-blocking-taints", `node-role.kubernetes.io/master`, "Nodes with taints in this comma-delimited list will not block the test framework from starting tests.")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	flags.BoolVar(&TestContext.ListImages, "list-images", false, "If true, will show list of images used for runnning tests.")
 | 
						flags.BoolVar(&TestContext.ListImages, "list-images", false, "If true, will show list of images used for runnning 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.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.")
 | 
						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.")
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user