Skip to content
Snippets Groups Projects
Verified Commit 5fc265c9 authored by Lucas Briese's avatar Lucas Briese
Browse files

test: wip itest tool-service -> data-provider

parent 7982718d
No related branches found
No related tags found
1 merge request!52feat/trivyEndpoint
......@@ -11,3 +11,12 @@ bin
src/test/testResults/*
app/tools/db/cockroach-data
kubernetes/scripts/test
.git
.idea
.kotlin
.run
.tmp
kubernetes/dev
kubernetes/prod
kubernetes/local
src/test/manual
......@@ -31,7 +31,6 @@ CORS_ORIGIN=*
PORT=4000
DB_USER=sa
DB_NAME=dataprovider
DB_PORT=26257
ADMIN_PASSWORD=01234567890123456789
ADMIN_USERNAME=012345678901234567890123456789
HMAC_KEY=012345678901234567890123456789
......
......@@ -22,9 +22,8 @@ spec:
secret:
secretName: cockroachdb.client.fraunhoferpoc
containers:
- imagePullPolicy: Always
name: b-container
image: registry.opencode.de/opencode-analyzer/data-provider:latest
- name: b-container
image: registry.opencode.de/opencode-analyzer/data-provider:temp_latest
volumeMounts:
- mountPath: "/cockroach-certs"
name: db-secret-volume
......
set -euo pipefail
(
VEXEC_LOG="$(mktemp)"
vexec() {
# verbose exec, print cmd befor executing so user can copy it from terminal
echo "$@"
"$@" | tee "$VEXEC_LOG"
}
_is_minikube_cluster_fine() {
current_status=$(minikube -p "$minikube_profile" status 2>&1 || true)
expected_status=("type: Control Plane" "host: Running" "kubelet: Running" "apiserver: Running" "kubeconfig: Configured")
status_fine="true"
for expected in "${expected_status[@]}"; do
if ! grep -qiFe "$expected" <<< "${current_status:-""}"; then
echo "Expected minikube status to contain \"$expected\" but it doesn't." >&2
status_fine="false"
fi
done
# if ! "$status_fine"; then
# printf "debug: current minikube status:\n%s\n" "${current_status:-""}" >&2
# fi
echo "$status_fine"
}
init() {
script_dir=$(realpath "$(dirname "$0")")
root_dir=$(realpath "$script_dir/../../..")
cd "$root_dir"
readonly minikube_profile="opencode"
readonly kubectl=(minikube -p "$minikube_profile" kubectl -- --namespace=fraunhofer)
minikube profile "$minikube_profile"
if [ "$(_is_minikube_cluster_fine)" != "true" ]; then
echo "Minikube cluster doesn't look perfect, exact message is above. Please load it from tool-service."
exit 1
fi
}
deploy() {
(
cd "$root_dir/kubernetes/dev"
eval "$(minikube docker-env)"
docker build -t registry.opencode.de/opencode-analyzer/data-provider:temp_latest "$root_dir"
vexec "${kubectl[@]}" delete --wait=true --timeout=10s -f .,../local/ > /dev/null 2>&1 || true
# XXX quickfix
sed -i -E 's|SPRING_PROFILES_ACTIVE:.*|SPRING_PROFILES_ACTIVE: local|' "$root_dir/kubernetes/dev/data-provider.configmap.yaml"
vexec "${kubectl[@]}" apply -f "$(pwd),../local/"
mapfile -t deployments < <(find . ../local -iname "*.deployment.*")
watch_rollout=$(printf '%s,' "${deployments[@]}")
watch_rollout="${watch_rollout::-1}"
vexec "${kubectl[@]}" rollout status --watch=true -f "$watch_rollout" || (
printf "\n\n\nDeploy failed, printing logs of deployments:\n"
for deployment in "${deployments[@]}"; do
vexec "${kubectl[@]}" logs -f "$deployment"
done
exit 1
)
vexec "${kubectl[@]}" port-forward deployment/b-deployment 15000:5000 15001:5001 &
# XXX port-forward to correct pod would be probably better
podcount=2
while [ "$podcount" -gt 1 ]; do
echo "waiting for deployment/tool-service to have a unique pod."
sleep 1s
podcount=$("${kubectl[@]}" get pods | grep tool-service | wc -l)
done
)
}
init
deploy
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.