forked from jaegertracing/jaeger-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add UI access tests (jaegertracing#1876)
* Small fixes for outside-cluster test Signed-off-by: Israel Blancas <[email protected]> * Fix missing make deps Signed-off-by: Israel Blancas <[email protected]> * Templatize Service Account creation Signed-off-by: Israel Blancas <[email protected]> * Removing superfluous message Signed-off-by: Israel Blancas <[email protected]> * Add retries Signed-off-by: Israel Blancas <[email protected]> * Recover old test Signed-off-by: Israel Blancas <[email protected]> * Move the uidefinition test to the new suite Signed-off-by: Israel Blancas <[email protected]> * Add new checks for the ui-allinone Signed-off-by: Israel Blancas <[email protected]> * Create new tool to get the tokens Signed-off-by: Israel Blancas <[email protected]> * Fix the test for OpenShift Signed-off-by: Israel Blancas <[email protected]> * Create a common script for variables Signed-off-by: Israel Blancas <[email protected]> * Create a common script for variables Signed-off-by: Israel Blancas <[email protected]> * Clean test Signed-off-by: Israel Blancas <[email protected]> * Refactor get token for OpenShift Signed-off-by: Israel Blancas <[email protected]> * Add production test Signed-off-by: Israel Blancas <[email protected]> * Fix CI Signed-off-by: Israel Blancas <[email protected]> * Fix outside-cluster Signed-off-by: Israel Blancas <[email protected]> * Fix missing variable Signed-off-by: Israel Blancas <[email protected]> * Fix base checks Signed-off-by: Israel Blancas <[email protected]> * Fix securty make target Signed-off-by: Israel Blancas <[email protected]> * Fix CI Signed-off-by: Israel Blancas <[email protected]> * Fix test for Kubernetes Signed-off-by: Israel Blancas <[email protected]> * Apply changes requested in CR Signed-off-by: Israel Blancas <[email protected]>
- Loading branch information
Israel Blancas
authored
May 11, 2022
1 parent
9200b02
commit c0759fb
Showing
49 changed files
with
426 additions
and
373 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
# Folders | ||
export TEST_DIR=$ROOT_DIR/tests | ||
export TEMPLATES_DIR=$TEST_DIR/templates | ||
export EXAMPLES_DIR=$ROOT_DIR/examples | ||
|
||
# Tools | ||
export GOMPLATE=$ROOT_DIR/bin/gomplate | ||
export YQ=$ROOT_DIR/bin/yq |
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,53 @@ | ||
#!/bin/bash | ||
|
||
if [ "$#" -ne 5 ]; then | ||
echo "$0 <url> <expected HTTP code> <is OpenShift?> <namespace> <Jaeger name>" | ||
exit 1 | ||
fi | ||
|
||
export URL=$1 | ||
export EXPECTED_CODE=$2 | ||
export IS_OPENSHIFT=$3 | ||
export NAMESPACE=$4 | ||
export JAEGER_NAME=$5 | ||
|
||
export ROOT_DIR=$(realpath $(dirname ${BASH_SOURCE[0]})/../../) | ||
source $ROOT_DIR/hack/common.sh | ||
|
||
echo "Checking an expected HTTP response" | ||
n=0 | ||
|
||
if [ $IS_OPENSHIFT = true ]; then | ||
echo "Running in OpenShift. Getting the token..." | ||
SECRET=$($ROOT_DIR/tests/cmd-utils/get-token.sh $NAMESPACE $JAEGER_NAME) | ||
fi | ||
|
||
|
||
export SLEEP_TIME=10 | ||
export MAX_RETRIES=30 | ||
export INSECURE_FLAG | ||
|
||
|
||
until [ "$n" -ge $MAX_RETRIES ]; do | ||
n=$((n+1)) | ||
echo "Try number $n/$MAX_RETRIES" | ||
|
||
HTTP_RESPONSE=$(curl -H "Authorization: Bearer ${SECRET}" -X GET $URL $INSECURE_FLAG -s -o /dev/null -w %{http_code}) | ||
CMD_EXIT_CODE=$? | ||
|
||
if [ $CMD_EXIT_CODE != 0 ]; then | ||
echo "Something failed while trying to contact the server. Trying insecure mode" | ||
INSECURE_FLAG="-k" | ||
continue | ||
fi | ||
|
||
if [[ $HTTP_RESPONSE = $EXPECTED_CODE ]]; then | ||
echo "curl response asserted properly" | ||
exit 0 | ||
fi | ||
|
||
echo "HTTP response is $HTTP_RESPONSE. $EXPECTED_CODE expected. Waiting $SLEEP_TIME s" | ||
sleep $SLEEP_TIME | ||
done | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
if [ "$#" -lt 2 ]; then | ||
echo "$0 <namespace> <Jaeger name> <output file (optional)>" | ||
exit 1 | ||
fi | ||
|
||
export NAMESPACE=$1 | ||
export JAEGER_NAME=$2 | ||
export OUTPUT_FILE=$3 | ||
|
||
set -e | ||
|
||
export ROOT_DIR=$(realpath $(dirname ${BASH_SOURCE[0]})/../../) | ||
source $ROOT_DIR/hack/common.sh | ||
|
||
# Ensure the tools are installed | ||
$ROOT_DIR/hack/install/install-gomplate.sh > /dev/null | ||
$ROOT_DIR/hack/install/install-yq.sh > /dev/null | ||
|
||
|
||
if [ -z "$SERVICE_ACCOUNT_NAME" ]; then | ||
export SERVICE_ACCOUNT_NAME="automation-sa" | ||
fi | ||
|
||
$GOMPLATE -f $TEMPLATES_DIR/openshift/configure-jaeger-sa.yaml.template -o /tmp/jaeger-sa.yaml | ||
kubectl apply -f /tmp/jaeger-sa.yaml -n $NAMESPACE > /dev/null | ||
|
||
# This takes some time | ||
sleep 5 | ||
|
||
SECRET_NAME=$(kubectl get sa $SERVICE_ACCOUNT_NAME -o yaml -n $NAMESPACE | $YQ eval '.secrets[] | select( .name == "*-token-*")'.name) | ||
SECRET=$(kubectl get secret $SECRET_NAME -n $NAMESPACE -o jsonpath='{.data.token}' | base64 -d) | ||
|
||
if [ ! -z $OUTPUT_FILE ]; then | ||
echo -n $SECRET > $OUTPUT_FILE | ||
else | ||
echo $SECRET | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"net/http" | ||
"strings" | ||
|
||
"github.com/sirupsen/logrus" | ||
"github.com/spf13/viper" | ||
|
||
"github.com/jaegertracing/jaeger-operator/tests/assert-jobs/utils" | ||
) | ||
|
||
const ( | ||
envExpectedContent = "EXPECTED_CONTENT" | ||
envQueryHostName = "QUERY_HOSTNAME" | ||
envAssertPresent = "ASSERT_PRESENT" | ||
) | ||
|
||
func main() { | ||
viper.AutomaticEnv() | ||
|
||
params := utils.NewParameters() | ||
params.Parse() | ||
|
||
expectedContent := viper.GetString(envExpectedContent) | ||
hostName := viper.GetString(envQueryHostName) | ||
assertPresent := viper.GetBool(envAssertPresent) | ||
|
||
if expectedContent == "" { | ||
logrus.Fatalln("EXPECTED_CONTENT env variable could not be empty") | ||
} | ||
|
||
logrus.Info("Querying ", hostName, "...") | ||
|
||
err := utils.TestGetHTTP(hostName, params, func(_ *http.Response, body []byte) (done bool, err error) { | ||
found := strings.Contains(string(body), expectedContent) | ||
|
||
if assertPresent && found { | ||
logrus.Infoln("Content found and asserted!") | ||
return true, nil | ||
} else if !assertPresent && !found { | ||
logrus.Infoln("Content not found and asserted it was not found!") | ||
return true, nil | ||
} | ||
logrus.Warningln("Found: ", found, ". Assert: ", assertPresent) | ||
return false, nil | ||
}) | ||
|
||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
|
||
logrus.Info("Success!") | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.