Skip to content

Commit b86d8e9

Browse files
committed
support Kubernetes 1.25 + Ginkgo v2
Kubernetes 1.25 is switching to Ginkgo v2 for the e2e.test suite. This has two implications: - we must built a matching ginkgo binary because communication between the ginkgo binary and library changed, affecting for example running of parallel tests: this is done by using the Kubernetes make rules to build the binary when using the Kubernetes e2e.test suite - the ginkgo v2 JUnit file is slightly different: filter-junit.go now first tries the old format, then the new one
1 parent ab0b0a3 commit b86d8e9

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

filter-junit.go

+18-2
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,18 @@ var (
3535
)
3636

3737
/*
38-
* TestSuite represents a JUnit file. Due to how encoding/xml works, we have
38+
* TestResults represents a JUnit file. Due to how encoding/xml works, we have
3939
* represent all fields that we want to be passed through. It's therefore
4040
* not a complete solution, but good enough for Ginkgo + Spyglass.
41+
*
42+
* Before Kubernetes 1.25 and ginkgo v2, we directly had <testsuite> in the
43+
* JUnit file. Now we get <testsuites> and inside it the <testsuite>.
4144
*/
45+
type TestResults struct {
46+
XMLName string `xml:"testsuites"`
47+
TestSuite TestSuite `xml:"testsuite"`
48+
}
49+
4250
type TestSuite struct {
4351
XMLName string `xml:"testsuite"`
4452
TestCases []TestCase `xml:"testcase"`
@@ -93,7 +101,15 @@ func main() {
93101
}
94102
}
95103
if err := xml.Unmarshal(data, &junit); err != nil {
96-
panic(err)
104+
if err.Error() != "expected element type <testsuite> but have <testsuites>" {
105+
panic(err)
106+
}
107+
// Fall back to Ginkgo v2 format.
108+
var junitv2 TestResults
109+
if err := xml.Unmarshal(data, &junitv2); err != nil {
110+
panic(err)
111+
}
112+
junit = junitv2.TestSuite
97113
}
98114
}
99115

prow.sh

+11-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ configvar CSI_PROW_GO_VERSION_KIND "${CSI_PROW_GO_VERSION_BUILD}" "Go version fo
9393
configvar CSI_PROW_GO_VERSION_GINKGO "${CSI_PROW_GO_VERSION_BUILD}" "Go version for building ginkgo" # depends on CSI_PROW_GINKGO_VERSION below
9494

9595
# ginkgo test runner version to use. If the pre-installed version is
96-
# different, the desired version is built from source.
96+
# different, the desired version is built from source. For Kubernetes,
97+
# the version built via "make WHAT=vendor/github.com/onsi/ginkgo/ginkgo" is
98+
# used, which is guaranteed to match what the Kubernetes e2e.test binary
99+
# needs.
97100
configvar CSI_PROW_GINKGO_VERSION v1.7.0 "Ginkgo"
98101

99102
# Ginkgo runs the E2E test in parallel. The default is based on the number
@@ -440,6 +443,10 @@ install_kind () {
440443

441444
# Ensure that we have the desired version of the ginkgo test runner.
442445
install_ginkgo () {
446+
if [ -e "${CSI_PROW_BIN}/ginkgo" ]; then
447+
return
448+
fi
449+
443450
# CSI_PROW_GINKGO_VERSION contains the tag with v prefix, the command line output does not.
444451
if [ "v$(ginkgo version 2>/dev/null | sed -e 's/.* //')" = "${CSI_PROW_GINKGO_VERSION}" ]; then
445452
return
@@ -943,7 +950,9 @@ install_e2e () {
943950
patch_kubernetes "${GOPATH}/src/${CSI_PROW_E2E_IMPORT_PATH}" "${CSI_PROW_WORK}" &&
944951
go_version="${CSI_PROW_GO_VERSION_E2E:-$(go_version_for_kubernetes "${GOPATH}/src/${CSI_PROW_E2E_IMPORT_PATH}" "${CSI_PROW_E2E_VERSION}")}" &&
945952
run_with_go "$go_version" make WHAT=test/e2e/e2e.test "-C${GOPATH}/src/${CSI_PROW_E2E_IMPORT_PATH}" &&
946-
ln -s "${GOPATH}/src/${CSI_PROW_E2E_IMPORT_PATH}/_output/bin/e2e.test" "${CSI_PROW_WORK}"
953+
ln -s "${GOPATH}/src/${CSI_PROW_E2E_IMPORT_PATH}/_output/bin/e2e.test" "${CSI_PROW_WORK}" &&
954+
run_with_go "$go_version" make WHAT=vendor/github.com/onsi/ginkgo/ginkgo "-C${GOPATH}/src/${CSI_PROW_E2E_IMPORT_PATH}" &&
955+
ln -s "${GOPATH}/src/${CSI_PROW_E2E_IMPORT_PATH}/_output/bin/ginkgo" "${CSI_PROW_BIN}"
947956
else
948957
run_with_go "${CSI_PROW_GO_VERSION_E2E}" go test -c -o "${CSI_PROW_WORK}/e2e.test" "${CSI_PROW_E2E_IMPORT_PATH}/test/e2e"
949958
fi

0 commit comments

Comments
 (0)