Skip to content

Commit 9d51b90

Browse files
authored
Provide an easy way to test ServiceControl instances from a PR build on GHCR (#4579)
* Provide an easy way to test ServiceControl instances from a PR build on GHCR * Link from main README as well
1 parent e3b0b66 commit 9d51b90

File tree

5 files changed

+128
-0
lines changed

5 files changed

+128
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ A video demo showing how to set it up is available on the Particular YouTube cha
2020

2121
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.
2222

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

2527
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

docs/test-ghcr-tag/.env

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Use `pr-####` or full alpha version such as `6.1.0-alpha.0.8`
2+
SERVICECONTROL_TAG=pr-4575
3+
4+
# ServicePulse image is pulled from Docker Hub
5+
SERVICEPULSE_TAG=latest
6+
7+
# RabbitMQ configuration
8+
TRANSPORTTYPE=RabbitMQ.QuorumConventionalRouting
9+
CONNECTIONSTRING="host=rabbitmq;username=guest;password=guest"
10+
11+
# Will load your local license if found in your environment variables
12+
PARTICULARSOFTWARE_LICENSE="$PARTICULARSOFTWARE_LICENSE"

docs/test-ghcr-tag/compose.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Important changes here due to new ServiceControl development should also be made in the following locations:
2+
# * /src/container-integration-test
3+
# * https://github.com/Particular/PlatformContainerExamples/tree/main/docker-compose
4+
# * https://github.com/ParticularLabs/AwsLoanBrokerSample/blob/main/docker-compose.yml
5+
6+
name: servicecontrol-pr
7+
8+
services:
9+
servicecontrol:
10+
image: ghcr.io/particular/servicecontrol:${SERVICECONTROL_TAG}
11+
env_file: .env
12+
ports:
13+
- "33333:33333"
14+
environment:
15+
RAVENDB_CONNECTIONSTRING: http://servicecontrol-db:8080
16+
REMOTEINSTANCES: '[{"api_uri":"http://servicecontrol-audit:44444/api"}]'
17+
command: --setup-and-run
18+
restart: unless-stopped
19+
depends_on:
20+
servicecontrol-db:
21+
condition: service_healthy
22+
rabbitmq:
23+
condition: service_healthy
24+
25+
servicecontrol-db:
26+
image: ghcr.io/particular/servicecontrol-ravendb:${SERVICECONTROL_TAG}
27+
ports:
28+
- "8080:8080"
29+
volumes:
30+
- db-config:/etc/ravendb
31+
- db-data:/var/lib/ravendb/data
32+
33+
servicecontrol-audit:
34+
image: ghcr.io/particular/servicecontrol-audit:${SERVICECONTROL_TAG}
35+
env_file: .env
36+
ports:
37+
- "44444:44444"
38+
environment:
39+
RAVENDB_CONNECTIONSTRING: http://servicecontrol-db:8080
40+
command: --setup-and-run
41+
restart: unless-stopped
42+
depends_on:
43+
servicecontrol-db:
44+
condition: service_healthy
45+
rabbitmq:
46+
condition: service_healthy
47+
48+
servicecontrol-monitoring:
49+
image: ghcr.io/particular/servicecontrol-monitoring:${SERVICECONTROL_TAG}
50+
env_file: .env
51+
restart: unless-stopped
52+
command: --setup-and-run
53+
ports:
54+
- "33633:33633"
55+
depends_on:
56+
rabbitmq:
57+
condition: service_healthy
58+
59+
servicepulse:
60+
image: particular/servicepulse:${SERVICEPULSE_TAG}
61+
ports:
62+
- "9090:9090"
63+
environment:
64+
SERVICECONTROL_URL: http://servicecontrol:33333
65+
MONITORING_URL: http://servicecontrol-monitoring:33633
66+
restart: unless-stopped
67+
depends_on:
68+
servicecontrol:
69+
condition: service_healthy
70+
servicecontrol-monitoring:
71+
condition: service_healthy
72+
rabbitmq:
73+
condition: service_healthy
74+
75+
rabbitmq:
76+
image: rabbitmq:3-management
77+
ports:
78+
- "5672:5672"
79+
- "15672:15672"
80+
restart: unless-stopped
81+
healthcheck:
82+
test: rabbitmq-diagnostics check_port_connectivity
83+
interval: 30s
84+
timeout: 10s
85+
start_period: 30s
86+
start_interval: 10s
87+
retries: 3
88+
volumes:
89+
- rabbitmq-data:/var/lib/rabbitmq
90+
91+
volumes:
92+
rabbitmq-data:
93+
db-config:
94+
db-data:

docs/testing.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,18 @@ Multi-instance tests validate the interaction between different ServiceControl i
3939
## Container tests
4040

4141
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/).
42+
43+
Containers built by a PR and stored on GitHub Container Registry can be tested locally:
44+
45+
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).
46+
2. In the terminal, navigate to []`/docs/test-ghcr-tag`](/docs/test/ghcr-tag).
47+
3. Edit the [`.env` file](/docs/test-ghcr-tag/.env) to specify the PR-based tag (in the form `pr-####`) to test.
48+
4. Run `docker compose up -d`.
49+
5. Services will be avialable at the following URLs:
50+
* [RabbitMQ Management](http://localhost:15672) (Login: `guest`/`guest`)
51+
* [RavenDB](http://localhost:8080)
52+
* [ServiceControl API](http://localhost:33333/api)
53+
* [Audit API](http://localhost:44444/api)
54+
* [Monitoring API](http://localhost:33633)
55+
* [ServicePulse (latest from Docker Hub)](http://localhost:9090)
56+
6. Tear down services using `docker compose down`.

src/container-integration-test/servicecontrol.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Important changes here due to new ServiceControl development should also be made in the following locations:
2+
# * /docs/test-ghcr-tag
3+
# * https://github.com/Particular/PlatformContainerExamples/tree/main/docker-compose
4+
# * https://github.com/ParticularLabs/AwsLoanBrokerSample/blob/main/docker-compose.yml
5+
16
name: service-platform
27

38
services:

0 commit comments

Comments
 (0)