Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .yamato/cmb-service-standalone-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ cmb_service_standalone_test_{{ project.name }}_{{ platform.name }}_{{ backend }}

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

- 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
- 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 }}
Expand Down
58 changes: 58 additions & 0 deletions Tools/CI/service.cmb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Testing against the CMB Service

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.

Due to this, there is some more setup needed when running tests against the CMB Service.

## Configuration

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.

By default, the tests are configured to look for the service on the local machine (`localhost`/`http://127.0.0.1`) at port `7789`.

## Running against the service

First, ensure the `USE_CMB_SERVICE` scripting define or environment variable is set.

### Download the service

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).

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.

### Run the service locally

Next we'll run the binary on the command line.

> [!NOTE]
> If you're running on macOS, you'll have to add execution privileges to the binary before running it.

```bash
xattr -c /path/to/comb-server
```

To run the service, run the following command:

```bash
/path/to/download/comb-server -l info --metrics-port 5000 standalone --port 7789 -t 60m
```

Note that we have set the port to `7789` to match where the tests will be looking.

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:

```bash
while :; do /path/to/download/file -l info --metrics-port 5000 standalone --port 7789 -t 60m; done
```

### Run the tests

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.

## Further configuration

The following environment variables allow for further configuration of the setup.

`CMB_SERVICE_PORT` defines the port where the tests will try to connect to the service (defaults to `7789`).

`NGO_HOST` defines the http address where the tests will try to connect to the service (defaults to `127.0.0.1`).
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,20 @@ logError(){

# Protocol Buffer Compiler ------------------------------------------------------

# Apply any updates
# Apply any updates
logMessage "Updating modules..."
sudo apt-get update

# Install Protocol Buffer Compiler (using apt-get)
logMessage "Installing protocol bufffer compiler as SUDO..."
logMessage "Installing protocol buffer 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..."
logMessage "Installing protocol buffer compiler as shell assigned account..."
apt-get install -y protobuf-compiler
else
logMessage "Protocol bufffer compiler was installed as sudo!"
logMessage "Protocol buffer compiler was installed as sudo!"
fi

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