Skip to content

Commit

Permalink
[ruby] Use healthcheck to get library version #2799 (#3196)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeauchesne authored Oct 9, 2024
1 parent 89e7a5b commit 5cdb5d5
Show file tree
Hide file tree
Showing 29 changed files with 235 additions and 3 deletions.
4 changes: 2 additions & 2 deletions utils/_context/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ def configure(self, replay):
)

# https://github.com/DataDog/system-tests/issues/2799
if self.library in ("dotnet", "nodejs", "python", "golang"):
if self.library in ("dotnet", "nodejs", "python", "golang", "ruby"):
self.healthcheck = {
"test": f"curl --fail --silent --show-error --max-time 2 localhost:{self.port}/healthcheck",
"retries": 60,
Expand Down Expand Up @@ -727,7 +727,7 @@ def post_start(self):

# new way of getting info from the weblog. Only working for nodejs and python right now
# https://github.com/DataDog/system-tests/issues/2799
if self.library in ("dotnet", "nodejs", "python", "golang"):
if self.library in ("dotnet", "nodejs", "python", "golang", "ruby"):
with open(self.healthcheck_log_file, mode="r", encoding="utf-8") as f:
data = json.load(f)
lib = data["library"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ def root
render plain: 'Hello, world!'
end

def healthcheck
render json: {
status: 'ok',
library: {
language: 'ruby',
version: Datadog::VERSION::STRING
}
}
end

def waf
render plain: 'Hello, world!'
end
Expand Down
2 changes: 2 additions & 0 deletions utils/build/docker/ruby/graphql23/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
get '/' => 'system_test#root'
post '/' => 'system_test#root'

get '/healthcheck' => 'system_test#healthcheck'

get '/waf' => 'system_test#waf'
post '/waf' => 'system_test#waf'
get '/waf/*other' => 'system_test#waf'
Expand Down
1 change: 0 additions & 1 deletion utils/build/docker/ruby/install_ddtrace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,3 @@ bundle install
bundle info $GEM_NAME | grep -m 1 $GEM_NAME > SYSTEM_TESTS_LIBRARY_VERSION

echo "dd-trace version: $(cat SYSTEM_TESTS_LIBRARY_VERSION)"

21 changes: 21 additions & 0 deletions utils/build/docker/ruby/rack/config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,25 @@ class Hello
end
end

# /healthcheck
class Healthcheck
def self.run
response = {
status: 'ok',
library: {
language: 'ruby',
version: Datadog::VERSION::STRING
}
}

[
200,
{ 'Content-Type' => 'application/json' },
[response.to_json]
]
end
end

# /spans
class Spans
def self.run(request)
Expand Down Expand Up @@ -216,6 +235,8 @@ app = proc do |env|
# %r{^/params(?:/.*|)$} doesn't really makes sense for Rack as it does not put the
# value anywhere for AppSec to receive it
Hello.run
elsif request.path == '/healthcheck'
Healthcheck.run
elsif request.path == '/spans'
Spans.run(request)
elsif request.path == '/headers'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ def root
render plain: 'Hello, world!'
end

def healthcheck
render json: {
status: 'ok',
library: {
language: 'ruby',
version: Datadog::VERSION::STRING
}
}
end

def waf
render plain: 'Hello, world!'
end
Expand Down
2 changes: 2 additions & 0 deletions utils/build/docker/ruby/rails42/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
get '/' => 'system_test#root'
post '/' => 'system_test#root'

get '/healthcheck' => 'system_test#healthcheck'

get '/waf' => 'system_test#waf'
post '/waf' => 'system_test#waf'
get '/waf/*other' => 'system_test#waf'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ def root
render plain: 'Hello, world!'
end

def healthcheck
render json: {
status: 'ok',
library: {
language: 'ruby',
version: Datadog::VERSION::STRING
}
}
end

def waf
render plain: 'Hello, world!'
end
Expand Down
2 changes: 2 additions & 0 deletions utils/build/docker/ruby/rails50/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
get '/' => 'system_test#root'
post '/' => 'system_test#root'

get '/healthcheck' => 'system_test#healthcheck'

get '/waf' => 'system_test#waf'
post '/waf' => 'system_test#waf'
get '/waf/*other' => 'system_test#waf'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ def root
render plain: 'Hello, world!'
end

def healthcheck
render json: {
status: 'ok',
library: {
language: 'ruby',
version: Datadog::VERSION::STRING
}
}
end

def waf
render plain: 'Hello, world!'
end
Expand Down
2 changes: 2 additions & 0 deletions utils/build/docker/ruby/rails51/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
get '/' => 'system_test#root'
post '/' => 'system_test#root'

get '/healthcheck' => 'system_test#healthcheck'

get '/waf' => 'system_test#waf'
post '/waf' => 'system_test#waf'
get '/waf/*other' => 'system_test#waf'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ def root
render plain: 'Hello, world!'
end

def healthcheck
render json: {
status: 'ok',
library: {
language: 'ruby',
version: Datadog::VERSION::STRING
}
}
end

def waf
render plain: 'Hello, world!'
end
Expand Down
2 changes: 2 additions & 0 deletions utils/build/docker/ruby/rails52/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
get '/' => 'system_test#root'
post '/' => 'system_test#root'

get '/healthcheck' => 'system_test#healthcheck'

get '/waf' => 'system_test#waf'
post '/waf' => 'system_test#waf'
get '/waf/*other' => 'system_test#waf'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ def root
render plain: 'Hello, world!'
end

def healthcheck
render json: {
status: 'ok',
library: {
language: 'ruby',
version: Datadog::VERSION::STRING
}
}
end

def waf
render plain: 'Hello, world!'
end
Expand Down
2 changes: 2 additions & 0 deletions utils/build/docker/ruby/rails60/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
get '/' => 'system_test#root'
post '/' => 'system_test#root'

get '/healthcheck' => 'system_test#healthcheck'

get '/waf' => 'system_test#waf'
post '/waf' => 'system_test#waf'
get '/waf/*other' => 'system_test#waf'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ def root
render plain: 'Hello, world!'
end

def healthcheck
render json: {
status: 'ok',
library: {
language: 'ruby',
version: Datadog::VERSION::STRING
}
}
end

def waf
render plain: 'Hello, world!'
end
Expand Down
2 changes: 2 additions & 0 deletions utils/build/docker/ruby/rails61/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
get '/' => 'system_test#root'
post '/' => 'system_test#root'

get '/healthcheck' => 'system_test#healthcheck'

get '/waf' => 'system_test#waf'
post '/waf' => 'system_test#waf'
get '/waf/*other' => 'system_test#waf'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ def root
render plain: 'Hello, world!'
end

def healthcheck
render json: {
status: 'ok',
library: {
language: 'ruby',
version: Datadog::VERSION::STRING
}
}
end

def waf
render plain: 'Hello, world!'
end
Expand Down
2 changes: 2 additions & 0 deletions utils/build/docker/ruby/rails70/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
get '/' => 'system_test#root'
post '/' => 'system_test#root'

get '/healthcheck' => 'system_test#healthcheck'

get '/waf' => 'system_test#waf'
post '/waf' => 'system_test#waf'
get '/waf/*other' => 'system_test#waf'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ def root
render plain: 'Hello, world!'
end

def healthcheck
render json: {
status: 'ok',
library: {
language: 'ruby',
version: Datadog::VERSION::STRING
}
}
end

def waf
render plain: 'Hello, world!'
end
Expand Down
2 changes: 2 additions & 0 deletions utils/build/docker/ruby/rails71/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
get '/' => 'system_test#root'
post '/' => 'system_test#root'

get '/healthcheck' => 'system_test#healthcheck'

get '/waf' => 'system_test#waf'
post '/waf' => 'system_test#waf'
get '/waf/*other' => 'system_test#waf'
Expand Down
13 changes: 13 additions & 0 deletions utils/build/docker/ruby/sinatra14/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@
'Hello, world!'
end

get '/healthcheck' do
content_type :json

{
status: 'ok',
library: {
language: 'ruby',
version: Datadog::VERSION::STRING
}
}.to_json

end

post '/' do
'Hello, world!'
end
Expand Down
13 changes: 13 additions & 0 deletions utils/build/docker/ruby/sinatra20/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@
'Hello, world!'
end

get '/healthcheck' do
content_type :json

{
status: 'ok',
library: {
language: 'ruby',
version: Datadog::VERSION::STRING
}
}.to_json

end

post '/' do
'Hello, world!'
end
Expand Down
13 changes: 13 additions & 0 deletions utils/build/docker/ruby/sinatra21/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@
'Hello, world!'
end

get '/healthcheck' do
content_type :json

{
status: 'ok',
library: {
language: 'ruby',
version: Datadog::VERSION::STRING
}
}.to_json

end

post '/' do
'Hello, world!'
end
Expand Down
13 changes: 13 additions & 0 deletions utils/build/docker/ruby/sinatra22/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@
'Hello, world!'
end

get '/healthcheck' do
content_type :json

{
status: 'ok',
library: {
language: 'ruby',
version: Datadog::VERSION::STRING
}
}.to_json

end

post '/' do
'Hello, world!'
end
Expand Down
13 changes: 13 additions & 0 deletions utils/build/docker/ruby/sinatra30/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@
'Hello, world!'
end

get '/healthcheck' do
content_type :json

{
status: 'ok',
library: {
language: 'ruby',
version: Datadog::VERSION::STRING
}
}.to_json

end

post '/' do
'Hello, world!'
end
Expand Down
Loading

0 comments on commit 5cdb5d5

Please sign in to comment.