client/vendor/knative.dev/hack
Knative Automation 0cf5aebdda
upgrade to latest dependencies (#1916)
bumping golang.org/x/oauth2 ebe81ad...85231f9:
  > 85231f9 go.mod: update golang.org/x dependencies
  > 34a7afa google/externalaccount: add Config.UniverseDomain
  > 95bec95 google/externalaccount: moves externalaccount package out of internal and exports it
bumping google.golang.org/genproto/googleapis/rpc 1f4bbc5...37d4d3c:
  > 37d4d3c chore(all): update all (# 1089)
  > df926f6 chore(all): auto-regenerate .pb.go files (# 1092)
  > 05fd2b7 chore(all): Update to google.golang.org/genproto/googleapis/rpc without backreference (# 1093)
  > 1f18d85 chore(all): Drop submodule backreferences (# 1087)
  > 6ceb2ff chore: make vet script less error prone (# 1091)
  > c5ed0a4 chore(all): auto-regenerate .pb.go files (# 1084)
  > 9b9be74 chore: updates for Go 1.22 (# 1090)
  > b0ce06b chore(all): update all (# 1088)
  > 012b6fc chore(all): update all (# 1086)
  > 31a09d3 chore(all): update all (# 1085)
bumping k8s.io/klog/v2 6ded808...007e661:
  > 007e661 textlogger: allow caller to override stack unwinding
  > 2d08296 Merge pull request # 396 from pohly/slog-helper
  > 2086216 Merge pull request # 393 from kaisoz/add-safeptr
  > e4deee8 slog: use main logr package instead of logr/slogr
  > 8dd3f2e Merge pull request # 395 from pohly/readme-update
  > 881fa0b Add SafePtr wrapper
  > 5d1d2d5 add SetSlogLogger
  > 761b630 Merge pull request # 394 from pohly/owners-update
  > d3dd725 docs: clarify relationship between different features
  > e3f75b8 Merge pull request # 384 from pohly/slog
  > 39afdba dependencies: logr v1.4.1
  > f33bd6c OWNERS: remove serathius, add mengjiao-liu, promote pohly
  > 02e7b69 Merge pull request # 391 from pohly/with-name-output
  > 44eadc3 add slog support
  > b588475 Merge pull request # 380 from pohly/golangci-lint-action
  > 009a04a output: handle WithName like zapr does
  > cc856bb update to logr 1.3.0
  > edee20c Merge pull request # 392 from pohly/promote-experimental
  > 1a0dfc5 github: run golangci-lint via action
  > 61b308a Merge pull request # 390 from pohly/go-vet-print
  > 18cdd3a promote experimental code to stable
  > ef25537 fix revive issues
  > 6632ba5 Merge pull request # 376 from pohly/stderr-threshold-docs
  > 6af4ad1 testing: bump Go version matrix
  > a4f9060 fix golangci-lint issues
  > ff82b97 Merge pull request # 379 from lowang-bh/fixWarning
  > 3838dbc stderrthreshold: fix flag comment
  > b394f4b enable "go vet" checks for parameters
  > 5ac9b76 Merge pull request # 378 from aimuz/fix-370
  > 6c35c6a resolve comments warning
  > 1e2789b fix: SetLogger via klog.SetLogger will output an unexpected newline
bumping knative.dev/client-pkg 2c46c44...ca457df:
  > ca457df upgrade to latest dependencies (# 154)
  > f170971 🎁 Terminal UI basic implementation (# 139)
  > ae3b852 [main] Upgrade to latest dependencies (# 146)
  > e7f1f8d Update community files (# 151)
bumping golang.org/x/term 353276a...c5eaf76:
  > c5eaf76 go.mod: update golang.org/x dependencies
bumping google.golang.org/api 87aa1d0...9c2cde8:
  > 9c2cde8 chore(main): release 0.169.0 (# 2451)
  > a488112 feat(all): auto-regenerate discovery clients (# 2457)
  > 2675c0a feat(all): auto-regenerate discovery clients (# 2454)
  > d22da18 feat(all): auto-regenerate discovery clients (# 2450)
  > e84ba36 chore(main): release 0.168.0 (# 2432)
  > 74538f7 chore(all): update module github.com/google/go-github/v58 to v59 (# 2411)
  > 6381123 chore(all): update all (# 2435)
  > b438981 feat(all): auto-regenerate discovery clients (# 2449)
  > af383c7 feat(all): auto-regenerate discovery clients (# 2448)
  > 022c85c feat(all): auto-regenerate discovery clients (# 2447)
  > 4fa90c9 feat(all): auto-regenerate discovery clients (# 2445)
  > ced0c09 feat(all): auto-regenerate discovery clients (# 2443)
  > 9f9c0cf feat(all): auto-regenerate discovery clients (# 2442)
  > 454cba5 chore: make vet script less error prone (# 2441)
  > 82eaa79 chore: updates for Go 1.22 (# 2440)
  > d290e18 feat(all): auto-regenerate discovery clients (# 2438)
  > 4dc71d4 feat(all): auto-regenerate discovery clients (# 2436)
  > 0c30ecc feat(all): auto-regenerate discovery clients (# 2433)
  > e635a5e feat(all): auto-regenerate discovery clients (# 2431)
  > 548436b chore(main): release 0.167.0 (# 2428)
  > 55a9e5a feat(all): auto-regenerate discovery clients (# 2429)
  > f72b5af feat(all): auto-regenerate discovery clients (# 2427)
  > 133e58b chore(main): release 0.166.0 (# 2418)
  > 446a6bd feat(all): auto-regenerate discovery clients (# 2426)
  > b7d596b chore(all): update all (# 2423)
  > 124a535 feat(all): auto-regenerate discovery clients (# 2425)
  > b3f9c38 feat(all): auto-regenerate discovery clients (# 2424)
  > af6aa38 feat(all): auto-regenerate discovery clients (# 2421)
  > 762eb61 feat(all): auto-regenerate discovery clients (# 2420)
  > c969083 feat(all): auto-regenerate discovery clients (# 2419)
  > 260fc1e feat(all): auto-regenerate discovery clients (# 2417)
  > e451477 chore(main): release 0.165.0 (# 2415)
  > deab77d feat(all): auto-regenerate discovery clients (# 2416)
  > c702880 feat(all): auto-regenerate discovery clients (# 2414)
  > 3ff4bc1 chore(main): release 0.164.0 (# 2407)
  > edbe996 fix(transport): disable universe domain check if token source (# 2413)
  > 05a0882 chore(all): update all (# 2410)
  > 51d5068 feat(all): auto-regenerate discovery clients (# 2412)
  > 246b19f feat(all): auto-regenerate discovery clients (# 2409)
  > f1b37df feat(all): auto-regenerate discovery clients (# 2408)
  > 1bd8304 feat(all): auto-regenerate discovery clients (# 2406)
bumping k8s.io/cli-runtime 9f2bd1f...d173469:
  > d173469 Update dependencies to v0.29.2 tag
  > b1485dd Merge pull request # 122429 from MadhavJivrajani/tools-bump-129
  > 9cab777 .*: bump golang.org/x/tools to v0.16.1
  > 907531b update go.mod
  > c19cbcf Merge pull request # 121552 from pohly/klog-update
  > 0c0de4e dependencies: klog v2.110.1
  > a832cfb Merge pull request # 121575 from apelisse/update-smd
  > 5ae4381 Update sigs.k8s.io/structured-merge-diff to v4.4.1
  > 7a70979 Merge pull request # 121524 from carlory/gomega
  > ed5a8bd bump gomega to 1.29.0
  > b52809d Merge pull request # 121338 from dims/working-otel-bump
  > 9fa1f3b working-config-otel
  > 7a5787c Merge pull request # 120397 from ty-dc/StaticCheck
  > 9a91d94 Merge pull request # 120757 from alexzielenski/apiserver/openapi/invalid-default
  > cb7ca27 cleanup: omit comparison with bool constants
  > 87ce7cf pin openapi
  > 5ed3353 Merge pull request # 121010 from Jefftree/decouple-openapi-v2v3-config
  > f0c756c Merge pull request # 120248 from pacoxu/grpc-container-probe
  > 3c03da5 bump kube-openapi
  > 7fedfc8 Merge pull request # 120735 from Jefftree/request-body
  > d9c5b0a remove GAed FG GRPCContainerProbe
  > dd10ae1 bump kube-openapi
  > a96869e Add shortname ambiguity warning in shortcut expander (# 117668)
  > 3d1197d Merge pull request # 121111 from dashpole/update_otel_deps
  > 5931efa dependencies: update otel-go dependencies
  > f509253 Merge pull request # 121117 from MadhavJivrajani/bump-x-net
  > 949c697 .: bump golang.org/x/net to v0.17.0
  > d37b3c0 Merge pull request # 121082 from pohly/ginkgo-gomega-update
  > 94fa062 dependencies: ginkgo v2.13.0, gomega v1.28.0
  > 0a75c85 Merge pull request # 120716 from xrstf/fix-typos
  > db86a55 Merge pull request # 119865 from charles-chenzz/bump_deps
  > 01d4bb0 fix typo exeucting => executing
  > 72a9dff bump github.com/emicklei/go-restful/v3 to v3.11.0.
  > 6a70d14 fix typo dervied => derived
  > b6a2760 Merge pull request # 119526 from sttts/sttts-idiomatic-cached
  > 54c1040 fix typo Mininum => Minimum
  > 8dc7d8d hack/update-vendor.sh
  > 0f867fc fix typo Conext => Context
  > e7b1ca8 Merge pull request # 120008 from skitt/drop-intstr-ptr-wrappers
  > 67e5a9b Merge pull request # 120499 from tukwila/gorilla/websocket_v1.5.0
  > 7d580a3 Use ptr.To to retrieve intstr addresses
  > 851c941 bump: upgrade gorilla/websocket from v1.4.2 to v1.5.0
  > 7b13f09 Merge pull request # 119334 from kmala/serverapply
  > edd7a6c Merge pull request # 119157 from seans3/websocket-executor
  > 43d2057 update the dependency sigs.k8s.io/structured-merge-diff/v4 to latest tag
  > 8c4ba9e WebSocket Client and V5 RemoteCommand Subprotocol
  > 634e424 Merge pull request # 120327 from liggitt/json-patch
  > 12b75d0 Merge pull request # 120218 from rakshitgondwal/feat/protobuf-version-update
  > 237f8f4 Revert to json-patch 4.12.0
  > a6e88af feat: update google.golang.org/protobuf to v1.31.0
  > 3c06e1a Merge pull request # 118401 from skitt/ioutil-sig-cli
  > 0daafa1 Merge pull request # 119725 from MadhavJivrajani/bump-net-dep
  > 75654d9 cli: stop using deprecated io/ioutil
bumping knative.dev/serving 096adcc...3504239:
  > 3504239 upgrade to latest dependencies (# 15009)
  > 0c8f4f3 Format go code (# 15006)
  > a194cb2 Add multi-container probing (# 14853)
  > b635c4c Update net-kourier nightly (# 15004)
  > 79498ab Update net-istio nightly (# 15003)
  > 54254a1 Update net-gateway-api nightly (# 15005)
  > 1c9495a Update net-certmanager nightly (# 15002)
  > 173ab17 upgrade to latest dependencies (# 15001)
  > 3e119d5 add contour-gateway.yaml to third_party folder (# 14998)
  > 455d3e5 Revert deactivated istio tls tests (# 14995)
  > 88abc84 upgrade to latest dependencies (# 14997)
  > a2ea3a1 Check for nil before calling deep-equal (# 14996)
  > 21ec47d Replace deprecated uses of sets.Int (# 14973)
  > 33b8bb4 Update net-kourier nightly (# 14993)
  > 57dc06d add upstream TLS trust from CM bundles (# 14717)
  > 5fdffba Update net-gateway-api nightly (# 14986)
  > 846c248 Update net-certmanager nightly (# 14991)
  > d8b4c5c Update net-istio nightly (# 14987)
  > 0e9c192 upgrade to latest dependencies (# 14985)
  > 72f91e5 Removed superfluous else statement (# 14982)
  > 74b5bed Update net-gateway-api nightly (# 14975)
  > 60211df Update net-certmanager nightly (# 14974)
  > 69fb735 Update net-contour nightly (# 14977)
  > 03c65f7 Update net-istio nightly (# 14976)
  > 4b88324 Update net-kourier nightly (# 14978)
  > 06335fe upgrade to latest dependencies (# 14970)
  > e069290 Update net-kourier nightly (# 14972)
  > f852ac6 Modify the description of ConfigMap  config-defaults (# 14969)
  > 0394a5f Update net-gateway-api nightly (# 14971)
  > 3f776db Update net-istio nightly (# 14966)
  > 0208f81 Update net-contour nightly (# 14967)
  > 7d49b34 Update net-certmanager nightly (# 14964)
  > 6dc7097 Update net-gateway-api nightly (# 14965)
  > 5cfa4a9 Update community files (# 14963)
  > 99f6b66 Update net-istio nightly (# 14957)
  > 80bb2f6 Update net-gateway-api nightly (# 14960)
  > 1a375ab Update net-kourier nightly (# 14958)
  > cdb41a4 Update net-certmanager nightly (# 14959)
  > 1c6d34f Update net-contour nightly (# 14956)
  > a1ad60a upgrade to latest dependencies (# 14949)
  > d7603f8 Update net-contour nightly (# 14953)
  > 6f88b3c Update net-istio nightly (# 14952)
  > cb84c77 Update net-kourier nightly (# 14943)
  > 21c2d43 Update net-certmanager nightly (# 14954)
  > 936f058 upgrade to latest dependencies (# 14947)
  > f40c8f9 Update net-contour nightly (# 14945)
  > 8a9828e Update net-gateway-api nightly (# 14946)
  > 77590bc Update net-istio nightly (# 14944)
  > 51db121 Update net-certmanager nightly (# 14942)
  > 8a727cd upgrade to latest dependencies (# 14941)
  > c171daa upgrade to latest dependencies (# 14936)
  > 167d42f Update net-gateway-api nightly (# 14937)
  > 64b7126 Update net-contour nightly (# 14938)
  > 2949f76 Update workflows to use knative/actions/setup-go (# 14934)
  > 852b4fd Update net-gateway-api nightly (# 14930)
  > f5ac3bb Update net-certmanager nightly (# 14928)
  > 831af95 Update net-istio nightly (# 14931)
  > 4323e27 Update net-kourier nightly (# 14932)
  > be71cf2 Update net-contour nightly (# 14929)
  > 6713050 upgrade to latest dependencies (# 14927)
  > a59e476 upgrade to latest dependencies (# 14926)
  > 961cc65 Update net-contour nightly (# 14924)
  > 5ab975d Update net-gateway-api nightly (# 14923)
  > d4a2637 Update net-istio nightly (# 14911)
  > 2f98a34 Update net-kourier nightly (# 14922)
  > ed66fdc Update net-certmanager nightly (# 14921)
  > 507b229 upgrade to latest dependencies (# 14920)
  > 7a7505d Update community files (# 14919)
  > 754b481 Update net-gateway-api nightly (# 14915)
  > 892f2d6 upgrade to latest dependencies (# 14917)
  > 9c131fd Update net-contour nightly (# 14916)
  > 7ce55e2 Update net-certmanager nightly (# 14914)
  > 2b7ace7 upgrade to latest dependencies (# 14913)
  > e8e53e4 Update net-gateway-api nightly (# 14912)
  > db76e10 Update net-kourier nightly (# 14900)
  > 82bb1b3 Update net-contour nightly (# 14910)
  > db92674 Update net-certmanager nightly (# 14905)
  > 9edd169 Update net-contour nightly (# 14907)
  > 3ded51b Update net-gateway-api nightly (# 14906)
  > 0a860c7 Update net-istio nightly (# 14908)
  > 77cc2dd drop k8s 1.27 from kind tests and update cluster version to v1.28 in e2e tests (# 14904)
  > 5aa8043 Scale to zero should ensure there are no failed replicas (# 14902)
  > 8589e0c Add revision-failure test image (# 14875)
  > 78c5029 Update net-contour nightly (# 14901)
  > 12315b5 Update net-istio nightly (# 14899)
bumping golang.org/x/sys 914b96c...360f961:
  > 360f961 unix: add API for fsconfig system call
  > 7ff74af unix: drop go version tags for unsupported versions
  > 6b4eab5 unix: suppress ENOMEM errors from sysctl's implementing Uname(uname *Utsname) on FreeBSD due to truncated fields.
  > 2f2cc5d unix: update IFLA and NETKIT constants with Linux kernel 6.7
bumping knative.dev/hack 999d7e6...b9f6bf0:
  > b9f6bf0 switch default region to avoid instability (# 373)
  > e6dedc7 bump various tools (# 372)
  > 7f60be0 Update community files (# 371)
  > 5f0998e Set default for GKE version to 1.28 (# 370)
  > fe1f2b4 drop toolchain directive (# 369)
  > 05f4e9c Update community files (# 368)
bumping knative.dev/networking 22eb3d0...f56f3aa:
  > f56f3aa upgrade to latest dependencies (# 946)
  > 3594f84 upgrade to latest dependencies (# 945)
  > 3252e63 upgrade to latest dependencies (# 944)
  > 9417101 upgrade to latest dependencies (# 943)
  > 918a090 upgrade to latest dependencies (# 942)
  > 48fd99c cleanup: drop unused e2e files (# 940)
  > d5fbe3f chore: drop OWNER files from ./test & ./hack (# 941)
  > e3f29af Update community files (# 939)
  > cfb3abd upgrade to latest dependencies (# 938)
  > 7391d20 drop unused types (# 933)
  > 54694f4 upgrade to latest dependencies (# 937)
  > ff63078 add the h2c app protocol value for the HTTP2 test (# 936)
  > 48f43ee Exclude test folder from code coverage calculation (# 934)
  > 5f213f7 upgrade to latest dependencies (# 935)
  > 1fbbbf9 Update GRPC/H2C conformance test (# 932)
  > 556d751 bump golang to v1.22 (# 931)
  > 71d6811 drop net-http01 from downstream testing (# 930)
  > 8bbc041 upgrade to latest dependencies (# 929)
  > f5845ef Update community files (# 928)
  > 630e71a feat: add isFailed for certificate (# 926)
  > 64e6032 upgrade to latest dependencies (# 927)
bumping k8s.io/utils d93618c...e7106e6:
  > e7106e6 Merge pull request # 290 from nitishfy/Nitish/go-get-deprecated
  > b307cd5 Merge pull request # 297 from skitt/fix-roundtoint32
  > be5d99e remove go install
  > cf03d44 Merge pull request # 289 from skitt/golang-1.21-set-clear
  > fc7c3d4 Use math.Round for rounding in RoundToInt32
  > 8a6db1c Transfer go get to go install
  > 3b25d92 Merge pull request # 283 from skitt/generic-ptr
  > 571d869 With Go 1.21, use clear in set.Clear()
  > 3019533 Merge pull request # 286 from skitt/set-equal
  > dc1a5d8 Add generic ptr.To, ptr.Deref, ptr.Equal
  > 9f67429 Merge pull request # 243 from logicalhan/generics
  > ecd9d48 Ensure set.Equal() compares the two set lengths
  > 10cedcc address tim's comments
  > c3703b2 fix lint issue
  > 46762cf make this implementation of sets compatible with the one in apimachinery
  > d8088cf add generic sets package to utils

Signed-off-by: Knative Automation <automation@knative.team>
2024-03-14 09:58:04 +00:00
..
CODE-OF-CONDUCT.md upgrade to latest dependencies (#1635) 2022-03-29 09:03:15 +00:00
LICENSE updating to use the hack repo (#1084) 2020-10-30 11:41:35 -07:00
README.md upgrade to latest dependencies (#1870) 2023-10-09 09:54:54 +00:00
codegen-library.sh [main] Upgrade to latest dependencies (#1910) 2024-01-24 13:51:12 +00:00
e2e-tests.sh [main] Upgrade to latest dependencies (#1852) 2023-08-23 16:37:56 +00:00
embed.go upgrade to latest dependencies (#1870) 2023-10-09 09:54:54 +00:00
go.work upgrade to latest dependencies (#1857) 2023-09-19 09:38:57 +00:00
infra-library.sh upgrade to latest dependencies (#1916) 2024-03-14 09:58:04 +00:00
library.sh upgrade to latest dependencies (#1916) 2024-03-14 09:58:04 +00:00
microbenchmarks.sh upgrade to latest dependencies (#1257) 2021-03-10 03:00:25 -08:00
performance-tests.sh [main] Upgrade to latest dependencies (#1852) 2023-08-23 16:37:56 +00:00
presubmit-tests.sh [main] Upgrade to latest dependencies (#1852) 2023-08-23 16:37:56 +00:00
release.sh [main] Upgrade to latest dependencies (#1910) 2024-01-24 13:51:12 +00:00
shellcheck-presubmit.sh updating to use the hack repo (#1084) 2020-10-30 11:41:35 -07:00

README.md

knative.dev/hack

hack is a collection of scripts used to bootstrap CI processes and other vital entrypoint functionality.

Using the presubmit-tests.sh helper script

This is a helper script to run the presubmit tests. To use it:

  1. Source this script:

    source "$(go run knative.dev/hack/cmd/script presubmit-tests.sh)"
    
  2. [optional] Define the function build_tests(). If you don't define this function, the default action for running the build tests is to:

    • run go build on the entire repo
    • run hack/verify-codegen.sh (if it exists)
    • check licenses in all go packages
  3. [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:

    • PRESUBMIT_TEST_FAIL_FAST: Fail the presubmit test immediately if a test fails, defaults to 0 (false).
  4. [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.

  5. [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.

  6. [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.

  7. [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.

  8. [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.

  9. Call the main() function passing "$@" (with 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 integration tests).

Use the flags --build-tests, --unit-tests and --integration-tests to run a specific set of tests.

To run specific programs as a test, use the --run-test flag, and provide the program as the argument. If arguments are required for the program, pass everything as a single quotes argument. For example, ./presubmit-tests.sh --run-test "test/my/test data". This flag can be used repeatedly, and each one will be ran in sequential order.

The script will automatically skip all presubmit tests for PRs where all changed files are exempt of tests (e.g., a PR changing only the OWNERS file).

Also, for PRs touching only markdown files, the unit and integration tests are skipped.

Sample presubmit test script

source "$(go run knative.dev/hack/cmd/script presubmit-tests.sh)"

function post_build_tests() {
  echo "Cleaning up after build tests"
  rm -fr ./build-cache
}

function unit_tests() {
  make -C tests test
}

function pre_integration_tests() {
  echo "Cleaning up before integration tests"
  rm -fr ./staging-area
}

# We use the default integration test runner.

main "$@"

Using the e2e-tests.sh helper script

This is a helper script for Knative E2E test scripts. To use it:

  1. [optional] Customize the test cluster. Pass the flags as described here to the initialize function call if the default values don't fit your needs.

  2. Source the script:

    source "$(go run knative.dev/hack/cmd/script e2e-tests.sh)"
    
  3. [optional] Write the knative_setup() function, which will set up your system under test (e.g., Knative Serving).

  4. [optional] Write the knative_teardown() function, which will tear down your system under test (e.g., Knative Serving).

  5. [optional] Write the test_setup() function, which will set up the test resources.

  6. [optional] Write the test_teardown() function, which will tear down the test resources.

  7. [optional] Write the cluster_setup() function, which will set up any resources before the test cluster is created.

  8. [optional] Write the cluster_teardown() function, which will tear down any resources after the test cluster is destroyed.

  9. [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).

  10. [optional] Write the on_success function. It will be called when a test succeeds

  11. [optional] Write the on_failure function. It will be called when a test fails

  12. [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.

  13. Call the initialize() function passing "$@".

  14. 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.

Notes:

  1. Calling your script without arguments will create a new cluster in your current GCP project and run the tests against it.

  2. Calling your script with --run-tests and the variable KO_DOCKER_REPO set will immediately start the tests against the cluster currently configured for kubectl.

  3. By default knative_teardown() and test_teardown() will be called after the tests finish, use --skip-teardowns if you don't want them to be called.

  4. By default Google Kubernetes Engine telemetry to Cloud Logging and Monitoring is disabled. This can be enabled by setting ENABLE_GKE_TELEMETRY to true.

  5. By default Spot Worker nodes are disabled. This can be enabled by setting ENABLE_PREEMPTIBLE_NODES to true.

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.

source "$(go run knative.dev/hack/cmd/script e2e-tests.sh)"

function knative_setup() {
  start_latest_knative_serving
  if (( WAIT_FOR_KNATIVE )); then
    wait_until_pods_running knative-serving || fail_test "Knative Serving not up"
  fi
}

function parse_flags() {
  if [[ "$1" == "--no-knative-wait" ]]; then
    WAIT_FOR_KNATIVE=0
    return 1
  fi
  return 0
}

WAIT_FOR_KNATIVE=1

# This test requires a cluster in LA
initialize $@ --region=us-west2

# TODO: use go_test_e2e to run the tests.
kubectl get pods || fail_test

success

Using the performance-tests.sh helper script

This is a helper script for Knative performance test scripts. In combination with specific Prow jobs, it can automatically manage the environment for running benchmarking jobs for each repo. To use it:

  1. Source the script:

    source "$(go run knative.dev/hack/cmd/script performance-tests.sh)"
    
  2. [optional] Customize GCP project settings for the benchmarks. Set the following environment variables if the default value doesn't fit your needs:

    • PROJECT_NAME: GCP project name for keeping the clusters that run the benchmarks. Defaults to knative-performance.
    • SERVICE_ACCOUNT_NAME: Service account name for controlling GKE clusters and interacting with Mako server. It MUST have Kubernetes Engine Admin and Storage Admin role, and be allowed by Mako admin. Defaults to mako-job.
  3. [optional] Customize root path of the benchmarks. This root folder should contain and only contain all benchmarks you want to run continuously. Set the following environment variable if the default value doesn't fit your needs:

    • BENCHMARK_ROOT_PATH: Benchmark root path, defaults to test/performance/benchmarks. Each repo can decide which folder to put its benchmarks in, and override this environment variable to be the path of that folder.
  4. [optional] Write the update_knative function, which will update your system under test (e.g. Knative Serving).

  5. [optional] Write the update_benchmark function, which will update the underlying resources for the benchmark (usually Knative resources and Kubernetes cronjobs for benchmarking). This function accepts a parameter, which is the benchmark name in the current repo.

  6. Call the main() function with all parameters (e.g. $@).

Sample performance test script

This script will update Knative serving and the given benchmark.

source "$(go run knative.dev/hack/cmd/script performance-tests.sh)"

function update_knative() {
  echo ">> Updating serving"
  ko apply -f config/ || abort "failed to apply serving"
}

function update_benchmark() {
  echo ">> Updating benchmark $1"
  ko apply -f ${BENCHMARK_ROOT_PATH}/$1 || abort "failed to apply benchmark $1"
}

main $@

Using the release.sh helper script

This is a helper script for Knative release scripts. To use it:

  1. Source the script:

    source "$(go run knative.dev/hack/cmd/script release.sh)"
    
  2. [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.

  3. 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:

    • 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 main 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.
    • RELEASE_DIR: contains the directory to store the manifests if --release-dir was passed. Defaults to empty value, but if --nopublish was passed then points to the repository root directory.
    • 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_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.

    All boolean environment variables default to false for safety.

    All environment variables above, except KO_FLAGS, are marked read-only once main() is called (see below).

  4. Call the main() function passing "$@" (with quotes).

Sample release script

source "$(go run knative.dev/hack/cmd/script release.sh)"

function build_release() {
  # config/ contains the manifests
  ko resolve ${KO_FLAGS} -f config/ > release.yaml
  ARTIFACTS_TO_PUBLISH="release.yaml"
}

main "$@"

Origins of hack

When Kubernetes was first getting started, someone was trying to introduce some quick shell scripts and land them into the ./scripts folder. But there was one that opposed this: Ville Aikas. The compromise was to put those quick scripts in a folder called hack to remind users and developers that there is likely a better way to perform the task you are attempting that is not using a shell script, like a tested python script.

"I was like fine, put them in hack not scripts, cause they are hacks." - Ville Aikas