Skip to content

Commit b7a6d53

Browse files
authored
Merge pull request kubernetes#88924 from dims/add-support-for-listing-conformance-tests-in-e2e.test
Add support for listing conformance tests in e2e.test
2 parents 413c81a + d1c948a commit b7a6d53

File tree

7 files changed

+51
-7
lines changed

7 files changed

+51
-7
lines changed

hack/generate-bindata.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ BINDATA_OUTPUT="test/e2e/generated/bindata.go"
4444
# test/e2e/generated/BUILD and/or build/bindata.bzl.
4545
go-bindata -nometadata -o "${BINDATA_OUTPUT}.tmp" -pkg generated \
4646
-ignore .jpg -ignore .png -ignore .md -ignore 'BUILD(\.bazel)?' \
47+
"test/conformance/testdata/..." \
4748
"test/e2e/testing-manifests/..." \
4849
"test/e2e_node/testing-manifests/..." \
4950
"test/images/..." \

test/conformance/BUILD

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ filegroup(
3434
":package-srcs",
3535
"//test/conformance/behaviors:all-srcs",
3636
"//test/conformance/kubeconform:all-srcs",
37+
"//test/conformance/testdata:all-srcs",
3738
],
3839
tags = ["automanaged"],
3940
visibility = ["//visibility:public"],
@@ -68,8 +69,8 @@ sh_test(
6869
name = "conformance_test",
6970
srcs = ["conformance_test.sh"],
7071
data = [
71-
"testdata/conformance.yaml",
7272
":list_conformance_tests",
73+
":testdata",
7374
],
7475
)
7576

test/conformance/testdata/BUILD

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package(default_visibility = ["//visibility:public"])
2+
3+
filegroup(
4+
name = "package-srcs",
5+
srcs = glob(["**"]),
6+
tags = ["automanaged"],
7+
visibility = ["//visibility:private"],
8+
)
9+
10+
filegroup(
11+
name = "all-srcs",
12+
srcs = [":package-srcs"],
13+
tags = ["automanaged"],
14+
)

test/e2e/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ go_test(
4343
"//test/e2e/windows:go_default_library",
4444
"//test/utils/image:go_default_library",
4545
"//vendor/github.com/stretchr/testify/require:go_default_library",
46+
"//vendor/gopkg.in/yaml.v2:go_default_library",
4647
],
4748
)
4849

test/e2e/e2e_test.go

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import (
2424
"testing"
2525
"time"
2626

27+
"gopkg.in/yaml.v2"
28+
2729
// Never, ever remove the line with "/ginkgo". Without it,
2830
// the ginkgo test runner will not detect that this
2931
// directory contains a Ginkgo test suite.
@@ -94,6 +96,32 @@ func TestMain(m *testing.M) {
9496
os.Exit(0)
9597
}
9698

99+
// Enable bindata file lookup as fallback.
100+
testfiles.AddFileSource(testfiles.BindataFileSource{
101+
Asset: generated.Asset,
102+
AssetNames: generated.AssetNames,
103+
})
104+
if framework.TestContext.ListConformanceTests {
105+
var tests []struct {
106+
Testname string `yaml:"testname"`
107+
Codename string `yaml:"codename"`
108+
Description string `yaml:"description"`
109+
Release string `yaml:"release"`
110+
File string `yaml:"file"`
111+
}
112+
113+
data := testfiles.ReadOrDie("test/conformance/testdata/conformance.yaml")
114+
if err := yaml.Unmarshal(data, &tests); err != nil {
115+
fmt.Fprintln(os.Stderr, err)
116+
os.Exit(1)
117+
}
118+
if err := yaml.NewEncoder(os.Stdout).Encode(tests); err != nil {
119+
fmt.Fprintln(os.Stderr, err)
120+
os.Exit(1)
121+
}
122+
os.Exit(0)
123+
}
124+
97125
framework.AfterReadingAllFlags(&framework.TestContext)
98126

99127
// TODO: Deprecating repo-root over time... instead just use gobindata_util.go , see #23987.
@@ -105,12 +133,6 @@ func TestMain(m *testing.M) {
105133
testfiles.AddFileSource(testfiles.RootFileSource{Root: framework.TestContext.RepoRoot})
106134
}
107135

108-
// Enable bindata file lookup as fallback.
109-
testfiles.AddFileSource(testfiles.BindataFileSource{
110-
Asset: generated.Asset,
111-
AssetNames: generated.AssetNames,
112-
})
113-
114136
rand.Seed(time.Now().UnixNano())
115137
os.Exit(m.Run())
116138
}

test/e2e/framework/test_context.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ type TestContextType struct {
8383
// ListImages will list off all images that are used then quit
8484
ListImages bool
8585

86+
// ListConformanceTests will list off all conformance tests that are available then quit
87+
ListConformanceTests bool
88+
8689
// Provider identifies the infrastructure provider (gce, gke, aws)
8790
Provider string
8891

@@ -301,6 +304,7 @@ func RegisterCommonFlags(flags *flag.FlagSet) {
301304
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.")
302305

303306
flags.BoolVar(&TestContext.ListImages, "list-images", false, "If true, will show list of images used for runnning tests.")
307+
flags.BoolVar(&TestContext.ListConformanceTests, "list-conformance-tests", false, "If true, will show list of conformance tests.")
304308
flags.StringVar(&TestContext.KubectlPath, "kubectl-path", "kubectl", "The kubectl binary to use. For development, you might use 'cluster/kubectl.sh' here.")
305309

306310
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.")

test/e2e/generated/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ go_library(
2323
go_bindata(
2424
name = "bindata",
2525
srcs = [
26+
"//test/conformance/testdata:all-srcs",
2627
"//test/e2e/testing-manifests:all-srcs",
2728
"//test/e2e_node/testing-manifests:all-srcs",
2829
"//test/fixtures:all-srcs",

0 commit comments

Comments
 (0)