diff --git a/Tools/CI/run_cmb_service.sh b/Tools/CI/run_cmb_service.sh index 84c211c1ed..c88d982b50 100755 --- a/Tools/CI/run_cmb_service.sh +++ b/Tools/CI/run_cmb_service.sh @@ -60,33 +60,98 @@ echo "Starting with echo server on port: $echo_port and the cmb service on port: # Setup ------------------------------------------------------------------------- + +ThrewError=false + +# Mimics "Try-Catch" where you have to check if an error occurred after invoking +try() { + ThrewError=false + "$@" || throw "$@" +} + +# Invoked by try +throw() { + logError "An error occurred executing this command:$@" + ThrewError=true +} + +# A way to log messages that are easy to distinguish from the rest of the logs +logMessage(){ + printf "\n############################################\n" + printf "$@\n" + printf "############################################\n" +} + +# A way to log error messages that are easy to distinguish from the rest of the logs +logError(){ + printf "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" + printf "$@\n" + printf "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" +} + +# Protocol Buffer Compiler ------------------------------------------------------ + +# Apply any updates +logMessage "Updating modules..." +sudo apt-get update + +# Install Protocol Buffer Compiler (using apt-get) +logMessage "Installing protocol bufffer compiler as SUDO..." +try sudo apt-get install -y protobuf-compiler + +# If the previous command failed, try without sudo +if $ThrewError; then +logMessage "Installing protocol bufffer compiler as shell assigned account..." +apt-get install -y protobuf-compiler +else +logMessage "Protocol bufffer compiler was installed as sudo!" +fi + +# Add the PROTOC environment variable that points to the Protocol Buffer Compiler binary +export PROTOC="/usr/bin/protoc" + +# Validate the PROTOC env var by getting the protoc version +try $PROTOC --version + +if $ThrewError; then +logError "Failed to properly run protoc!" +exit -1 +else +logMessage "Protocol Buffer Compiler Installed & ENV variables verified!\n PROTOC path is: $PROTOC" +fi + # clone the cmb service repo git clone https://github.com/Unity-Technologies/mps-common-multiplayer-backend.git + # navigate to the cmb service directory cd ./mps-common-multiplayer-backend/runtime # Install rust curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + # Add the cargo bin directory to the PATH export PATH="$HOME/.cargo/bin:$PATH" - # Echo server ------------------------------------------------------------------- # Build the echo server +logMessage "Beginning echo server build..." cargo build --example ngo_echo_server + # Run the echo server in the background +logMessage "Running echo server tests..." cargo run --example ngo_echo_server -- --port $echo_port & - # CMB Service ------------------------------------------------------------------- # Build a release version of the standalone cmb service +logMessage "Beginning service release build..." cargo build --release --locked # Run the standalone service on an infinite loop in the background. # The infinite loop is required as the service will exit each time all connected clients disconnect. # This means the service will exit after each test. The infinite loop will immediately restart the service each time it exits. +logMessage "Running service integration tests..." while :; do ./target/release/comb-server -l error --metrics-port 5000 standalone --port $service_port -t 60m; done & # <- use & to run the entire loop in the background