Skip to content

Commit 32c09c3

Browse files
feat(ci): nightly checks with connectivity recovery test (#1471)
Resolves #1465 --------- Co-authored-by: Ryan Schumacher <[email protected]>
1 parent 54de8f4 commit 32c09c3

File tree

3 files changed

+118
-0
lines changed

3 files changed

+118
-0
lines changed

.github/scripts/connectivity-test.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
3+
# Randomly drop db connections to test CLI connectivity for 15 minutes total
4+
start_time=$(date +%s)
5+
postgresql_container_id=$(docker ps --filter "name=platform-opentdfdb-1" -q)
6+
7+
resource_subcommands=("attributes" "attributes namespaces" "subject-mappings" "resource-mappings" "kas-registry")
8+
9+
while true; do
10+
# Randomly wait before running the connectivity test (between 1 and 10 seconds)
11+
sleep $((RANDOM % 10 + 1))
12+
13+
echo "Restarting PostgreSQL container..."
14+
docker restart $postgresql_container_id
15+
16+
# Determine how many random otdfctl commands to run after the restart
17+
num_runs=$((RANDOM % 5 + 1)) # Randomly choose to run between 1 and 5 times
18+
19+
for ((i=0; i<num_runs; i++)); do
20+
random_subcommand=${resource_subcommands[$RANDOM % ${#resource_subcommands[@]}]}
21+
22+
# Introduce random delay before each execution (between 1 and 4 seconds)
23+
sleep $((RANDOM % 4 + 1))
24+
25+
echo "Running randomly selected command './otdfctl policy $random_subcommand list...'"
26+
result=$(./otdfctl policy $random_subcommand list --with-client-creds '{"clientId":"opentdf","clientSecret":"secret"}' --host http://localhost:8080 | grep -i "success")
27+
echo $result
28+
if [ -z "$result" ]; then
29+
echo "Failure: 'success' not found in output; CLI failed."
30+
exit 1
31+
fi
32+
done
33+
# Exit if 15 minutes have passed (900 seconds)
34+
current_time=$(date +%s)
35+
elapsed_time=$((current_time - start_time))
36+
37+
if [ $elapsed_time -ge 120 ]; then
38+
# if [ $elapsed_time -ge 900 ]; then
39+
exit 0
40+
fi
41+
done

.github/workflows/checks.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ on:
1717
- main
1818
types:
1919
- checks_requested
20+
workflow_call:
2021

2122
jobs:
2223
go:

.github/workflows/nightly-checks.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: 'Nightly Checks'
2+
3+
on:
4+
schedule:
5+
# Run at 12:15 AM UTC (Scheduled actions are not guaranteed during times of high load like the top of the
6+
# hour or 00:00. See discussion: https://github.com/orgs/community/discussions/27130)
7+
- cron: '15 0 * * *'
8+
9+
jobs:
10+
db-flakiness-recovery:
11+
runs-on: ubuntu-22.04
12+
permissions:
13+
contents: read
14+
steps:
15+
######## CHECKOUT/SETUP PLATFORM #############
16+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
17+
with:
18+
fetch-depth: 0
19+
path: platform
20+
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7
21+
with:
22+
go-version-file: 'platform/service/go.mod'
23+
check-latest: false
24+
cache-dependency-path: |
25+
platform/examples/go.sum
26+
platform/protocol/go/go.sum
27+
platform/sdk/go.sum
28+
platform/service/go.sum
29+
######## SPIN UP PLATFORM/BACKEND #############
30+
- run: |
31+
./.github/scripts/init-temp-keys.sh
32+
cp opentdf-dev.yaml opentdf.yaml
33+
working-directory: platform
34+
- name: Added Trusted Certs
35+
run: |
36+
sudo chmod -R 777 ./keys
37+
sudo apt-get install -y ca-certificates
38+
sudo cp ./keys/localhost.crt /usr/local/share/ca-certificates
39+
sudo update-ca-certificates
40+
working-directory: platform
41+
- run: docker compose up -d --wait --wait-timeout 240
42+
working-directory: platform
43+
- run: go run ./service provision keycloak
44+
working-directory: platform
45+
- run: go run ./service provision fixtures
46+
working-directory: platform
47+
- uses: JarvusInnovations/background-action@2428e7b970a846423095c79d43f759abf979a635
48+
name: start server in background
49+
with:
50+
run: >
51+
go build -o opentdf -v service/main.go
52+
&& .github/scripts/watch.sh opentdf.yaml ./opentdf start
53+
wait-on: |
54+
tcp:localhost:8080
55+
log-output-if: true
56+
wait-for: 90s
57+
working-directory: platform
58+
59+
######## CHECKOUT/BUILD 'otdfctl' #############
60+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
61+
with:
62+
repository: opentdf/otdfctl
63+
ref: main
64+
fetch-depth: 0
65+
path: otdfctl
66+
- run: go build -o otdfctl
67+
working-directory: otdfctl
68+
- run: cp otdfctl ../platform
69+
working-directory: otdfctl
70+
71+
######## RUN TESTS #############
72+
- run: ./.github/scripts/connectivity-test.sh
73+
name: Flaky Connectivity Test
74+
working-directory: platform
75+
ci-checks:
76+
uses: opentdf/platform/.github/workflows/checks.yaml@main

0 commit comments

Comments
 (0)