-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: integration tests with different runtimes (#23)
* chore(*): tune gitignore Signed-off-by: ArtemTrofimushkin <[email protected]> * feat(sample): add web project as target app Signed-off-by: ArtemTrofimushkin <[email protected]> * feat(sample): add dockerfile Signed-off-by: ArtemTrofimushkin <[email protected]> * chore(tests): extract common fixtures logic to separate method Signed-off-by: ArtemTrofimushkin <[email protected]> * chore(tests): replace prebuilt target container with custom sample Signed-off-by: ArtemTrofimushkin <[email protected]> * chore(tests): cleanup scripts Signed-off-by: ArtemTrofimushkin <[email protected]> * chore(tests): add ability to specify target framework & override image in tests Signed-off-by: ArtemTrofimushkin <[email protected]> * chore(ci): add matrix to gha build Signed-off-by: ArtemTrofimushkin <[email protected]> * chore(tests): extend timeout Signed-off-by: ArtemTrofimushkin <[email protected]> * chore(ci): fix pipeline Signed-off-by: ArtemTrofimushkin <[email protected]> * chore(tests): fix tags Signed-off-by: ArtemTrofimushkin <[email protected]> * fix(sample): set different target frameworks property Signed-off-by: ArtemTrofimushkin <[email protected]> * chore(ci): disable fail-fast Signed-off-by: ArtemTrofimushkin <[email protected]> * fix(tests): try to fix concurrent testcases Signed-off-by: ArtemTrofimushkin <[email protected]> * chore(kubernetes): add container state description to pod waiting in case of error Signed-off-by: ArtemTrofimushkin <[email protected]> * chore(tests): use builder to generate testcases Signed-off-by: ArtemTrofimushkin <[email protected]> * fix(kubernetes): use correct fields for error message generation Signed-off-by: ArtemTrofimushkin <[email protected]> * fix(tests): try to fix parallel execution Signed-off-by: ArtemTrofimushkin <[email protected]> * fix(cli): use better error message in case of failure Signed-off-by: ArtemTrofimushkin <[email protected]> * fix(tests): simplify test execution Signed-off-by: ArtemTrofimushkin <[email protected]> * fix(tests): lower parallel degree Signed-off-by: ArtemTrofimushkin <[email protected]>
- Loading branch information
1 parent
4c04363
commit fd12c59
Showing
24 changed files
with
607 additions
and
368 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ trash/ | |
vendor/ | ||
dist/ | ||
**/bin/** | ||
**/obj/** | ||
|
||
# Binaries for programs and plugins | ||
*.exe | ||
|
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 |
---|---|---|
@@ -1,45 +1,93 @@ | ||
#!/bin/bash | ||
set -o errexit | ||
#!/usr/bin/env bash | ||
set -eu | ||
|
||
script_dir="$(dirname "${BASH_SOURCE[0]}")" | ||
project_dir="${script_dir}/.." | ||
[ $# -lt 4 ] && echo "Usage: $(basename $0) <directory> <context> <arch|[amd64, arm64]> <framework|[netcoreapp3.1, net5.0, net6.0]>" && exit 1 | ||
|
||
kind_context="kind-kind" | ||
current_context=$(kubectl config current-context) | ||
directory=$1 | ||
context=$2 | ||
arch=$3 | ||
framework=$4 | ||
|
||
if [ "${current_context}" != "${kind_context}" ]; then | ||
echo "Your context is wrong. Use ${kind_context}" | ||
current_context=$(kubectl config current-context) | ||
if [ "${current_context}" != "$context" ]; then | ||
echo "Current context must be $context. Set current context with command \"kubectl config set-context $context\"" | ||
exit 1 | ||
fi | ||
|
||
arch=${1} | ||
cluster_os="linux" | ||
if [ "$arch" == "x86_64" ]; then | ||
arch="amd64" | ||
cluster_arch="amd64" | ||
elif [ "$arch" == "arm64" ]; then | ||
cluster_arch="arm64" | ||
else | ||
echo "Unsupported arch $arch, choose from: x86_64 or arm64" | ||
exit 1 | ||
fi | ||
|
||
if [ "$arch" != "amd64" ] && [ "$arch" != "arm64" ]; then | ||
echo "Unsupported arch, choose from: amd64 or arm64" | ||
# dumper options | ||
dumper_image_tag="latest" | ||
dumper_image_repository="kubectl-shovel/dumper-integration-tests" | ||
dumper_context="${directory}/dumper" | ||
dumper_binary="$dumper_context/bin/dumper" | ||
|
||
# sample app options | ||
sample_image_tag="$framework" | ||
sample_image_repository="kubectl-shovel/sample-integration-tests" | ||
sample_context="${directory}/sample" | ||
|
||
if [ "$framework" == "netcoreapp3.1" ]; then | ||
sample_sdk_image_tag="3.1-focal" | ||
sample_runtime_image_tag="3.1.23-focal" | ||
elif [ "$framework" == "net5.0" ]; then | ||
sample_sdk_image_tag="5.0.406-focal" | ||
sample_runtime_image_tag="5.0.15-focal" | ||
elif [ "$framework" == "net6.0" ]; then | ||
sample_sdk_image_tag="6.0-focal" | ||
sample_runtime_image_tag="6.0.3-focal" | ||
else | ||
echo "Unsupported .net target framework $framework specified, choose from: netcoreapp3.1, net5.0 or net6.0" | ||
exit 1 | ||
fi | ||
|
||
echo "Building dumper..." | ||
GOOS=linux GOARCH=$arch CGO_ENABLED=0 \ | ||
go build -v \ | ||
-o ${project_dir}/dumper/bin/dumper \ | ||
${project_dir}/dumper | ||
|
||
image_tag="latest" | ||
image_repository="kubectl-shovel/dumper-integration-tests" | ||
echo "Building dumper binary ($cluster_os/$cluster_arch):" | ||
GOOS=$cluster_os GOARCH=$cluster_arch CGO_ENABLED=0 \ | ||
go build \ | ||
-v \ | ||
-o "$dumper_binary" \ | ||
"./dumper" | ||
|
||
echo "Building dumper's image..." | ||
echo "Building dumper docker image ($cluster_os/$cluster_arch):" | ||
docker buildx build \ | ||
--platform "linux/$arch" \ | ||
--platform "$cluster_os/$cluster_arch" \ | ||
--progress plain \ | ||
--load \ | ||
-t ${image_repository}:${image_tag} \ | ||
-f "${project_dir}/dumper/Dockerfile" \ | ||
"${project_dir}/dumper" | ||
rm "${project_dir}/dumper/bin/dumper" | ||
-t "$dumper_image_repository:$dumper_image_tag" \ | ||
-f "$dumper_context/Dockerfile" \ | ||
"$dumper_context" | ||
rm "$dumper_binary" | ||
|
||
echo "Building sample docker image ($cluster_os/$cluster_arch):" | ||
docker buildx build \ | ||
--platform "$cluster_os/$cluster_arch" \ | ||
--progress plain \ | ||
--load \ | ||
--build-arg SDK_IMAGE_TAG="$sample_sdk_image_tag" \ | ||
--build-arg RUNTIME_IMAGE_TAG="$sample_runtime_image_tag" \ | ||
--build-arg FRAMEWORK="$framework" \ | ||
-t "$sample_image_repository:$sample_image_tag" \ | ||
-t "$sample_image_repository:latest" \ | ||
-f "$sample_context/Dockerfile" \ | ||
"$sample_context" | ||
|
||
images=( | ||
"$dumper_image_repository:$dumper_image_tag" | ||
"$sample_image_repository:$sample_image_tag" | ||
"$sample_image_repository:latest" | ||
) | ||
|
||
for image in "${images[@]}"; do | ||
echo "Loading image to cluster ($image):" | ||
kind load docker-image "$image" | ||
done | ||
|
||
echo "Loading dumper's image to kind cluster..." | ||
kind load docker-image ${image_repository}:${image_tag} |
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 |
---|---|---|
@@ -1,21 +1,28 @@ | ||
#!/bin/bash | ||
set -ox errexit | ||
#!/usr/bin/env bash | ||
set -eu | ||
|
||
[ $# -lt 1 ] && echo "Usage: $(basename $0) <framework|[netcoreapp3.1, net5.0, net6.0]>" && exit 1 | ||
|
||
framework=$1 | ||
|
||
if [ "$framework" != "netcoreapp3.1" ] && [ "$framework" == "net5.0" ] && [ "$framework" == "net6.0" ]; then | ||
echo "Unsupported .net target framework $framework specified, choose from: netcoreapp3.1, net5.0 or net6.0" | ||
exit 1 | ||
fi | ||
|
||
ci=${CI:-""} | ||
flags="" | ||
|
||
if [ -z "$ci" ]; then | ||
if [ -z "${CI:-""}" ]; then | ||
# disable parallel execution on locally for better debugging experience | ||
flags="-parallel 1" | ||
else | ||
flags="-parallel 4" | ||
# restrict parallel degree for ci mode because kind can hang with large amount of pods | ||
flags="-parallel 2" | ||
fi | ||
|
||
echo "Running tests..." | ||
go test -v $flags \ | ||
go test $flags \ | ||
-v \ | ||
-ldflags="-X github.com/dodopizza/kubectl-shovel/test/integration_test.TargetContainerImage=kubectl-shovel/sample-integration-tests:$framework" \ | ||
-timeout 600s \ | ||
--tags=integration \ | ||
-timeout 300s \ | ||
./test/integration/... | | ||
sed "/PASS/s//$(printf "\033[32mPASS\033[0m")/" | | ||
sed "/FAIL/s//$(printf "\033[31mFAIL\033[0m")/" | ||
|
||
exit ${PIPESTATUS[0]} | ||
./test/integration/... |
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
Oops, something went wrong.