Skip to content

Commit bc97722

Browse files
authored
test: add nat-ted environment test to CI (#107)
1 parent 5faa992 commit bc97722

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

.github/workflows/test.yaml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ on:
1414
pull_request:
1515
branches:
1616
- master
17+
defaults:
18+
run:
19+
shell: bash
1720
jobs:
1821
lint:
1922
name: Lint
@@ -189,6 +192,72 @@ jobs:
189192
run: bundle exec rake test_cluster_scale
190193
- name: Stop containers
191194
run: docker compose -f $DOCKER_COMPOSE_FILE down
195+
nat-ted-env:
196+
name: NAT-ted Environments
197+
timeout-minutes: 15
198+
strategy:
199+
fail-fast: false
200+
runs-on: ubuntu-latest
201+
env:
202+
REDIS_VERSION: '7.0.1'
203+
DOCKER_COMPOSE_FILE: 'docker-compose.nat.yaml'
204+
steps:
205+
- name: Check out code
206+
uses: actions/checkout@v3
207+
- name: Set up Ruby
208+
uses: ruby/setup-ruby@v1
209+
with:
210+
ruby-version: '3.1'
211+
bundler-cache: true
212+
- name: Pull Docker images
213+
run: docker pull redis:$REDIS_VERSION
214+
- name: Get IP address of host
215+
id: host_ip_addr
216+
run: |
217+
host_ip_addr=$(ip a | grep eth0 | grep inet | awk '{print $2}' | cut -d'/' -f1)
218+
echo "::set-output name=host_ip_addr::$host_ip_addr"
219+
- name: Run containers
220+
run: docker compose -f $DOCKER_COMPOSE_FILE up -d
221+
env:
222+
HOST_ADDR: ${{ steps.host_ip_addr.outputs.host_ip_addr }}
223+
- name: Wait for nodes to be ready
224+
run: |
225+
node_cnt=$(docker compose -f $DOCKER_COMPOSE_FILE ps | awk '{print $3}' | tail -n +2 | wc -l)
226+
i=0
227+
while :
228+
do
229+
if [[ $i -gt $MAX_ATTEMPTS ]]
230+
then
231+
echo "Max attempts exceeded: $i times"
232+
exit 1
233+
fi
234+
healthy_cnt=$(docker compose -f $DOCKER_COMPOSE_FILE ps | awk '{print $5}' | (grep '(healthy)' || true) | wc -l)
235+
if [[ $healthy_cnt -eq $node_cnt ]]
236+
then
237+
break
238+
fi
239+
echo 'Waiting for nodes to be ready...'
240+
sleep 3
241+
: $((++i))
242+
done
243+
env:
244+
HOST_ADDR: ${{ steps.host_ip_addr.outputs.host_ip_addr }}
245+
MAX_ATTEMPTS: "10"
246+
- name: Print containers
247+
run: docker compose -f $DOCKER_COMPOSE_FILE ps
248+
env:
249+
HOST_ADDR: ${{ steps.host_ip_addr.outputs.host_ip_addr }}
250+
- name: Build cluster
251+
run: bundle exec rake "build_cluster[$HOST_ADDR]"
252+
env:
253+
HOST_ADDR: ${{ steps.host_ip_addr.outputs.host_ip_addr }}
254+
DEBUG: "1"
255+
- name: Run minitest
256+
run: bundle exec rake test
257+
- name: Stop containers
258+
run: docker compose -f $DOCKER_COMPOSE_FILE down
259+
env:
260+
HOST_ADDR: ${{ steps.host_ip_addr.outputs.host_ip_addr }}
192261
benchmark:
193262
name: Benchmark
194263
timeout-minutes: 15

0 commit comments

Comments
 (0)