From 5f843f09f6e3c02d070e5bb036a41543fd6813e3 Mon Sep 17 00:00:00 2001 From: jrangelramos Date: Wed, 25 Aug 2021 17:14:31 -0300 Subject: [PATCH] =?UTF-8?q?test:=20separated=20with=20tags=20common=20lang?= =?UTF-8?q?uage=20runtime=20e2e=20tests=20from=20othe=E2=80=A6=20(#492)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * test: separated with tags common language runtime e2e tests from other e2e tests * test: rewording e2e scripts and tags to better represent its purposes --- .github/workflows/pull_requests.yaml | 8 --- Makefile | 3 +- test/_e2e/e2e_functions_test.go | 2 +- test/_e2e/main_test.go | 2 +- test/_e2e/trigger_events_test.go | 3 +- test/e2e_extended_tests.sh | 51 +++++++++++++++++++ ...run_e2e_test.sh => e2e_lifecycle_tests.sh} | 28 +++++----- 7 files changed, 68 insertions(+), 29 deletions(-) create mode 100755 test/e2e_extended_tests.sh rename test/{run_e2e_test.sh => e2e_lifecycle_tests.sh} (76%) diff --git a/.github/workflows/pull_requests.yaml b/.github/workflows/pull_requests.yaml index b85a3e53..c82892b4 100644 --- a/.github/workflows/pull_requests.yaml +++ b/.github/workflows/pull_requests.yaml @@ -150,11 +150,3 @@ jobs: run: ./hack/test.sh - name: E2E Test run: make test-e2e - #- name: E2E Test Go - # run: ./test/run_e2e_test.sh go - #- name: E2E Test Python - # run: ./test/run_e2e_test.sh python - #- name: E2E Test Quarkus - # run: ./test/run_e2e_test.sh quarkus - #- name: E2E Test Springboot - # run: ./test/run_e2e_test.sh springboot diff --git a/Makefile b/Makefile index f6565b29..8730cfb9 100644 --- a/Makefile +++ b/Makefile @@ -124,7 +124,8 @@ test-integration: ## Run integration tests using an available cluster. go test -tags integration ./... -v test-e2e: ## Run end-to-end tests using an available cluster. - ./test/run_e2e_test.sh + ./test/e2e_lifecycle_tests.sh node + ./test/e2e_extended_tests.sh ###################### diff --git a/test/_e2e/e2e_functions_test.go b/test/_e2e/e2e_functions_test.go index a19e2f82..6ca93b2f 100644 --- a/test/_e2e/e2e_functions_test.go +++ b/test/_e2e/e2e_functions_test.go @@ -1,4 +1,4 @@ -// +build e2e e2efunc +// +build e2elc package e2e diff --git a/test/_e2e/main_test.go b/test/_e2e/main_test.go index 561070e1..dac201de 100644 --- a/test/_e2e/main_test.go +++ b/test/_e2e/main_test.go @@ -1,4 +1,4 @@ -// +build e2e +// +build e2e e2elc package e2e diff --git a/test/_e2e/trigger_events_test.go b/test/_e2e/trigger_events_test.go index 86bd28d9..00e36deb 100644 --- a/test/_e2e/trigger_events_test.go +++ b/test/_e2e/trigger_events_test.go @@ -25,11 +25,10 @@ func (s SimpleTestEvent) pushTo(url string, t *testing.T) (body string, statusCo req.Header.Add("Content-Type", s.ContentType) resp, err := client.Do(req) - t.Logf("event POST %v -> %v", url, resp.Status) - if err != nil { return "", 0, err } + t.Logf("event POST %v -> %v", url, resp.Status) defer resp.Body.Close() b, err := ioutil.ReadAll(resp.Body) if err != nil { diff --git a/test/e2e_extended_tests.sh b/test/e2e_extended_tests.sh new file mode 100755 index 00000000..c4d83027 --- /dev/null +++ b/test/e2e_extended_tests.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# Runs E2E additional set of tests against kn func cli. +# By default it will run e2e tests against 'func' binary, but you can change it to use 'kn func' instead +# +# The following environment variable can be set in order to customize e2e execution: +# +# E2E_USE_KN_FUNC When set to "true" indicates e2e to issue func command using kn cli. +# +# E2E_REGISTRY_URL Indicates a specific registry (i.e: "quay.io/user") should be used. Make sure +# to authenticate to the registry (i.e: docker login ...) prior to execute the script +# +# E2E_FUNC_BIN_PATH Path to func binary. Derived by this script +# + +set -o errexit +set -o nounset +set -o pipefail + +use_kn_func=${E2E_USE_KN_FUNC:-} + +curdir=$(pwd) +cd $(dirname $0) +cd ../ + +# Make sure 'func' binary is built in case KN FUNC was not required for testing +if [[ ! -f func && "$use_kn_func" != "true" ]]; then + echo "func binary not found. Please run 'make build' prior to run e2e." + exit 1 +fi + +export E2E_FUNC_BIN_PATH=$(pwd)/func + +go clean -testcache +go test -v -test.v -tags="e2e" ./test/_e2e/ +ret=$? + +cd $curdir +exit $ret diff --git a/test/run_e2e_test.sh b/test/e2e_lifecycle_tests.sh similarity index 76% rename from test/run_e2e_test.sh rename to test/e2e_lifecycle_tests.sh index bf04a524..b6e8ae85 100755 --- a/test/run_e2e_test.sh +++ b/test/e2e_lifecycle_tests.sh @@ -12,9 +12,14 @@ # limitations under the License. # -# Runs E2E tests against for func cli. +# Runs basic lifecycle E2E tests against kn func cli for a given language/runtime. # By default it will run e2e tests against 'func' binary, but you can change it to use 'kn func' instead # +# Use: +# ./e2e_lifecycle_tests.sh (defaults to "node") +# Example: +# ./e2e_lifecycle_tests.sh python +# # The following environment variable can be set in order to customize e2e execution: # # E2E_USE_KN_FUNC When set to "true" indicates e2e to issue func command using kn cli. @@ -24,26 +29,19 @@ # # E2E_FUNC_BIN_PATH Path to func binary. Derived by this script # -# In additional to these env variables, for convinience you can run only the tests specific per runtime -# without running other e2e tests, by passing the runtime as an argument for this script. Example: -# -# ./run_e2e_test.sh python -# set -o errexit set -o nounset set -o pipefail runtime=${1:-} -tag=e2e use_kn_func=${E2E_USE_KN_FUNC:-} -curdir=`pwd` -cd `dirname $0` -projectdir=../ -cd $projectdir +curdir=$(pwd) +cd $(dirname $0) +cd ../ -# Make sure 'func' binary is built in case KN FUNC was not required for this test +# Make sure 'func' binary is built in case KN FUNC was not required for testing if [[ ! -f func && "$use_kn_func" != "true" ]]; then echo "func binary not found. Please run 'make build' prior to run e2e." exit 1 @@ -51,14 +49,12 @@ fi if [[ "$runtime" != "" ]]; then export E2E_RUNTIME=$runtime - tag=e2efunc fi -export E2E_FUNC_BIN_PATH=`pwd`/func -echo Binary $E2E_FUNC_BIN_PATH +export E2E_FUNC_BIN_PATH=$(pwd)/func go clean -testcache -go test -v -test.v -tags="${tag}" ./test/_e2e/ +go test -v -test.v -tags="e2elc" ./test/_e2e/ ret=$? cd $curdir