-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We had originally setup silk in an enitre other repo with the intention that it could be imported, used, and extended by other projects. This never happened and now we have a separate repo for `silk` when it is only used in `silk-release. This commit takes [code.cloudfoundry.org/silk at commit 8e48b8d1e6812ccd3da7c93fb30728ad1d9000ed](cloudfoundry/silk@8e48b8d), and folds it into `silk-release` under `src/code.cloudfoundry.org/silk`. Other changes worth mentioning: - `scripts/test.sh` and `scripts/start-db-helper` taken from `cf-networking`, e.g. https://github.com/cloudfoundry/cf-networking-release/blob/develop/scripts/test.sh - the `silk` tests now require some databases to run - removes scripts from the `silk` source repo - Updates bosh packaging specs for the new pakage import path - Consolidates `modules/modules.go` and `tools/tools.go` since they seem to do the same thing and we don't need to import the silk stuff Addresses: cloudfoundry/silk#52 [#185149418](https://www.pivotaltracker.com/story/show/185149418) Signed-off-by: Renee Chu <reneec@vmware.com>
- Loading branch information
1 parent
5850efb
commit 96abf2b
Showing
197 changed files
with
20,530 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
function bootDB { | ||
db="$1" | ||
|
||
if [ "${db}" = "postgres" ]; then | ||
launchDB="(/postgres-entrypoint.sh postgres &> /var/log/postgres-boot.log) &" | ||
testConnection="psql -h localhost -U postgres -c '\conninfo'" | ||
elif [ "${db}" = "mysql" ] || [ "${db}" = "mysql-5.6" ] || [ "${db}" = "mysql8" ]; then | ||
launchDB="(MYSQL_ROOT_PASSWORD=password /mysql-entrypoint.sh mysqld &> /var/log/mysql-boot.log) &" | ||
testConnection="mysql -h localhost -u root -D mysql -e '\s;' --password='password'" | ||
else | ||
echo "skipping database" | ||
return 0 | ||
fi | ||
|
||
echo -n "booting ${db}" | ||
eval "$launchDB" | ||
for _ in $(seq 1 60); do | ||
if eval "${testConnection}" &> /dev/null; then | ||
echo "connection established to ${db}" | ||
return 0 | ||
fi | ||
echo -n "." | ||
sleep 1 | ||
done | ||
eval "${testConnection}" || true | ||
echo "unable to connect to ${db}" | ||
exit 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,104 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
set -o pipefail | ||
specificied_package="${1}" | ||
|
||
set -e -u | ||
|
||
go version # so we see the version tested in CI | ||
|
||
# In the cf-networking-and-silk-pr.yml pipeline, we need to run db-unit tests for cf-networking, but | ||
# concourse doesn't have a way of conditionally adding jobs, so it will end up running db-unit tests | ||
# against silk, which doesn't do anything other than run unit tests again, so we skip it here. | ||
if [[ -n "${DB:-""}" ]]; then | ||
echo "No DB specific silk tests have been defined. Skipping this step." | ||
exit 0 | ||
fi | ||
SCRIPT_PATH="$(cd "$(dirname "${0}")" && pwd)" | ||
. "${SCRIPT_PATH}/start-db-helper" | ||
|
||
cd "${SCRIPT_PATH}/.." | ||
|
||
cd $(dirname $0)/.. | ||
DB="${DB:-"notset"}" | ||
|
||
## Setting to other than 1 node will break cni-wrapper-plugin/integration | ||
serial_nodes=1 | ||
|
||
declare -a serial_packages=( | ||
"src/code.cloudfoundry.org/cni-wrapper-plugin/integration" | ||
"src/code.cloudfoundry.org/vxlan-policy-agent/integration/linux" | ||
"src/code.cloudfoundry.org/silk-daemon-shutdown/integration" | ||
"src/code.cloudfoundry.org/silk-daemon-bootstrap/integration" | ||
"src/code.cloudfoundry.org/silk-daemon-shutdown/integration" | ||
"src/code.cloudfoundry.org/silk/cni/integration" | ||
"src/code.cloudfoundry.org/vxlan-policy-agent/integration/linux" | ||
) | ||
|
||
declare -a windows_packages=( | ||
"src/code.cloudfoundry.org/vxlan-policy-agent/integration/windows" | ||
) | ||
|
||
# get all git submodule paths | print only the path without the extra info | cut the "package root" for go | deduplicate | ||
declare -a git_modules=($(git config --file .gitmodules --get-regexp path | awk '{ print $2 }' | cut -d'/' -f1,2 | sort -u)) | ||
declare -a ignored_packages | ||
|
||
declare -a packages=($(find src -type f -name "*_test.go" | xargs -L 1 -I{} dirname {} | sort -u)) | ||
# gather ignored packages from exclude_packages | ||
for pkg in $(echo "${exclude_packages:-""}" | jq -r .[]); do | ||
ignored_packages+=("${pkg}") | ||
done | ||
|
||
# gather more ignored packages because they are windows code | ||
for pkg in "${windows_packages[@]}"; do | ||
ignored_packages+=("${pkg}") | ||
done | ||
|
||
containsElement() { | ||
local e match="$1" | ||
shift | ||
for e; do [[ "$e" == "$match" ]] && return 0; done | ||
return 1 | ||
} | ||
|
||
test_package() { | ||
local package=$1 | ||
if [ ! -d "${package}" ]; then | ||
return 0 | ||
fi | ||
shift | ||
pushd "${package}" &>/dev/null | ||
pwd | ||
go run github.com/onsi/ginkgo/v2/ginkgo --race -randomize-all -randomize-suites -fail-fast \ | ||
-ldflags="extldflags=-WL,--allow-multiple-definition" \ | ||
"${@}"; | ||
rc=$? | ||
popd &>/dev/null | ||
return "${rc}" | ||
} | ||
|
||
bootDB "${DB}" | ||
|
||
declare -a packages | ||
if [[ -n "${include_only:-""}" ]]; then | ||
mapfile -t packages < <(echo "${include_only}" | jq -r .[]) | ||
else | ||
mapfile -t packages < <(find src -type f -name '*_test.go' -print0 | xargs -0 -L1 -I{} dirname {} | sort -u) | ||
fi | ||
|
||
# filter out serial_packages from packages | ||
for i in "${serial_packages[@]}"; do | ||
packages=(${packages[@]//*$i*}) | ||
packages=("${packages[@]//*$i*}") | ||
done | ||
|
||
# filter out windows_packages from packages | ||
for i in "${windows_packages[@]}"; do | ||
packages=(${packages[@]//*$i*}) | ||
# filter out explicitly ignored packages | ||
for i in "${ignored_packages[@]}"; do | ||
packages=("${packages[@]//*$i*}") | ||
serial_packages=("${serial_packages[@]//*$i*}") | ||
done | ||
|
||
if [ "${1:-""}" = "" ]; then | ||
if [[ -z "${specificied_package}" ]]; then | ||
echo "testing packages: " "${packages[@]}" | ||
for dir in "${packages[@]}"; do | ||
pushd "$dir" | ||
go run github.com/onsi/ginkgo/v2/ginkgo -p --race --randomize-all --randomize-suites \ | ||
-ldflags="-extldflags=-Wl,--allow-multiple-definition" \ | ||
${@:2} | ||
popd | ||
test_package "${dir}" -p | ||
done | ||
echo "testing serial packages: " "${serial_packages[@]}" | ||
for dir in "${serial_packages[@]}"; do | ||
pushd "$dir" | ||
go run github.com/onsi/ginkgo/v2/ginkgo --race --randomize-all --randomize-suites --fail-fast \ | ||
-ldflags="-extldflags=-Wl,--allow-multiple-definition" \ | ||
${@:2} | ||
popd | ||
test_package "${dir}" --nodes "${serial_nodes}" | ||
done | ||
else | ||
dir="${@: -1}" | ||
dir="${dir#./}" | ||
for package in "${serial_packages[@]}"; do | ||
if [[ "${dir##$package}" != "${dir}" ]]; then | ||
go run github.com/onsi/ginkgo/v2/ginkgo --race --randomize-all --randomize-suites --fail-fast \ | ||
-ldflags="-extldflags=-Wl,--allow-multiple-definition" \ | ||
"${@}" | ||
exit $? | ||
fi | ||
done | ||
go run github.com/onsi/ginkgo/v2/ginkgo -p --race --randomize-all --randomize-suites --fail-fast --skip-package windows \ | ||
-ldflags="-extldflags=-Wl,--allow-multiple-definition" \ | ||
"${@}" | ||
specificied_package="${specificied_package#./}" | ||
if containsElement "${specificied_package}" "${serial_packages[@]}"; then | ||
echo "testing serial package ${specificied_package}" | ||
test_package "${specificied_package}" --nodes "${serial_nodes}" | ||
else | ||
echo "testing package ${specificied_package}" | ||
test_package "${specificied_package}" -p | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
/pkg | ||
/bin | ||
bin |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.