11#! /usr/bin/env bash
22
3- # Licensed under the Apache License, Version 2.0 (the "License");
4- # you may not use this file except in compliance with the License.
5- # You may obtain a copy of the License at
3+ # This script runs unit, integration and e2e tests with all optional tests
4+ # enabled:
5+ # - Matrix (for each runtime/language/builder c. product)
6+ # - Podman
7+ # - Gitlab
8+ # - Pipelines
9+ # - etc.
610#
7- # https://www.apache.org/licenses/LICENSE-2.0
11+ # (See the environment variables which allow selective overriding.)
812#
9- # Unless required by applicable law or agreed to in writing, software
10- # distributed under the License is distributed on an "AS IS" BASIS,
11- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12- # See the License for the specific language governing permissions and
13- # limitations under the License.
14-
15- #
16- # Run full test suite with all features enabled
17- # This script sets up the environment for comprehensive testing including
18- # Podman, Tekton, GitLab, and matrix tests
19- #
20- # Cluster Setup:
21- # This script defaults to running all of the optional tests. This requires
22- # one install the toolchains for all core language runtimes, Podman,
23- # and configure the cluster with:
24- # hack/cluster.sh
25- # hack/registry.sh
26- # hack/git-server.sh
27- # hack/gitlab.sh
13+ # This script presumes a local testing environment set up using the
14+ # helper scripts in ./hack and performs some precondition checks to ensure
15+ # resources are available for the features enabled (nonexhaustive).
16+ # hack/binaries.sh - Installs necessary binaries in ./hack/bin
17+ # hack/cluster.sh - Start test cluster with Knative Serving/Eventing
18+ # hack/registry.sh - Starts and configures a local container registry
19+ # hack/git-server.sh - Starts a git server in-cluster
20+ # hack/gitlab.sh - Installs GitLab in-cluster
2821
2922set -o errexit
3023set -o nounset
3124set -o pipefail
3225
33- # Determine script directory
34- SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
35- PROJECT_ROOT=" $( cd " ${SCRIPT_DIR} /.." && pwd) "
36-
37- # Generate a timestamp for use setting things which require uniqueness
38- TIMESTAMP=$( date +%Y%m%d%H%M%S 2> /dev/null || date +%s 2> /dev/null || echo " $( date) " )
39-
40- # Set up PATH and KUBECONFIG
41- export PATH=" ${PROJECT_ROOT} /hack/bin:${PATH} "
42- export KUBECONFIG=" ${KUBECONFIG:- ${PROJECT_ROOT} / hack/ bin/ kubeconfig.yaml} "
43-
44- # Set up test environment variables
26+ # Enable Optional Tests
27+ # ---------------------
4528# The defaults in the e2e test implementation are a bit more conservative.
4629# Here we toggle on All The Things. Note that we still allow any settings
4730# made explicitly in the current environment to take precidence; just setting
@@ -55,13 +38,34 @@ export GITLAB_TESTS_ENABLED="${GITLAB_TESTS_ENABLED:-1}"
5538export GITLAB_HOSTNAME=" ${GITLAB_HOSTNAME:- gitlab.localtest.me} "
5639export PAC_CONTROLLER_HOSTNAME=" ${PAC_CONTROLLER_HOSTNAME:- pac-ctr.localtest.me} "
5740
41+
42+ # Environment Setup
43+ # -------------------
44+
45+ # Determine script directory
46+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
47+ PROJECT_ROOT=" $( cd " ${SCRIPT_DIR} /.." && pwd) "
48+
49+ # Set up PATH and KUBECONFIG
50+ export PATH=" ${PROJECT_ROOT} /hack/bin:${PATH} "
51+ export KUBECONFIG=" ${KUBECONFIG:- ${PROJECT_ROOT} / hack/ bin/ kubeconfig.yaml} "
52+
5853# GitLab test configuration
5954# This is the default set by ./hack/gitlab.sh, and is overridden in CI, and
6055# a warning is issued that users should not only use ./hack/gitlab.sh for
6156# configuring test cluster available locally, such as that created by
6257# hack/cluster.sh
6358export GITLAB_ROOT_PASSWORD=" ${GITLAB_ROOT_PASSWORD:- test-password-123} "
6459
60+ # Generate a timestamp for use setting things which require uniqueness
61+ TIMESTAMP=$( date +%Y%m%d%H%M%S 2> /dev/null || date +%s 2> /dev/null || echo " $( date) " )
62+
63+ # Initialize coverage file
64+ echo " mode: atomic" > coverage.txt
65+
66+ # Precondition Checks
67+ # -------------------
68+
6569# Check if binaries are installed
6670if [ ! -d " ${PROJECT_ROOT} /hack/bin" ]; then
6771 echo " ERROR: hack/bin directory not found!"
121125echo " ✓ Prerequisites check passed"
122126echo " "
123127
128+ # Podman Setup
129+ # -------------
130+
124131# Check Podman service if Podman tests are enabled
125132if [ " ${FUNC_E2E_PODMAN} " = " true" ]; then
126133 # Check if Podman service is running
@@ -161,31 +168,36 @@ if [ "${FUNC_E2E_PODMAN}" = "true" ]; then
161168 export FUNC_E2E_PODMAN_HOST=" unix://${PODMAN_SOCKET} "
162169 fi
163170 fi
164- echo " Podman socket: ${FUNC_E2E_PODMAN_HOST} "
171+ echo " ✓ Podman socket: ${FUNC_E2E_PODMAN_HOST} "
165172fi
166173
167- # Initialize coverage file
168- echo " mode: atomic " > coverage.txt
174+ # Unit and Integration Tests
175+ # --------------------------
169176
170- # Run unit and integration tests together
171- # echo ""
172- # echo "Running unit and integration tests..."
173- # go test -tags integration -timeout 60m -coverprofile=coverage-integration.txt ./... -v
174- # tail -n +2 coverage-integration.txt >> coverage.txt
175- # rm -f coverage-integration.text -run TestMetadata_Labels_Remove
177+ Run unit and integration tests together
178+ echo " "
179+ echo " Running unit and integration tests..."
180+ go test -tags integration -timeout 60m -coverprofile=coverage-integration.txt ./... -v
181+ tail -n +2 coverage-integration.txt >> coverage.txt
182+ rm -f coverage-integration.text -run TestMetadata_Labels_Remove
183+
184+ echo " ✓ Unit and Integration tests completed successfully"
185+
186+ # E2E Tests
187+ # --------------------------
176188
177189# Run E2E tests
178- echo " "
179- echo " Running E2E tests..."
180- cd " ${PROJECT_ROOT} /e2e"
181- go test -tags e2e -timeout 120m -coverprofile=coverage-e2e.txt -coverpkg=../... -v -run TestMatrix_Deploy
190+ # echo ""
191+ # echo "Running E2E tests..."
192+ # cd "${PROJECT_ROOT}/e2e"
193+ # # go test -tags e2e -timeout 120m -coverprofile=coverage-e2e.txt -coverpkg=../... -v -run TestMatrix_Run
182194# go test -tags e2e -timeout 120m -coverprofile=coverage-e2e.txt -coverpkg=../... -v
183- tail -n +2 coverage-e2e.txt >> ../coverage.txt
184- rm -f coverage-e2e.txt
195+ # tail -n +2 coverage-e2e.txt >> ../coverage.txt
196+ # rm -f coverage-e2e.txt
185197
186198cd " ${PROJECT_ROOT} "
187199echo " "
188- echo " Coverage report created: coverage.txt"
200+ echo " ✓ Coverage report created: coverage.txt"
189201
190202echo " "
191- echo " All tests completed successfully! "
203+ echo " ✓ All tests completed successfully"
0 commit comments