diff --git a/README.md b/README.md index 18961f2e8e..2f2582778f 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/test-ghcr-tag/.env b/docs/test-ghcr-tag/.env new file mode 100644 index 0000000000..63f6ab23e8 --- /dev/null +++ b/docs/test-ghcr-tag/.env @@ -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" \ No newline at end of file diff --git a/docs/test-ghcr-tag/compose.yml b/docs/test-ghcr-tag/compose.yml new file mode 100644 index 0000000000..fcec624227 --- /dev/null +++ b/docs/test-ghcr-tag/compose.yml @@ -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: diff --git a/docs/testing.md b/docs/testing.md index 9056a8d583..86f9eb07f7 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -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`. diff --git a/src/container-integration-test/servicecontrol.yml b/src/container-integration-test/servicecontrol.yml index 19b2c0df91..8c0bbdef9f 100644 --- a/src/container-integration-test/servicecontrol.yml +++ b/src/container-integration-test/servicecontrol.yml @@ -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: