Skip to content

Commit

Permalink
Merge branch 'VKPR-144-teste-automatizado-loki' into stage
Browse files Browse the repository at this point in the history
  • Loading branch information
HumbertoPeluso committed Sep 22, 2021
2 parents ea76641 + d16ae00 commit adbe96a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
37 changes: 37 additions & 0 deletions vkpr-test/loki-test.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
VKPR_HOME=~/.vkpr
setup_file() {
load 'common-setup'
_common_setup
if [ "$VKPR_TEST_SKIP_SETUP" == "true" ]; then
echo "setup: skipping setup due to VKPR_TEST_SKIP_SETUP=true" >&3
else
echo "setup: installing loki...." >&3
rit vkpr loki install
kubectl wait --for=condition=ready --timeout=1m pod --all
sleep 2
fi
}

setup() {
load $VKPR_HOME/bats/bats-support/load.bash
load $VKPR_HOME/bats/bats-assert/load.bash
}

@test "curl to Loki must return ready" {
run echo "$(kubectl run --wait --timeout 1m curl-test --image=radial/busyboxplus:curl -i --rm --restart=Never --command -- curl -s -H "Content-Type: application/json" http://vkpr-loki-stack:3100/ready)"
actual="${lines[0]}"
trim "$actual"
actual="$TRIMMED"
expected="ready"
assert_equal "$actual" "$expected"

}

trim() {
local var="$*"
# remove leading whitespace characters
var="${var#"${var%%[![:space:]]*}"}"
# remove trailing whitespace characters
var="${var%"${var##*[![:space:]]}"}"
TRIMMED="$var"
}
2 changes: 1 addition & 1 deletion vkpr/loki/install/src/unix/formula/formula.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ addRepLoki(){

existGrafana(){
check_pod_name "vkpr-prometheus-stack-grafana"
if [[ $POD_EXISTS ]]; then
if [[ $POD_EXISTS == true ]]; then
echoColor "yellow" "Adding Loki to Grafana's datasource..."
local LOGINGRAFANA="$($VKPR_KUBECTL get secret vkpr-prometheus-stack-grafana -o yaml | $VKPR_YQ eval '.data.admin-user' - | base64 -d):$($VKPR_KUBECTL get secret vkpr-prometheus-stack-grafana -o yaml | $VKPR_YQ eval '.data.admin-password' - | base64 -d)"
local TOKEN_API_GRAFANA=$(curl -k -X POST -H "Host: grafana.localhost" -H "Content-Type: application/json" -d '{"name": "apikeycurl","role": "Admin"}' http://$LOGINGRAFANA@127.0.0.1:8000/api/auth/keys | $VKPR_JQ --raw-output '.key')
Expand Down

0 comments on commit adbe96a

Please sign in to comment.