@@ -144,6 +144,10 @@ This example configures the package [through the environment][s-env-config]. It
144
144
the configurable environment variables. Optionally, enable the [ ` RedisSentinel `
145
145
facade] [ s-facade ] .
146
146
147
+ For those that need a quick development Sentinel server cluster, try the
148
+ [ * start-cluster.sh* ] [ s-integration-tests ] script included with the package's
149
+ testing files.
150
+
147
151
Configuration
148
152
-------------
149
153
@@ -661,15 +665,74 @@ Testing
661
665
-------
662
666
663
667
This package includes a PHPUnit test suite with unit tests for the package's
664
- classes. This package does not perform functional/integration tests against
665
- running Redis or Sentinel servers because Predis and Laravel both contain full
666
- test suites, and because the package code simply wraps these libraries. We may
667
- add these types of tests in the future if needed .
668
+ classes and an integration test suite for Sentinel-specific functionality and
669
+ known issues. These tests do not verify every Redis command because Predis and
670
+ Laravel both contain full test suites themselves , and because the package code
671
+ simply wraps these libraries .
668
672
673
+ ``` shell
674
+ $ phpunit --testsuite unit
675
+ $ phpunit --testsuite integration
669
676
```
670
- $ phpunit
677
+
678
+ The unit tests do not require live Redis servers. Read the next section for
679
+ integration testing environment suggestions.
680
+
681
+ ** Note:** Composer does not download this package's testing files with a normal
682
+ installation. We need to clone the package repository directly or install it
683
+ with the ` --prefer-source ` option.
684
+
685
+ ### Integration Tests
686
+
687
+ This package's integration test suite validates Sentinel- and Redis-specific
688
+ functionality against real servers. These tests require at least one Sentinel
689
+ server that monitors a Redis master. Additionally, at least one replica should
690
+ synchronize with the master for optimal test coverage. Developers may supply
691
+ their own servers or start an environment using the package's tools described
692
+ below.
693
+
694
+ To customize the Sentinel connection settings used by the integration tests,
695
+ copy * phpunit.xml.dist* to * phpunit.xml* and change the constants defined in
696
+ the ` <php>...</php> ` block.
697
+
698
+ We can run the [ * start-cluster.sh* ] ( start-cluster.sh ) script provided in the
699
+ project's root directory to spin up Redis and Sentinel servers for a testing
700
+ environment. Read the script help page for usage information.
701
+
702
+ ``` shell
703
+ $ ./start-cluster.sh help
671
704
```
672
705
706
+ Docker users may wish to use the script to start testing servers in a container:
707
+
708
+ ``` shell
709
+ $ docker run --name redis-sentinel \
710
+ -v " $( pwd) :/project" \
711
+ -w /project \
712
+ -u " $( id -u) :$( id -g) " \
713
+ -e BIND_ADDRESS=0.0.0.0 \
714
+ -e SENTINEL_PORTS=' 26379-26381' \
715
+ -e REDIS_GROUP_1=' service1 6379-6381' \
716
+ -e REDIS_GROUP_2=' service2 6382-6384' \
717
+ -e LOGGING=yes \
718
+ -p 6379-6384:6379-6384 \
719
+ -p 26379-26381:26379-26381 \
720
+ --entrypoint start-cluster.sh \
721
+ redis:alpine
722
+ ```
723
+
724
+ The package provides a [ Compose file] ( docker-compose.yml ) with the same options
725
+ for running tests:
726
+
727
+ ``` shell
728
+ $ export CONTAINER_USER_ID=" $( id -u) :$( id -g) "
729
+ $ docker-compose up -d cluster
730
+ $ docker-compose run --rm tests [--testsuite ...]
731
+ ```
732
+
733
+ Developers can also customize the Compose file by copying * docker-compose.yml*
734
+ to * docker-compose.override.yml* .
735
+
673
736
License
674
737
-------
675
738
@@ -986,6 +1049,7 @@ Sentinel Documentation][sentinel].
986
1049
[ s-env-config-examples ] : #environment-based-configuration-examples
987
1050
[ s-facade ] : #executing-redis-commands-redissentinel-facade
988
1051
[ s-hybrid-config ] : #hybrid-configuration
1052
+ [ s-integration-tests ] : #integration-tests
989
1053
[ s-multi-sentinel-example ] : #multi-sentinel-connection-configuration
990
1054
[ s-multi-service-example ] : #multi-service-connection-configuration
991
1055
[ s-multiple-hosts ] : #specifying-multiple-hosts
0 commit comments