diff --git a/.github/containers/firestore/docker-compose.yml b/.github/containers/firestore/docker-compose.yml new file mode 100644 index 000000000..56c68687b --- /dev/null +++ b/.github/containers/firestore/docker-compose.yml @@ -0,0 +1,31 @@ +# Copyright 2010 New Relic, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +services: + firestore: + image: gcr.io/google.com/cloudsdktool/google-cloud-cli:437.0.1-emulators + command: + [ + "/bin/bash", + "-c", + "gcloud emulators firestore start --host-port=0.0.0.0:8080", + ] + ports: + - 8080:8080 + healthcheck: + test: ["CMD-SHELL", "curl -fsS http://localhost:8080/ || exit 1"] + interval: 5s + timeout: 3s + retries: 12 + start_period: 10s diff --git a/.github/containers/rediscluster/Dockerfile b/.github/containers/rediscluster/Dockerfile new file mode 100644 index 000000000..c393cd62c --- /dev/null +++ b/.github/containers/rediscluster/Dockerfile @@ -0,0 +1,28 @@ +# syntax=docker/dockerfile:1.4 +# Copyright 2010 New Relic, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM redis:7.0.12 + +COPY <<"EOF" /etc/redis.conf +cluster-announce-hostname 'host.docker.internal' +bind 0.0.0.0 +port 6379 +cluster-enabled yes +cluster-config-file nodes.conf +cluster-node-timeout 5000 +appendonly yes +EOF + +CMD ["redis-server", "/etc/redis.conf"] diff --git a/.github/containers/rediscluster/docker-compose.yml b/.github/containers/rediscluster/docker-compose.yml new file mode 100644 index 000000000..59c56d4fb --- /dev/null +++ b/.github/containers/rediscluster/docker-compose.yml @@ -0,0 +1,89 @@ +# Copyright 2010 New Relic, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +x-redis-node: &redis-node + build: . + image: redis-cluster-node:local + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 2s + timeout: 3s + retries: 15 + +services: + redis1: + <<: *redis-node + ports: + - 6379:6379 + - 16379:16379 + + redis2: + <<: *redis-node + ports: + - 6380:6379 + - 16380:16379 + + redis3: + <<: *redis-node + ports: + - 6381:6379 + - 16381:16379 + + redis4: + <<: *redis-node + ports: + - 6382:6379 + - 16382:16379 + + redis5: + <<: *redis-node + ports: + - 6383:6379 + - 16383:16379 + + redis6: + <<: *redis-node + ports: + - 6384:6379 + - 16384:16379 + + cluster-setup: + image: redis-cluster-node:local + restart: "no" + command: + - bash + - -c + - >- + redis-cli --cluster create + redis1:6379 redis2:6379 redis3:6379 redis4:6379 redis5:6379 redis6:6379 + --cluster-replicas 1 + --cluster-yes && + exec sleep infinity + healthcheck: + test: + [ + "CMD-SHELL", + "redis-cli -h redis1 cluster info | grep -q cluster_state:ok", + ] + interval: 2s + timeout: 3s + retries: 30 + start_period: 30s + depends_on: + redis1: { condition: service_healthy } + redis2: { condition: service_healthy } + redis3: { condition: service_healthy } + redis4: { condition: service_healthy } + redis5: { condition: service_healthy } + redis6: { condition: service_healthy } diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 866e1f1f4..58335ba28 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -751,26 +751,6 @@ jobs: options: >- --add-host=host.docker.internal:host-gateway timeout-minutes: 30 - services: - firestore: - # Image set here MUST be repeated down below in options. See comment below. - image: gcr.io/google.com/cloudsdktool/google-cloud-cli:437.0.1-emulators - ports: - - 8080:8080 - # Set health checks to wait until container has started - options: >- - --health-cmd "echo success" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - --health-start-period 5s - gcr.io/google.com/cloudsdktool/google-cloud-cli:437.0.1-emulators /bin/bash -c "gcloud emulators firestore start --host-port=0.0.0.0:8080" || - # This is a very hacky solution. GitHub Actions doesn't provide APIs for setting commands on services, but allows adding arbitrary options. - # --entrypoint won't work as it only accepts an executable and not the [] syntax. - # Instead, we specify the image again the command afterwards like a call to docker create. The result is a few environment variables - # and the original command being appended to our hijacked docker create command. We can avoid any issues by adding || to prevent that - # from every being executed as bash commands. - steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2 @@ -784,6 +764,18 @@ jobs: mkdir -p /github/home/.cache/pip chown -R "$(whoami)" /github/home/.cache/pip + - name: Start firestore + run: | + docker compose \ + -f .github/containers/firestore/docker-compose.yml \ + up -d \ + --wait \ + --wait-timeout 60 \ + && exit 0 + echo "firestore did not become healthy in time" + docker compose -f .github/containers/firestore/docker-compose.yml logs + exit 1 + - name: Get Environments id: get-envs run: | @@ -821,6 +813,11 @@ jobs: if-no-files-found: error retention-days: 1 + - name: Stop firestore + if: always() + run: | + docker compose -f .github/containers/firestore/docker-compose.yml down + grpc: env: TOTAL_GROUPS: 1 @@ -1874,60 +1871,6 @@ jobs: options: >- --add-host=host.docker.internal:host-gateway timeout-minutes: 30 - services: - redis1: - image: hmstepanek/redis-cluster-node:1.0.0 - ports: - - 6379:6379 - - 16379:16379 - options: >- - --add-host=host.docker.internal:host-gateway - - redis2: - image: hmstepanek/redis-cluster-node:1.0.0 - ports: - - 6380:6379 - - 16380:16379 - options: >- - --add-host=host.docker.internal:host-gateway - - redis3: - image: hmstepanek/redis-cluster-node:1.0.0 - ports: - - 6381:6379 - - 16381:16379 - options: >- - --add-host=host.docker.internal:host-gateway - - redis4: - image: hmstepanek/redis-cluster-node:1.0.0 - ports: - - 6382:6379 - - 16382:16379 - options: >- - --add-host=host.docker.internal:host-gateway - - redis5: - image: hmstepanek/redis-cluster-node:1.0.0 - ports: - - 6383:6379 - - 16383:16379 - options: >- - --add-host=host.docker.internal:host-gateway - - redis6: - image: hmstepanek/redis-cluster-node:1.0.0 - ports: - - 6384:6379 - - 16384:16379 - options: >- - --add-host=host.docker.internal:host-gateway - - cluster-setup: - image: hmstepanek/redis-cluster:1.0.0 - options: >- - --add-host=host.docker.internal:host-gateway - steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2 @@ -1941,6 +1884,23 @@ jobs: mkdir -p /github/home/.cache/pip chown -R "$(whoami)" /github/home/.cache/pip + - name: Start rediscluster + run: | + # Build only the redis1 image to prevent fighting, then start the entire cluster + docker compose \ + -f .github/containers/rediscluster/docker-compose.yml \ + build \ + redis1 && \ + docker compose \ + -f .github/containers/rediscluster/docker-compose.yml \ + up -d \ + --wait \ + --wait-timeout 120 \ + && exit 0 + echo "rediscluster did not become healthy in time" + docker compose -f .github/containers/rediscluster/docker-compose.yml logs + exit 1 + - name: Get Environments id: get-envs run: | @@ -1978,6 +1938,11 @@ jobs: if-no-files-found: error retention-days: 1 + - name: Stop rediscluster + if: always() + run: | + docker compose -f .github/containers/rediscluster/docker-compose.yml down + solr: env: TOTAL_GROUPS: 1