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

Update prow #50

Merged
merged 49 commits into from
Aug 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
94fc1e3
build.make: avoid unit-testing E2E test suite
pohly Mar 15, 2019
fb13c51
verify-shellcheck.sh: import from Kubernetes
pohly Mar 15, 2019
e6db50d
check vendor directory
pohly Mar 27, 2019
34010e7
Merge pull request #10 from pohly/vendor-check
k8s-ci-robot Mar 27, 2019
104a1ac
build.make: avoid unit-testing E2E test suite
pohly Mar 15, 2019
3b6af7b
Merge pull request #12 from pohly/local-e2e-suite
k8s-ci-robot Mar 29, 2019
b2d25d4
verify-shellcheck.sh: make it usable in csi-release-tools
pohly Mar 15, 2019
6c7ba1b
build.make: integrate shellcheck into "make test"
pohly Mar 26, 2019
55212ff
initial Prow test job
pohly Mar 15, 2019
2069a0a
Merge pull request #11 from pohly/verify-shellcheck
k8s-ci-robot Apr 2, 2019
0a0fd49
prow.sh: comment clarification
pohly Apr 2, 2019
429581c
prow.sh: pull Go version from travis.yml
pohly Apr 2, 2019
29545bb
prow.sh: take Go version from Kubernetes source
pohly Apr 3, 2019
741319b
prow.sh: improve building Kubernetes from source
pohly Apr 3, 2019
6602d38
prow.sh: different E2E suite depending on Kubernetes version
pohly Apr 3, 2019
d87eccb
prow.sh: switch back to upstream csi-driver-host-path
pohly Apr 3, 2019
95ae9de
Merge pull request #9 from pohly/prow
k8s-ci-robot Apr 3, 2019
f501443
prow.sh: AllAlpha=true for unknown Kubernetes versions
pohly Apr 5, 2019
31dfaf3
prow.sh: fix running of just "alpha" tests
pohly Apr 8, 2019
f3d1d2d
prow.sh: fix hostpath driver version check
pohly Apr 8, 2019
aa45a1c
prow.sh: more efficient execution of individual tests
pohly Apr 8, 2019
9b0d9cd
build.make: skip shellcheck if Docker is not available
pohly Apr 8, 2019
546d550
prow.sh: debug failing KinD cluster creation
pohly Apr 8, 2019
cda2fc5
prow.sh: avoid AllAlpha=true
pohly Apr 8, 2019
6617773
Merge pull request #13 from pohly/prow
k8s-ci-robot Apr 9, 2019
7aaac22
prow.sh: remove AllAlpha=all, part II
pohly Apr 10, 2019
c60f382
Merge pull request #14 from pohly/prow
k8s-ci-robot Apr 10, 2019
ff9bce4
Replace 'return' to 'exit' to fix shellcheck error
pengzhisun Apr 11, 2019
0c2677e
Merge pull request #15 from pengzhisun/master
k8s-ci-robot Apr 11, 2019
0b10f6a
prow.sh: update csi-driver-host-path
pohly Apr 11, 2019
bcac1c1
Merge pull request #16 from pohly/prow
k8s-ci-robot Apr 11, 2019
0fafc66
prow.sh: skip sanity testing if component doesn't support it
pohly Apr 11, 2019
88dc9a4
Merge pull request #17 from pohly/prow
k8s-ci-robot Apr 11, 2019
e157b6b
update to Go 1.12.4
pohly Apr 15, 2019
0bee749
Merge pull request #18 from pohly/go-version
k8s-ci-robot Apr 15, 2019
066143d
build.make: allow repos to use 'go mod' for vendoring
pohly May 10, 2019
0399988
Merge pull request #19 from pohly/go-mod-vendor
k8s-ci-robot May 13, 2019
b2f4e05
prow.sh: flexible test driver config
pohly Jul 8, 2019
db8abb6
Merge pull request #20 from pohly/test-driver-config
k8s-ci-robot Jul 8, 2019
a6f21d4
Add variables for 1.15
msau42 Jul 11, 2019
ecc7918
Update kind to v0.4.0. This requires overriding Kubernetes versions
msau42 Jul 11, 2019
4b6fa4a
Update hostpath version for sidecar testing to v1.2.0-rc2
msau42 Jul 11, 2019
4e31f07
Change default hostpath driver name to hostpath.csi.k8s.io
msau42 Jul 12, 2019
f4f73ce
Merge pull request #21 from msau42/add-1.15-jobs
k8s-ci-robot Jul 12, 2019
0c0dc30
prow.sh: tag master images with a large version number
msau42 Jul 15, 2019
1cac3af
Merge pull request #22 from msau42/add-1.15-jobs
k8s-ci-robot Jul 16, 2019
f46191d
Kubernetes master changed the way that releases are tagged, which needed
msau42 Aug 5, 2019
aa85b82
Merge pull request #23 from msau42/fix-master-jobs
k8s-ci-robot Aug 9, 2019
8206402
Merge commit 'aa85b82ca778e3b4df175c2123985e3213ebfea2' into update-prow
msau42 Aug 16, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions release-tools/.prow.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! /bin/bash -e
#
# This is for testing csi-release-tools itself in Prow. All other
# repos use prow.sh for that, but as csi-release-tools isn't a normal
# repo with some Go code in it, it has a custom Prow test script.

./verify-shellcheck.sh "$(pwd)"
57 changes: 57 additions & 0 deletions release-tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,60 @@ Cheat sheet:
- `git subtree add --prefix=release-tools https://github.com/kubernetes-csi/csi-release-tools.git master` - add release tools to a repo which does not have them yet (only once)
- `git subtree pull --prefix=release-tools https://github.com/kubernetes-csi/csi-release-tools.git master` - update local copy to latest upstream (whenever upstream changes)
- edit, `git commit`, `git subtree push --prefix=release-tools [email protected]:<user>/csi-release-tools.git <my-new-or-existing-branch>` - push to a new branch before submitting a PR

verify-shellcheck.sh
--------------------

The [verify-shellcheck.sh](./verify-shellcheck.sh) script in this repo
is a stripped down copy of the [corresponding
script](https://github.com/kubernetes/kubernetes/blob/release-1.14/hack/verify-shellcheck.sh)
in the Kubernetes repository. It can be used to check for certain
errors shell scripts, like missing quotation marks. The default
`test-shellcheck` target in [build.make](./build.make) only checks the
scripts in this directory. Components can add more directories to
`TEST_SHELLCHECK_DIRS` to check also other scripts.

End-to-end testing
------------------

A repo that wants to opt into testing via Prow must set up a top-level
`.prow.sh`. Typically that will source `prow.sh` and then transfer
control to it:

``` bash
#! /bin/bash -e

. release-tools/prow.sh
main
```

All Kubernetes-CSI repos are expected to switch to Prow. For details
on what is enabled in Prow, see
https://github.com/kubernetes/test-infra/tree/master/config/jobs/kubernetes-csi

Test results for periodic jobs are visible in
https://testgrid.k8s.io/sig-storage-csi

It is possible to reproduce the Prow testing locally on a suitable machine:
- Linux host
- Docker installed
- code to be tested checkout out in `$GOPATH/src/<import path>`
- `cd $GOPATH/src/<import path> && ./.prow.sh`

Beware that the script intentionally doesn't clean up after itself and
modifies the content of `$GOPATH`, in particular the `kubernetes` and
`kind` repositories there. Better run it in an empty, disposable
`$GOPATH`.

When it terminates, the following command can be used to get access to
the Kubernetes cluster that was brought up for testing (assuming that
this step succeeded):

export KUBECONFIG="$(kind get kubeconfig-path --name="csi-prow")"

It is possible to control the execution via environment variables. See
`prow.sh` for details. Particularly useful is testing against different
Kubernetes releases:

CSI_PROW_KUBERNETES_VERSION=1.13.3 ./.prow.sh
CSI_PROW_KUBERNETES_VERSION=latest ./.prow.sh
56 changes: 55 additions & 1 deletion release-tools/build.make
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ test:
test: test-go
test-go:
@ echo; echo "### $@:"
go test `go list ./... | grep -v 'vendor' $(TEST_GO_FILTER_CMD)` $(TESTARGS)
go test `go list ./... | grep -v -e 'vendor' -e '/test/e2e$$' $(TEST_GO_FILTER_CMD)` $(TESTARGS)

.PHONY: test-vet
test: test-vet
Expand All @@ -117,8 +117,62 @@ test-fmt:
false; \
fi

# This test only runs when dep >= 0.5 is installed, which is the case for the CI setup.
# When using 'go mod', we allow the test to be skipped in the Prow CI under some special
# circumstances, because it depends on accessing all remote repos and thus
# running it all the time would defeat the purpose of vendoring:
# - not handling a PR or
# - the fabricated merge commit leaves go.mod, go.sum and vendor dir unchanged
# - release-tools also didn't change (changing rules or Go version might lead to
# a different result and thus must be tested)
.PHONY: test-vendor
test: test-vendor
test-vendor:
@ echo; echo "### $@:"
@ if [ -f Gopkg.toml ]; then \
echo "Repo uses 'dep' for vendoring."; \
case "$$(dep version 2>/dev/null | grep 'version *:')" in \
*v0.[56789]*) dep check && echo "vendor up-to-date" || false;; \
*) echo "skipping check, dep >= 0.5 required";; \
esac; \
else \
echo "Repo uses 'go mod' for vendoring."; \
if [ "$${JOB_NAME}" ] && \
( [ "$${JOB_TYPE}" != "presubmit" ] || \
[ $$(git diff "${PULL_BASE_SHA}..HEAD" -- go.mod go.sum vendor release-tools | wc -l) -eq 0 ] ); then \
echo "Skipping vendor check because the Prow pre-submit job does not change vendoring."; \
elif ! GO111MODULE=on go mod vendor; then \
echo "ERROR: vendor check failed."; \
false; \
elif [ $$(git status --porcelain -- vendor | wc -l) -gt 0 ]; then \
echo "ERROR: vendor directory *not* up-to-date, it did get modified by 'GO111MODULE=on go mod vendor':"; \
git status -- vendor; \
git diff -- vendor; \
false; \
fi; \
fi;

.PHONY: test-subtree
test: test-subtree
test-subtree:
@ echo; echo "### $@:"
./release-tools/verify-subtree.sh release-tools

# Components can extend the set of directories which must pass shellcheck.
# The default is to check only the release-tools directory itself.
TEST_SHELLCHECK_DIRS=release-tools
.PHONY: test-shellcheck
test: test-shellcheck
test-shellcheck:
@ echo; echo "### $@:"
@ ret=0; \
if ! command -v docker; then \
echo "skipped, no Docker"; \
exit 0; \
fi; \
for dir in $(abspath $(TEST_SHELLCHECK_DIRS)); do \
echo; \
echo "$$dir:"; \
./release-tools/verify-shellcheck.sh "$$dir" || ret=1; \
done; \
exit $$ret
133 changes: 133 additions & 0 deletions release-tools/filter-junit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/*
Copyright 2019 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/*
* This command filters a JUnit file such that only tests with a name
* matching a regular expression are passed through. By concatenating
* multiple input files it is possible to merge them into a single file.
*/
package main

import (
"encoding/xml"
"flag"
"io/ioutil"
"os"
"regexp"
)

var (
output = flag.String("o", "-", "junit file to write, - for stdout")
tests = flag.String("t", "", "regular expression matching the test names that are to be included in the output")
)

/*
* TestSuite represents a JUnit file. Due to how encoding/xml works, we have
* represent all fields that we want to be passed through. It's therefore
* not a complete solution, but good enough for Ginkgo + Spyglass.
*/
type TestSuite struct {
XMLName string `xml:"testsuite"`
TestCases []TestCase `xml:"testcase"`
}

type TestCase struct {
Name string `xml:"name,attr"`
Time string `xml:"time,attr"`
SystemOut string `xml:"system-out,omitempty"`
Failure string `xml:"failure,omitempty"`
Skipped SkipReason `xml:"skipped,omitempty"`
}

// SkipReason deals with the special <skipped></skipped>:
// if present, we must re-encode it, even if empty.
type SkipReason string

func (s *SkipReason) UnmarshalText(text []byte) error {
*s = SkipReason(text)
if *s == "" {
*s = " "
}
return nil
}

func (s SkipReason) MarshalText() ([]byte, error) {
if s == " " {
return []byte{}, nil
}
return []byte(s), nil
}

func main() {
var junit TestSuite
var data []byte

flag.Parse()

re := regexp.MustCompile(*tests)

// Read all input files.
for _, input := range flag.Args() {
if input == "-" {
if _, err := os.Stdin.Read(data); err != nil {
panic(err)
}
} else {
var err error
data, err = ioutil.ReadFile(input)
if err != nil {
panic(err)
}
}
if err := xml.Unmarshal(data, &junit); err != nil {
panic(err)
}
}

// Keep only matching testcases. Testcases skipped in all test runs are only stored once.
filtered := map[string]TestCase{}
for _, testcase := range junit.TestCases {
if !re.MatchString(testcase.Name) {
continue
}
entry, ok := filtered[testcase.Name]
if !ok || // not present yet
entry.Skipped != "" && testcase.Skipped == "" { // replaced skipped test with real test run
filtered[testcase.Name] = testcase
}
}
junit.TestCases = nil
for _, testcase := range filtered {
junit.TestCases = append(junit.TestCases, testcase)
}

// Re-encode.
data, err := xml.MarshalIndent(junit, "", " ")
if err != nil {
panic(err)
}

// Write to output.
if *output == "-" {
if _, err := os.Stdout.Write(data); err != nil {
panic(err)
}
} else {
if err := ioutil.WriteFile(*output, data, 0644); err != nil {
panic(err)
}
}
}
Loading