Skip to content

Commit b7dcc09

Browse files
authored
chore: Add instructions for testing with CMB Service (#3738)
1 parent 8001aeb commit b7dcc09

File tree

3 files changed

+63
-5
lines changed

3 files changed

+63
-5
lines changed

.yamato/cmb-service-standalone-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ cmb_service_standalone_test_{{ project.name }}_{{ platform.name }}_{{ backend }}
5454

5555
commands:
5656
# run_cmb_service.sh builds and starts a release version of the full CMB service (along with the limited echo server)
57-
- ./Tools/CI/run_cmb_service.sh -e $ECHO_SERVER_PORT -s $CMB_SERVICE_PORT
57+
- ./Tools/CI/service.cmb/run_cmb_service.sh -e $ECHO_SERVER_PORT -s $CMB_SERVICE_PORT
5858

5959
- unity-downloader-cli --fast --wait -u {{ editor }} -c Editor {% if backend == "il2cpp" %} -c il2cpp {% endif %} {% if platform.name == "mac" %} --arch arm64 {% endif %} # For macOS we use ARM64 models
6060
- UnifiedTestRunner --suite=playmode --player-load-path=build/players --artifacts-path=test-results --testproject={{ project.path }} --editor-location=.Editor --playergraphicsapi=Null --fail-on-assert --rerun-strategy=Test --retry={{ num_test_retries }} --clean-library-on-rerun --timeout={{ test_timeout }}

Tools/CI/service.cmb/README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Testing against the CMB Service
2+
3+
The CMB Service is a tool that is external to our repository. The tool is inside the `runtime` folder in the [mps-common-multiplayer-backend](https://github.com/Unity-Technologies/mps-common-multiplayer-backend) repository.
4+
5+
Due to this, there is some more setup needed when running tests against the CMB Service.
6+
7+
## Configuration
8+
9+
The tests are automatically configured to run any `HostOrServer.DAHost` or `NetworkTopologyTypes.DistributedAuthority` test against the CMB server when either the `USE_CMB_SERVICE` scripting define is set, or when an environment variable is passed in with `USE_CMB_SERVICE=true`. When set, all non-distributed authority compatible tests will be ignored.
10+
11+
By default, the tests are configured to look for the service on the local machine (`localhost`/`http://127.0.0.1`) at port `7789`.
12+
13+
## Running against the service
14+
15+
First, ensure the `USE_CMB_SERVICE` scripting define or environment variable is set.
16+
17+
### Download the service
18+
19+
Go to the `CMB Runtime CI` action inside the cmb repo ([link here](https://github.com/Unity-Technologies/mps-common-multiplayer-backend/actions/workflows/runtime.yaml)). Open the most recent job and scroll down to the bottom of the page (You may have to scroll in the sidebar on the left, the centre of the page is not scrollable).
20+
21+
Inside the **Artifacts** section at the bottom of the page, download the `comb-server-<platform>-latest` that matches your computer architecture. This will download a pre-built binary of the most recent CMB Service.
22+
23+
### Run the service locally
24+
25+
Next we'll run the binary on the command line.
26+
27+
> [!NOTE]
28+
> If you're running on macOS, you'll have to add execution privileges to the binary before running it.
29+
30+
```bash
31+
xattr -c /path/to/comb-server
32+
```
33+
34+
To run the service, run the following command:
35+
36+
```bash
37+
/path/to/download/comb-server -l info --metrics-port 5000 standalone --port 7789 -t 60m
38+
```
39+
40+
Note that we have set the port to `7789` to match where the tests will be looking.
41+
42+
After each test, all connected clients will disconnect from the service. The service will automatically shut down when that happens. When running multiple tests in a row, it can be more convenient to run the service in a loop:
43+
44+
```bash
45+
while :; do /path/to/download/file -l info --metrics-port 5000 standalone --port 7789 -t 60m; done
46+
```
47+
48+
### Run the tests
49+
50+
With `USE_CMB_SERVICE` set, everything should be configured so that running any distributed authority test in the editor should run against the service we have running on the command line. Try running a test to validate that information is logged in the command line.
51+
52+
## Further configuration
53+
54+
The following environment variables allow for further configuration of the setup.
55+
56+
`CMB_SERVICE_PORT` defines the port where the tests will try to connect to the service (defaults to `7789`).
57+
58+
`NGO_HOST` defines the http address where the tests will try to connect to the service (defaults to `127.0.0.1`).

Tools/CI/run_cmb_service.sh renamed to Tools/CI/service.cmb/run_cmb_service.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,20 @@ logError(){
9191

9292
# Protocol Buffer Compiler ------------------------------------------------------
9393

94-
# Apply any updates
94+
# Apply any updates
9595
logMessage "Updating modules..."
9696
sudo apt-get update
9797

9898
# Install Protocol Buffer Compiler (using apt-get)
99-
logMessage "Installing protocol bufffer compiler as SUDO..."
99+
logMessage "Installing protocol buffer compiler as SUDO..."
100100
try sudo apt-get install -y protobuf-compiler
101101

102102
# If the previous command failed, try without sudo
103103
if $ThrewError; then
104-
logMessage "Installing protocol bufffer compiler as shell assigned account..."
104+
logMessage "Installing protocol buffer compiler as shell assigned account..."
105105
apt-get install -y protobuf-compiler
106106
else
107-
logMessage "Protocol bufffer compiler was installed as sudo!"
107+
logMessage "Protocol buffer compiler was installed as sudo!"
108108
fi
109109

110110
# Add the PROTOC environment variable that points to the Protocol Buffer Compiler binary

0 commit comments

Comments
 (0)