github.com/criteo/command-launcher@v0.0.0-20230407142452-fb616f546e98/test/integration/test-remote.sh (about) 1 #!/bin/bash 2 3 # required environment varibale 4 # CL_PATH 5 # CL_HOME 6 # OUTPUT_DIR 7 SCRIPT_DIR=${1:-$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )} 8 9 EXAMPLE_BRANCH_NAME=main 10 ## 11 # test remote command 12 ## 13 echo "> test download remote command" 14 RESULT=$($OUTPUT_DIR/cl config command_repository_base_url https://raw.githubusercontent.com/criteo/command-launcher/${EXAMPLE_BRANCH_NAME}/examples/remote-repo) 15 RESULT=$($OUTPUT_DIR/cl) 16 17 echo "$RESULT" 18 19 echo "$RESULT" | grep -q "hello" 20 if [ $? -eq 0 ]; then 21 # ok 22 echo "OK" 23 else 24 echo "KO - hello command should exist" 25 exit 1 26 fi 27 28 echo "> test run remote command" 29 RESULT=$($OUTPUT_DIR/cl hello) 30 echo "$RESULT" | grep -q "Hello World!" 31 if [ $? -eq 0 ]; then 32 echo "OK" 33 else 34 echo "KO - wrong output of hello command: $RESULT" 35 exit 1 36 fi 37 38 echo "> test remote config" 39 export CL_REMOTE_CONFIG_URL=https://raw.githubusercontent.com/criteo/command-launcher/${EXAMPLE_BRANCH_NAME}/examples/remote-config/remote_config.json 40 RESULT=$($OUTPUT_DIR/cl config) 41 echo "$RESULT" | grep -q "test/remote-repo" 42 if [ $? -eq 0 ]; then 43 echo "OK" 44 else 45 echo "KO - remote config didn't set correctly" 46 exit 1 47 fi 48 49 echo "> test update command" 50 RESULT=$($OUTPUT_DIR/cl update --package) 51 echo "$RESULT" | grep "upgrade command 'command-launcher-demo' from version 1.0.0 to version 2.0.0" 52 if [ $? -eq 0 ]; then 53 echo "OK" 54 else 55 echo "KO - failed to run update command" 56 exit 1 57 fi 58 59 echo "> test update command updates bonjour package" 60 RESULT=$($OUTPUT_DIR/cl) 61 echo "$RESULT" | grep -q "bonjour" 62 if [ $? -eq 0 ]; then 63 echo "OK" 64 else 65 echo "KO - bonjour command should exist" 66 exit 1 67 fi 68 69 echo "> test bonjour command from remote config" 70 RESULT=$($OUTPUT_DIR/cl bonjour) 71 echo "$RESULT" | grep -q "bonjour!" 72 if [ $? -eq 0 ]; then 73 echo "OK" 74 else 75 echo "KO - wrong output of bonjour command: $RESULT" 76 exit 1 77 fi 78 79 echo "> test downloaded package specified from a remote config" 80 RESULT=$($OUTPUT_DIR/cl hello) 81 echo "$RESULT" | grep -q "Hello World v2!" 82 if [ $? -eq 0 ]; then 83 echo "OK" 84 else 85 echo "KO - wrong output of hello command: $RESULT" 86 exit 1 87 fi