Skip to content

Commit

Permalink
Merge pull request #4372 from DataDog/tonycthsu/test-agent-enable
Browse files Browse the repository at this point in the history
Run test agent check in Github Actions
  • Loading branch information
TonyCTHsu authored Feb 12, 2025
2 parents 47ef2d0 + 3d817fa commit 20886bc
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ step_get_test_agent_trace_check_results: &step_get_test_agent_trace_check_result
run:
name: Get APM Test Agent Trace Check Results
command: |
ruby .circleci/test_agent_check.rb
ruby .github/scripts/test_agent_check.rb
when: always

filters_all_branches_and_tags: &filters_all_branches_and_tags
Expand Down
42 changes: 0 additions & 42 deletions .circleci/test_agent_check.rb

This file was deleted.

45 changes: 45 additions & 0 deletions .github/scripts/test_agent_check.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env ruby

require "net/http"
require "uri"
require "json"

# Disable exiting on command failure
agent_host = ENV["DD_AGENT_HOST"] || raise("DD_AGENT_HOST is not set")
agent_port = ENV["DD_TRACE_AGENT_PORT"] || raise("DD_TRACE_AGENT_PORT is not set")

begin
# Check if test agent is running
summary_uri = URI.parse("http://#{agent_host}:#{agent_port}/test/trace_check/summary")
summary_response = Net::HTTP.get_response(summary_uri)

if summary_response.code == "200"
puts "APM Test Agent is running. (HTTP 200)"
else
puts "APM Test Agent is not running and was not used for testing. No checks failed."
exit 0
end

# Check for test failures
failures_uri = URI.parse("http://#{agent_host}:#{agent_port}/test/trace_check/failures")
failures_response = Net::HTTP.get_response(failures_uri)

case failures_response.code
when "200"
puts "All APM Test Agent Check Traces returned successful! (HTTP 200)"
puts "APM Test Agent Check Traces Summary Results:"
puts JSON.pretty_generate(JSON.parse(summary_response.body))
when "404"
puts "Real APM Agent running in place of TestAgent, no checks to validate!"
else
puts "APM Test Agent Check Traces failed with response code: #{failures_response.code}"
puts "Failures:"
puts failures_response.body
puts "APM Test Agent Check Traces Summary Results:"
puts JSON.pretty_generate(JSON.parse(summary_response.body))
exit 1
end
rescue => e
puts "An error occurred: #{e.message}"
exit 1
end
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ jobs:
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
with:
limit-access-to-actor: true
- if: always()
run: ruby .github/scripts/test_agent_check.rb
- if: always()
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
with:
Expand Down Expand Up @@ -280,6 +282,8 @@ jobs:
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
with:
limit-access-to-actor: true
- if: always()
run: ruby .github/scripts/test_agent_check.rb
- if: always()
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
with:
Expand Down Expand Up @@ -415,6 +419,8 @@ jobs:
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
with:
limit-access-to-actor: true
- if: always()
run: ruby .github/scripts/test_agent_check.rb
- if: always()
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
with:
Expand Down Expand Up @@ -550,6 +556,8 @@ jobs:
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
with:
limit-access-to-actor: true
- if: always()
run: ruby .github/scripts/test_agent_check.rb
- if: always()
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
with:
Expand Down Expand Up @@ -685,6 +693,8 @@ jobs:
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
with:
limit-access-to-actor: true
- if: always()
run: ruby .github/scripts/test_agent_check.rb
- if: always()
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
with:
Expand Down Expand Up @@ -820,6 +830,8 @@ jobs:
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
with:
limit-access-to-actor: true
- if: always()
run: ruby .github/scripts/test_agent_check.rb
- if: always()
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
with:
Expand Down Expand Up @@ -955,6 +967,8 @@ jobs:
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
with:
limit-access-to-actor: true
- if: always()
run: ruby .github/scripts/test_agent_check.rb
- if: always()
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
with:
Expand Down Expand Up @@ -1090,6 +1104,8 @@ jobs:
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
with:
limit-access-to-actor: true
- if: always()
run: ruby .github/scripts/test_agent_check.rb
- if: always()
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
with:
Expand Down Expand Up @@ -1225,6 +1241,8 @@ jobs:
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
with:
limit-access-to-actor: true
- if: always()
run: ruby .github/scripts/test_agent_check.rb
- if: always()
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
with:
Expand Down Expand Up @@ -1360,6 +1378,8 @@ jobs:
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
with:
limit-access-to-actor: true
- if: always()
run: ruby .github/scripts/test_agent_check.rb
- if: always()
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
with:
Expand Down Expand Up @@ -1495,6 +1515,8 @@ jobs:
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
with:
limit-access-to-actor: true
- if: always()
run: ruby .github/scripts/test_agent_check.rb
- if: always()
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
with:
Expand Down
4 changes: 4 additions & 0 deletions tasks/github.rake
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ namespace :github do
'limit-access-to-actor' => true,
}
},
{
'if' => 'always()',
'run' => 'ruby .github/scripts/test_agent_check.rb'
},
{
'if' => 'always()',
'uses' => 'actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08',
Expand Down

0 comments on commit 20886bc

Please sign in to comment.