@@ -60,33 +60,98 @@ echo "Starting with echo server on port: $echo_port and the cmb service on port:
6060
6161# Setup -------------------------------------------------------------------------
6262
63+
64+ ThrewError=false
65+
66+ # Mimics "Try-Catch" where you have to check if an error occurred after invoking
67+ try () {
68+ ThrewError=false
69+ " $@ " || throw " $@ "
70+ }
71+
72+ # Invoked by try
73+ throw () {
74+ logError " An error occurred executing this command:$@ "
75+ ThrewError=true
76+ }
77+
78+ # A way to log messages that are easy to distinguish from the rest of the logs
79+ logMessage (){
80+ printf " \n############################################\n"
81+ printf " $@ \n"
82+ printf " ############################################\n"
83+ }
84+
85+ # A way to log error messages that are easy to distinguish from the rest of the logs
86+ logError (){
87+ printf " \n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
88+ printf " $@ \n"
89+ printf " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
90+ }
91+
92+ # Protocol Buffer Compiler ------------------------------------------------------
93+
94+ # Apply any updates
95+ logMessage " Updating modules..."
96+ sudo apt-get update
97+
98+ # Install Protocol Buffer Compiler (using apt-get)
99+ logMessage " Installing protocol bufffer compiler as SUDO..."
100+ try sudo apt-get install -y protobuf-compiler
101+
102+ # If the previous command failed, try without sudo
103+ if $ThrewError ; then
104+ logMessage " Installing protocol bufffer compiler as shell assigned account..."
105+ apt-get install -y protobuf-compiler
106+ else
107+ logMessage " Protocol bufffer compiler was installed as sudo!"
108+ fi
109+
110+ # Add the PROTOC environment variable that points to the Protocol Buffer Compiler binary
111+ export PROTOC=" /usr/bin/protoc"
112+
113+ # Validate the PROTOC env var by getting the protoc version
114+ try $PROTOC --version
115+
116+ if $ThrewError ; then
117+ logError " Failed to properly run protoc!"
118+ exit -1
119+ else
120+ logMessage " Protocol Buffer Compiler Installed & ENV variables verified!\n PROTOC path is: $PROTOC "
121+ fi
122+
63123# clone the cmb service repo
64124git clone https://github.com/Unity-Technologies/mps-common-multiplayer-backend.git
125+
65126# navigate to the cmb service directory
66127cd ./mps-common-multiplayer-backend/runtime
67128
68129# Install rust
69130curl --proto ' =https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
131+
70132# Add the cargo bin directory to the PATH
71133export PATH=" $HOME /.cargo/bin:$PATH "
72134
73-
74135# Echo server -------------------------------------------------------------------
75136
76137# Build the echo server
138+ logMessage " Beginning echo server build..."
77139cargo build --example ngo_echo_server
140+
78141# Run the echo server in the background
142+ logMessage " Running echo server tests..."
79143cargo run --example ngo_echo_server -- --port $echo_port &
80144
81-
82145# CMB Service -------------------------------------------------------------------
83146
84147# Build a release version of the standalone cmb service
148+ logMessage " Beginning service release build..."
85149cargo build --release --locked
86150
87151# Run the standalone service on an infinite loop in the background.
88152# The infinite loop is required as the service will exit each time all connected clients disconnect.
89153# This means the service will exit after each test. The infinite loop will immediately restart the service each time it exits.
154+ logMessage " Running service integration tests..."
90155while : ; do
91156 ./target/release/comb-server -l error --metrics-port 5000 standalone --port $service_port -t 60m;
92157done & # <- use & to run the entire loop in the background
0 commit comments