Skip to content

Commit 1be1d70

Browse files
committed
WIP
1 parent ff5ac8d commit 1be1d70

File tree

4 files changed

+218
-9
lines changed

4 files changed

+218
-9
lines changed

.devcontainer/docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ services:
5959
profiles:
6060
- e2e
6161
env_file: [".env"]
62+
healthcheck:
63+
test: ["CMD", "curl", "-f", "http://localhost:4000/health"]
64+
interval: 10s
65+
timeout: 5s
66+
retries: 5
67+
start_period: 30s
6268

6369
sentry-svelte-mini:
6470
build:
@@ -80,6 +86,12 @@ services:
8086
profiles:
8187
- e2e
8288
env_file: [".env"]
89+
healthcheck:
90+
test: ["CMD", "curl", "-f", "http://localhost:4001/health"]
91+
interval: 10s
92+
timeout: 5s
93+
retries: 5
94+
start_period: 30s
8395

8496
redis:
8597
image: redis:latest

.devcontainer/entrypoint-rails-mini.sh

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,40 @@
22

33
set -e
44

5+
echo "=== Rails Mini Container Starting ==="
6+
echo "Timestamp: $(date)"
7+
echo "Working directory: $(pwd)"
8+
echo "User: $(whoami)"
9+
echo "Ruby version: $(ruby --version)"
10+
11+
echo "=== Environment Variables ==="
12+
echo "PORT: ${PORT:-not set}"
13+
echo "SENTRY_DSN: ${SENTRY_DSN:-not set}"
14+
echo "SENTRY_E2E_RAILS_APP_PORT: ${SENTRY_E2E_RAILS_APP_PORT:-not set}"
15+
echo "RAILS_ENV: ${RAILS_ENV:-not set}"
16+
17+
echo "=== Setting up log directory permissions ==="
518
sudo chown -R sentry:sentry /workspace/sentry/log
19+
ls -la /workspace/sentry/log/
620

21+
echo "=== Changing to Rails mini directory ==="
722
cd /workspace/sentry/spec/apps/rails-mini
23+
echo "Current directory: $(pwd)"
24+
ls -la
25+
26+
echo "=== Installing Ruby dependencies for Rails mini ==="
27+
bundle install --verbose
28+
29+
echo "=== Checking if Gemfile.lock exists ==="
30+
if [ -f "Gemfile.lock" ]; then
31+
echo "✅ Gemfile.lock found"
32+
echo "Bundled gems:"
33+
bundle list
34+
else
35+
echo "❌ Gemfile.lock not found"
36+
fi
837

9-
echo "Installing Ruby dependencies for Rails mini..."
10-
bundle install
38+
echo "=== About to execute command: $@ ==="
39+
echo "=== Rails Mini Container Setup Complete ==="
1140

1241
exec "$@"

.github/workflows/e2e_tests.yml

Lines changed: 89 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,37 +35,122 @@ jobs:
3535
run: |
3636
cd .devcontainer
3737
source .env
38+
echo "=== Environment variables ==="
39+
echo "SENTRY_E2E_RAILS_APP_PORT: ${SENTRY_E2E_RAILS_APP_PORT}"
40+
echo "SENTRY_DSN: ${SENTRY_DSN}"
41+
echo "=== Starting Rails mini app ==="
3842
docker compose --profile e2e up -d sentry-rails-mini
43+
echo "=== Checking container status ==="
44+
docker compose --profile e2e ps
45+
echo "=== Rails mini app logs ==="
46+
docker compose --profile e2e logs sentry-rails-mini
3947
4048
- name: Start mini svelte app
4149
run: |
4250
cd .devcontainer
4351
source .env
52+
echo "=== Starting Svelte mini app ==="
4453
docker compose --profile e2e up -d sentry-svelte-mini
54+
echo "=== Checking container status ==="
55+
docker compose --profile e2e ps
56+
echo "=== Svelte mini app logs ==="
57+
docker compose --profile e2e logs sentry-svelte-mini
4558
4659
- name: Wait for services to be healthy
4760
run: |
4861
cd .devcontainer
4962
source .env
5063
64+
echo "=== Debugging container status ==="
65+
docker compose --profile e2e ps
66+
echo "=== Checking port bindings ==="
67+
docker compose --profile e2e port sentry-rails-mini 4000 || echo "Rails port binding failed"
68+
docker compose --profile e2e port sentry-svelte-mini 4001 || echo "Svelte port binding failed"
69+
70+
echo "=== Latest container logs ==="
71+
echo "Rails mini logs:"
72+
docker compose --profile e2e logs --tail=50 sentry-rails-mini
73+
echo "Svelte mini logs:"
74+
docker compose --profile e2e logs --tail=50 sentry-svelte-mini
75+
76+
echo "=== Waiting for Docker health checks ==="
77+
timeout 120 bash -c "
78+
while true; do
79+
rails_health=\$(docker compose --profile e2e ps --format json sentry-rails-mini | jq -r '.[0].Health // \"none\"')
80+
svelte_health=\$(docker compose --profile e2e ps --format json sentry-svelte-mini | jq -r '.[0].Health // \"none\"')
81+
echo \"Rails health: \$rails_health, Svelte health: \$svelte_health\"
82+
83+
if [[ \"\$rails_health\" == \"healthy\" && \"\$svelte_health\" == \"healthy\" ]]; then
84+
echo \"Both containers are healthy!\"
85+
break
86+
fi
87+
88+
if [[ \"\$rails_health\" == \"unhealthy\" || \"\$svelte_health\" == \"unhealthy\" ]]; then
89+
echo \"One or more containers are unhealthy\"
90+
docker compose --profile e2e ps
91+
docker compose --profile e2e logs sentry-rails-mini
92+
docker compose --profile e2e logs sentry-svelte-mini
93+
exit 1
94+
fi
95+
96+
sleep 5
97+
done
98+
"
99+
51100
echo "Waiting for Rails mini app to be ready on port ${SENTRY_E2E_RAILS_APP_PORT}..."
52-
timeout 60 bash -c "until curl -s http://localhost:${SENTRY_E2E_RAILS_APP_PORT}/health | grep -q 'ok'; do echo 'Waiting for Rails app...'; sleep 2; done"
101+
timeout 60 bash -c "
102+
while true; do
103+
echo 'Attempting to connect to Rails app...'
104+
response=\$(curl -s http://localhost:${SENTRY_E2E_RAILS_APP_PORT}/health || echo 'connection_failed')
105+
echo \"Response: \$response\"
106+
if echo \"\$response\" | grep -q 'ok'; then
107+
echo 'Rails app responded with ok'
108+
break
109+
fi
110+
echo 'Waiting 2 seconds...'
111+
sleep 2
112+
done
113+
"
53114
echo "✅ Rails mini app is ready"
54115
55116
echo "Waiting for Svelte mini app to be ready on port ${SENTRY_E2E_SVELTE_APP_PORT}..."
56-
timeout 60 bash -c "until curl -s http://localhost:${SENTRY_E2E_SVELTE_APP_PORT}/health | grep -q 'ok'; do echo 'Waiting for Svelte app...'; sleep 2; done"
117+
timeout 60 bash -c "
118+
while true; do
119+
echo 'Attempting to connect to Svelte app...'
120+
response=\$(curl -s http://localhost:${SENTRY_E2E_SVELTE_APP_PORT}/health || echo 'connection_failed')
121+
echo \"Response: \$response\"
122+
if echo \"\$response\" | grep -q 'ok'; then
123+
echo 'Svelte app responded with ok'
124+
break
125+
fi
126+
echo 'Waiting 2 seconds...'
127+
sleep 2
128+
done
129+
"
57130
echo "✅ Svelte mini app is ready"
58131
59132
echo "All services are healthy!"
60133
134+
- name: Final status check before tests
135+
run: |
136+
cd .devcontainer
137+
source .env
138+
echo "=== Final container status ==="
139+
docker compose --profile e2e ps
140+
echo "=== Final logs check ==="
141+
echo "Rails mini logs:"
142+
docker compose --profile e2e logs --tail=20 sentry-rails-mini
143+
echo "Svelte mini logs:"
144+
docker compose --profile e2e logs --tail=20 sentry-svelte-mini
145+
61146
- name: Run e2e tests
62147
run: |
63148
cd .devcontainer
64149
source .env
65150
docker compose --profile e2e run --rm sentry-test bundle exec rake
66151
env:
67-
SENTRY_E2E_RAILS_APP_URL: http://sentry-rails-mini:5000
68-
SENTRY_E2E_SVELTE_APP_URL: http://sentry-svelte-mini:5001
152+
SENTRY_E2E_RAILS_APP_URL: http://sentry-rails-mini:4000
153+
SENTRY_E2E_SVELTE_APP_URL: http://sentry-svelte-mini:4001
69154

70155
- name: Stop e2e services
71156
if: always()

spec/apps/rails-mini/app.rb

Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,26 @@ class EventsController < ActionController::Base
8484
before_action :set_cors_headers
8585

8686
def health
87-
render json: {
87+
puts "=== Health check requested at #{Time.now.utc.iso8601} ==="
88+
89+
health_data = {
8890
status: "ok",
8991
timestamp: Time.now.utc.iso8601,
9092
sentry_initialized: Sentry.initialized?,
91-
log_file_writable: check_log_file_writable
93+
log_file_writable: check_log_file_writable,
94+
environment: {
95+
rails_env: ENV['RAILS_ENV'],
96+
port: ENV['PORT'],
97+
sentry_dsn_set: !ENV['SENTRY_DSN'].nil? && !ENV['SENTRY_DSN'].empty?
98+
},
99+
process: {
100+
pid: Process.pid,
101+
working_directory: Dir.pwd
102+
}
92103
}
104+
105+
puts "Health data: #{health_data.to_json}"
106+
render json: health_data
93107
end
94108

95109
def trace_headers
@@ -136,6 +150,75 @@ def set_cors_headers
136150
require "rack"
137151
require "rack/handler/puma"
138152

153+
puts "=== Rails Mini App Starting ==="
154+
puts "Timestamp: #{Time.now.utc.iso8601}"
155+
puts "Ruby version: #{RUBY_VERSION}"
156+
puts "Rails version: #{Rails::VERSION::STRING}"
157+
puts "Working directory: #{Dir.pwd}"
158+
159+
puts "=== Environment Check ==="
160+
puts "RAILS_ENV: #{ENV['RAILS_ENV']}"
161+
puts "PORT: #{ENV['PORT'] || 'not set (will default to 4000)'}"
162+
puts "SENTRY_DSN: #{ENV['SENTRY_DSN'] ? 'set' : 'NOT SET'}"
163+
puts "SENTRY_E2E_RAILS_APP_PORT: #{ENV['SENTRY_E2E_RAILS_APP_PORT'] || 'not set'}"
164+
165+
puts "=== Sentry Configuration Check ==="
166+
puts "Sentry initialized: #{Sentry.initialized?}"
167+
if Sentry.initialized?
168+
puts "Sentry DSN configured: #{Sentry.configuration.dsn ? 'yes' : 'no'}"
169+
puts "Sentry debug mode: #{Sentry.configuration.debug}"
170+
end
171+
172+
puts "=== Log File Check ==="
173+
log_file_path = "/workspace/sentry/log/sentry_debug_events.log"
174+
puts "Log file path: #{log_file_path}"
175+
puts "Log file exists: #{File.exist?(log_file_path)}"
176+
puts "Log file writable: #{File.writable?(File.dirname(log_file_path))}"
177+
139178
port = ENV.fetch("PORT", "4000").to_i
140-
Rack::Handler::Puma.run(RailsMiniApp, Host: "0.0.0.0", Port: port)
179+
puts "=== Starting Puma Server ==="
180+
puts "Host: 0.0.0.0"
181+
puts "Port: #{port}"
182+
puts "=== Server starting... ==="
183+
184+
begin
185+
# Configure Puma with more verbose output
186+
puma_config = {
187+
Host: "0.0.0.0",
188+
Port: port,
189+
Verbose: true,
190+
Silent: false
191+
}
192+
193+
puts "Puma configuration: #{puma_config}"
194+
puts "=== Puma is starting up... ==="
195+
196+
# Add a callback to log when server is ready
197+
server_thread = Thread.new do
198+
Rack::Handler::Puma.run(RailsMiniApp, puma_config)
199+
end
200+
201+
# Give the server a moment to start, then test the health endpoint
202+
sleep 2
203+
puts "=== Testing server readiness ==="
204+
begin
205+
require 'net/http'
206+
uri = URI("http://localhost:#{port}/health")
207+
response = Net::HTTP.get_response(uri)
208+
puts "Health check response: #{response.code} - #{response.body}"
209+
puts "=== Server is ready and responding! ==="
210+
rescue => health_error
211+
puts "Health check failed (server may still be starting): #{health_error.message}"
212+
end
213+
214+
# Wait for the server thread
215+
server_thread.join
216+
217+
rescue => e
218+
puts "=== ERROR: Failed to start server ==="
219+
puts "Error: #{e.class}: #{e.message}"
220+
puts "Backtrace:"
221+
puts e.backtrace.join("\n")
222+
exit(1)
223+
end
141224
end

0 commit comments

Comments
 (0)