Skip to content

Commit

Permalink
Port GHA compose tests to use dctest.
Browse files Browse the repository at this point in the history
  • Loading branch information
kanaka committed Jun 5, 2024
1 parent 2ddd23a commit fb21eac
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 40 deletions.
44 changes: 7 additions & 37 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,47 +46,17 @@ jobs:
- name: Run npm tests
run: node build/test.js

compose-tests:
dctest-compose-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: dhcp test
run: |
echo "COMPOSE_PROFILES=dhcp" > .env
docker-compose up --force-recreate -d
while ! docker-compose logs net | grep "Creating veth"; do
echo "Waiting for compose startup, sleeping 2 seconds"; sleep 2
done
while true; do
[ $(docker-compose logs | grep "client.*ACK from" | wc -l) -ge 4 ] && break
echo "Waiting for 4 client ACKs, sleeping 2 second"; sleep 2
done
docker-compose down --remove-orphans -t1
- name: npm install dctest
run: npm install @lonocloud/dctest --no-save --ignore-scripts

- name: ping test
run: |
echo "COMPOSE_PROFILES=ping" > .env
docker-compose up --force-recreate -d
while ! docker-compose logs net | grep "Creating veth"; do
echo "Waiting for compose startup, sleeping 2 seconds"; sleep 2
done
while true; do
[ $(docker-compose logs | grep "echo-reply" | wc -l) -ge 2 ] && break
echo "Waiting for 2+ echo replies, sleeping 2 second"; sleep 2
done
docker-compose down --remove-orphans -t1
- name: compose build (dhcp,ping,mac2ip profiles)
run: docker compose --profile dhcp --profile ping --profile mac2ip build

- name: mac2ip test
run: |
echo "COMPOSE_PROFILES=mac2ip" > .env
docker-compose up --force-recreate -d
while ! docker-compose logs net | grep "Creating veth"; do
echo "Waiting for compose startup, sleeping 2 seconds"; sleep 2
done
while true; do
[ $(docker-compose logs | grep -o "worker-.*ACK to" | sort | uniq | wc -l) -ge 2 ] && break
echo "Waiting for 2+ uniq workers to ACK, sleeping 2 second"; sleep 2
done
docker-compose down --remove-orphans -t1
- name: run dctest tests
run: time node_modules/.bin/dctest --verbose-commands clj-protocol-test test/basics.yaml
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
"description": "clj-protocol - Declarative protocol library",
"repository": "https://github.com/LonoCloud/clj-protocol",
"license": "SEE LICENSE IN LICENSE",
"devDependencies": {
"shadow-cljs": "2.14.4"
},
"dependencies": {
"ffi-napi": "^4.0.3",
"fs-extra": "^3.0.1",
Expand All @@ -16,5 +13,9 @@
"pcap": "3.1.0",
"raw-socket": "1.7.0",
"ref-napi": "^3.0.3"
},
"devDependencies": {
"shadow-cljs": "2.14.4",
"@lonocloud/dctest": "0.1.1"
}
}
71 changes: 71 additions & 0 deletions test/basics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: "Basic tests (DHCP, ping, mac2ip)"

env:
DC: "${{ process.env.DOCKER_COMPOSE || 'docker compose' }}"

tests:
dhcp:
name: "DHCP test"
env:
COMPOSE_PROFILES: dhcp
steps:
- exec: :host
run: |
${DC} down --remove-orphans --volumes -t1
${DC} up -d --force-recreate
- exec: :host
run: |
echo "Waiting for compose startup"
${DC} logs net | grep "Creating veth"
repeat: { retries: 30, interval: '2s' }

- exec: :host
run: '[ $(${DC} logs | grep "client.*ACK from" | wc -l) -ge 4 ]'
repeat: { retries: 30, interval: '2s' }

- exec: :host
run: ${DC} down --remove-orphans --volumes -t1

ping:
name: "ping test"
env:
COMPOSE_PROFILES: ping
steps:
- exec: :host
run: |
${DC} down --remove-orphans --volumes -t1
${DC} up -d --force-recreate
- exec: :host
run: |
echo "Waiting for compose startup"
${DC} logs net | grep "Creating veth"
repeat: { retries: 30, interval: '2s' }

- exec: :host
run: '[ $(${DC} logs | grep "echo-reply" | wc -l) -ge 2 ]'
repeat: { retries: 30, interval: '2s' }

- exec: :host
run: ${DC} down --remove-orphans --volumes -t1

mac2ip:
name: "mac2ipi test"
env:
COMPOSE_PROFILES: mac2ip
steps:
- exec: :host
run: |
${DC} down --remove-orphans --volumes -t1
${DC} up -d --force-recreate
- exec: :host
run: |
echo "Waiting for compose startup"
${DC} logs net | grep "Creating veth"
repeat: { retries: 30, interval: '2s' }

- exec: :host
run: '[ $(${DC} logs | grep -o "worker-.*ACK to" | sort | uniq | wc -l) -ge 2 ]'
repeat: { retries: 30, interval: '2s' }

- exec: :host
run: ${DC} down --remove-orphans --volumes -t1

0 comments on commit fb21eac

Please sign in to comment.