Skip to content

Commit

Permalink
Move Redis cluster docker yml to separate file (#11162)
Browse files Browse the repository at this point in the history
  • Loading branch information
mna authored Apr 12, 2023
1 parent 1ebfbb1 commit 9aab3d6
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
# Pre-starting dependencies here means they are ready to go when we need them.
- name: Start Infra Dependencies
# Use & to background this
run: FLEET_MYSQL_IMAGE=${{ matrix.mysql }} docker-compose up -d mysql_test redis redis-cluster-1 redis-cluster-2 redis-cluster-3 redis-cluster-4 redis-cluster-5 redis-cluster-6 redis-cluster-setup minio saml_idp mailhog mailpit &
run: FLEET_MYSQL_IMAGE=${{ matrix.mysql }} docker-compose -f docker-compose.yml -f docker-compose-redis-cluster.yml up -d mysql_test redis redis-cluster-1 redis-cluster-2 redis-cluster-3 redis-cluster-4 redis-cluster-5 redis-cluster-6 redis-cluster-setup minio saml_idp mailhog mailpit &

# It seems faster not to cache Go dependencies
- name: Install Go Dependencies
Expand Down
89 changes: 89 additions & 0 deletions docker-compose-redis-cluster.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
version: "2"
services:
redis-cluster-setup:
image: redis:5
command: redis-cli --cluster create 172.20.0.31:7001 172.20.0.32:7002 172.20.0.33:7003 172.20.0.34:7004 172.20.0.35:7005 172.20.0.36:7006 --cluster-yes --cluster-replicas 1
networks:
cluster_network:
ipv4_address: 172.20.0.30
depends_on:
- redis-cluster-1
- redis-cluster-2
- redis-cluster-3
- redis-cluster-4
- redis-cluster-5
- redis-cluster-6

redis-cluster-1:
image: redis:5
command: redis-server /usr/local/etc/redis/redis.conf
ports:
- "7001:7001"
volumes:
- ./tools/redis-tests/redis-cluster-1.conf:/usr/local/etc/redis/redis.conf
networks:
cluster_network:
ipv4_address: 172.20.0.31

redis-cluster-2:
image: redis:5
command: redis-server /usr/local/etc/redis/redis.conf
ports:
- "7002:7002"
volumes:
- ./tools/redis-tests/redis-cluster-2.conf:/usr/local/etc/redis/redis.conf
networks:
cluster_network:
ipv4_address: 172.20.0.32

redis-cluster-3:
image: redis:5
command: redis-server /usr/local/etc/redis/redis.conf
ports:
- "7003:7003"
volumes:
- ./tools/redis-tests/redis-cluster-3.conf:/usr/local/etc/redis/redis.conf
networks:
cluster_network:
ipv4_address: 172.20.0.33

redis-cluster-4:
image: redis:5
command: redis-server /usr/local/etc/redis/redis.conf
ports:
- "7004:7004"
volumes:
- ./tools/redis-tests/redis-cluster-4.conf:/usr/local/etc/redis/redis.conf
networks:
cluster_network:
ipv4_address: 172.20.0.34

redis-cluster-5:
image: redis:5
command: redis-server /usr/local/etc/redis/redis.conf
ports:
- "7005:7005"
volumes:
- ./tools/redis-tests/redis-cluster-5.conf:/usr/local/etc/redis/redis.conf
networks:
cluster_network:
ipv4_address: 172.20.0.35

redis-cluster-6:
image: redis:5
command: redis-server /usr/local/etc/redis/redis.conf
ports:
- "7006:7006"
volumes:
- ./tools/redis-tests/redis-cluster-6.conf:/usr/local/etc/redis/redis.conf
networks:
cluster_network:
ipv4_address: 172.20.0.36

networks:
cluster_network:
driver: bridge
ipam:
config:
- subnet: 172.20.0.0/24
87 changes: 0 additions & 87 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,86 +81,6 @@ services:
ports:
- "6379:6379"

redis-cluster-setup:
image: redis:5
command: redis-cli --cluster create 172.20.0.31:7001 172.20.0.32:7002 172.20.0.33:7003 172.20.0.34:7004 172.20.0.35:7005 172.20.0.36:7006 --cluster-yes --cluster-replicas 1
networks:
cluster_network:
ipv4_address: 172.20.0.30
depends_on:
- redis-cluster-1
- redis-cluster-2
- redis-cluster-3
- redis-cluster-4
- redis-cluster-5
- redis-cluster-6

redis-cluster-1:
image: redis:5
command: redis-server /usr/local/etc/redis/redis.conf
ports:
- "7001:7001"
volumes:
- ./tools/redis-tests/redis-cluster-1.conf:/usr/local/etc/redis/redis.conf
networks:
cluster_network:
ipv4_address: 172.20.0.31

redis-cluster-2:
image: redis:5
command: redis-server /usr/local/etc/redis/redis.conf
ports:
- "7002:7002"
volumes:
- ./tools/redis-tests/redis-cluster-2.conf:/usr/local/etc/redis/redis.conf
networks:
cluster_network:
ipv4_address: 172.20.0.32

redis-cluster-3:
image: redis:5
command: redis-server /usr/local/etc/redis/redis.conf
ports:
- "7003:7003"
volumes:
- ./tools/redis-tests/redis-cluster-3.conf:/usr/local/etc/redis/redis.conf
networks:
cluster_network:
ipv4_address: 172.20.0.33

redis-cluster-4:
image: redis:5
command: redis-server /usr/local/etc/redis/redis.conf
ports:
- "7004:7004"
volumes:
- ./tools/redis-tests/redis-cluster-4.conf:/usr/local/etc/redis/redis.conf
networks:
cluster_network:
ipv4_address: 172.20.0.34

redis-cluster-5:
image: redis:5
command: redis-server /usr/local/etc/redis/redis.conf
ports:
- "7005:7005"
volumes:
- ./tools/redis-tests/redis-cluster-5.conf:/usr/local/etc/redis/redis.conf
networks:
cluster_network:
ipv4_address: 172.20.0.35

redis-cluster-6:
image: redis:5
command: redis-server /usr/local/etc/redis/redis.conf
ports:
- "7006:7006"
volumes:
- ./tools/redis-tests/redis-cluster-6.conf:/usr/local/etc/redis/redis.conf
networks:
cluster_network:
ipv4_address: 172.20.0.36

saml_idp:
image: fleetdm/docker-idp:latest
environment:
Expand Down Expand Up @@ -223,10 +143,3 @@ volumes:
mysql-persistent-volume:
data-minio:


networks:
cluster_network:
driver: bridge
ipam:
config:
- subnet: 172.20.0.0/24
8 changes: 8 additions & 0 deletions docs/Contributing/Testing-and-local-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ Make sure it is available in your `PATH`. To execute the basic unit and integrat
REDIS_TEST=1 MYSQL_TEST=1 make test
```

Note that on a Linux system, the Redis tests will include running in cluster mode, so the docker Redis Cluster setup must be running. This implies starting the docker dependencies as follows:

```
# start both the default docker-compose.yml and the redis cluster-specific
# docker-compose-redis-cluster.yml
$ docker-compose -f docker-compose.yml -f docker-compose-redis-cluster.yml up
```

### Go unit tests

To run all Go unit tests, run the following:
Expand Down
4 changes: 2 additions & 2 deletions server/service/appconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (
"github.com/kolide/kit/version"
)

// //////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Get AppConfig
// //////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

type appConfigResponse struct {
fleet.AppConfig
Expand Down

0 comments on commit 9aab3d6

Please sign in to comment.