|
| 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`). |
0 commit comments