-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathtest
executable file
·84 lines (68 loc) · 2.84 KB
/
test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0
set -e
# to mute ginkgo deprecation warnings
export ACK_GINKGO_DEPRECATIONS=2.0.0
# For the test step concourse will set the following environment variables:
# SOURCE_PATH - path to component repository root directory.
if [[ $(uname) == 'Darwin' ]]; then
READLINK_BIN="greadlink"
else
READLINK_BIN="readlink"
fi
if [[ -z "${SOURCE_PATH}" ]]; then
export SOURCE_PATH="$(${READLINK_BIN} -f $(dirname ${0})/..)"
else
export SOURCE_PATH="$(${READLINK_BIN} -f "${SOURCE_PATH}")"
fi
# The `go <cmd>` commands requires to see the target repository to be part of a
# Go workspace. Thus, if we are not yet in a Go workspace, let's create one
# temporarily by using symbolic links.
if [[ "${SOURCE_PATH}" != *"src/github.com/gardener/machine-controller-manager-provider-aws" ]]; then
SOURCE_SYMLINK_PATH="${SOURCE_PATH}/tmp/src/github.com/gardener/machine-controller-manager-provider-aws"
if [[ -d "${SOURCE_PATH}/tmp" ]]; then
rm -rf "${SOURCE_PATH}/tmp"
fi
mkdir -p "${SOURCE_PATH}/tmp/src/github.com/gardener"
ln -s "${SOURCE_PATH}" "${SOURCE_SYMLINK_PATH}"
cd "${SOURCE_SYMLINK_PATH}"
export GOPATH="${SOURCE_PATH}/tmp"
export GOBIN="${SOURCE_PATH}/tmp/bin"
export PATH="${GOBIN}:${PATH}"
fi
# Install Ginkgo (test framework) to be able to execute the tests.
echo "Fetching Ginkgo framework"
GO111MODULE=on go install github.com/onsi/ginkgo/v2/ginkgo
echo "Successfully fetched Ginkgo framework"
ginkgo version
##############################################################################
function test_with_coverage() {
local output_dir=test/output
local coverprofile_file=coverprofile.out
mkdir -p test/output
ginkgo $GINKGO_COMMON_FLAGS --coverprofile ${coverprofile_file} -covermode=set --output-dir ${output_dir} ${TEST_PACKAGES}
sed -i -e '/mode: set/d' ${output_dir}/${coverprofile_file}
{( echo "mode: set"; cat ${output_dir}/${coverprofile_file} )} > ${output_dir}/${coverprofile_file}.temp
mv ${output_dir}/${coverprofile_file}.temp ${output_dir}/${coverprofile_file}
go tool cover -func ${output_dir}/${coverprofile_file}
}
###############################################################################
if [[ "${SKIP_UNIT_TESTS}" != "" ]]; then
echo ">>>>>Skipping unit tests"
else
echo ">>>>> Invoking unit tests"
TEST_PACKAGES="pkg"
GINKGO_COMMON_FLAGS="-r -timeout=1h0m0s --randomize-all --randomize-suites --fail-on-pending --show-node-events"
test_with_coverage
echo ">>>>> Finished executing unit tests"
fi
if [[ "${SKIP_INTEGRATION_TESTS}" != "" ]]; then
echo ">>>>> Skipping integration tests"
else
echo ">>>>> Invoking intergration tests"
.ci/pipeline_integration_test
echo ">>>>> Finished executing integration tests"
fi
echo "CI tests have passed successfully"