forked from golemcloud/golem
-
Notifications
You must be signed in to change notification settings - Fork 0
206 lines (180 loc) · 6.52 KB
/
python-api-client-tests.yaml
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: Python API Client Tests
on:
push:
paths:
- 'tests/api_client_test.py'
- 'tests/requirements.txt'
- '.github/workflows/python-api-client-tests.yaml'
- 'golem-worker-service-base/src/gateway_api_definition/http/**'
pull_request:
paths:
- 'tests/api_client_test.py'
- 'tests/requirements.txt'
- '.github/workflows/python-api-client-tests.yaml'
- 'golem-worker-service-base/src/gateway_api_definition/http/**'
env:
CARGO_TERM_COLOR: always
RUST_LOG: debug
RUST_PORT: 8001
PROTOC_VERSION: 21.12
# Database Configuration
POSTGRES_DB: golem_db
POSTGRES_USER: golem_user
POSTGRES_PASSWORD: golem_password
POSTGRES_PORT: 5432
# Redis Configuration
REDIS_PORT: 6380
REDIS_URL: redis://localhost:6380
# Golem Service Ports
GOLEM_ROUTER_PORT: 9881
WORKER_SERVICE_HTTP_PORT: 9005
WORKER_SERVICE_GRPC_PORT: 9007
WORKER_SERVICE_CUSTOM_REQUEST_PORT: 9006
COMPONENT_SERVICE_HTTP_PORT: 8083
COMPONENT_SERVICE_GRPC_PORT: 9090
SHARD_MANAGER_HTTP_PORT: 8081
SHARD_MANAGER_GRPC_PORT: 9002
COMPONENT_COMPILATION_SERVICE_HTTP_PORT: 8084
COMPONENT_COMPILATION_SERVICE_GRPC_PORT: 9091
WORKER_EXECUTOR_HTTP_PORT: 8082
WORKER_EXECUTOR_GRPC_PORT: 9000
# Additional Golem Configuration
GOLEM_ROUTER_COMPONENT_MAX_SIZE_ALLOWED: 1g
ENVIRONMENT: local
jobs:
python-api-tests:
name: Run Python API Client Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: golem_db
POSTGRES_USER: golem_user
POSTGRES_PASSWORD: golem_password
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:latest
ports:
- 6380:6380
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install Protocol Buffers Compiler
run: |
PB_REL="https://github.com/protocolbuffers/protobuf/releases"
curl -LO $PB_REL/download/v${{ env.PROTOC_VERSION }}/protoc-${{ env.PROTOC_VERSION }}-linux-x86_64.zip
unzip protoc-${{ env.PROTOC_VERSION }}-linux-x86_64.zip -d $HOME/.local
echo "$HOME/.local/bin" >> $GITHUB_PATH
protoc --version
- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
source "$HOME/.cargo/env"
rustup install stable
rustup default stable
rustup component add rustfmt clippy
cargo --version
rustc --version
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "python-api-tests"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r tests/requirements.txt
- name: Build Golem CLI
run: |
cargo build --bin golem-cli
- name: Initialize Golem Configuration
run: |
# Install expect
sudo apt-get update && sudo apt-get install -y expect
echo "Expect installation completed"
# Create .env file with custom configuration
cat << EOF > .env
GOLEM_ROUTER_PORT=${{ env.GOLEM_ROUTER_PORT }}
POSTGRES_DB=${{ env.POSTGRES_DB }}
POSTGRES_USER=${{ env.POSTGRES_USER }}
POSTGRES_PASSWORD=${{ env.POSTGRES_PASSWORD }}
POSTGRES_PORT=${{ env.POSTGRES_PORT }}
REDIS_PORT=${{ env.REDIS_PORT }}
REDIS_URL=${{ env.REDIS_URL }}
WORKER_SERVICE_HTTP_PORT=${{ env.WORKER_SERVICE_HTTP_PORT }}
WORKER_SERVICE_GRPC_PORT=${{ env.WORKER_SERVICE_GRPC_PORT }}
WORKER_SERVICE_CUSTOM_REQUEST_PORT=${{ env.WORKER_SERVICE_CUSTOM_REQUEST_PORT }}
COMPONENT_SERVICE_HTTP_PORT=${{ env.COMPONENT_SERVICE_HTTP_PORT }}
COMPONENT_SERVICE_GRPC_PORT=${{ env.COMPONENT_SERVICE_GRPC_PORT }}
SHARD_MANAGER_HTTP_PORT=${{ env.SHARD_MANAGER_HTTP_PORT }}
SHARD_MANAGER_GRPC_PORT=${{ env.SHARD_MANAGER_GRPC_PORT }}
COMPONENT_COMPILATION_SERVICE_HTTP_PORT=${{ env.COMPONENT_COMPILATION_SERVICE_HTTP_PORT }}
COMPONENT_COMPILATION_SERVICE_GRPC_PORT=${{ env.COMPONENT_COMPILATION_SERVICE_GRPC_PORT }}
WORKER_EXECUTOR_HTTP_PORT=${{ env.WORKER_EXECUTOR_HTTP_PORT }}
WORKER_EXECUTOR_GRPC_PORT=${{ env.WORKER_EXECUTOR_GRPC_PORT }}
GOLEM_ROUTER_COMPONENT_MAX_SIZE_ALLOWED=${{ env.GOLEM_ROUTER_COMPONENT_MAX_SIZE_ALLOWED }}
EOF
echo ".env file created"
# Create expect script
cat << 'EOF' > init.exp
#!/usr/bin/expect -f
set timeout -1
# Enable verbose logging
exp_internal 1
spawn cargo run --bin golem-cli init
# Select default option whenever there's a choice
expect {
"*\[↑↓ to move, enter to select, type to filter\]*" {
send "\r"
exp_continue
}
"Select database type:" {
send "2\r"
exp_continue
}
"Default output format:" {
send "\r"
exp_continue
}
eof
}
EOF
echo "expect script created"
# Make expect script executable and run it
chmod +x init.exp
echo "Running expect script..."
./init.exp
echo "Expect script completed"
- name: Start Golem Server
run: |
# Start the server in the background
cargo run --bin golem-cli start &
# Wait for the server to be ready
echo "Waiting for Rust server to be ready..."
timeout 30 bash -c 'until curl -s http://localhost:${{ env.RUST_PORT }}/health > /dev/null 2>&1; do sleep 1; done'
- name: Run Python Tests
run: |
python tests/api_client_test.py --rust-port ${{ env.RUST_PORT }}
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: test-output/