Skip to content

Commit 3ae6f98

Browse files
authored
Merge pull request #1393 from input-output-hk/artur/docker_sync_checks
Add db-sync docker sync tests
2 parents 6029526 + b82456b commit 3ae6f98

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed

Diff for: .github/workflows/db_sync_docker_sync_test.yaml

+140
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
name: db-sync docker sync check
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
db_sync_branch:
7+
description: cardano-db-sync branch that will be used
8+
required: true
9+
default: "13.0.5-extra-args"
10+
11+
jobs:
12+
setup_and_start_db_sync:
13+
strategy:
14+
matrix:
15+
os: [ubuntu-latest]
16+
env: [mainnet, preprod, preview]
17+
fail-fast: false
18+
runs-on: ${{ matrix.os }}
19+
timeout-minutes: 60
20+
steps:
21+
22+
- name: Checkout cardano-db-sync Repository
23+
uses: actions/checkout@v2
24+
with:
25+
repository: input-output-hk/cardano-db-sync
26+
path: cardano-db-sync
27+
ref: ${{ github.event.inputs.db_sync_branch }}
28+
29+
- name: Start docker-compose WITHOUT flags
30+
run: |
31+
cd cardano-db-sync
32+
echo "DB_SYNC_REVISION=$(git rev-parse --short=40 HEAD)" >> $GITHUB_ENV
33+
echo "DB_SYNC_VERSION=$(echo ${{ inputs.db_sync_branch }} | grep -oE "(\w*[.]\w*)*")" >> $GITHUB_ENV
34+
sudo NETWORK=${{ matrix.env }} docker-compose up -d
35+
36+
- name: Wait for 60 seconds
37+
run: |
38+
echo "Waiting 60 seconds for startup"
39+
sleep 60
40+
41+
- name: Print db-sync Logs
42+
run: |
43+
cd cardano-db-sync
44+
echo "db-sync logs:"
45+
sudo docker-compose logs cardano-db-sync | tee db_sync_no_flags_logs.txt
46+
47+
- name: Network Check
48+
run: |
49+
cd cardano-db-sync
50+
if grep -i ${{ matrix.env }} "db_sync_no_flags_logs.txt"; then echo "Connected to correct network"; else echo "WRONG or NO NETWORK found !" && exit 1; fi
51+
52+
- name: Version and Revision Check
53+
run: |
54+
cd cardano-db-sync
55+
if grep -i ${{ env.DB_SYNC_VERSION }} "db_sync_no_flags_logs.txt"; then echo "Correct version"; else echo "WRONG Version !" && exit 1; fi
56+
if grep -i ${{ env.DB_SYNC_REVISION }} "db_sync_no_flags_logs.txt"; then echo "Correct SHA"; else echo "WRONG SHA !" && exit 1; fi
57+
58+
- name: Flags Check - Should be False
59+
run: |
60+
cd cardano-db-sync
61+
if grep -i "Option disable-ledger: False" "db_sync_no_flags_logs.txt"; then echo "Flag disable-ledger set to False"; else echo "disable-ledger = True !" && exit 1; fi
62+
if grep -i "Option disable-cache: False" "db_sync_no_flags_logs.txt"; then echo "Flag disable-cache set to False"; else echo "disable-cache = True !" && exit 1; fi
63+
if grep -i "Option disable-epoch: False" "db_sync_no_flags_logs.txt"; then echo "Flag disable-epoch set to False"; else echo "disable-epoch = True !" && exit 1; fi
64+
65+
- name: Errors Check
66+
run: |
67+
cd cardano-db-sync
68+
if grep -i Error "db_sync_no_flags_logs.txt"; then echo "Found Error(s) !" && exit 1; fi
69+
70+
- name: Blocks Insertion Check
71+
run: |
72+
cd cardano-db-sync
73+
if grep -i epochPluginInsertBlockDetails "db_sync_no_flags_logs.txt"; then echo "Blocks inserted into DB"; else echo "NO block insertion !" && exit 1; fi
74+
75+
- name: Cache Statistics Check
76+
run: |
77+
cd cardano-db-sync
78+
if grep -i "Cache Statistics" "db_sync_no_flags_logs.txt"; then echo "Cache Statistics present"; else echo "NO Cache Statistics !" && exit 1; fi
79+
80+
- name: Shut down docker-compose and remove volumes
81+
run: |
82+
cd cardano-db-sync
83+
sudo docker-compose down -v
84+
85+
- name: Wait for 10 seconds
86+
run: |
87+
echo "Waiting 10 seconds for startup"
88+
sleep 10
89+
90+
- name: Start docker-compose WITH flags
91+
run: |
92+
cd cardano-db-sync
93+
sudo NETWORK=${{ matrix.env }} EXTRA_DB_SYNC_ARGS="--disable-ledger --disable-cache --disable-epoch" docker-compose up -d
94+
95+
- name: Wait for 60 seconds
96+
run: |
97+
echo "Waiting 60 seconds for startup"
98+
sleep 60
99+
100+
- name: Print db-sync Logs
101+
run: |
102+
cd cardano-db-sync
103+
echo "db-sync logs:"
104+
sudo docker-compose logs cardano-db-sync | tee db_sync_flags_logs.txt
105+
106+
- name: Errors Check
107+
run: |
108+
cd cardano-db-sync
109+
if grep -i Error "db_sync_flags_logs.txt"; then echo "Found Error(s) !" && exit 1; fi
110+
111+
- name: Epoch Plugin Check - Should be Gone
112+
run: |
113+
cd cardano-db-sync
114+
if grep -i epochPluginInsertBlockDetails "db_sync_flags_logs.txt"; then echo "Epoch Plugin should be blocked !" && exit 1; fi
115+
116+
- name: Cache Statistics Check - Should be Gone
117+
run: |
118+
cd cardano-db-sync
119+
if grep -i "Cache Statistics" "db_sync_flags_logs.txt"; then echo "Error - Found Cache Statistics !" && exit 1; fi
120+
121+
- name: Block Insertion Check
122+
run: |
123+
cd cardano-db-sync
124+
if grep -i insert "db_sync_flags_logs.txt"; then echo "Blocks inserted into DB"; else echo "NO block insertion !" && exit 1; fi
125+
126+
- name: Flags Check - Should be True
127+
run: |
128+
cd cardano-db-sync
129+
if grep -i "Option disable-ledger: True" "db_sync_flags_logs.txt"; then echo "Flag disable-ledger set to True"; else echo "disable-ledger = False !" && exit 1; fi
130+
if grep -i "Option disable-cache: True" "db_sync_flags_logs.txt"; then echo "Flag disable-cache set to True"; else echo "disable-cache = False !" && exit 1; fi
131+
if grep -i "Option disable-epoch: True" "db_sync_flags_logs.txt"; then echo "Flag disable-epoch set to True"; else echo "disable-epoch = False !" && exit 1; fi
132+
133+
- name: Upload Logs
134+
uses: actions/upload-artifact@v3
135+
with:
136+
name: ${{ matrix.env }}-db-sync-logs
137+
path: |
138+
cardano-db-sync/db_sync_no_flags_logs.txt
139+
cardano-db-sync/db_sync_flags_logs.txt
140+
retention-days: 5

0 commit comments

Comments
 (0)