Skip to content

Commit

Permalink
Provide an easy way to test ServiceControl instances from a PR build …
Browse files Browse the repository at this point in the history
…on GHCR (#4579)

* Provide an easy way to test ServiceControl instances from a PR build on GHCR

* Link from main README as well
  • Loading branch information
DavidBoike authored Nov 6, 2024
1 parent e3b0b66 commit 9d51b90
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ A video demo showing how to set it up is available on the Particular YouTube cha

All containers are [created on each build and pushed](.github/workflows/push-container-images.yml) to the [GitHub container registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry) where the various instance type can be [accessed by their names](/.github/workflows/push-container-images.yml#L33) and run locally.

It's also possible to [locally test containers built from PRs in GitHub Container Registry](/docs/testing.md#container-tests)

### Infrastructure setup

If the instance is executed for the first time, it must set up the required infrastructure. To do so, once the instance is configured to use the selected transport and persister, run it in setup mode. This can be done by using the `Setup {instance name}` launch profile that is defined in
Expand Down
12 changes: 12 additions & 0 deletions docs/test-ghcr-tag/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Use `pr-####` or full alpha version such as `6.1.0-alpha.0.8`
SERVICECONTROL_TAG=pr-4575

# ServicePulse image is pulled from Docker Hub
SERVICEPULSE_TAG=latest

# RabbitMQ configuration
TRANSPORTTYPE=RabbitMQ.QuorumConventionalRouting
CONNECTIONSTRING="host=rabbitmq;username=guest;password=guest"

# Will load your local license if found in your environment variables
PARTICULARSOFTWARE_LICENSE="$PARTICULARSOFTWARE_LICENSE"
94 changes: 94 additions & 0 deletions docs/test-ghcr-tag/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Important changes here due to new ServiceControl development should also be made in the following locations:
# * /src/container-integration-test
# * https://github.com/Particular/PlatformContainerExamples/tree/main/docker-compose
# * https://github.com/ParticularLabs/AwsLoanBrokerSample/blob/main/docker-compose.yml

name: servicecontrol-pr

services:
servicecontrol:
image: ghcr.io/particular/servicecontrol:${SERVICECONTROL_TAG}
env_file: .env
ports:
- "33333:33333"
environment:
RAVENDB_CONNECTIONSTRING: http://servicecontrol-db:8080
REMOTEINSTANCES: '[{"api_uri":"http://servicecontrol-audit:44444/api"}]'
command: --setup-and-run
restart: unless-stopped
depends_on:
servicecontrol-db:
condition: service_healthy
rabbitmq:
condition: service_healthy

servicecontrol-db:
image: ghcr.io/particular/servicecontrol-ravendb:${SERVICECONTROL_TAG}
ports:
- "8080:8080"
volumes:
- db-config:/etc/ravendb
- db-data:/var/lib/ravendb/data

servicecontrol-audit:
image: ghcr.io/particular/servicecontrol-audit:${SERVICECONTROL_TAG}
env_file: .env
ports:
- "44444:44444"
environment:
RAVENDB_CONNECTIONSTRING: http://servicecontrol-db:8080
command: --setup-and-run
restart: unless-stopped
depends_on:
servicecontrol-db:
condition: service_healthy
rabbitmq:
condition: service_healthy

servicecontrol-monitoring:
image: ghcr.io/particular/servicecontrol-monitoring:${SERVICECONTROL_TAG}
env_file: .env
restart: unless-stopped
command: --setup-and-run
ports:
- "33633:33633"
depends_on:
rabbitmq:
condition: service_healthy

servicepulse:
image: particular/servicepulse:${SERVICEPULSE_TAG}
ports:
- "9090:9090"
environment:
SERVICECONTROL_URL: http://servicecontrol:33333
MONITORING_URL: http://servicecontrol-monitoring:33633
restart: unless-stopped
depends_on:
servicecontrol:
condition: service_healthy
servicecontrol-monitoring:
condition: service_healthy
rabbitmq:
condition: service_healthy

rabbitmq:
image: rabbitmq:3-management
ports:
- "5672:5672"
- "15672:15672"
restart: unless-stopped
healthcheck:
test: rabbitmq-diagnostics check_port_connectivity
interval: 30s
timeout: 10s
start_period: 30s
start_interval: 10s
retries: 3
volumes:
- rabbitmq-data:/var/lib/rabbitmq

volumes:
rabbitmq-data:
db-config:
db-data:
15 changes: 15 additions & 0 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,18 @@ Multi-instance tests validate the interaction between different ServiceControl i
## Container tests

Containers images generated for all builds are pushed to the [GitHub container registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry). Once pushed all images are tested by [spinning them all up for each supported transport](/src/container-integration-test/).

Containers built by a PR and stored on GitHub Container Registry can be tested locally:

1. [Authenticate to the GitHub Container Registry using a personal access token](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#authenticating-with-a-personal-access-token-classic).
2. In the terminal, navigate to []`/docs/test-ghcr-tag`](/docs/test/ghcr-tag).
3. Edit the [`.env` file](/docs/test-ghcr-tag/.env) to specify the PR-based tag (in the form `pr-####`) to test.
4. Run `docker compose up -d`.
5. Services will be avialable at the following URLs:
* [RabbitMQ Management](http://localhost:15672) (Login: `guest`/`guest`)
* [RavenDB](http://localhost:8080)
* [ServiceControl API](http://localhost:33333/api)
* [Audit API](http://localhost:44444/api)
* [Monitoring API](http://localhost:33633)
* [ServicePulse (latest from Docker Hub)](http://localhost:9090)
6. Tear down services using `docker compose down`.
5 changes: 5 additions & 0 deletions src/container-integration-test/servicecontrol.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Important changes here due to new ServiceControl development should also be made in the following locations:
# * /docs/test-ghcr-tag
# * https://github.com/Particular/PlatformContainerExamples/tree/main/docker-compose
# * https://github.com/ParticularLabs/AwsLoanBrokerSample/blob/main/docker-compose.yml

name: service-platform

services:
Expand Down

0 comments on commit 9d51b90

Please sign in to comment.