@@ -60,33 +60,98 @@ echo "Starting with echo server on port: $echo_port and the cmb service on port:
60
60
61
61
# Setup -------------------------------------------------------------------------
62
62
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
+
63
123
# clone the cmb service repo
64
124
git clone https://github.com/Unity-Technologies/mps-common-multiplayer-backend.git
125
+
65
126
# navigate to the cmb service directory
66
127
cd ./mps-common-multiplayer-backend/runtime
67
128
68
129
# Install rust
69
130
curl --proto ' =https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
131
+
70
132
# Add the cargo bin directory to the PATH
71
133
export PATH=" $HOME /.cargo/bin:$PATH "
72
134
73
-
74
135
# Echo server -------------------------------------------------------------------
75
136
76
137
# Build the echo server
138
+ logMessage " Beginning echo server build..."
77
139
cargo build --example ngo_echo_server
140
+
78
141
# Run the echo server in the background
142
+ logMessage " Running echo server tests..."
79
143
cargo run --example ngo_echo_server -- --port $echo_port &
80
144
81
-
82
145
# CMB Service -------------------------------------------------------------------
83
146
84
147
# Build a release version of the standalone cmb service
148
+ logMessage " Beginning service release build..."
85
149
cargo build --release --locked
86
150
87
151
# Run the standalone service on an infinite loop in the background.
88
152
# The infinite loop is required as the service will exit each time all connected clients disconnect.
89
153
# 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..."
90
155
while : ; do
91
156
./target/release/comb-server -l error --metrics-port 5000 standalone --port $service_port -t 60m;
92
157
done & # <- use & to run the entire loop in the background
0 commit comments