mirror of https://github.com/knative/docs.git
Use knative.dev/test-infra (#1627)
This commit is contained in:
parent
0ef8366c97
commit
003aca0f76
|
@ -11,7 +11,7 @@
|
|||
"internal/optional",
|
||||
"internal/trace",
|
||||
"internal/version",
|
||||
"storage",
|
||||
"storage"
|
||||
]
|
||||
pruneopts = "NUT"
|
||||
revision = "28a4bc8c44b3acbcc482cff0cdf7de29a4688b61"
|
||||
|
@ -38,7 +38,7 @@
|
|||
name = "github.com/eclipse/paho.mqtt.golang"
|
||||
packages = [
|
||||
".",
|
||||
"packets",
|
||||
"packets"
|
||||
]
|
||||
pruneopts = "NUT"
|
||||
revision = "36d01c2b4cbeb3d2a12063e4880ce30800af9560"
|
||||
|
@ -53,7 +53,7 @@
|
|||
"ptypes",
|
||||
"ptypes/any",
|
||||
"ptypes/duration",
|
||||
"ptypes/timestamp",
|
||||
"ptypes/timestamp"
|
||||
]
|
||||
pruneopts = "NUT"
|
||||
revision = "b4deda0973fb4c70b50d226b1af49f3da59f5265"
|
||||
|
@ -85,7 +85,7 @@
|
|||
"stringclassifier",
|
||||
"stringclassifier/internal/pq",
|
||||
"stringclassifier/searchset",
|
||||
"stringclassifier/searchset/tokenizer",
|
||||
"stringclassifier/searchset/tokenizer"
|
||||
]
|
||||
pruneopts = "NUT"
|
||||
revision = "c2a262e3078ad90718f59866f1ec18601b2fee1b"
|
||||
|
@ -114,17 +114,6 @@
|
|||
revision = "e3702bed27f0d39777b0b37b664b6280e8ef8fbf"
|
||||
version = "v1.6.2"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:8cbd2b6c179d93c5cdc5f75c1acda0aa7ef7649cf9ca138e587d9ac98a137802"
|
||||
name = "github.com/knative/test-infra"
|
||||
packages = [
|
||||
"scripts",
|
||||
"tools/dep-collector",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "7d0c44fb03a996501f10e3af4a718fd008fe9bed"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:5985ef4caf91ece5d54817c11ea25f182697534f8ae6521eadcd628c142ac4b6"
|
||||
name = "github.com/matttproud/golang_protobuf_extensions"
|
||||
|
@ -142,7 +131,7 @@
|
|||
"model",
|
||||
"propagation",
|
||||
"reporter",
|
||||
"reporter/http",
|
||||
"reporter/http"
|
||||
]
|
||||
pruneopts = "NUT"
|
||||
revision = "f197ec29e729f226d23370ea60f0e49b8f44ccf4"
|
||||
|
@ -153,7 +142,7 @@
|
|||
name = "github.com/prometheus/client_golang"
|
||||
packages = [
|
||||
"prometheus",
|
||||
"prometheus/promhttp",
|
||||
"prometheus/promhttp"
|
||||
]
|
||||
pruneopts = "NUT"
|
||||
revision = "c5b7fccd204277076155f10851dad72b76a49317"
|
||||
|
@ -174,7 +163,7 @@
|
|||
packages = [
|
||||
"expfmt",
|
||||
"internal/bitbucket.org/ww/goautoneg",
|
||||
"model",
|
||||
"model"
|
||||
]
|
||||
pruneopts = "NUT"
|
||||
revision = "7600349dcfe1abd18d72d3a1770870d9800a7801"
|
||||
|
@ -187,7 +176,7 @@
|
|||
".",
|
||||
"internal/util",
|
||||
"nfs",
|
||||
"xfs",
|
||||
"xfs"
|
||||
]
|
||||
pruneopts = "NUT"
|
||||
revision = "ae68e2d4c00fed4943b5f6698d504a5fe083da8a"
|
||||
|
@ -225,7 +214,7 @@
|
|||
"tag",
|
||||
"trace",
|
||||
"trace/internal",
|
||||
"trace/propagation",
|
||||
"trace/propagation"
|
||||
]
|
||||
pruneopts = "NUT"
|
||||
revision = "e262766cd0d230a1bb7c37281e345e465f19b41b"
|
||||
|
@ -246,7 +235,7 @@
|
|||
"internal/timeseries",
|
||||
"proxy",
|
||||
"trace",
|
||||
"websocket",
|
||||
"websocket"
|
||||
]
|
||||
pruneopts = "NUT"
|
||||
revision = "d0887baf81f4598189d4e12a37c6da86f0bba4d0"
|
||||
|
@ -260,7 +249,7 @@
|
|||
"google",
|
||||
"internal",
|
||||
"jws",
|
||||
"jwt",
|
||||
"jwt"
|
||||
]
|
||||
pruneopts = "NUT"
|
||||
revision = "ef147856a6ddbb60760db74283d2424e98c87bff"
|
||||
|
@ -290,7 +279,7 @@
|
|||
"unicode/bidi",
|
||||
"unicode/cldr",
|
||||
"unicode/norm",
|
||||
"unicode/rangetable",
|
||||
"unicode/rangetable"
|
||||
]
|
||||
pruneopts = "NUT"
|
||||
revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0"
|
||||
|
@ -309,7 +298,7 @@
|
|||
"option",
|
||||
"storage/v1",
|
||||
"transport/http",
|
||||
"transport/http/internal/propagation",
|
||||
"transport/http/internal/propagation"
|
||||
]
|
||||
pruneopts = "NUT"
|
||||
revision = "19e022d8cf43ce81f046bae8cc18c5397cc7732f"
|
||||
|
@ -328,7 +317,7 @@
|
|||
"internal/modules",
|
||||
"internal/remote_api",
|
||||
"internal/urlfetch",
|
||||
"urlfetch",
|
||||
"urlfetch"
|
||||
]
|
||||
pruneopts = "NUT"
|
||||
revision = "b1f26356af11148e710935ed1ac8a7f5702c7612"
|
||||
|
@ -342,7 +331,7 @@
|
|||
"googleapis/api/annotations",
|
||||
"googleapis/iam/v1",
|
||||
"googleapis/rpc/code",
|
||||
"googleapis/rpc/status",
|
||||
"googleapis/rpc/status"
|
||||
]
|
||||
pruneopts = "NUT"
|
||||
revision = "ae2f86662275e140f395167f1dab7081a5bd5fa8"
|
||||
|
@ -381,7 +370,7 @@
|
|||
"resolver/passthrough",
|
||||
"stats",
|
||||
"status",
|
||||
"tap",
|
||||
"tap"
|
||||
]
|
||||
pruneopts = "NUT"
|
||||
revision = "df014850f6dee74ba2fc94874043a9f3f75fbfd8"
|
||||
|
@ -392,7 +381,7 @@
|
|||
name = "gopkg.in/go-playground/webhooks.v3"
|
||||
packages = [
|
||||
".",
|
||||
"github",
|
||||
"github"
|
||||
]
|
||||
pruneopts = "NUT"
|
||||
revision = "8ffb2ffc32b7af2c7e940944eccba4dcd66c692a"
|
||||
|
@ -406,6 +395,17 @@
|
|||
revision = "51d6538a90f86fe93ac480b35f37b2be17fef232"
|
||||
version = "v2.2.2"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:68050b4ce26531655bac0f6e109d04eb0a4550ead73e320119ed3c628ced4a0a"
|
||||
name = "knative.dev/test-infra"
|
||||
packages = [
|
||||
"scripts",
|
||||
"tools/dep-collector"
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "17f2331e80ad0d3e170ea2bae45c3922744f83af"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
|
@ -416,8 +416,6 @@
|
|||
"github.com/golang/protobuf/proto",
|
||||
"github.com/google/go-github/github",
|
||||
"github.com/gorilla/mux",
|
||||
"github.com/knative/test-infra/scripts",
|
||||
"github.com/knative/test-infra/tools/dep-collector",
|
||||
"github.com/openzipkin/zipkin-go",
|
||||
"github.com/openzipkin/zipkin-go/reporter/http",
|
||||
"github.com/satori/go.uuid",
|
||||
|
@ -435,6 +433,8 @@
|
|||
"gopkg.in/go-playground/webhooks.v3",
|
||||
"gopkg.in/go-playground/webhooks.v3/github",
|
||||
"gopkg.in/yaml.v2",
|
||||
"knative.dev/test-infra/scripts",
|
||||
"knative.dev/test-infra/tools/dep-collector"
|
||||
]
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
# for detailed Gopkg.toml documentation.
|
||||
|
||||
required = [
|
||||
"github.com/knative/test-infra/scripts",
|
||||
"github.com/knative/test-infra/tools/dep-collector",
|
||||
"knative.dev/test-infra/scripts",
|
||||
"knative.dev/test-infra/tools/dep-collector",
|
||||
]
|
||||
|
||||
[prune]
|
||||
|
@ -12,5 +12,5 @@ required = [
|
|||
non-go = true
|
||||
|
||||
[[prune.project]]
|
||||
name = "github.com/knative/test-infra"
|
||||
name = "knative.dev/test-infra"
|
||||
non-go = false
|
||||
|
|
|
@ -18,7 +18,7 @@ set -o errexit
|
|||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
source $(dirname $0)/../vendor/github.com/knative/test-infra/scripts/library.sh
|
||||
source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/library.sh
|
||||
|
||||
cd ${REPO_ROOT_DIR}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
source $(dirname $0)/../vendor/github.com/knative/test-infra/scripts/e2e-tests.sh
|
||||
source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/e2e-tests.sh
|
||||
|
||||
function knative_setup() {
|
||||
start_latest_knative_serving
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
DISABLE_MD_LINTING=1
|
||||
DISABLE_MD_LINK_CHECK=1
|
||||
|
||||
source $(dirname $0)/../vendor/github.com/knative/test-infra/scripts/presubmit-tests.sh
|
||||
source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/presubmit-tests.sh
|
||||
|
||||
# We use the default build, unit and integration test runners.
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Helper scripts
|
||||
|
||||
This directory contains helper scripts used by Prow test jobs, as well and
|
||||
local development scripts.
|
||||
This directory contains helper scripts used by Prow test jobs, as well and local
|
||||
development scripts.
|
||||
|
||||
## Using the `presubmit-tests.sh` helper script
|
||||
|
||||
|
@ -28,45 +28,47 @@ This is a helper script to run the presubmit tests. To use it:
|
|||
in the `/test` directory.
|
||||
|
||||
1. [optional] Customize the default build test runner, if you're using it. Set
|
||||
the following environment variables if the default values don't fit your needs:
|
||||
the following environment variables if the default values don't fit your
|
||||
needs:
|
||||
|
||||
- `DISABLE_MD_LINTING`: Disable linting markdown files, defaults to 0 (false).
|
||||
- `DISABLE_MD_LINTING`: Disable linting markdown files, defaults to 0
|
||||
(false).
|
||||
- `DISABLE_MD_LINK_CHECK`: Disable checking links in markdown files, defaults
|
||||
to 0 (false).
|
||||
- `PRESUBMIT_TEST_FAIL_FAST`: Fail the presubmit test immediately if a test fails,
|
||||
defaults to 0 (false).
|
||||
- `PRESUBMIT_TEST_FAIL_FAST`: Fail the presubmit test immediately if a test
|
||||
fails, defaults to 0 (false).
|
||||
|
||||
1. [optional] Define the functions `pre_build_tests()` and/or
|
||||
`post_build_tests()`. These functions will be called before or after the
|
||||
build tests (either your custom one or the default action) and will cause
|
||||
the test to fail if they don't return success.
|
||||
build tests (either your custom one or the default action) and will cause the
|
||||
test to fail if they don't return success.
|
||||
|
||||
1. [optional] Define the function `unit_tests()`. If you don't define this
|
||||
function, the default action for running the unit tests is to run all go tests
|
||||
in the repo.
|
||||
function, the default action for running the unit tests is to run all go
|
||||
tests in the repo.
|
||||
|
||||
1. [optional] Define the functions `pre_unit_tests()` and/or
|
||||
`post_unit_tests()`. These functions will be called before or after the
|
||||
unit tests (either your custom one or the default action) and will cause
|
||||
the test to fail if they don't return success.
|
||||
`post_unit_tests()`. These functions will be called before or after the unit
|
||||
tests (either your custom one or the default action) and will cause the test
|
||||
to fail if they don't return success.
|
||||
|
||||
1. [optional] Define the function `integration_tests()`. If you don't define
|
||||
this function, the default action for running the integration tests is to run
|
||||
all run all `./test/e2e-*tests.sh` scripts, in sequence.
|
||||
|
||||
1. [optional] Define the functions `pre_integration_tests()` and/or
|
||||
`post_integration_tests()`. These functions will be called before or after the
|
||||
integration tests (either your custom one or the default action) and will cause
|
||||
the test to fail if they don't return success.
|
||||
`post_integration_tests()`. These functions will be called before or after
|
||||
the integration tests (either your custom one or the default action) and will
|
||||
cause the test to fail if they don't return success.
|
||||
|
||||
1. Call the `main()` function passing `$@` (without quotes).
|
||||
|
||||
Running the script without parameters, or with the `--all-tests` flag causes
|
||||
all tests to be executed, in the right order (i.e., build, then unit, then
|
||||
Running the script without parameters, or with the `--all-tests` flag causes all
|
||||
tests to be executed, in the right order (i.e., build, then unit, then
|
||||
integration tests).
|
||||
|
||||
Use the flags `--build-tests`, `--unit-tests` and `--integration-tests` to run
|
||||
a specific set of tests. The flag `--emit-metrics` is used to emit metrics when
|
||||
Use the flags `--build-tests`, `--unit-tests` and `--integration-tests` to run a
|
||||
specific set of tests. The flag `--emit-metrics` is used to emit metrics when
|
||||
running the tests, and is automatically handled by the default action for
|
||||
integration tests (see above).
|
||||
|
||||
|
@ -79,7 +81,7 @@ skipped.
|
|||
### Sample presubmit test script
|
||||
|
||||
```bash
|
||||
source vendor/github.com/knative/test-infra/scripts/presubmit-tests.sh
|
||||
source vendor/knative.dev/test-infra/scripts/presubmit-tests.sh
|
||||
|
||||
function post_build_tests() {
|
||||
echo "Cleaning up after build tests"
|
||||
|
@ -104,63 +106,64 @@ main $@
|
|||
|
||||
This is a helper script for Knative E2E test scripts. To use it:
|
||||
|
||||
1. [optional] Customize the test cluster. Set the following environment variables
|
||||
if the default values don't fit your needs:
|
||||
1. [optional] Customize the test cluster. Set the following environment
|
||||
variables if the default values don't fit your needs:
|
||||
|
||||
- `E2E_CLUSTER_REGION`: Cluster region, defaults to `us-central1`.
|
||||
- `E2E_CLUSTER_BACKUP_REGIONS`: Space-separated list of regions to retry test
|
||||
cluster creation in case of stockout. Defaults to `us-west1 us-east1`.
|
||||
- `E2E_CLUSTER_ZONE`: Cluster zone (e.g., `a`), defaults to none (i.e. use a regional
|
||||
cluster).
|
||||
- `E2E_CLUSTER_BACKUP_ZONES`: Space-separated list of zones to retry test cluster
|
||||
creation in case of stockout. If defined, `E2E_CLUSTER_BACKUP_REGIONS` will be
|
||||
ignored thus it defaults to none.
|
||||
- `E2E_CLUSTER_MACHINE`: Cluster node machine type, defaults to `n1-standard-4}`.
|
||||
- `E2E_MIN_CLUSTER_NODES`: Minimum number of nodes in the cluster when autoscaling,
|
||||
defaults to 1.
|
||||
- `E2E_MAX_CLUSTER_NODES`: Maximum number of nodes in the cluster when autoscaling,
|
||||
defaults to 3.
|
||||
- `E2E_CLUSTER_ZONE`: Cluster zone (e.g., `a`), defaults to none (i.e. use a
|
||||
regional cluster).
|
||||
- `E2E_CLUSTER_BACKUP_ZONES`: Space-separated list of zones to retry test
|
||||
cluster creation in case of stockout. If defined,
|
||||
`E2E_CLUSTER_BACKUP_REGIONS` will be ignored thus it defaults to none.
|
||||
- `E2E_CLUSTER_MACHINE`: Cluster node machine type, defaults to
|
||||
`n1-standard-4}`.
|
||||
- `E2E_MIN_CLUSTER_NODES`: Minimum number of nodes in the cluster when
|
||||
autoscaling, defaults to 1.
|
||||
- `E2E_MAX_CLUSTER_NODES`: Maximum number of nodes in the cluster when
|
||||
autoscaling, defaults to 3.
|
||||
|
||||
1. Source the script.
|
||||
|
||||
1. [optional] Write the `knative_setup()` function, which will set up your
|
||||
system under test (e.g., Knative Serving). This function won't be called if you
|
||||
use the `--skip-knative-setup` flag.
|
||||
system under test (e.g., Knative Serving). This function won't be called if
|
||||
you use the `--skip-knative-setup` flag.
|
||||
|
||||
1. [optional] Write the `knative_teardown()` function, which will tear down your
|
||||
system under test (e.g., Knative Serving). This function won't be called if you
|
||||
use the `--skip-knative-setup` flag.
|
||||
system under test (e.g., Knative Serving). This function won't be called if
|
||||
you use the `--skip-knative-setup` flag.
|
||||
|
||||
1. [optional] Write the `test_setup()` function, which will set up the test
|
||||
resources.
|
||||
|
||||
1. [optional] Write the `test_teardown()` function, which will tear down the test
|
||||
resources.
|
||||
1. [optional] Write the `test_teardown()` function, which will tear down the
|
||||
test resources.
|
||||
|
||||
1. [optional] Write the `cluster_setup()` function, which will set up any resources
|
||||
before the test cluster is created.
|
||||
1. [optional] Write the `cluster_setup()` function, which will set up any
|
||||
resources before the test cluster is created.
|
||||
|
||||
1. [optional] Write the `cluster_teardown()` function, which will tear down any
|
||||
resources after the test cluster is destroyed.
|
||||
|
||||
1. [optional] Write the `dump_extra_cluster_state()` function. It will be
|
||||
called when a test fails, and can dump extra information about the current state
|
||||
of the cluster (typically using `kubectl`).
|
||||
1. [optional] Write the `dump_extra_cluster_state()` function. It will be called
|
||||
when a test fails, and can dump extra information about the current state of
|
||||
the cluster (typically using `kubectl`).
|
||||
|
||||
1. [optional] Write the `parse_flags()` function. It will be called whenever an
|
||||
unrecognized flag is passed to the script, allowing you to define your own flags.
|
||||
The function must return 0 if the flag is unrecognized, or the number of items
|
||||
to skip in the command line if the flag was parsed successfully. For example,
|
||||
return 1 for a simple flag, and 2 for a flag with a parameter.
|
||||
unrecognized flag is passed to the script, allowing you to define your own
|
||||
flags. The function must return 0 if the flag is unrecognized, or the number
|
||||
of items to skip in the command line if the flag was parsed successfully. For
|
||||
example, return 1 for a simple flag, and 2 for a flag with a parameter.
|
||||
|
||||
1. Call the `initialize()` function passing `$@` (without quotes).
|
||||
|
||||
1. Write logic for the end-to-end tests. Run all go tests using `go_test_e2e()`
|
||||
(or `report_go_test()` if you need a more fine-grained control) and call
|
||||
`fail_test()` or `success()` if any of them failed. The environment variable
|
||||
`KO_DOCKER_REPO` and `E2E_PROJECT_ID` will be set according to the test cluster.
|
||||
You can also use the following boolean (0 is false, 1 is true) environment
|
||||
variables for the logic:
|
||||
`KO_DOCKER_REPO` and `E2E_PROJECT_ID` will be set according to the test
|
||||
cluster. You can also use the following boolean (0 is false, 1 is true)
|
||||
environment variables for the logic:
|
||||
|
||||
- `EMIT_METRICS`: true if `--emit-metrics` was passed.
|
||||
|
||||
|
@ -175,25 +178,26 @@ This is a helper script for Knative E2E test scripts. To use it:
|
|||
will immediately start the tests against the cluster currently configured for
|
||||
`kubectl`.
|
||||
|
||||
1. By default Istio is installed on the cluster via Addon, use `--skip-istio-addon` if
|
||||
you choose not to have it preinstalled.
|
||||
1. By default Istio is installed on the cluster via Addon, use
|
||||
`--skip-istio-addon` if you choose not to have it preinstalled.
|
||||
|
||||
1. You can force running the tests against a specific GKE cluster version by using
|
||||
the `--cluster-version` flag and passing a full version as the flag value.
|
||||
1. You can force running the tests against a specific GKE cluster version by
|
||||
using the `--cluster-version` flag and passing a full version as the flag
|
||||
value.
|
||||
|
||||
### Sample end-to-end test script
|
||||
|
||||
This script will test that the latest Knative Serving nightly release works. It
|
||||
defines a special flag (`--no-knative-wait`) that causes the script not to
|
||||
wait for Knative Serving to be up before running the tests. It also requires that
|
||||
the test cluster is created in a specific region, `us-west2`.
|
||||
defines a special flag (`--no-knative-wait`) that causes the script not to wait
|
||||
for Knative Serving to be up before running the tests. It also requires that the
|
||||
test cluster is created in a specific region, `us-west2`.
|
||||
|
||||
```bash
|
||||
|
||||
# This test requires a cluster in LA
|
||||
E2E_CLUSTER_REGION=us-west2
|
||||
|
||||
source vendor/github.com/knative/test-infra/scripts/e2e-tests.sh
|
||||
source vendor/knative.dev/test-infra/scripts/e2e-tests.sh
|
||||
|
||||
function knative_setup() {
|
||||
start_latest_knative_serving
|
||||
|
@ -226,40 +230,46 @@ This is a helper script for Knative release scripts. To use it:
|
|||
|
||||
1. Source the script.
|
||||
|
||||
1. [optional] By default, the release script will run `./test/presubmit-tests.sh`
|
||||
as the release validation tests. If you need to run something else, set the
|
||||
environment variable `VALIDATION_TESTS` to the executable to run.
|
||||
1. [optional] By default, the release script will run
|
||||
`./test/presubmit-tests.sh` as the release validation tests. If you need to
|
||||
run something else, set the environment variable `VALIDATION_TESTS` to the
|
||||
executable to run.
|
||||
|
||||
1. Write logic for building the release in a function named `build_release()`.
|
||||
Set the environment variable `ARTIFACTS_TO_PUBLISH` to the list of files created,
|
||||
space separated. Use the following boolean (0 is false, 1 is true) and string
|
||||
environment variables for the logic:
|
||||
Set the environment variable `ARTIFACTS_TO_PUBLISH` to the list of files
|
||||
created, space separated. Use the following boolean (0 is false, 1 is true)
|
||||
and string environment variables for the logic:
|
||||
|
||||
- `RELEASE_VERSION`: contains the release version if `--version` was passed. This
|
||||
also overrides the value of the `TAG` variable as `v<version>`.
|
||||
- `RELEASE_BRANCH`: contains the release branch if `--branch` was passed. Otherwise
|
||||
it's empty and `master` HEAD will be considered the release branch.
|
||||
- `RELEASE_NOTES`: contains the filename with the release notes if `--release-notes`
|
||||
was passed. The release notes is a simple markdown file.
|
||||
- `RELEASE_GCS_BUCKET`: contains the GCS bucket name to store the manifests if
|
||||
`--release-gcs` was passed, otherwise the default value `knative-nightly/<repo>`
|
||||
will be used. It is empty if `--publish` was not passed.
|
||||
- `BUILD_COMMIT_HASH`: the commit short hash for the current repo. If the current
|
||||
git tree is dirty, it will have `-dirty` appended to it.
|
||||
- `RELEASE_VERSION`: contains the release version if `--version` was passed.
|
||||
This also overrides the value of the `TAG` variable as `v<version>`.
|
||||
- `RELEASE_BRANCH`: contains the release branch if `--branch` was passed.
|
||||
Otherwise it's empty and `master` HEAD will be considered the release
|
||||
branch.
|
||||
- `RELEASE_NOTES`: contains the filename with the release notes if
|
||||
`--release-notes` was passed. The release notes is a simple markdown file.
|
||||
- `RELEASE_GCS_BUCKET`: contains the GCS bucket name to store the manifests
|
||||
if `--release-gcs` was passed, otherwise the default value
|
||||
`knative-nightly/<repo>` will be used. It is empty if `--publish` was not
|
||||
passed.
|
||||
- `BUILD_COMMIT_HASH`: the commit short hash for the current repo. If the
|
||||
current git tree is dirty, it will have `-dirty` appended to it.
|
||||
- `BUILD_YYYYMMDD`: current UTC date in `YYYYMMDD` format.
|
||||
- `BUILD_TIMESTAMP`: human-readable UTC timestamp in `YYYY-MM-DD HH:MM:SS` format.
|
||||
- `BUILD_TIMESTAMP`: human-readable UTC timestamp in `YYYY-MM-DD HH:MM:SS`
|
||||
format.
|
||||
- `BUILD_TAG`: a tag in the form `v$BUILD_YYYYMMDD-$BUILD_COMMIT_HASH`.
|
||||
- `KO_DOCKER_REPO`: contains the GCR to store the images if `--release-gcr` was
|
||||
passed, otherwise the default value `gcr.io/knative-nightly` will be used. It
|
||||
is set to `ko.local` if `--publish` was not passed.
|
||||
- `SKIP_TESTS`: true if `--skip-tests` was passed. This is handled automatically.
|
||||
- `TAG_RELEASE`: true if `--tag-release` was passed. In this case, the environment
|
||||
variable `TAG` will contain the release tag in the form `v$BUILD_TAG`.
|
||||
- `PUBLISH_RELEASE`: true if `--publish` was passed. In this case, the environment
|
||||
variable `KO_FLAGS` will be updated with the `-L` option and `TAG` will contain
|
||||
the release tag in the form `v$RELEASE_VERSION`.
|
||||
- `PUBLISH_TO_GITHUB`: true if `--version`, `--branch` and `--publish-release`
|
||||
were passed.
|
||||
- `KO_DOCKER_REPO`: contains the GCR to store the images if `--release-gcr`
|
||||
was passed, otherwise the default value `gcr.io/knative-nightly` will be
|
||||
used. It is set to `ko.local` if `--publish` was not passed.
|
||||
- `SKIP_TESTS`: true if `--skip-tests` was passed. This is handled
|
||||
automatically.
|
||||
- `TAG_RELEASE`: true if `--tag-release` was passed. In this case, the
|
||||
environment variable `TAG` will contain the release tag in the form
|
||||
`v$BUILD_TAG`.
|
||||
- `PUBLISH_RELEASE`: true if `--publish` was passed. In this case, the
|
||||
environment variable `KO_FLAGS` will be updated with the `-L` option and
|
||||
`TAG` will contain the release tag in the form `v$RELEASE_VERSION`.
|
||||
- `PUBLISH_TO_GITHUB`: true if `--version`, `--branch` and
|
||||
`--publish-release` were passed.
|
||||
|
||||
All boolean environment variables default to false for safety.
|
||||
|
||||
|
@ -271,7 +281,7 @@ This is a helper script for Knative release scripts. To use it:
|
|||
### Sample release script
|
||||
|
||||
```bash
|
||||
source vendor/github.com/knative/test-infra/scripts/release.sh
|
||||
source vendor/knative.dev/test-infra/scripts/release.sh
|
||||
|
||||
function build_release() {
|
||||
# config/ contains the manifests
|
|
@ -83,7 +83,7 @@ function go_test_e2e() {
|
|||
local go_options=""
|
||||
(( EMIT_METRICS )) && test_options="-emitmetrics"
|
||||
[[ ! " $@" == *" -tags="* ]] && go_options="-tags=e2e"
|
||||
report_go_test -v -count=1 ${go_options} $@ ${test_options}
|
||||
report_go_test -v -race -count=1 ${go_options} $@ ${test_options}
|
||||
}
|
||||
|
||||
# Dump info about the test cluster. If dump_extra_cluster_info() is defined, calls it too.
|
||||
|
@ -127,29 +127,41 @@ function save_metadata() {
|
|||
EOF
|
||||
}
|
||||
|
||||
# Delete target pools and health checks that might have leaked.
|
||||
# See https://github.com/knative/serving/issues/959 for details.
|
||||
# TODO(adrcunha): Remove once the leak issue is resolved.
|
||||
function delete_leaked_network_resources() {
|
||||
# On boskos, don't bother with leaks as the janitor will delete everything in the project.
|
||||
(( IS_BOSKOS )) && return
|
||||
# Ensure we're using the GCP project used by kubetest
|
||||
local gcloud_project="$(gcloud config get-value project)"
|
||||
local http_health_checks="$(gcloud compute target-pools list \
|
||||
--project=${gcloud_project} --format='value(healthChecks)' --filter="instances~-${E2E_CLUSTER_NAME}-" | \
|
||||
grep httpHealthChecks | tr '\n' ' ')"
|
||||
local target_pools="$(gcloud compute target-pools list \
|
||||
--project=${gcloud_project} --format='value(name)' --filter="instances~-${E2E_CLUSTER_NAME}-" | \
|
||||
tr '\n' ' ')"
|
||||
if [[ -n "${target_pools}" ]]; then
|
||||
echo "Found leaked target pools, deleting"
|
||||
gcloud compute forwarding-rules delete -q --project=${gcloud_project} --region=${E2E_CLUSTER_REGION} ${target_pools}
|
||||
gcloud compute target-pools delete -q --project=${gcloud_project} --region=${E2E_CLUSTER_REGION} ${target_pools}
|
||||
# Set E2E_CLUSTER_VERSION to a specific GKE version.
|
||||
# Parameters: $1 - target GKE version (X.Y, X.Y.Z, X.Y.Z-gke.W, default or gke-latest).
|
||||
# $2 - region[-zone] where the clusteer will be created.
|
||||
function resolve_k8s_version() {
|
||||
local target_version="$1"
|
||||
if [[ "${target_version}" == "default" ]]; then
|
||||
local version="$(gcloud container get-server-config \
|
||||
--format='value(defaultClusterVersion)' \
|
||||
--zone=$2)"
|
||||
[[ -z "${version}" ]] && return 1
|
||||
E2E_CLUSTER_VERSION="${version}"
|
||||
echo "Using default version, ${E2E_CLUSTER_VERSION}"
|
||||
return 0
|
||||
fi
|
||||
if [[ -n "${http_health_checks}" ]]; then
|
||||
echo "Found leaked health checks, deleting"
|
||||
gcloud compute http-health-checks delete -q --project=${gcloud_project} ${http_health_checks}
|
||||
# Fetch valid versions
|
||||
local versions="$(gcloud container get-server-config \
|
||||
--format='value(validMasterVersions)' \
|
||||
--zone=$2)"
|
||||
[[ -z "${versions}" ]] && return 1
|
||||
local gke_versions=($(echo -n "${versions//;/ }"))
|
||||
echo "Available GKE versions in $2 are [${versions//;/, }]"
|
||||
if [[ "${target_version}" == "gke-latest" ]]; then
|
||||
# Get first (latest) version, excluding the "-gke.#" suffix
|
||||
E2E_CLUSTER_VERSION="${gke_versions[0]}"
|
||||
echo "Using latest version, ${E2E_CLUSTER_VERSION}"
|
||||
else
|
||||
local latest="$(echo "${gke_versions[@]}" | tr ' ' '\n' | grep -E ^${target_version} | cut -f1 -d- | sort | tail -1)"
|
||||
if [[ -z "${latest}" ]]; then
|
||||
echo "ERROR: version ${target_version} is not available"
|
||||
return 1
|
||||
fi
|
||||
E2E_CLUSTER_VERSION="${latest}"
|
||||
echo "Using ${E2E_CLUSTER_VERSION} for supplied version ${target_version}"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# Create a test cluster with kubetest and call the current script again.
|
||||
|
@ -172,9 +184,11 @@ function create_test_cluster() {
|
|||
--deployment=gke
|
||||
--cluster="${E2E_CLUSTER_NAME}"
|
||||
--gcp-network="${E2E_NETWORK_NAME}"
|
||||
--gcp-node-image="${SERVING_GKE_IMAGE}"
|
||||
--gke-environment="${E2E_GKE_ENVIRONMENT}"
|
||||
--gke-command-group="${E2E_GKE_COMMAND_GROUP}"
|
||||
--test=false
|
||||
--up
|
||||
)
|
||||
if (( ! IS_BOSKOS )); then
|
||||
CLUSTER_CREATION_ARGS+=(--gcp-project=${GCP_PROJECT})
|
||||
|
@ -200,21 +214,33 @@ function create_test_cluster() {
|
|||
[[ -n "${GCP_PROJECT}" ]] && test_cmd_args+=" --gcp-project ${GCP_PROJECT}"
|
||||
[[ -n "${E2E_SCRIPT_CUSTOM_FLAGS[@]}" ]] && test_cmd_args+=" ${E2E_SCRIPT_CUSTOM_FLAGS[@]}"
|
||||
local extra_flags=()
|
||||
# If using boskos, save time and let it tear down the cluster
|
||||
(( ! IS_BOSKOS )) && extra_flags+=(--down)
|
||||
if (( IS_BOSKOS )); then # Add arbitrary duration, wait for Boskos projects acquisition before error out
|
||||
extra_flags+=(--boskos-wait-duration=20m)
|
||||
else # Only let kubetest tear down the cluster if not using Boskos, it's done by Janitor if using Boskos
|
||||
extra_flags+=(--down)
|
||||
fi
|
||||
|
||||
# Set a minimal kubernetes environment that satisfies kubetest
|
||||
# TODO(adrcunha): Remove once https://github.com/kubernetes/test-infra/issues/13029 is fixed.
|
||||
local kubedir="$(mktemp -d -t kubernetes.XXXXXXXXXX)"
|
||||
local test_wrapper="${kubedir}/e2e-test.sh"
|
||||
mkdir ${kubedir}/cluster
|
||||
ln -s "$(which kubectl)" ${kubedir}/cluster/kubectl.sh
|
||||
echo "#!/bin/bash" > ${test_wrapper}
|
||||
echo "cd $(pwd) && set -x" >> ${test_wrapper}
|
||||
echo "${E2E_SCRIPT} ${test_cmd_args}" >> ${test_wrapper}
|
||||
chmod +x ${test_wrapper}
|
||||
cd ${kubedir}
|
||||
|
||||
# Create cluster and run the tests
|
||||
create_test_cluster_with_retries "${CLUSTER_CREATION_ARGS[@]}" \
|
||||
--up \
|
||||
--extract "${E2E_CLUSTER_VERSION}" \
|
||||
--gcp-node-image "${SERVING_GKE_IMAGE}" \
|
||||
--test-cmd "${E2E_SCRIPT}" \
|
||||
--test-cmd-args "${test_cmd_args}" \
|
||||
--test-cmd "${test_wrapper}" \
|
||||
${extra_flags[@]} \
|
||||
${EXTRA_KUBETEST_FLAGS[@]}
|
||||
echo "Test subprocess exited with code $?"
|
||||
# Ignore any errors below, this is a best-effort cleanup and shouldn't affect the test result.
|
||||
set +o errexit
|
||||
function_exists cluster_teardown && cluster_teardown
|
||||
delete_leaked_network_resources
|
||||
local result=$(get_test_return_code)
|
||||
echo "Artifacts were written to ${ARTIFACTS}"
|
||||
echo "Test result code is ${result}"
|
||||
|
@ -240,21 +266,23 @@ function create_test_cluster_with_retries() {
|
|||
echo "No backup region/zone set, cluster creation will fail in case of stockout"
|
||||
fi
|
||||
|
||||
local e2e_cluster_target_version="${E2E_CLUSTER_VERSION}"
|
||||
for e2e_cluster_region in "${e2e_cluster_regions[@]}"; do
|
||||
for e2e_cluster_zone in "${e2e_cluster_zones[@]}"; do
|
||||
E2E_CLUSTER_REGION=${e2e_cluster_region}
|
||||
E2E_CLUSTER_ZONE=${e2e_cluster_zone}
|
||||
[[ "${E2E_CLUSTER_ZONE}" == "${zone_not_provided}" ]] && E2E_CLUSTER_ZONE=""
|
||||
local cluster_creation_zone="${E2E_CLUSTER_REGION}"
|
||||
[[ -n "${E2E_CLUSTER_ZONE}" ]] && cluster_creation_zone="${E2E_CLUSTER_REGION}-${E2E_CLUSTER_ZONE}"
|
||||
resolve_k8s_version ${e2e_cluster_target_version} ${cluster_creation_zone} || return 1
|
||||
|
||||
local geoflag="--gcp-region=${E2E_CLUSTER_REGION}"
|
||||
[[ -n "${E2E_CLUSTER_ZONE}" ]] && geoflag="--gcp-zone=${E2E_CLUSTER_REGION}-${E2E_CLUSTER_ZONE}"
|
||||
|
||||
header "Creating test cluster in $E2E_CLUSTER_REGION $E2E_CLUSTER_ZONE"
|
||||
header "Creating test cluster ${E2E_CLUSTER_VERSION} in ${cluster_creation_zone}"
|
||||
# Don't fail test for kubetest, as it might incorrectly report test failure
|
||||
# if teardown fails (for details, see success() below)
|
||||
set +o errexit
|
||||
{ run_go_tool k8s.io/test-infra/kubetest \
|
||||
kubetest "$@" ${geoflag}; } 2>&1 | tee ${cluster_creation_log}
|
||||
export CLUSTER_API_VERSION=${E2E_CLUSTER_VERSION}
|
||||
run_go_tool k8s.io/test-infra/kubetest \
|
||||
kubetest "$@" --gcp-region=${cluster_creation_zone} 2>&1 | tee ${cluster_creation_log}
|
||||
|
||||
# Exit if test succeeded
|
||||
[[ "$(get_test_return_code)" == "0" ]] && return 0
|
||||
|
@ -262,7 +290,8 @@ function create_test_cluster_with_retries() {
|
|||
# - stockout (https://github.com/knative/test-infra/issues/592)
|
||||
# - latest GKE not available in this region/zone yet (https://github.com/knative/test-infra/issues/694)
|
||||
[[ -z "$(grep -Fo 'does not have enough resources available to fulfill' ${cluster_creation_log})" \
|
||||
&& -z "$(grep -Fo 'ResponseError: code=400, message=No valid versions with the prefix' ${cluster_creation_log})" ]] \
|
||||
&& -z "$(grep -Fo 'ResponseError: code=400, message=No valid versions with the prefix' ${cluster_creation_log})" \
|
||||
&& -z "$(grep -Po 'ResponseError: code=400, message=Master version "[0-9a-z\-\.]+" is unsupported' ${cluster_creation_log})" ]] \
|
||||
&& return 1
|
||||
done
|
||||
done
|
||||
|
@ -297,9 +326,14 @@ function setup_test_cluster() {
|
|||
if [[ -z "$(kubectl get clusterrolebinding cluster-admin-binding 2> /dev/null)" ]]; then
|
||||
acquire_cluster_admin_role ${k8s_user} ${E2E_CLUSTER_NAME} ${E2E_CLUSTER_REGION} ${E2E_CLUSTER_ZONE}
|
||||
kubectl config set-context ${k8s_cluster} --namespace=default
|
||||
export KO_DOCKER_REPO=gcr.io/${E2E_PROJECT_ID}/${E2E_BASE_NAME}-e2e-img
|
||||
# Incorporate an element of randomness to ensure that each run properly publishes images.
|
||||
export KO_DOCKER_REPO=gcr.io/${E2E_PROJECT_ID}/${E2E_BASE_NAME}-e2e-img/${RANDOM}
|
||||
fi
|
||||
|
||||
# Safety checks
|
||||
is_protected_gcr ${KO_DOCKER_REPO} && \
|
||||
abort "\$KO_DOCKER_REPO set to ${KO_DOCKER_REPO}, which is forbidden"
|
||||
|
||||
echo "- Project is ${E2E_PROJECT_ID}"
|
||||
echo "- Cluster is ${k8s_cluster}"
|
||||
echo "- User is ${k8s_user}"
|
||||
|
@ -417,16 +451,12 @@ function initialize() {
|
|||
echo "\$PROJECT_ID is set to '${PROJECT_ID}', using it to run the tests"
|
||||
GCP_PROJECT="${PROJECT_ID}"
|
||||
fi
|
||||
if (( ! IS_PROW )) && [[ -z "${GCP_PROJECT}" ]]; then
|
||||
if (( ! IS_PROW )) && (( ! RUN_TESTS )) && [[ -z "${GCP_PROJECT}" ]]; then
|
||||
abort "set \$PROJECT_ID or use --gcp-project to select the GCP project where the tests are run"
|
||||
fi
|
||||
|
||||
(( IS_PROW )) && [[ -z "${GCP_PROJECT}" ]] && IS_BOSKOS=1
|
||||
|
||||
# Safety checks
|
||||
is_protected_gcr ${KO_DOCKER_REPO} && \
|
||||
abort "\$KO_DOCKER_REPO set to ${KO_DOCKER_REPO}, which is forbidden"
|
||||
|
||||
(( SKIP_ISTIO_ADDON )) || GKE_ADDONS="--addons=Istio"
|
||||
|
||||
readonly RUN_TESTS
|
|
@ -36,7 +36,8 @@ fi
|
|||
# Useful environment variables
|
||||
[[ -n "${PROW_JOB_ID:-}" ]] && IS_PROW=1 || IS_PROW=0
|
||||
readonly IS_PROW
|
||||
readonly REPO_ROOT_DIR="$(git rev-parse --show-toplevel)"
|
||||
[[ -z "${REPO_ROOT_DIR:-}" ]] && REPO_ROOT_DIR="$(git rev-parse --show-toplevel)"
|
||||
readonly REPO_ROOT_DIR
|
||||
readonly REPO_NAME="$(basename ${REPO_ROOT_DIR})"
|
||||
|
||||
# Useful flags about the current OS
|
||||
|
@ -75,6 +76,9 @@ function make_banner() {
|
|||
local msg="$1$1$1$1 $2 $1$1$1$1"
|
||||
local border="${msg//[-0-9A-Za-z _.,\/()\']/$1}"
|
||||
echo -e "${border}\n${msg}\n${border}"
|
||||
# TODO(adrcunha): Remove once logs have timestamps on Prow
|
||||
# For details, see https://github.com/kubernetes/test-infra/issues/10100
|
||||
echo -e "$1$1$1$1 $(TZ='America/Los_Angeles' date)\n${border}"
|
||||
}
|
||||
|
||||
# Simple header for logging purposes.
|
||||
|
@ -253,7 +257,7 @@ function dump_app_logs() {
|
|||
for pod in $(get_app_pods "$1" "$2")
|
||||
do
|
||||
echo ">>> Pod: $pod"
|
||||
kubectl -n "$2" logs "$pod" -c "$1"
|
||||
kubectl -n "$2" logs "$pod" --all-containers
|
||||
done
|
||||
}
|
||||
|
||||
|
@ -295,28 +299,72 @@ function acquire_cluster_admin_role() {
|
|||
$2 ${geoflag} --project $(gcloud config get-value project)
|
||||
}
|
||||
|
||||
# Run a command through tee and capture its output.
|
||||
# Parameters: $1 - file where the output will be stored.
|
||||
# $2... - command to run.
|
||||
function capture_output() {
|
||||
local report="$1"
|
||||
shift
|
||||
"$@" 2>&1 | tee "${report}"
|
||||
local failed=( ${PIPESTATUS[@]} )
|
||||
[[ ${failed[0]} -eq 0 ]] && failed=${failed[1]} || failed=${failed[0]}
|
||||
return ${failed}
|
||||
}
|
||||
|
||||
# Create a JUnit XML for a test.
|
||||
# Parameters: $1 - check class name as an identifier (e.g. BuildTests)
|
||||
# $2 - check name as an identifier (e.g., GoBuild)
|
||||
# $3 - failure message (can contain newlines), optional (means success)
|
||||
function create_junit_xml() {
|
||||
local xml="$(mktemp ${ARTIFACTS}/junit_XXXXXXXX.xml)"
|
||||
local failure=""
|
||||
if [[ "$3" != "" ]]; then
|
||||
# Transform newlines into HTML code.
|
||||
# Also escape `<` and `>` as here: https://github.com/golang/go/blob/50bd1c4d4eb4fac8ddeb5f063c099daccfb71b26/src/encoding/json/encode.go#L48,
|
||||
# this is temporary solution for fixing https://github.com/knative/test-infra/issues/1204,
|
||||
# which should be obsolete once Test-infra 2.0 is in place
|
||||
local msg="$(echo -n "$3" | sed 's/$/\
/g' | sed 's/</\\u003c/' | sed 's/>/\\u003e/' | tr -d '\n')"
|
||||
failure="<failure message=\"Failed\" type=\"\">${msg}</failure>"
|
||||
fi
|
||||
cat << EOF > "${xml}"
|
||||
<testsuites>
|
||||
<testsuite tests="1" failures="1" time="0.000" name="$1">
|
||||
<testcase classname="" name="$2" time="0.0">
|
||||
${failure}
|
||||
</testcase>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
EOF
|
||||
}
|
||||
|
||||
# Runs a go test and generate a junit summary.
|
||||
# Parameters: $1... - parameters to go test
|
||||
function report_go_test() {
|
||||
# Run tests in verbose mode to capture details.
|
||||
# go doesn't like repeating -v, so remove if passed.
|
||||
local args=" $@ "
|
||||
local go_test="go test -race -v ${args/ -v / }"
|
||||
local go_test="go test -v ${args/ -v / }"
|
||||
# Just run regular go tests if not on Prow.
|
||||
echo "Running tests with '${go_test}'"
|
||||
local report=$(mktemp)
|
||||
${go_test} | tee ${report}
|
||||
local failed=( ${PIPESTATUS[@]} )
|
||||
[[ ${failed[0]} -eq 0 ]] && failed=${failed[1]} || failed=${failed[0]}
|
||||
local report="$(mktemp)"
|
||||
capture_output "${report}" ${go_test}
|
||||
local failed=$?
|
||||
echo "Finished run, return code is ${failed}"
|
||||
# Install go-junit-report if necessary.
|
||||
run_go_tool github.com/jstemmer/go-junit-report go-junit-report --help > /dev/null 2>&1
|
||||
local xml=$(mktemp ${ARTIFACTS}/junit_XXXXXXXX.xml)
|
||||
cat ${report} \
|
||||
| go-junit-report \
|
||||
| sed -e "s#\"github.com/knative/${REPO_NAME}/#\"#g" \
|
||||
| sed -e "s#\"\(github\.com/knative\|knative\.dev\)/${REPO_NAME}/#\"#g" \
|
||||
> ${xml}
|
||||
echo "XML report written to ${xml}"
|
||||
if [[ -n "$(grep '<testsuites></testsuites>' ${xml})" ]]; then
|
||||
# XML report is empty, something's wrong; use the output as failure reason
|
||||
create_junit_xml _go_tests "GoTests" "$(cat ${report})"
|
||||
fi
|
||||
# Capture and report any race condition errors
|
||||
local race_errors="$(sed -n '/^WARNING: DATA RACE$/,/^==================$/p' ${report})"
|
||||
create_junit_xml _go_tests "DataRaceAnalysis" "${race_errors}"
|
||||
if (( ! IS_PROW )); then
|
||||
# Keep the suffix, so files are related.
|
||||
local logfile=${xml/junit_/go_test_}
|
||||
|
@ -327,24 +375,29 @@ function report_go_test() {
|
|||
return ${failed}
|
||||
}
|
||||
|
||||
# Install the latest stable Knative/serving in the current cluster.
|
||||
function start_latest_knative_serving() {
|
||||
# Install Knative Serving in the current cluster.
|
||||
# Parameters: $1 - Knative Serving manifest.
|
||||
function start_knative_serving() {
|
||||
header "Starting Knative Serving"
|
||||
subheader "Installing Knative Serving"
|
||||
echo "Installing Serving from ${KNATIVE_SERVING_RELEASE}"
|
||||
# Some CRDs defined in serving YAML are also referenced by other components in serving. As it takes
|
||||
# time for CRDs to become effective, there is a race condition between when the CRDs are effective
|
||||
# and when the resources that references those CRDs are created.
|
||||
# The current workaround is to re-apply serving.yaml if it fails. Remove the retry logic after the
|
||||
# race condition is fixed. (https://github.com/knative/serving/issues/4176)
|
||||
if ! kubectl apply -f ${KNATIVE_SERVING_RELEASE}; then
|
||||
echo "Install failed, waiting 60s and then retrying..."
|
||||
sleep 60
|
||||
kubectl apply -f ${KNATIVE_SERVING_RELEASE} || return 1
|
||||
fi
|
||||
echo "Installing Serving CRDs from $1"
|
||||
kubectl apply --selector knative.dev/crd-install=true -f "$1"
|
||||
echo "Installing the rest of serving components from $1"
|
||||
kubectl apply -f "$1"
|
||||
wait_until_pods_running knative-serving || return 1
|
||||
}
|
||||
|
||||
# Install the stable release Knative/serving in the current cluster.
|
||||
# Parameters: $1 - Knative Serving version number, e.g. 0.6.0.
|
||||
function start_release_knative_serving() {
|
||||
start_knative_serving "https://storage.googleapis.com/knative-releases/serving/previous/v$1/serving.yaml"
|
||||
}
|
||||
|
||||
# Install the latest stable Knative Serving in the current cluster.
|
||||
function start_latest_knative_serving() {
|
||||
start_knative_serving "${KNATIVE_SERVING_RELEASE}"
|
||||
}
|
||||
|
||||
# Run a go tool, installing it first if necessary.
|
||||
# Parameters: $1 - tool package/dir for go get/install.
|
||||
# $2 - tool to run.
|
||||
|
@ -367,16 +420,17 @@ function update_licenses() {
|
|||
cd ${REPO_ROOT_DIR} || return 1
|
||||
local dst=$1
|
||||
shift
|
||||
run_go_tool ./vendor/github.com/knative/test-infra/tools/dep-collector dep-collector $@ > ./${dst}
|
||||
run_go_tool knative.dev/test-infra/tools/dep-collector dep-collector $@ > ./${dst}
|
||||
}
|
||||
|
||||
# Run dep-collector to check for forbidden liceses.
|
||||
# Parameters: $1...$n - directories and files to inspect.
|
||||
function check_licenses() {
|
||||
# Fetch the google/licenseclassifier for its license db
|
||||
rm -fr ${GOPATH}/src/github.com/google/licenseclassifier
|
||||
go get -u github.com/google/licenseclassifier
|
||||
# Check that we don't have any forbidden licenses in our images.
|
||||
run_go_tool ./vendor/github.com/knative/test-infra/tools/dep-collector dep-collector -check $@
|
||||
run_go_tool knative.dev/test-infra/tools/dep-collector dep-collector -check $@
|
||||
}
|
||||
|
||||
# Run the given linter on the given files, checking it exists first.
|
||||
|
@ -457,7 +511,7 @@ function remove_broken_symlinks() {
|
|||
target="${target##* -> }"
|
||||
[[ ${target} == /* ]] || target="./${target}"
|
||||
target="$(cd `dirname ${link}` && cd ${target%/*} && echo $PWD/${target##*/})"
|
||||
if [[ ${target} != *github.com/knative/* ]]; then
|
||||
if [[ ${target} != *github.com/knative/* && ${target} != *knative.dev/* ]]; then
|
||||
unlink ${link}
|
||||
continue
|
||||
fi
|
||||
|
@ -475,31 +529,41 @@ function get_canonical_path() {
|
|||
echo "$(cd ${path%/*} && echo $PWD/${path##*/})"
|
||||
}
|
||||
|
||||
# Return the base url we use to build the actual knative yaml sources.
|
||||
function get_knative_base_yaml_source() {
|
||||
local knative_base_yaml_source="https://storage.googleapis.com/knative-nightly/@/latest"
|
||||
# Returns the URL to the latest manifest for the given Knative project.
|
||||
# Parameters: $1 - repository name of the given project
|
||||
# $2 - name of the yaml file, without extension
|
||||
function get_latest_knative_yaml_source() {
|
||||
local branch_name=""
|
||||
local repo_name="$1"
|
||||
local yaml_name="$2"
|
||||
# Get the branch name from Prow's env var, see https://github.com/kubernetes/test-infra/blob/master/prow/jobs.md.
|
||||
# Otherwise, try getting the current branch from git.
|
||||
(( IS_PROW )) && branch_name="${PULL_BASE_REF:-}"
|
||||
[[ -z "${branch_name}" ]] && branch_name="$(git rev-parse --abbrev-ref HEAD)"
|
||||
# If it's a release branch, base URL should point to a specific version.
|
||||
# If it's a release branch, the yaml source URL should point to a specific version.
|
||||
if [[ ${branch_name} =~ ^release-[0-9\.]+$ ]]; then
|
||||
# Get the latest tag name for the current branch, which is likely formatted as v0.5.0
|
||||
local tag_name="$(git describe --tags --abbrev=0)"
|
||||
knative_base_yaml_source="https://storage.googleapis.com/knative-releases/@/previous/${tag_name}"
|
||||
# The given repo might not have this tag, so we need to find its latest release manifest with the same major&minor version.
|
||||
local major_minor="$(echo ${tag_name} | cut -d. -f1-2)"
|
||||
local yaml_source_path="$(gsutil ls gs://knative-releases/${repo_name}/previous/${major_minor}.*/${yaml_name}.yaml \
|
||||
| sort \
|
||||
| tail -n 1 \
|
||||
| cut -b6-)"
|
||||
echo "https://storage.googleapis.com/${yaml_source_path}"
|
||||
# If it's not a release branch, the yaml source URL should be nightly build.
|
||||
else
|
||||
echo "https://storage.googleapis.com/knative-nightly/${repo_name}/latest/${yaml_name}.yaml"
|
||||
fi
|
||||
echo "${knative_base_yaml_source}"
|
||||
}
|
||||
|
||||
# Initializations that depend on previous functions.
|
||||
# These MUST come last.
|
||||
|
||||
readonly _TEST_INFRA_SCRIPTS_DIR="$(dirname $(get_canonical_path ${BASH_SOURCE[0]}))"
|
||||
readonly REPO_NAME_FORMATTED="Knative $(capitalize ${REPO_NAME//-/})"
|
||||
readonly REPO_NAME_FORMATTED="Knative $(capitalize ${REPO_NAME//-/ })"
|
||||
|
||||
# Public latest nightly or release yaml files.
|
||||
readonly KNATIVE_BASE_YAML_SOURCE="$(get_knative_base_yaml_source)"
|
||||
readonly KNATIVE_SERVING_RELEASE="${KNATIVE_BASE_YAML_SOURCE/@/serving}/serving.yaml"
|
||||
readonly KNATIVE_BUILD_RELEASE="${KNATIVE_BASE_YAML_SOURCE/@/build}/build.yaml"
|
||||
readonly KNATIVE_EVENTING_RELEASE="${KNATIVE_BASE_YAML_SOURCE/@/eventing}/release.yaml"
|
||||
readonly KNATIVE_SERVING_RELEASE="$(get_latest_knative_yaml_source "serving" "serving")"
|
||||
readonly KNATIVE_BUILD_RELEASE="$(get_latest_knative_yaml_source "build" "build")"
|
||||
readonly KNATIVE_EVENTING_RELEASE="$(get_latest_knative_yaml_source "eventing" "release")"
|
|
@ -111,6 +111,19 @@ function run_build_tests() {
|
|||
return ${failed}
|
||||
}
|
||||
|
||||
# Run a build test and report its output as the failure if it fails.
|
||||
# Parameters: $1 - report name.
|
||||
# $2... - command (test) to run.
|
||||
function report_build_test() {
|
||||
local report="$(mktemp)"
|
||||
local report_name="$1"
|
||||
shift
|
||||
local errors=""
|
||||
capture_output "${report}" "$@" || errors="$(cat ${report})"
|
||||
create_junit_xml _build_tests "${report_name}" "${errors}"
|
||||
[[ -z "${errors}" ]]
|
||||
}
|
||||
|
||||
# Perform markdown build tests if necessary, unless disabled.
|
||||
function markdown_build_tests() {
|
||||
(( DISABLE_MD_LINTING && DISABLE_MD_LINK_CHECK )) && return 0
|
||||
|
@ -123,11 +136,11 @@ function markdown_build_tests() {
|
|||
local failed=0
|
||||
if (( ! DISABLE_MD_LINTING )); then
|
||||
subheader "Linting the markdown files"
|
||||
lint_markdown ${mdfiles} || failed=1
|
||||
report_build_test Markdown_Lint lint_markdown ${mdfiles} || failed=1
|
||||
fi
|
||||
if (( ! DISABLE_MD_LINK_CHECK )); then
|
||||
subheader "Checking links in the markdown files"
|
||||
check_links_in_markdown ${mdfiles} || failed=1
|
||||
report_build_test Markdown_Link check_links_in_markdown ${mdfiles} || failed=1
|
||||
fi
|
||||
return ${failed}
|
||||
}
|
||||
|
@ -148,20 +161,34 @@ function default_build_test_runner() {
|
|||
[[ -z "${go_pkg_dirs}" ]] && return ${failed}
|
||||
# Ensure all the code builds
|
||||
subheader "Checking that go code builds"
|
||||
go build -v ./... || failed=1
|
||||
local report="$(mktemp)"
|
||||
local errors_go1=""
|
||||
local errors_go2=""
|
||||
if ! capture_output "${report}" go build -v ./... ; then
|
||||
failed=1
|
||||
# Consider an error message everything that's not a package name.
|
||||
errors_go1="$(grep -v '^\(github\.com\|knative\.dev\)/' "${report}" | sort | uniq)"
|
||||
fi
|
||||
# Get all build tags in go code (ignore /vendor)
|
||||
local tags="$(grep -r '// +build' . \
|
||||
| grep -v '^./vendor/' | cut -f3 -d' ' | sort | uniq | tr '\n' ' ')"
|
||||
if [[ -n "${tags}" ]]; then
|
||||
go test -run=^$ -tags="${tags}" ./... || failed=1
|
||||
errors=""
|
||||
if ! capture_output "${report}" go test -run=^$ -tags="${tags}" ./... ; then
|
||||
failed=1
|
||||
# Consider an error message everything that's not a successful test result.
|
||||
errors_go2="$(grep -v '^\(ok\|\?\)\s\+\(github\.com\|knative\.dev\)/' "${report}")"
|
||||
fi
|
||||
fi
|
||||
local errors_go="$(echo -e "${errors_go1}\n${errors_go2}" | uniq)"
|
||||
create_junit_xml _build_tests Build_Go "${errors_go}"
|
||||
if [[ -f ./hack/verify-codegen.sh ]]; then
|
||||
subheader "Checking autogenerated code is up-to-date"
|
||||
./hack/verify-codegen.sh || failed=1
|
||||
report_build_test Verify_CodeGen ./hack/verify-codegen.sh || failed=1
|
||||
fi
|
||||
# Check that we don't have any forbidden licenses in our images.
|
||||
subheader "Checking for forbidden licenses"
|
||||
check_licenses ${go_pkg_dirs} || failed=1
|
||||
report_build_test Check_Licenses check_licenses ${go_pkg_dirs} || failed=1
|
||||
return ${failed}
|
||||
}
|
||||
|
||||
|
@ -197,7 +224,7 @@ function run_unit_tests() {
|
|||
|
||||
# Default unit test runner that runs all go tests in the repo.
|
||||
function default_unit_test_runner() {
|
||||
report_go_test ./...
|
||||
report_go_test -race ./...
|
||||
}
|
||||
|
||||
# Run integration tests. If there's no `integration_tests` function, run the
|
||||
|
@ -272,12 +299,23 @@ function main() {
|
|||
go version
|
||||
echo ">> git version"
|
||||
git version
|
||||
echo ">> ko built from commit"
|
||||
[[ -f /ko_version ]] && cat /ko_version || echo "unknown"
|
||||
echo ">> bazel version"
|
||||
bazel version 2> /dev/null
|
||||
[[ -f /bazel_version ]] && cat /bazel_version || echo "unknown"
|
||||
if [[ "${DOCKER_IN_DOCKER_ENABLED}" == "true" ]]; then
|
||||
echo ">> docker version"
|
||||
docker version
|
||||
fi
|
||||
# node/pod names are important for debugging purposes, but they are missing
|
||||
# after migrating from bootstrap to podutil.
|
||||
# Report it here with the same logic as in bootstrap until it is fixed.
|
||||
# (https://github.com/kubernetes/test-infra/blob/09bd4c6709dc64308406443f8996f90cf3b40ed1/jenkins/bootstrap.py#L588)
|
||||
# TODO(chaodaiG): follow up on https://github.com/kubernetes/test-infra/blob/0fabd2ea816daa8c15d410c77a0c93c0550b283f/prow/initupload/run.go#L49
|
||||
echo ">> node name"
|
||||
echo "$(curl -H "Metadata-Flavor: Google" 'http://169.254.169.254/computeMetadata/v1/instance/name' 2> /dev/null)"
|
||||
echo ">> pod name"
|
||||
echo ${HOSTNAME}
|
||||
fi
|
||||
|
||||
[[ -z $1 ]] && set -- "--all-tests"
|
|
@ -19,12 +19,15 @@
|
|||
|
||||
source $(dirname ${BASH_SOURCE})/library.sh
|
||||
|
||||
# Organization name in GitHub; defaults to Knative.
|
||||
readonly ORG_NAME="${ORG_NAME:-knative}"
|
||||
|
||||
# GitHub upstream.
|
||||
readonly KNATIVE_UPSTREAM="https://github.com/knative/${REPO_NAME}"
|
||||
readonly REPO_UPSTREAM="https://github.com/${ORG_NAME}/${REPO_NAME}"
|
||||
|
||||
# GCRs for Knative releases.
|
||||
readonly NIGHTLY_GCR="gcr.io/knative-nightly/github.com/knative/${REPO_NAME}"
|
||||
readonly RELEASE_GCR="gcr.io/knative-releases/github.com/knative/${REPO_NAME}"
|
||||
readonly NIGHTLY_GCR="gcr.io/knative-nightly/github.com/${ORG_NAME}/${REPO_NAME}"
|
||||
readonly RELEASE_GCR="gcr.io/knative-releases/github.com/${ORG_NAME}/${REPO_NAME}"
|
||||
|
||||
# Georeplicate images to {us,eu,asia}.gcr.io
|
||||
readonly GEO_REPLICATION=(us eu asia)
|
||||
|
@ -108,7 +111,7 @@ function hub_tool() {
|
|||
# Shortcut to "git push" that handles authentication.
|
||||
# Parameters: $1..$n - arguments to "git push <repo>".
|
||||
function git_push() {
|
||||
local repo_url="${KNATIVE_UPSTREAM}"
|
||||
local repo_url="${REPO_UPSTREAM}"
|
||||
[[ -n "${GITHUB_TOKEN}}" ]] && repo_url="${repo_url/:\/\//:\/\/${GITHUB_TOKEN}@}"
|
||||
git push ${repo_url} $@
|
||||
}
|
||||
|
@ -144,15 +147,15 @@ function setup_upstream() {
|
|||
local upstream="$(git config --get remote.upstream.url)"
|
||||
echo "Remote upstream URL is '${upstream}'"
|
||||
if [[ -z "${upstream}" ]]; then
|
||||
echo "Setting remote upstream URL to '${KNATIVE_UPSTREAM}'"
|
||||
git remote add upstream ${KNATIVE_UPSTREAM}
|
||||
echo "Setting remote upstream URL to '${REPO_UPSTREAM}'"
|
||||
git remote add upstream ${REPO_UPSTREAM}
|
||||
fi
|
||||
}
|
||||
|
||||
# Fetch the release branch, so we can check it out.
|
||||
function setup_branch() {
|
||||
[[ -z "${RELEASE_BRANCH}" ]] && return
|
||||
git fetch ${KNATIVE_UPSTREAM} ${RELEASE_BRANCH}:upstream/${RELEASE_BRANCH}
|
||||
git fetch ${REPO_UPSTREAM} ${RELEASE_BRANCH}:upstream/${RELEASE_BRANCH}
|
||||
}
|
||||
|
||||
# Setup version, branch and release notes for a auto release.
|
||||
|
@ -198,6 +201,7 @@ function prepare_dot_release() {
|
|||
echo "Dot release requested"
|
||||
TAG_RELEASE=1
|
||||
PUBLISH_RELEASE=1
|
||||
git fetch --all || abort "error fetching branches/tags from remote"
|
||||
# List latest release
|
||||
local releases # don't combine with the line below, or $? will be 0
|
||||
releases="$(hub_tool release)"
|
||||
|
@ -210,21 +214,26 @@ function prepare_dot_release() {
|
|||
fi
|
||||
local last_version="$(echo "${releases}" | grep '^v[0-9]\+\.[0-9]\+\.[0-9]\+$' | sort -r | head -1)"
|
||||
[[ -n "${last_version}" ]] || abort "no previous release exist"
|
||||
local major_minor_version=""
|
||||
if [[ -z "${RELEASE_BRANCH}" ]]; then
|
||||
echo "Last release is ${last_version}"
|
||||
# Determine branch
|
||||
local major_minor_version="$(master_version ${last_version})"
|
||||
major_minor_version="$(master_version ${last_version})"
|
||||
RELEASE_BRANCH="release-${major_minor_version}"
|
||||
echo "Last release branch is ${RELEASE_BRANCH}"
|
||||
else
|
||||
major_minor_version="${RELEASE_BRANCH##release-}"
|
||||
fi
|
||||
[[ -n "${major_minor_version}" ]] || abort "cannot get release major/minor version"
|
||||
# Ensure there are new commits in the branch, otherwise we don't create a new release
|
||||
setup_branch
|
||||
local last_release_commit="$(git rev-list -n 1 ${last_version})"
|
||||
local release_branch_commit="$(git rev-list -n 1 upstream/${RELEASE_BRANCH})"
|
||||
[[ -n "${last_release_commit}" ]] || abort "cannot get last release commit"
|
||||
[[ -n "${release_branch_commit}" ]] || abort "cannot get release branch last commit"
|
||||
echo "Version ${last_version} is at commit ${last_release_commit}"
|
||||
echo "Branch ${RELEASE_BRANCH} is at commit ${release_branch_commit}"
|
||||
if [[ "${last_release_commit}" == "${release_branch_commit}" ]]; then
|
||||
echo "*** Branch ${RELEASE_BRANCH} is at commit ${release_branch_commit}"
|
||||
echo "*** Branch ${RELEASE_BRANCH} has no new cherry-picks since release ${last_version}"
|
||||
echo "*** No dot release will be generated, as no changes exist"
|
||||
exit 0
|
||||
|
@ -549,10 +558,17 @@ function publish_to_github() {
|
|||
git_push tag ${TAG}
|
||||
|
||||
[[ -n "${RELEASE_BRANCH}" ]] && commitish="--commitish=${RELEASE_BRANCH}"
|
||||
hub_tool release create \
|
||||
--prerelease \
|
||||
${attachments[@]} \
|
||||
--file=${description} \
|
||||
${commitish} \
|
||||
${TAG}
|
||||
for i in {2..0}; do
|
||||
hub_tool release create \
|
||||
--prerelease \
|
||||
${attachments[@]} \
|
||||
--file=${description} \
|
||||
${commitish} \
|
||||
${TAG} && return 0
|
||||
if [[ "${i}" -gt 0 ]]; then
|
||||
echo "Error publishing the release, retrying in 15s..."
|
||||
sleep 15
|
||||
fi
|
||||
done
|
||||
abort "Cannot publish release to GitHub"
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
# dep-collector
|
||||
|
||||
`dep-collector` is a tool for gathering up a collection of licenses for Go
|
||||
dependencies that have been pulled into the idiomatic `vendor/` directory.
|
||||
The resulting file from running `dep-collector` is intended for inclusion
|
||||
in container images to respect the licenses of the included software.
|
||||
dependencies that have been pulled into the idiomatic `vendor/` directory. The
|
||||
resulting file from running `dep-collector` is intended for inclusion in
|
||||
container images to respect the licenses of the included software.
|
||||
|
||||
## Basic Usage
|
||||
|
||||
You can run `dep-collector` on one or more Go import paths as entrypoints,
|
||||
and it will:
|
||||
You can run `dep-collector` on one or more Go import paths as entrypoints, and
|
||||
it will:
|
||||
|
||||
1. Walk the transitive dependencies to identify vendored software packages,
|
||||
1. Search for licenses for each vendored dependency,
|
||||
|
@ -43,11 +43,11 @@ Import: github.com/mattmoor/warm-image/vendor/cloud.google.com/go
|
|||
|
||||
## CSV Usage
|
||||
|
||||
You can also run `dep-collector` in a mode that produces CSV output,
|
||||
including basic classification of the license.
|
||||
You can also run `dep-collector` in a mode that produces CSV output, including
|
||||
basic classification of the license.
|
||||
|
||||
> In order to run dep-collector in this mode, you must first run:
|
||||
> go get github.com/google/licenseclassifier
|
||||
> In order to run dep-collector in this mode, you must first run: go get
|
||||
> github.com/google/licenseclassifier
|
||||
|
||||
For example:
|
||||
|
||||
|
@ -61,18 +61,19 @@ github.com/sergi/go-diff,Static,,https://github.com/mattmoor/dep-collector/blob/
|
|||
|
||||
The columns here are:
|
||||
|
||||
* Import Path,
|
||||
* How the dependency is linked in (always reports "static"),
|
||||
* A column for whether any modifications have been made (always empty),
|
||||
* The URL by which to access the license file (assumes `master`),
|
||||
* A classification of what license this is ([using this](https://github.com/google/licenseclassifier)).
|
||||
- Import Path,
|
||||
- How the dependency is linked in (always reports "static"),
|
||||
- A column for whether any modifications have been made (always empty),
|
||||
- The URL by which to access the license file (assumes `master`),
|
||||
- A classification of what license this is
|
||||
([using this](https://github.com/google/licenseclassifier)).
|
||||
|
||||
## Check mode
|
||||
|
||||
`dep-collector` also includes a mode that will check for "forbidden" licenses.
|
||||
|
||||
> In order to run dep-collector in this mode, you must first run:
|
||||
> go get github.com/google/licenseclassifier
|
||||
> In order to run dep-collector in this mode, you must first run: go get
|
||||
> github.com/google/licenseclassifier
|
||||
|
||||
For example (failing):
|
||||
|
Loading…
Reference in New Issue