ServiceControl tests cover different components and behaviors.
ServiceControl components have specific unit test projects verifying their behaviors and API.
Packaging tests check:
- Folder structure and content of the packaging process output.
- That packaged assembly versions match.
Installation engine tests run partial installations and check:
- That the generated configuration is correct.
- That transport and persistence are correctly extracted.
Persistence tests check assumptions at the persistence seam level by exercising each persister. For local setup details, see Local testing of persistence providers.
Transport tests run the transport test suite for each transport.
Acceptance tests run the full ServiceControl and use the HTTP API to validate results. LearningTransport is used for all tests.
For how to write one that fails when it should, see Writing acceptance tests.
On Windows, every acceptance test fails on first run with:
System.Security.SecurityException : The source ServiceControl was not found on computer .,
but some or all event logs could not be searched. Inaccessible logs: Security.
Setup registers a Windows event source, and checking whether one already exists enumerates every event log, including Security, which a process without administrator rights cannot read.
Register both sources once, from an elevated PowerShell prompt:
[System.Diagnostics.EventLog]::CreateEventSource('ServiceControl', 'Application')
[System.Diagnostics.EventLog]::CreateEventSource('ServiceControl.Audit', 'Application')Use the .NET API as shown rather than New-EventLog, which is not available in PowerShell 7. Afterwards the tests run normally without elevation, because the lookup finds the registered source before it needs to read Security.
Multi-instance tests validate the interaction between different ServiceControl instances. ServiceControl instances are run in-memory in the same process. LearningTransport is used for all tests.
Container images generated for all builds are pushed to the GitHub container registry. Once pushed, all images are tested by starting them all for each supported transport.
Containers built by a PR and stored on GitHub Container Registry can be tested locally:
- Authenticate to the GitHub Container Registry using a personal access token.
- Create a classic token. Select the scope for
read:packages - Copy the newly created token text.
- Run the following command in a terminal:
Docker prompts for a username (your particular.net email) and a password (the token).
docker login ghcr.io
- Confirm that the login succeeds.
- Use
docker logout ghcr.ioonce the following steps are complete. Consider removing the token from GitHub if you no longer need it.
- Create a classic token. Select the scope for
- In the terminal, go to
/docs/test-ghcr-tag. - Edit the
.envfile to specify the PR-based tag (in the formpr-####) to test. - Run
docker compose up -d. - Open the services at the following URLs:
- RabbitMQ Management (Login:
guest/guest) - RavenDB
- ServiceControl API
- Audit API
- Monitoring API
- ServicePulse (latest from Docker Hub)
- RabbitMQ Management (Login:
- Stop the services using
docker compose down.
The Particular.Aspire.Hosting.ServicePlatform package integrates the Particular Platform with the Aspire hosting platform. This package configures environment variables to attach the platform. A single-file apphost in test-ghcr-tag-aspire starts ServiceControl from a prerelease container image.
Containers built by a PR and stored on GitHub Container Registry can be tested locally:
- Set up your GitHub Container Registry credentials as described in the Container tests section above.
- Install the Aspire CLI.
- Run
aspire updateso that the testing AppHost filedocs/test-ghcr-tag-aspire/AppHost.csuses the latest Aspire SDK and RabbitMQ integration package. - Run
aspire run docs/test-ghcr-tag-aspire/AppHost.cs -- tagto start the application, wheretagis the PR-based tag (in the formpr-####) to test. Without a tag, the command uses thelatesttag. - Open the dashboard from the link in the terminal. The dashboard shows the assigned ports for each service:
- RabbitMQ Management (Login:
guest/guest) - RavenDB
- ServiceControl API
- Audit API
- Monitoring API
- ServicePulse (latest from Docker Hub)
- RabbitMQ Management (Login:
- Exit the CLI process. Aspire stops the application automatically.