forked from datazip-inc/olake
-
Notifications
You must be signed in to change notification settings - Fork 0
149 lines (127 loc) · 5.25 KB
/
performance-test.yml
File metadata and controls
149 lines (127 loc) · 5.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Performance Tests
on:
push:
branches:
- "staging"
paths:
- '**/*.go'
- '**/*.java'
permissions:
actions: read
id-token: write
contents: read
jobs:
performance-tests:
environment: Performance Testing
runs-on: ubuntu-latest
strategy:
matrix:
include:
- driver: mysql
driver_upper: MYSQL
- driver: postgres
driver_upper: POSTGRES
# TODO: add benchmark tests for the below databases
# - driver: mongodb
# driver_upper: MONGODB
# - driver: oracle
# driver_upper: ORACLE
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.24.2'
- name: Set up Java for Maven
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Setup VPN Client
if: matrix.driver != 'oracle'
run: |
sudo apt-get update -qq && sudo apt-get install -y openvpn iproute2 iputils-ping netcat-openbsd telnet
sudo mkdir -p /etc/openvpn/client && sudo chmod 700 /etc/openvpn/client
echo "${{ secrets[format('{0}_OPENVPN_CONFIG', matrix.driver_upper)] }}" | base64 --decode | sudo tee /etc/openvpn/client/client.ovpn > /dev/null
echo "${{ secrets.OPENVPN_USERNAME }}" | sudo tee /etc/openvpn/client/auth.txt > /dev/null
sudo chmod 600 /etc/openvpn/client/client.ovpn /etc/openvpn/client/auth.txt
sudo chown root:root /etc/openvpn/client/client.ovpn /etc/openvpn/client/auth.txt
sudo openvpn --config /etc/openvpn/client/client.ovpn --daemon ovpn-client --log /var/log/openvpn-client.log --verb 3
echo "Establishing VPN connection..."
for i in {1..30}; do
if ip addr show | grep -q "tun0\|tap0"; then echo "✅ VPN connected"; break; fi
[ $i -eq 30 ] && { echo "❌ VPN timeout"; sudo cat /var/log/openvpn-client.log; exit 1; }
sleep 2
done
sudo resolvectl dns tun0 ${{ secrets.VPN_DNS_SERVER }}
sudo resolvectl domain tun0 ~private.postgres.database.azure.com
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-session-name: performance_test_gh
role-to-assume: ${{ secrets.AWS_GITHUB_ROLE }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Install Go Dependencies
run: go mod download
- name: Build Project
run: go build -v ./...
- name: Build Iceberg Sink
working-directory: ./destination/iceberg/olake-iceberg-java-writer
run: mvn clean package -DskipTests
- name: Create source
run: |
echo '${{ secrets[format('{0}_SOURCE_JSON', matrix.driver_upper)] }}' | base64 --decode > ./drivers/${{ matrix.driver }}/internal/testdata/source.json
- name: Create destination
run: |
echo '${{ secrets[format('{0}_DESTINATION_JSON', matrix.driver_upper)] }}' | base64 --decode > ./drivers/${{ matrix.driver }}/internal/testdata/destination.json
- name: Get Last Successful Run ID
id: last_run
env:
GH_TOKEN: ${{ github.token }}
run: |
PREVIOUS_ID=$(gh run list --workflow ".github/workflows/performance-test.yml" --branch "staging" --status success --limit 1 --json databaseId --jq '.[0].databaseId')
if [ -n "$PREVIOUS_ID" ]; then
echo "id=$PREVIOUS_ID" >> $GITHUB_OUTPUT
fi
- name: Download Benchmarks History
if: steps.last_run.outputs.id != ''
uses: actions/download-artifact@v4
continue-on-error: true
with:
name: benchmarks_${{ matrix.driver }}
path: ./drivers/${{ matrix.driver }}/internal/testdata/
run-id: ${{ steps.last_run.outputs.id }}
github-token: ${{ github.token }}
- name: Run Performance Tests
run: go test -v ./drivers/${{ matrix.driver }}/internal/... -timeout 0 -run 'Performance'
- name: Upload Benchmarks History
uses: actions/upload-artifact@v4
if: success()
continue-on-error: true
with:
name: benchmarks_${{ matrix.driver }}
path: ./drivers/${{ matrix.driver }}/internal/testdata/benchmarks.json
retention-days: 90
- name: Cleanup
if: always()
run: |
# Delete all Glue databases matching prefix
for db in $(aws glue get-databases \
--query "DatabaseList[?starts_with(Name, 'performance_${{ matrix.driver }}')].Name" \
--output text); do
echo "Deleting Glue database: $db"
aws glue delete-database --name "$db" \
|| echo "Failed to delete Glue database: $db"
done
# Delete corresponding S3 path
aws s3 rm s3://dz-stag-github-actions/performance_${{ matrix.driver }}/ --recursive \
|| { echo "Failed to delete S3 bucket: performance_${{ matrix.driver }}"; \
aws s3 ls s3://dz-stag-github-actions/performance_${{ matrix.driver }} || true; }
echo "Catalog cleanup completed"
if [[ "${{ matrix.driver }}" != "oracle" ]]; then
sudo pkill -f "openvpn.*client.ovpn" || true
sudo rm -rf /etc/openvpn/client/ /var/log/openvpn-client.log || true
echo "VPN cleanup completed"
fi